/* ==========================================================
   MOC ARCANA — Arena (luxe sombre, flat, readable)
   ========================================================== */

/* ---------- Lobby ---------- */
.opponent-card { display: block; text-align: center; padding: 2.4rem 1.6rem; cursor: pointer; position: relative; transition: border-color .25s, background .25s; height: 100%; }
.opponent-card input { position: absolute; opacity: 0; }
.opponent-card:hover { border-color: var(--line-2); }
.opponent-card:has(input:checked) { border-color: var(--gold); background: linear-gradient(180deg, var(--gold-dim), transparent 70%), var(--surface); }
.opp-avatar { width: 72px; height: 72px; margin: 0 auto 1.2rem; border-radius: 50%; display: grid; place-items: center; font-size: 1.7rem; color: var(--gold); border: 1px solid rgba(111,76,177,.4); }
.opp-level { text-transform: uppercase; letter-spacing: .3em; font-size: .62rem; font-weight: 600; color: var(--muted); margin-bottom: .4rem; }
.opponent-card .h4 { font-family: var(--serif); font-size: 1.6rem; font-weight: 600; }

/* ---------- Shell ---------- */
body.in-game { overflow: hidden; }
body.in-game .arcana-nav, body.in-game .arcana-footer { display: none; }
.arena { position: fixed; inset: 0; z-index: 1500; display: grid; grid-template-columns: minmax(0, 1fr) 340px; background: radial-gradient(ellipse 70% 55% at 50% 50%, #18205a, var(--bg) 78%); user-select: none;
  --cw: clamp(96px, 8.4vw, 136px); }
.arena[hidden] { display: none; }
.arena-main { display: grid; grid-template-rows: auto 1fr auto 1fr auto auto; min-height: 0; padding: 14px 24px 0; gap: 8px; position: relative; }

/* ---------- Player bars ---------- */
.pbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 10px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); transition: border-color .25s, box-shadow .25s; }
.pbar-id { display: flex; align-items: center; gap: 12px; min-width: 240px; }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 1.15rem; color: var(--gold); border: 1px solid rgba(111,76,177,.45); flex-shrink: 0; }
.pname { font-family: var(--serif); font-size: 1.2rem; font-weight: 600; line-height: 1.1; }
.cp { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.cp-bar { width: 170px; height: 4px; border-radius: 999px; background: var(--line); overflow: hidden; }
.cp-fill { height: 100%; width: 100%; background: var(--c-green); transition: width .6s cubic-bezier(.2,.8,.2,1), background .4s; }
.cp-fill.mid { background: #f5d27a; } .cp-fill.low { background: var(--c-red); }
.cp-val { font-size: .78rem; color: var(--muted); white-space: nowrap; } .cp-val b { color: var(--text); font-size: 1rem; font-weight: 600; }
.piles { display: flex; gap: 16px; font-size: .82rem; color: var(--muted); }
.piles b { color: var(--text); font-weight: 600; }
.dead-btn { background: none; border: 0; color: var(--muted); padding: 0; font-size: .82rem; }
.dead-btn:hover { color: var(--text); }
.pbar.targetable { border-color: var(--c-red); box-shadow: 0 0 0 1px var(--c-red); cursor: crosshair; }

/* ---------- Fields ---------- */
.field { display: flex; justify-content: center; align-items: center; gap: clamp(10px, 1.4vw, 22px); min-height: 0; }
.slot { width: var(--cw); aspect-ratio: 400 / 556; border-radius: 10px; border: 1px dashed rgba(255,255,255,.09); position: relative; flex-shrink: 0; margin-bottom: 26px; }

.tok { position: absolute; inset: 0; cursor: pointer; border-radius: 10px; transition: box-shadow .2s, transform .2s, opacity .3s; }
.tok img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; display: block; pointer-events: none; box-shadow: 0 10px 24px rgba(0,0,0,.55); }
.tok .st { position: absolute; left: 0; right: 0; top: calc(100% + 6px); display: flex; justify-content: center; gap: 6px; font-size: .78rem; font-weight: 600; pointer-events: none; }
.tok .st span { padding: .08rem .5rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line-2); white-space: nowrap; }
.tok .st .a { color: #f3c98b; } .tok .st .d { color: #cfc6f5; }
.tok .st .up { color: var(--c-green); border-color: rgba(127,191,143,.5); } .tok .st .down { color: var(--c-red); border-color: rgba(217,119,107,.5); }
.tok .st .pop { animation: pop .45s; }
@keyframes pop { 40% { transform: scale(1.25); } }
.tok:hover { transform: translateY(-3px); }
.tok.ready { box-shadow: 0 0 0 2px rgba(127,191,143,.85); }
.tok.selected { box-shadow: 0 0 0 2px var(--gold), 0 0 24px rgba(111,76,177,.35) !important; transform: translateY(-4px); }
.tok.pickable { box-shadow: 0 0 0 2px var(--gold); }
.tok.picked { box-shadow: 0 0 0 3px var(--c-red); opacity: .55; }
.tok.target { box-shadow: 0 0 0 2px var(--c-red); cursor: crosshair; }
.tok.spent img { filter: grayscale(.6) brightness(.75); }
.tok .badge-out { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); font-size: .66rem; font-weight: 700; letter-spacing: .08em; padding: .2rem .55rem; border-radius: 999px; white-space: nowrap; pointer-events: none; z-index: 3; }
.tok .badge-out.win { background: var(--c-green); color: #08130b; } .tok .badge-out.lose { background: var(--c-red); color: #1a0806; } .tok .badge-out.even { background: var(--surface-2); color: var(--text); border: 1px solid var(--line-2); }
.tok .flag { position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: .7rem; background: rgba(7,8,12,.85); border: 1px solid var(--line-2); pointer-events: none; }
.tok.summoning { animation: summon .45s cubic-bezier(.2,.8,.2,1) both; }
@keyframes summon { from { opacity: 0; transform: translateY(-18px) scale(1.06); } }
.tok.flash img { animation: flash-img .4s; }
@keyframes flash-img { 40% { filter: brightness(1.7); } }
.tok.dying { animation: dying .4s ease-in forwards; pointer-events: none; }
@keyframes dying { to { opacity: 0; transform: scale(.92); filter: grayscale(1); } }
.tok.hit, .pbar.hit { animation: hit .35s; }
@keyframes hit { 25% { transform: translateX(-6px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }

/* ---------- Center bar ---------- */
.center-bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; padding: 6px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.turn-info { display: flex; align-items: center; gap: 14px; }
.turn-txt { font-family: var(--serif); font-size: 1.25rem; font-weight: 600; white-space: nowrap; }
.turn-txt.theirs { color: var(--muted); }
.phase-track { display: flex; gap: 2px; }
.phase-track span { padding: .2rem .6rem; font-size: .62rem; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: #55534f; border-bottom: 1px solid transparent; }
.phase-track span.on { color: var(--gold); border-bottom-color: var(--gold); }
.hint { text-align: center; color: var(--muted); font-size: .9rem; max-width: 560px; }
.hint b { color: var(--text); font-weight: 600; }
.phase-btn { justify-self: end; min-width: 170px; }
.phase-btn.nudge { box-shadow: 0 0 0 4px var(--gold-dim); }

/* ---------- Hands ---------- */
.hand { display: flex; justify-content: center; align-items: flex-end; gap: 8px; }
.hand-me { height: calc(var(--cw) * 1.39 * .62 + 14px); padding: 0 0 10px; overflow: visible; }
.hcard { flex: 0 1 var(--cw); min-width: 56px; aspect-ratio: 400 / 556; cursor: pointer; position: relative; align-self: flex-start; }
.hcard .hc-in { position: absolute; inset: 0; transition: transform .22s cubic-bezier(.2,.8,.2,1), box-shadow .22s; border-radius: 9px; }
.hcard img { width: 100%; height: 100%; object-fit: cover; border-radius: 9px; display: block; pointer-events: none; box-shadow: 0 10px 22px rgba(0,0,0,.55); }
.hand-me .hcard:hover .hc-in { transform: translateY(-22px); }
.hcard.playable .hc-in { box-shadow: 0 0 0 2px rgba(127,191,143,.85); }
.hcard.selected .hc-in { transform: translateY(-30px); box-shadow: 0 0 0 2px var(--gold), 0 0 24px rgba(111,76,177,.35); }
.hcard.drawn .hc-in { animation: drawn .4s cubic-bezier(.2,.8,.2,1) both; }
@keyframes drawn { from { opacity: 0; transform: translateY(30px); } }
.hand-opp { gap: 0; }
.hand-opp .hcard { flex: 0 0 24px; min-width: 0; height: 34px; aspect-ratio: auto; cursor: default; margin-left: -8px; }
.hand-opp .hcard img { border-radius: 3px; box-shadow: 0 2px 6px rgba(0,0,0,.6); }

/* ---------- Side panel ---------- */
.arena-side { border-left: 1px solid var(--line); background: var(--bg-2); padding: 18px; display: flex; flex-direction: column; min-height: 0; gap: 12px; }
.detail-empty { border: 1px dashed var(--line-2); border-radius: 12px; padding: 2rem 1rem; text-align: center; color: var(--muted); font-size: .88rem; }
.detail-card { display: grid; grid-template-columns: 120px 1fr; gap: 12px; align-items: start; }
.detail-card img { width: 120px; border-radius: 8px; box-shadow: 0 10px 24px rgba(0,0,0,.6); }
.d-name { font-family: var(--serif); font-size: 1.3rem; font-weight: 600; line-height: 1.1; }
.d-meta { font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; margin: 4px 0 8px; }
.d-stats { display: flex; gap: 6px; flex-wrap: wrap; }
.d-stats span { font-size: .78rem; font-weight: 600; padding: .1rem .5rem; border-radius: 999px; border: 1px solid var(--line-2); }
.d-eff { font-size: .82rem; color: #cfcac0; line-height: 1.5; border-left: 1px solid var(--gold); padding-left: .6rem; margin-top: 10px; }
.d-eff.inactive { color: var(--muted); border-left-color: var(--line-2); }
.actions { display: flex; flex-direction: column; gap: 8px; }
.actions:empty { display: none; }
.actions .act-title { font-size: .64rem; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: var(--gold); }
.actions .act-note { font-size: .82rem; color: var(--muted); }
.actions .btn { text-align: left; display: flex; justify-content: space-between; align-items: center; gap: 8px; text-transform: none; letter-spacing: .02em; font-size: .86rem; padding: .7rem 1rem; border-radius: 10px; }
.actions .btn small { font-weight: 400; opacity: .75; }
.log-title { font-size: .62rem; font-weight: 600; letter-spacing: .22em; text-transform: uppercase; color: var(--muted); margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); }
.log { height: 180px; overflow-y: auto; font-size: .78rem; display: flex; flex-direction: column; gap: 2px; }
.log div { padding: .2rem 0; color: var(--muted); border-bottom: 1px solid rgba(255,255,255,.03); }
.log .dmg { color: #e0a49b; } .log .heal { color: #a9d3b3; } .log .summon { color: var(--text); } .log .event { color: var(--gold-2); } .log .attack { color: #e3c08f; }

/* ---------- FX ---------- */
.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 2400; }
.float-num { position: fixed; font-family: var(--serif); font-weight: 700; font-size: 2rem; transform: translate(-50%,-50%); animation: float-up 1.1s ease-out forwards; z-index: 2500; pointer-events: none; white-space: nowrap; text-shadow: 0 4px 16px rgba(0,0,0,.9); }
.float-num.small { font-family: var(--sans); font-size: .9rem; font-weight: 700; }
.float-num.dmg { color: var(--c-red); } .float-num.heal { color: var(--c-green); } .float-num.buff { color: var(--gold-2); } .float-num.debuff { color: #b7a3d8; }
@keyframes float-up { 0% { opacity: 0; transform: translate(-50%,-30%); } 15% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%,-150%); } }
.overlay-center { position: fixed; inset: 0 340px 0 0; z-index: 2450; pointer-events: none; display: grid; place-items: center; }
.cast { text-align: center; animation: cast 1.1s ease forwards; }
.cast img { width: min(260px, 36vw); border-radius: 14px; box-shadow: 0 40px 90px rgba(0,0,0,.85), 0 0 0 1px var(--line-2); }
.cast div { margin-top: 14px; font-family: var(--serif); font-size: 1.5rem; }
@keyframes cast { 0% { opacity: 0; transform: translateY(14px) scale(.96); } 18% { opacity: 1; transform: none; } 82% { opacity: 1; } 100% { opacity: 0; } }
.turn-pill { font-family: var(--serif); font-size: 2.2rem; padding: .4rem 2.2rem; border-radius: 999px; background: rgba(7,8,12,.92); border: 1px solid var(--line-2); animation: pill .9s ease forwards; letter-spacing: .06em; }
.turn-pill.mine { color: var(--gold-2); border-color: rgba(111,76,177,.5); }
@keyframes pill { 0% { opacity: 0; } 20% { opacity: 1; } 75% { opacity: 1; } 100% { opacity: 0; } }
.coin { width: 120px; height: 120px; position: relative; transform-style: preserve-3d; animation: coin-flip 1.1s cubic-bezier(.3,.6,.3,1) forwards; margin: 0 auto; }
.coin div { position: absolute; inset: 0; border-radius: 50%; display: grid; place-items: center; backface-visibility: hidden; font-family: var(--serif); font-weight: 700; font-size: 1.1rem; letter-spacing: .1em; background: radial-gradient(circle at 35% 30%, #fff3c4, #f5d27a 55%, #a67c2b); color: #3a2a06; border: 2px solid #9b7be0; }
.coin .tails { transform: rotateY(180deg); background: radial-gradient(circle at 35% 30%, #e4e2dc, #9b988f 55%, #55534d); border-color: #cfcac0; }
@keyframes coin-flip { from { transform: rotateY(0) translateY(0); } 50% { transform: rotateY(var(--spin)) translateY(-70px); } to { transform: rotateY(var(--spin)); } }
.reveal-title { text-align: center; font-family: var(--serif); font-size: 1.3rem; margin-bottom: 10px; }
.reveal-row { display: flex; gap: 10px; }
.reveal-row img { width: 120px; border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.7); }
.clash { position: fixed; z-index: 2500; transform: translate(-50%,-50%); font-weight: 700; font-size: .95rem; padding: .3rem .8rem; border-radius: 999px; background: rgba(7,8,12,.92); border: 1px solid var(--line-2); pointer-events: none; white-space: nowrap; animation: pill .9s ease forwards; }

/* ---------- Game over ---------- */
.gameover { position: fixed; inset: 0; z-index: 2800; display: grid; place-items: center; background: rgba(5,6,9,.94); animation: fade .5s; pointer-events: auto; }
@keyframes fade { from { opacity: 0; } }
.go-box { text-align: center; padding: 2rem; max-width: 640px; }
.go-kicker { text-transform: uppercase; letter-spacing: .4em; font-size: .7rem; color: var(--muted); }
.go-title { font-family: var(--serif); font-weight: 500; font-size: clamp(3.4rem, 9vw, 6.4rem); line-height: 1; margin: .3rem 0 1rem; animation: go-in .9s ease both; }
.victory .go-title { color: var(--gold-2); }
.defeat .go-title { color: #cfcac0; }
@keyframes go-in { from { opacity: 0; letter-spacing: .3em; } }
.go-stats { display: flex; justify-content: center; gap: 2.4rem; margin: 1.6rem 0; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .16em; }
.go-stats b { display: block; font-family: var(--serif); font-size: 2rem; color: var(--text); letter-spacing: 0; font-weight: 600; }
.go-reward { margin-bottom: 1.8rem; color: var(--muted); }

@media (max-width: 1100px) {
  .arena { grid-template-columns: 1fr; }
  .arena-side { position: fixed; right: 0; bottom: 0; width: 300px; max-height: 46vh; z-index: 20; border-top: 1px solid var(--line); border-radius: 14px 0 0 0; }
  .arena-side .log, .arena-side .log-title { display: none; }
  .overlay-center { inset: 0; }
}
@media (max-height: 820px) { .arena { --cw: clamp(84px, 7vw, 112px); } .log { height: 120px; } }
