*{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%;overflow:hidden}
body{background:#0d0d1a;color:#e0e0e0;font-family:Arial,sans-serif;display:flex;flex-direction:column}

/* ── Outer layout ───────────────────────────────────────────── */
.game-layout{flex:1;display:flex;overflow:hidden;min-height:0}
.main-col{flex:1;display:flex;flex-direction:column;overflow:hidden;min-height:0}
.right-col{width:620px;flex-shrink:0;display:flex;flex-direction:column;overflow:hidden;border-left:1px solid #1e1e3a}
.log-panel{height:180px;flex-shrink:0;background:#0a0a14;border-top:1px solid #1e1e3a;display:flex;flex-direction:column;overflow:hidden}
.shop-col{flex:1;background:#08080f;display:flex;flex-direction:column;overflow:hidden;padding:8px}
.log-title{padding:5px 8px;font-size:10px;font-weight:bold;color:#444;border-bottom:1px solid #1e1e3a;letter-spacing:1px;flex-shrink:0}
.log-entries{flex:1;overflow-y:auto;padding:4px 6px}
.log-entry{font-size:10px;padding:2px 3px;border-radius:2px;margin-bottom:1px;line-height:1.4}
.log-entry.system{color:#4a9eda;font-weight:bold}
.log-entry.attack{color:#fc8181}
.log-entry.block{color:#63b3ed}
.log-entry.damage{color:#f6ad55;font-weight:bold}
.log-entry.buy{color:#68d391}
.log-entry.warn{color:#f6e05e}
.log-entry.win{color:#68d391;font-weight:bold}
.log-entry.lose{color:#fc8181;font-weight:bold}
.log-entry.info{color:#666}

/* ── Sections — all flex-shrink:0 except player-main ───────── */
.section{flex-shrink:0;padding:5px 10px;border-bottom:1px solid #1e1e3a}
.ai-section{background:#0f0f20}
.shop-section{flex:1;overflow-y:auto;transition:opacity .2s}
.shop-section.dimmed{opacity:.35;pointer-events:none}
.shop-label.dimmed{opacity:.35;pointer-events:none}
.player-main{flex:1;min-height:0;display:flex;flex-direction:column;padding:5px 10px;background:#0a0a18;border-top:1px solid #1e1e3a}
.phase-bar{flex-shrink:0;padding:5px 10px;background:#111128;font-size:12px;font-weight:bold;color:#a0aec0;border-bottom:1px solid #1e1e3a;border-top:1px solid #1e1e3a}
.phase-bar.win{background:#1a3a1a;color:#68d391}
.phase-bar.lose{background:#3a1a1a;color:#fc8181}
.phase-bar.blk{background:#0d1f33;color:#63b3ed}
/* min-height is a defensive floor matching a .btn's own rendered height —
   every reachable phase currently fills this row with a button or a
   .pool status line, but pin the height anyway so a future phase that
   doesn't can't reintroduce the same collapse pattern here. */
.btn-row{flex-shrink:0;display:flex;align-items:center;gap:6px;padding:5px 10px;background:#080812;min-height:33px}

/* ── Section header ─────────────────────────────────────────── */
.sec-header{display:flex;align-items:center;gap:8px;margin-bottom:4px;flex-wrap:wrap}
.sec-label{font-size:12px;font-weight:bold}
.hp-wrap{width:70px;height:7px;background:#1e1e3a;border-radius:4px;overflow:hidden;flex-shrink:0}
.hp-fill{height:100%;border-radius:4px;transition:width .3s}
.hp-num{font-size:12px;font-weight:bold}
.deck-stat{font-size:10px;color:#444;margin-left:auto}
.shop-label{font-size:11px;font-weight:bold;color:#888;letter-spacing:1px;margin-bottom:6px;flex-shrink:0}
.shop-grid{display:flex;flex-wrap:wrap;align-content:flex-start;gap:8px;overflow-y:auto;padding:2px;flex:1}

/* ── Card rows — horizontal scroll, never vertical ──────────── */
/* min-height locked to a full card's rendered height (190px + this row's
   own 2px top/bottom padding) so an empty hand still reserves exactly the
   space a full one would use — without this, the row's height comes
   purely from its content (a full-size card vs. a couple lines of
   .empty-hand text), so the whole layout above/below it would visibly
   jump every time a hand emptied out or refilled. */
.card-row{display:flex;flex-wrap:nowrap;gap:5px;overflow-x:auto;overflow-y:hidden;padding:2px 1px;align-items:flex-start;flex-shrink:0;min-height:194px}
/* Player hand row grows to fill available space (flex:1) — the min-height
   here is a floor, not the primary sizing mechanism, but matters because
   flex:1's "available space" itself depends on sibling sections' heights
   (ai-section above, in particular), so keeping every card-holding zone's
   floor consistent is what actually makes the whole page stable. */
.player-hand-row{flex:1;min-height:194px;display:flex;flex-wrap:nowrap;gap:5px;overflow-x:auto;overflow-y:hidden;padding:2px 1px;align-items:flex-start}
.empty-hand{color:#2d2d4e;font-size:11px;padding:6px 2px}

/* ── Cards ──────────────────────────────────────────────────── */
.card{width:136px;min-width:136px;height:190px;border-radius:6px;border:2px solid transparent;background:#1a1a2e;display:flex;flex-direction:column;position:relative;transition:transform .12s,box-shadow .12s;flex-shrink:0;cursor:default;overflow:hidden;padding:0}
.card.clickable{cursor:pointer}
.card.clickable:hover{transform:translateY(-4px);box-shadow:0 5px 14px rgba(0,0,0,.6)}
.card.selected{transform:translateY(-7px);box-shadow:0 0 0 2px #ffd700,0 7px 18px rgba(255,215,0,.25);border-color:#ffd700}
.card.retained{transform:translateY(-7px);box-shadow:0 0 0 2px #68d391,0 7px 18px rgba(104,211,145,.35);border-color:#68d391}
.card.affordable{cursor:pointer;box-shadow:0 0 0 2px #38a169,0 3px 12px rgba(56,161,105,.3)}
.card.affordable:hover{transform:translateY(-4px)}
.card.dimmed{opacity:.35;cursor:default}
/* Only ever the opponent's (redacted) hand — real cards never use this
   class — so shrinking it doesn't touch anything else. Slightly smaller
   than a normal card and noticeably dimmed (real illustrated back,
   gpt_cardback.png, not the placeholder paw icon this used to be) so it
   reads as "hidden," not as a card competing for attention with the
   actually-playable ones below it. */
.card.face-down{width:116px;min-width:116px;height:162px;border-color:#000;cursor:default;filter:brightness(.55)}
.card-name{padding:3px 4px 1px;font-size:9px;font-weight:bold;color:#ddd;line-height:1.2;min-height:22px;display:flex;align-items:center}
.card-art{flex:1;margin:0 3px;border-radius:3px;display:flex;align-items:flex-end;justify-content:center;padding-bottom:3px;min-height:0;position:relative;overflow:hidden}
.card-art img{position:absolute;top:0;left:0;width:100%;height:100%;object-fit:contain;object-position:center}
.card-png{width:100%;height:100%;object-fit:cover;border-radius:4px;display:block}
.type-lbl{font-size:8px;font-weight:bold;letter-spacing:.4px;opacity:.8;text-transform:uppercase}
.card-fx{padding:1px 4px;font-size:8px;color:#888;line-height:1.3;min-height:16px;max-height:26px;overflow:hidden}
.card-stats{display:flex;gap:2px;padding:2px 3px;flex-wrap:wrap}
.stat{padding:1px 4px;border-radius:2px;font-size:9px;font-weight:bold}
.stat.atk{background:#742a2a;color:#fc8181}
.stat.def{background:#1a365d;color:#63b3ed}
.stat.val{background:#744210;color:#f6ad55}
.cost-badge{position:absolute;top:-6px;right:-6px;background:#d4ac0d;color:#1a1200;border-radius:50%;width:17px;height:17px;font-size:9px;font-weight:bold;display:flex;align-items:center;justify-content:center;z-index:2}
/* min-height matches one armor-chip's rendered height (~18px content +
   border) so the row reserves its space even with zero armor — paired
   with armorRowHtml() (game_ai.html/game_multiplayer.html) always
   rendering the wrapping div now, instead of returning '' and removing
   it from the DOM entirely when armor.length is 0. */
.armor-row{display:flex;flex-wrap:wrap;gap:4px;margin-top:3px;min-height:20px}
.showdown{background:#0a0a18;border-radius:8px;margin:4px 0;padding:5px 6px}
.showdown-row{display:flex;align-items:center;gap:10px}
.showdown-col{display:flex;flex-direction:column;gap:3px}
.showdown-lbl{font-size:8px;font-weight:bold;letter-spacing:.4px;text-transform:uppercase;opacity:.5}
/* min-height matches .showdown-cards .card's own height (124px) below —
   was 74px, smaller than an actual showdown card, so the zone still grew
   every time an attack/block sequence populated it and shrank back down
   after. Now the "no attack in progress" (em-dash) state and the
   cards-showing state render at the exact same height. */
.showdown-cards{display:flex;gap:3px;flex-wrap:nowrap;min-height:124px;align-items:center}
.showdown-cards .card{width:88px;min-width:88px;height:124px;font-size:8px}
.showdown-cards .card-name{font-size:7px;min-height:14px;padding:2px 3px 0}
.showdown-cards .card-fx{font-size:6px;min-height:10px;max-height:16px}
.showdown-cards .stat{font-size:7px;padding:1px 3px}
.showdown-empty{font-size:9px;color:#252535;font-style:italic;padding:4px}
.showdown-vs{font-size:14px;color:#2a2a3a;flex-shrink:0}
.armor-chip{display:flex;align-items:center;gap:4px;background:#0d1f3c;border:1px solid #1a4276;border-radius:4px;padding:2px 6px;font-size:10px;white-space:nowrap}
.armor-chip .chip-track{width:32px;height:4px;background:#1a2a3a;border-radius:2px;overflow:hidden}
.armor-chip .chip-fill{height:100%;background:#63b3ed;border-radius:2px;transition:width .3s}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn{padding:5px 12px;border:none;border-radius:4px;font-size:11px;font-weight:bold;cursor:pointer;transition:opacity .15s}
.btn:hover{opacity:.82}
.btn:disabled{opacity:.3;cursor:not-allowed}
.btn-primary{background:#2b6cb0;color:#fff}
.btn-danger{background:#c53030;color:#fff}
.btn-secondary{background:#2d3748;color:#cbd5e0}
.btn-green{background:#276749;color:#fff}
.pool{font-size:12px;color:#a0aec0;font-weight:bold}
