:root {
  --cyan: #2EF2FF; --magenta: #FF2BD6; --gold: #F2B83A; --ember: #FF5A1F; --mint: #6CFFB8;
  --bone: #EDE6D6; --obsidian: #08070C; --slate: #1E1B26; --slate2: #15121c; --hair: #9c7a35;
  --rail: clamp(150px, 15vw, 230px);
  --cw: clamp(96px, min(11vw, 17.5vh), 170px);
  --chamf: polygon(8px 0, calc(100% - 8px) 0, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0 calc(100% - 8px), 0 8px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--obsidian); color: var(--bone); overflow: hidden; }
body { font-family: 'Chakra Petch', system-ui, sans-serif; font-weight: 400; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
button { font-family: inherit; color: inherit; cursor: pointer; }
#app { position: fixed; inset: 0; }
#bg { position: absolute; inset: 0; background: url(assets/hall_backdrop.webp) center 40% / cover no-repeat; }
#app.in-game #bg { filter: brightness(0.5) saturate(0.9); }
.screen { position: absolute; inset: 0; display: none; }
.screen.show { display: block; }

/* ---------- buttons ---------- */
.bar {
  position: relative; display: block; min-height: 44px; padding: 10px 26px; border: 0;
  background: linear-gradient(180deg, #1a1622, #0b0a10); color: var(--bone);
  font: 600 15px/1 'Chakra Petch'; letter-spacing: 0.14em; text-transform: uppercase;
  clip-path: var(--chamf); box-shadow: inset 0 0 0 1px var(--hair), inset 0 0 0 3px #0b0a10, inset 0 0 0 4px rgba(156,122,53,0.35);
  transition: box-shadow .18s, transform .12s, color .18s;
}
.bar:hover, .bar:focus-visible { outline: none; color: #fff9ea; box-shadow: inset 0 0 0 1px var(--cyan), inset 0 0 14px rgba(46,242,255,0.45), inset 0 0 0 4px rgba(46,242,255,0.25); }
.bar:active { transform: translateY(1px); }
.bar.big { font-size: 18px; min-height: 52px; }
.bar:disabled { opacity: .4; cursor: default; }

/* ---------- title ---------- */
#title { overflow: hidden; }
#title::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(8,7,12,0.55), rgba(8,7,12,0.05) 40%, rgba(8,7,12,0.65)); pointer-events: none; }
.tlight { position: absolute; top: 0; bottom: 0; width: 45%; mix-blend-mode: screen; pointer-events: none; z-index: 1; animation: breathe 5s ease-in-out infinite; }
.tlight.cyan { left: 0; background: radial-gradient(60% 55% at 10% 45%, rgba(46,242,255,0.28), transparent 70%); }
.tlight.magenta { right: 0; background: radial-gradient(60% 55% at 90% 45%, rgba(255,43,214,0.28), transparent 70%); animation-delay: -2.5s; }
@keyframes breathe { 0%,100% { opacity: .35 } 50% { opacity: 1 } }
.t-inner { position: relative; z-index: 3; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.2vh; padding: 3vh 16px 7vh; }
.t-letter { width: min(92vw, 78vh, 760px); filter: drop-shadow(0 6px 20px rgba(0,0,0,.8)); animation: letterIn 1.1s cubic-bezier(.2,.9,.3,1) both; }
@keyframes letterIn { from { opacity: 0; transform: translateY(-14px) scale(.96); filter: blur(6px); } }
.tagline { margin: 0; font: 500 clamp(11px, 1.6vw, 15px)/1.3 'Chakra Petch'; letter-spacing: .22em; text-transform: uppercase; text-align: center; color: var(--bone); text-shadow: 0 0 10px #000, 0 0 3px #000; }
.t-crown { position: relative; height: min(22vh, 42vw); aspect-ratio: 915/701; animation: bob 4s ease-in-out infinite; }
.t-crown img { position: relative; width: 100%; height: 100%; filter: drop-shadow(0 0 18px rgba(242,184,58,0.55)); }
.t-crown .halo { position: absolute; inset: -30% -25%; background: radial-gradient(closest-side, rgba(242,184,58,0.35), rgba(242,184,58,0.08) 60%, transparent); animation: breathe 4s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-10px) } }
.pulse-ring { position: absolute; left: 50%; top: 64%; width: 40vmin; height: 12vmin; margin: -6vmin 0 0 -20vmin; border: 1.5px solid rgba(242,184,58,.8); border-radius: 50%; z-index: 2; opacity: 0; animation: ring 4.5s ease-out infinite; pointer-events: none; box-shadow: 0 0 12px rgba(242,184,58,.5); }
.pulse-ring.r2 { animation-delay: 2.25s; }
@keyframes ring { 0% { transform: scale(.3); opacity: 0 } 10% { opacity: .9 } 100% { transform: scale(3.2); opacity: 0 } }
#motes { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
#motes i { position: absolute; bottom: -10px; width: 4px; height: 4px; border-radius: 50%; background: #ffd77a; box-shadow: 0 0 8px 2px rgba(242,184,58,.7); animation: rise linear infinite; }
@keyframes rise { 0% { transform: translate(0,0); opacity: 0 } 15% { opacity: 1 } 100% { transform: translate(var(--dx), -95vh); opacity: 0 } }
.t-menu { display: flex; flex-direction: column; align-items: stretch; gap: 10px; width: min(330px, 88vw); }
.diff { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.diff button { min-height: 40px; border: 0; background: rgba(15,13,20,.85); font: 600 12px 'Chakra Petch'; letter-spacing: .06em; clip-path: var(--chamf); box-shadow: inset 0 0 0 1px rgba(156,122,53,.6); color: rgba(237,230,214,.75); }
.diff button[aria-checked="true"] { color: var(--bone); box-shadow: inset 0 0 0 1px var(--cyan), inset 0 0 12px rgba(46,242,255,.4); }
.diff-note { margin: -4px 0 2px; min-height: 2.6em; font-size: 12px; line-height: 1.3; text-align: center; color: rgba(237,230,214,.8); text-shadow: 0 0 6px #000; }
.record { margin: 2px 0 0; text-align: center; font: 500 12px 'Chakra Petch'; letter-spacing: .08em; color: rgba(237,230,214,.75); min-height: 1.2em; text-shadow: 0 0 6px #000; }
.record b { font-family: 'Oxanium'; font-weight: 700; color: var(--bone); }
.credit { position: absolute; z-index: 3; left: 0; right: 0; bottom: max(10px, env(safe-area-inset-bottom)); margin: 0; text-align: center; font-size: 12px; letter-spacing: .1em; color: var(--bone); opacity: .6; }
.credit.in { position: static; margin-top: 10px; }

/* ---------- match layout: landscape ---------- */
#game { display: none; }
#game.show { display: grid; grid-template-columns: var(--rail) 1fr var(--rail); grid-template-rows: minmax(0,1fr) auto auto; grid-template-areas: "pl center rv" "prompt prompt prompt" "hand hand hand"; padding: 8px 10px max(6px, env(safe-area-inset-bottom)); gap: 4px 10px; }
#railP { grid-area: pl; } #railR { grid-area: rv; } #center { grid-area: center; } #prompt { grid-area: prompt; } #handRow { grid-area: hand; }
#center { position: relative; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
#boardWrap { position: relative; flex: 1; min-height: 0; margin: 0 -10px -34px; }
#railP, #railR, #prompt, #handRow { position: relative; z-index: 2; }
#boardWrap canvas { display: block; }

/* rails */
.rail { position: relative; align-self: start; display: flex; flex-direction: column; align-items: stretch; gap: 8px; padding: 10px; margin-top: 4px;
  background: linear-gradient(180deg, rgba(22,19,29,.92), rgba(12,10,16,.92)); clip-path: var(--chamf);
  box-shadow: inset 0 0 0 1px rgba(156,122,53,.55), inset 0 0 0 4px rgba(8,7,12,.9), inset 0 0 0 5px var(--sidecol-dim); }
.rail[data-side="P"] { --sidecol: var(--cyan); --sidecol-dim: rgba(46,242,255,.35); }
.rail[data-side="R"] { --sidecol: var(--magenta); --sidecol-dim: rgba(255,43,214,.35); }
.rail.active { box-shadow: inset 0 0 0 1px rgba(156,122,53,.7), inset 0 0 0 4px rgba(8,7,12,.9), inset 0 0 0 5px var(--sidecol), inset 0 0 22px var(--sidecol-dim); }
.portrait { width: 82%; align-self: center; aspect-ratio: 587/810; }
.portrait img { width: 100%; height: 100%; object-fit: contain; display: block; }
.hp { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.num { font: 700 34px/1 'Oxanium'; color: var(--bone); text-shadow: 0 0 8px var(--sidecol-dim); }
.seg { display: flex; gap: 2px; width: 100%; height: 10px; }
.seg i { flex: 1; background: #2a2533; clip-path: polygon(2px 0,100% 0,calc(100% - 2px) 100%,0 100%); }
.seg i.on { background: var(--sidecol); box-shadow: 0 0 6px var(--sidecol); }
.seg.hit { animation: hitflash .4s; }
@keyframes hitflash { 30% { filter: brightness(2.5) saturate(0); } }
.guards { display: flex; flex-direction: column; gap: 4px; }
.g { display: grid; grid-template-columns: 22px 1fr 22px; align-items: center; gap: 6px; font: 700 14px 'Oxanium'; }
.g img { height: 24px; width: 22px; object-fit: contain; }
.g .seg { height: 6px; }
.g.dead { opacity: .3; }
.energy { display: flex; justify-content: center; gap: 6px; }
.energy img { height: 40px; transition: filter .25s, opacity .25s, transform .25s; filter: drop-shadow(0 0 6px rgba(46,242,255,.7)); }
.rail[data-side="R"] .energy img { filter: hue-rotate(95deg) saturate(1.3) drop-shadow(0 0 6px rgba(255,43,214,.7)); }
.energy img.spent { filter: grayscale(1) brightness(.35) !important; opacity: .55; transform: scale(.9); }
.piles { display: flex; justify-content: space-around; font: 700 15px 'Oxanium'; align-items: center; }
.piles span { display: flex; align-items: center; gap: 6px; }
.piles img { height: 26px; }
.disc { opacity: .8; font-size: 13px; }
.backs { position: relative; height: 70px; margin: 4px 0; }
.backs img { position: absolute; left: 50%; bottom: 0; height: 62px; transform-origin: 50% 120%; transition: transform .3s; }
.lvname { text-align: center; font: 600 13px 'Chakra Petch'; letter-spacing: .12em; text-transform: uppercase; padding: 6px; box-shadow: inset 0 0 0 1px rgba(156,122,53,.6); clip-path: var(--chamf); }

#turnPlate { position: absolute; left: 50%; top: 0; transform: translateX(-50%); padding: 4px 30px 6px; background: linear-gradient(180deg, #1a1622, #0b0a10); clip-path: polygon(14px 0, calc(100% - 14px) 0, 100% 50%, calc(100% - 14px) 100%, 14px 100%, 0 50%);
  box-shadow: inset 0 0 0 1px rgba(156,122,53,.7), inset 0 0 16px rgba(46,242,255,.45); transition: box-shadow .3s; z-index: 2; }
#turnPlate span { font: 400 clamp(22px, 3vh, 30px)/1 'Grenze Gotisch'; letter-spacing: .04em; color: var(--bone); text-shadow: 0 0 10px var(--cyan); }
#turnPlate.rival { box-shadow: inset 0 0 0 1px rgba(156,122,53,.7), inset 0 0 16px rgba(255,43,214,.5); }
#turnPlate.rival span { text-shadow: 0 0 10px var(--magenta); }
#turnPlate.swap { animation: plate .5s; }
@keyframes plate { 0% { filter: brightness(2.2); } }
#capBanner { position: absolute; left: 50%; bottom: 2px; transform: translateX(-50%); display: none; align-items: center; gap: 8px; padding: 4px 16px; background: rgba(8,7,12,.9); clip-path: var(--chamf); box-shadow: inset 0 0 0 1px var(--gold), inset 0 0 14px rgba(242,184,58,.35); z-index: 3; white-space: nowrap; }
#capBanner.show { display: flex; animation: plate .5s; }
#capBanner img { height: 20px; }
#capBanner span { font: 700 15px 'Oxanium'; letter-spacing: .12em; color: var(--gold); }
#capBanner.R span { text-shadow: 0 0 8px var(--magenta); } #capBanner.P span { text-shadow: 0 0 8px var(--cyan); }

#prompt { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 34px; padding: 4px 10px; font: 500 14px/1.3 'Chakra Petch'; text-align: center; color: var(--bone); }
#prompt b { font-weight: 600; color: #fff6df; }
#prompt .pc { font-family: 'Oxanium'; font-weight: 700; color: var(--cyan); }
#cancelBtn { display: none; flex: none; min-height: 32px; padding: 4px 12px; border: 0; background: #14111a; font: 600 12px 'Chakra Petch'; letter-spacing: .1em; text-transform: uppercase; clip-path: var(--chamf); box-shadow: inset 0 0 0 1px rgba(255,43,138,.7); }
#prompt.cancel #cancelBtn { display: block; }

/* hand */
#handRow { position: relative; display: grid; grid-template-columns: var(--rail) 1fr var(--rail); align-items: end; gap: 10px; }
#hand { grid-column: 2; margin-top: -24px; position: relative; z-index: 4; display: flex; justify-content: center; align-items: flex-end; gap: calc(var(--cw) * 0.06); height: calc(var(--cw) * 1.587 + 10px); padding-bottom: 2px; }
#endTurn { grid-column: 3; align-self: center; display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 64px; padding: 10px 14px; font: 400 26px/1 'Grenze Gotisch'; letter-spacing: .03em; text-transform: none; }
#endTurn img { height: 30px; }
#endTurn.pulse { animation: endpulse 1.4s ease-in-out infinite; }
@keyframes endpulse { 50% { box-shadow: inset 0 0 0 1px var(--cyan), inset 0 0 22px rgba(46,242,255,.65), inset 0 0 0 4px rgba(46,242,255,.35); } }

.card { position: relative; flex: none; width: var(--cw); aspect-ratio: 645/1024; container-type: inline-size; transform-origin: 50% 100%;
  transform: translateY(var(--dy, 0)) rotate(var(--rot, 0deg)); transition: transform .2s cubic-bezier(.2,.8,.3,1), filter .2s, opacity .2s; cursor: pointer; }
.card > * { position: absolute; pointer-events: none; }
.card .art { left: 13%; top: 13%; width: 75%; height: 48.2%; object-fit: cover; }
.card .frame { inset: 0; width: 100%; height: 100%; filter: drop-shadow(0 6px 8px rgba(0,0,0,.7)); }
.card .cost { left: 7%; top: 5%; width: 11%; height: 8%; display: grid; place-items: center; font: 700 9.5cqw/1 'Oxanium'; color: #08070c; z-index: 2; }
.card .cost::before { content: ''; position: absolute; inset: 4% 0; background: linear-gradient(135deg, #b9fbff, var(--cyan) 45%, #0b8a9a); clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); box-shadow: 0 0 8px var(--cyan); z-index: -1; }
.card.rival .cost::before { background: linear-gradient(135deg, #ffd0f5, var(--magenta) 45%, #8a0b74); }
.card .name { left: 24%; top: 5%; width: 61%; height: 7%; display: grid; place-items: center; font: 400 10.5cqw/1 'Grenze Gotisch'; color: var(--bone); white-space: nowrap; text-shadow: 0 0 4px #000; }
.card .rules { left: 10%; top: 65.5%; width: 80%; height: 28%; display: flex; flex-direction: column; justify-content: center; gap: 4%; text-align: center; font: 500 6.4cqw/1.22 'Chakra Petch'; color: var(--bone); }
.card .rules .tgt { font-size: 5.3cqw; color: rgba(46,242,255,.85); font-weight: 600; }
.card.rival .rules .tgt { color: rgba(255,120,230,.9); }
@container (max-width: 112px) {
  .card .rules { display: none; }
  .card .name { top: 66%; left: 8%; width: 84%; height: 26%; white-space: normal; text-align: center; font-size: 17cqw; line-height: .95; }
  .card .cost { font-size: 13cqw; left: 5%; top: 4%; width: 15%; height: 10%; }
}
.card.poor { opacity: .45; }
.card.poor .cost::before { background: linear-gradient(135deg, #bbb, #666); box-shadow: none; }
.card.sel { --dy: -18%; transform: translateY(var(--dy)) rotate(0deg) scale(1.06); z-index: 5; }
.card.sel .frame { filter: drop-shadow(0 0 10px var(--cyan)) drop-shadow(0 0 3px var(--cyan)); }
.card.drawn { animation: drawIn .4s cubic-bezier(.2,.8,.3,1) both; }
@keyframes drawIn { from { opacity: 0; transform: translate(40vw, 10px) rotate(20deg) scale(.6); } }
@media (hover: hover) and (min-width: 720px) {
  .card:hover { transform: translateY(-20%) rotate(0deg) scale(1.3); z-index: 10; }
  .card.sel:hover { transform: translateY(-20%) rotate(0deg) scale(1.3); }
}
#hand.locked .card { cursor: default; }
.flycard { position: fixed; z-index: 60; pointer-events: none; }

#topBtns { position: absolute; top: 2px; right: 0; display: flex; gap: 6px; z-index: 20; }
.ico { width: 40px; height: 40px; padding: 5px; border: 0; background: rgba(12,10,16,.9); clip-path: var(--chamf); box-shadow: inset 0 0 0 1px rgba(156,122,53,.7); display: grid; place-items: center; font: 700 18px 'Oxanium'; }
.ico img { width: 100%; height: 100%; object-fit: contain; }
.ico:hover { box-shadow: inset 0 0 0 1px var(--cyan), inset 0 0 10px rgba(46,242,255,.4); }

#rivalCard { position: absolute; left: 50%; top: 12%; width: clamp(130px, 15vw, 210px); transform: translateX(-50%); z-index: 40; pointer-events: none; display: none; }
#rivalCard.show { display: block; animation: rivIn .25s ease-out both; }
#rivalCard .card { width: 100%; transform: none; }
#rivalCard .card .frame { filter: drop-shadow(0 0 16px var(--magenta)) drop-shadow(0 0 4px var(--magenta)); }
@keyframes rivIn { from { opacity: 0; transform: translate(-50%, -20px) scale(.7); } }
#flood { position: absolute; inset: 0; pointer-events: none; z-index: 30; opacity: 0; background: radial-gradient(circle at 50% 45%, rgba(255,226,140,.85), rgba(242,184,58,.45) 45%, rgba(242,184,58,.1)); transition: opacity 1.2s; }
#flood.on { opacity: .7; }
#game.defeat .rail, #game.defeat #handRow, #game.defeat #prompt { filter: grayscale(1) brightness(.7); transition: filter 1.5s; }
#game.defeat #railR { filter: none; }

/* overlays */
.overlay { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; background: rgba(8,7,12,.72); padding: 16px; }
.overlay.show { display: flex; }
.panel { width: min(420px, 100%); max-height: 100%; display: flex; flex-direction: column; gap: 10px; padding: 22px; background: linear-gradient(180deg, #1c1824, #0e0c13); clip-path: var(--chamf); box-shadow: inset 0 0 0 1px rgba(156,122,53,.8), inset 0 0 0 5px #0b0a10, inset 0 0 0 6px rgba(156,122,53,.3); }
.panel h2 { margin: 0 0 6px; text-align: center; font: 400 34px/1 'Grenze Gotisch'; text-shadow: 0 0 10px rgba(46,242,255,.6); }
#result .panel { width: min(520px, 100%); background: transparent; box-shadow: none; clip-path: none; align-items: center; animation: resIn .7s cubic-bezier(.2,.9,.3,1) both; }
@keyframes resIn { from { opacity: 0; transform: scale(.6); } }
#resBanner { width: min(460px, 92vw); filter: drop-shadow(0 0 30px rgba(242,184,58,.5)); }
#result.lose #resBanner { filter: drop-shadow(0 0 30px rgba(255,43,214,.5)); }
#resWhy { margin: 0; font: 500 16px 'Chakra Petch'; letter-spacing: .06em; text-align: center; text-shadow: 0 0 8px #000; }
#resStats { display: grid; grid-template-columns: repeat(3, auto); gap: 4px 20px; padding: 10px 18px; background: rgba(12,10,16,.9); clip-path: var(--chamf); box-shadow: inset 0 0 0 1px rgba(156,122,53,.6); font-size: 12px; text-align: center; letter-spacing: .08em; text-transform: uppercase; }
#resStats b { display: block; font: 700 22px 'Oxanium'; }
.row { display: flex; gap: 10px; }
.how { width: min(620px, 100%); }
.how-body { overflow-y: auto; font-size: 14px; line-height: 1.45; padding-right: 6px; }
.how-body p { margin: 0 0 8px; }
.t-h { color: var(--ember); font-weight: 600; } .t-m { color: var(--mint); font-weight: 600; }
#cardList { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-top: 6px; }
#cardList .card { width: 100%; transform: none; cursor: default; }
#toast { position: fixed; left: 50%; bottom: 30%; transform: translateX(-50%); z-index: 90; padding: 8px 16px; background: rgba(8,7,12,.92); clip-path: var(--chamf); box-shadow: inset 0 0 0 1px rgba(255,43,138,.7); font: 600 14px 'Chakra Petch'; opacity: 0; transition: opacity .25s; pointer-events: none; text-align: center; max-width: 90vw; }
#toast.show { opacity: 1; }

/* ---------- portrait / narrow ---------- */
@media (max-aspect-ratio: 1/1), (max-width: 719px) {
  :root { --cw: min(calc((100vw - 40px) / 5), 15vh, 120px); }
  #game.show { grid-template-columns: 1fr; grid-template-rows: auto minmax(0,1fr) auto auto auto; grid-template-areas: "rv" "center" "pl" "prompt" "hand"; padding: max(6px, env(safe-area-inset-top)) 8px max(6px, env(safe-area-inset-bottom)); gap: 4px; }
  .rail { flex-direction: row; align-items: center; gap: 8px; padding: 6px 10px; margin: 0; align-self: stretch; }
  .portrait { width: auto; height: 54px; flex: none; align-self: center; }
  .vitals { display: flex; flex: 1; align-items: center; gap: 8px; min-width: 0; }
  .hp { flex-direction: row; gap: 6px; flex: 1.3; min-width: 0; }
  .num { font-size: 24px; }
  .seg { height: 8px; }
  .guards { flex: 1; min-width: 0; gap: 3px; }
  .g { grid-template-columns: 14px 1fr 16px; gap: 3px; font-size: 11px; }
  .g img { height: 16px; width: 14px; }
  .g .seg { height: 4px; }
  .energy { gap: 2px; flex: none; }
  .energy img { height: 24px; }
  .piles { flex-direction: column; gap: 0; font-size: 12px; flex: none; }
  .piles img { height: 16px; }
  .disc { display: none !important; }
  .backs, .lvname { display: none; }
  #turnPlate { position: static; transform: none; align-self: flex-start; padding: 3px 22px 4px; }
  #boardWrap { margin: 0 -8px -10px; }
  #turnPlate span { font-size: 21px; }
  .ico { width: 34px; height: 34px; padding: 4px; font-size: 16px; }
  #prompt { font-size: 13px; min-height: 38px; padding: 2px 4px; }
  #handRow { grid-template-columns: 1fr; gap: 6px; }
  #endTurn { grid-column: 1; grid-row: 1; min-height: 44px; font-size: 22px; padding: 6px; }
  #endTurn img { height: 24px; }
  #hand { margin-top: 0; grid-column: 1; grid-row: 2; height: calc(var(--cw) * 1.587 + 4px); }
  #rivalCard { top: 70px; width: clamp(120px, 38vw, 180px); }
  #capBanner span { font-size: 13px; }
}
/* very short landscape (phone on its side) */
@media (min-aspect-ratio: 1/1) and (max-height: 500px) and (min-width: 720px) {
  :root { --rail: clamp(130px, 18vw, 180px); --cw: min(9vw, 19vh); }
  .portrait { width: 44%; }
  .num { font-size: 22px; }
  .energy img { height: 24px; }
  .backs { display: none; }
  .rail { gap: 4px; padding: 6px; }
  #endTurn { min-height: 44px; font-size: 20px; }
  #prompt { min-height: 26px; font-size: 12px; }
}

/* v2: card detail, ward, coach */
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ward { display: none; text-align: center; font: 600 11px 'Chakra Petch'; letter-spacing: .14em; text-transform: uppercase; padding: 4px 6px; color: var(--bone); box-shadow: inset 0 0 0 1px var(--sidecol), inset 0 0 10px var(--sidecol-dim); clip-path: var(--chamf); }
.ward.on { display: block; animation: breathe 2s ease-in-out infinite; }
#cardDetail { display: none; }
#coach { display: none; position: absolute; z-index: 45; left: 50%; top: 52px; transform: translateX(-50%); width: min(560px, calc(100% - 16px)); padding: 12px 14px; background: linear-gradient(180deg, rgba(28,24,36,.97), rgba(14,12,19,.97)); clip-path: var(--chamf); box-shadow: inset 0 0 0 1px var(--cyan), inset 0 0 18px rgba(46,242,255,.3); }
#coach.show { display: block; animation: rivIn .3s ease-out both; }
#coach p { margin: 0 0 8px; font: 500 14px/1.4 'Chakra Petch'; }
#coach p b { color: #fff6df; }
#coach .bar { min-height: 36px; padding: 6px 14px; font-size: 12px; }
#coach.noNext #coachNext { display: none; }
.coach-focus { animation: focusPulse 1.1s ease-in-out infinite !important; }
.card.coach-focus .frame { filter: drop-shadow(0 0 12px var(--cyan)) drop-shadow(0 0 4px #fff) !important; }
@keyframes focusPulse { 50% { filter: brightness(1.35); } }
@media (max-aspect-ratio: 1/1), (max-width: 719px) {
  .ward.on { position: absolute; right: 64px; top: 4px; padding: 2px 6px; font-size: 9px; }
  #cardDetail.show { grid-area: pl; z-index: 6; display: flex; gap: 10px; align-items: stretch; padding: 6px 10px; min-height: 66px; background: linear-gradient(180deg, rgba(28,24,36,.98), rgba(12,10,16,.98)); clip-path: var(--chamf); box-shadow: inset 0 0 0 1px var(--hair), inset 0 0 0 4px #0b0a10, inset 0 0 0 5px rgba(46,242,255,.45); }
  .cd-art { position: relative; flex: none; width: 58px; align-self: center; aspect-ratio: 1; }
  .cd-art img { width: 100%; height: 100%; object-fit: cover; clip-path: var(--chamf); box-shadow: inset 0 0 0 1px var(--hair); }
  .cd-cost { position: absolute; left: -6px; top: -6px; width: 26px; height: 26px; display: grid; place-items: center; font: 700 15px 'Oxanium'; color: #08070c; }
  .cd-cost::before { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(135deg, #b9fbff, var(--cyan) 45%, #0b8a9a); clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
  #cardDetail.poor .cd-cost::before { background: linear-gradient(135deg, #bbb, #666); }
  .cd-body { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 1px; }
  .cd-name { font: 400 20px/1 'Grenze Gotisch'; }
  .cd-text { font: 500 12.5px/1.25 'Chakra Petch'; }
  .cd-tgt { font: 600 11.5px/1.2 'Chakra Petch'; color: var(--cyan); }
  .cd-note { font: 600 11.5px/1.2 'Chakra Petch'; color: #ff6a9a; }
  .cd-note:empty { display: none; }
  #coach { top: 4px; }
  #coach p { font-size: 13px; }
}

#btnMuteT { position: absolute; z-index: 4; top: max(10px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); }

/* ---------- online card duel ---------- */
.t-menu .bar small { display: block; font: 600 10px 'Chakra Petch'; letter-spacing: .14em; margin-top: 3px; opacity: .8; text-transform: uppercase; }
.bar.duelon { box-shadow: inset 0 0 0 1px var(--magenta), inset 0 0 14px rgba(255,43,214,.35); }
.panel.dl { width: min(440px, 100%); overflow-y: auto; gap: 8px; }
.panel.dl h2 { margin-bottom: 0; }
#dlPeople { display: flex; flex-direction: column; gap: 4px; }
#dlPeople .dp { display: flex; align-items: center; gap: 8px; padding: 7px 10px; background: rgba(255,255,255,.04); box-shadow: inset 0 0 0 1px rgba(156,122,53,.45); font: 600 13px 'Chakra Petch'; }
#dlPeople .dp i { width: 10px; height: 10px; border-radius: 50%; flex: none; }
#dlPeople .dp .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#dlPeople .dp .tag { font-size: 11px; opacity: .7; }
#dlPeople .dp.empty { opacity: .6; font-weight: 400; font-style: italic; }
.dlpass input, .dlinput { flex: 1; min-width: 0; padding: 8px; background: #07060c; color: var(--bone); border: 1px solid rgba(156,122,53,.7); font: 14px 'Chakra Petch'; }
.dlpass { align-items: center; gap: 6px; }
#dlLock { font: 600 11px 'Chakra Petch'; color: #F2B83A; margin-left: auto; }
#onlineBar { position: absolute; left: 50%; top: 46px; transform: translateX(-50%); z-index: 30; display: none; align-items: center; gap: 8px; padding: 6px 10px; max-width: 94%; background: rgba(10,8,16,.9); box-shadow: inset 0 0 0 1px var(--magenta); font: 500 12px/1.3 'Chakra Petch'; color: var(--bone); text-align: center; }
#onlineBar.away { display: flex; }
#onlineBar #claimBtn { display: none; flex: none; }
#onlineBar.claim #claimBtn { display: block; }
#mResign { display: none; }
#app.online #mResign { display: block; }
#app.online #mRestart, #app.online #btnRestart { display: none; }
.panel.dl .row > .bar { flex: 1; }
