/* ============================================================================
 * TerraMon — visual system
 * A premium, Pokémon-TCG-flavoured skin over the existing class contract.
 * Depth & atmosphere come from the transparent three.js scene (#bg3d) and the
 * painted arena backdrop (body::before); the DOM stays crisp and readable.
 * Every selector the JS emits is preserved here — restyled, never renamed.
 * ==========================================================================*/

/* ----- design tokens ------------------------------------------------------ */
:root {
  /* surfaces */
  --bg: #070a12;
  --panel: #111a2e;
  --panel2: #1a2440;
  --panel3: #232f4f;
  --ink: #eaf0fb;
  --muted: #9db0d4;
  --faint: #5d6c8f;
  --line: #29344f;
  --line2: #3b496e;
  /* accents */
  --gold: #ffd27d;
  --gold-deep: #b9842b;
  --gold-ink: #2a1c03;
  --good: #5fe39b;
  --bad: #ff7d8e;
  --header: 56px;
  /* type — the TerraMon brand font (Cinzel) is used everywhere */
  --font-display: "Cinzel", "Trebuchet MS", "Georgia", serif;
  --font-ui: "Cinzel", "Trebuchet MS", "Georgia", serif;
  /* motion */
  --ease-spring:      cubic-bezier(.34,1.56,.64,1);
  --ease-spring-big:  cubic-bezier(.5,-0.3,.2,1.4);
  --ease-out-quart:   cubic-bezier(.16,.84,.44,1);
  --ease-out-back:    cubic-bezier(.22,1.2,.36,1);
  --ease-in-wind:     cubic-bezier(.5,0,.9,.3);
  --ease-in-dissolve: cubic-bezier(.4,0,1,1);
  --ease-std:         cubic-bezier(.4,0,.2,1);
  /* card metal */
  --frame: linear-gradient(160deg, #46557d 0%, #222c44 42%, #141a2c 100%);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  height: 100vh; overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* no text highlighting — drag/double-click selection was breaking interactions */
  -webkit-user-select: none; -moz-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
/* …except where the user actually types/selects */
input, textarea, [contenteditable], .chat-msg, .igc-log, .log-line {
  -webkit-user-select: text; -moz-user-select: text; user-select: text;
}
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 6px; }

/* element theme variables (must cover every key of ELEMENTS in cards.js) */
.el-fire     { --el:#ff6a48; --elglow:#ffc07a; --eldeep:#7a1f12; }
.el-water    { --el:#3f86f0; --elglow:#8fdcff; --eldeep:#0f2f5e; }
.el-earth    { --el:#c2914a; --elglow:#efcf8f; --eldeep:#4a3415; }
.el-air      { --el:#6cc6e2; --elglow:#cdf0f7; --eldeep:#1f4a57; }
.el-dark     { --el:#9148e0; --elglow:#caa0ff; --eldeep:#2c134a; }
.el-light    { --el:#f3c93a; --elglow:#fff2b0; --eldeep:#5a4700; }
.el-electric { --el:#f4d63a; --elglow:#fff572; --eldeep:#5a4d00; }
.el-nature   { --el:#43b873; --elglow:#9aefb9; --eldeep:#12492c; }
.el-neutral  { --el:#69769a; --elglow:#aab4cc; --eldeep:#2a3145; }

/* ----- background layers -------------------------------------------------- */
/* Painted arena art sits behind the transparent 3D canvas. A slight blur +
 * dark scrim turns it into calm atmosphere so the cards stay the focus
 * (overscaled so the blur can't reveal the canvas edges). */
body::before {
  content: ''; position: fixed; inset: -4%; z-index: 0; pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 8%, transparent 42%, rgba(4,7,14,.6) 100%),
    linear-gradient(180deg, rgba(5,8,15,.58) 0%, rgba(5,8,15,.24) 40%, rgba(5,8,15,.34) 64%, rgba(4,6,12,.84) 100%),
    url('assets/arena/arena-menu.png') center / cover no-repeat var(--bg);
  transition: opacity .6s ease;
  filter: saturate(1.04) blur(1px);
  transform: scale(1.04);
}
/* battle art is bright/busy — soften it further and dim the centre band where
 * the board sits, so card text and the HUD read cleanly over it. */
body.in-battle::before {
  background:
    radial-gradient(75% 60% at 50% 52%, rgba(3,5,11,.62), transparent 70%),
    linear-gradient(180deg, rgba(5,8,15,.6) 0%, rgba(5,8,15,.34) 40%, rgba(5,8,15,.42) 62%, rgba(4,6,12,.85) 100%),
    url('assets/arena/arena-battle.png') center / cover no-repeat var(--bg);
  filter: saturate(.96) blur(2.5px);
}
/* three.js canvases (transparent, alpha:true) */
#bg3d { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 0; display: block; pointer-events: none; }

/* ----- top bar ------------------------------------------------------------ */
.topbar {
  position: relative; z-index: 5; height: var(--header);
  display: flex; align-items: center; justify-content: space-between; padding: 0 18px;
  background: linear-gradient(180deg, rgba(13,19,34,.92), rgba(8,12,22,.82));
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 18px rgba(0,0,0,.45), inset 0 -1px 0 rgba(255,255,255,.03);
  backdrop-filter: blur(8px);
}
.brand {
  font-family: var(--font-display); font-size: 21px; font-weight: 700; letter-spacing: 1px;
  background: linear-gradient(180deg, #fff, var(--gold) 120%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  display: flex; align-items: baseline; gap: 10px;
}
.brand span {
  font-family: var(--font-ui); font-size: 10px; color: var(--gold);
  font-weight: 600; letter-spacing: 2px; text-transform: uppercase;
  -webkit-text-fill-color: var(--gold);
}
.top-actions { display: flex; gap: 8px; }
.topbar button {
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  color: var(--ink); border: 1px solid var(--line); padding: 8px 13px; border-radius: 9px;
  cursor: pointer; font-weight: 700; font-size: 13px; transition: border-color .15s, color .15s, transform .1s;
}
.topbar button:hover { border-color: var(--gold); color: var(--gold); }
.topbar button:active { transform: translateY(1px); }

/* ----- arena -------------------------------------------------------------- */
.arena { position: relative; z-index: 1; height: calc(100vh - var(--header)); display: flex; align-items: center; justify-content: center; overflow: hidden; }
/* sized to its content (incl. the side dock) so fitBoard can scale it to fit
 * the viewport instead of the content overflowing and getting clipped */
/* FIXED size (both axes) so fitBoard's scale stays constant — the board must not
 * re-zoom every time a card is deployed, an action panel grows, or log/detail
 * text changes (that felt jumpy/confusing). The height is generous enough to
 * hold the tallest layout (both rows + a full side action dock + the hand); any
 * spare space is absorbed as middle slack (the hand is pinned to the bottom, the
 * enemy row to the top), so internal growth never moves either end or rescales. */
.board { position: relative; width: 1320px; height: 920px; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 6px; transform-origin: center center; }
.board.start-mode { width: auto; height: auto; }

/* play row: tabletop + the right-side turn dock */
.play-row { display: flex; align-items: center; gap: 18px; }
.turn-dock {
  flex: 0 0 auto; width: 152px; align-self: stretch; display: flex; flex-direction: column; justify-content: center; align-items: stretch; gap: 11px;
  padding: 16px 13px; border-radius: 18px;
  background: linear-gradient(180deg, rgba(20,28,48,.58), rgba(9,13,23,.42));
  border: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 10px 26px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.06);
  backdrop-filter: blur(3px);
}
.dock-hint { font-size: 11.5px; color: var(--muted); text-align: center; line-height: 1.45; }
.dock-hint b { color: var(--gold); }
.dock-btn { width: 100%; justify-content: center; }
.turn-dock .endturn { padding: 16px 12px; font-size: 15px; box-shadow: 0 8px 22px rgba(20,100,55,.55), inset 0 1px 0 rgba(255,255,255,.4), inset 0 -4px 9px rgba(10,60,30,.5); }

/* ============================================================================
 *  CARD FRAME  (shared by field, hand, detail, deckbuilder, start picks)
 * ==========================================================================*/
.tcard {
  position: relative; width: 150px; border-radius: 14px; overflow: hidden;
  background: var(--frame);
  border: 1px solid color-mix(in srgb, var(--el, #2a3450) 55%, #0a0e18);
  box-shadow:
    0 8px 22px rgba(0,0,0,.5),
    0 1px 0 rgba(255,255,255,.06) inset,
    0 0 0 1px rgba(0,0,0,.4);
  transition: transform .12s var(--ease-out-back), box-shadow .15s ease;
  isolation: isolate;
}
/* element-tinted metallic edge */
.tcard::before {
  content: ''; position: absolute; inset: 0; border-radius: 14px; padding: 1px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--elglow,#9bb) 70%, #fff 0%), transparent 40%, color-mix(in srgb, var(--el,#345) 60%, #000) 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  pointer-events: none; z-index: 4; opacity: .85;
}
.tcard.dead { opacity: .4; filter: grayscale(1) brightness(.8); }

.tc-top {
  position: relative; display: flex; justify-content: space-between; align-items: center; gap: 6px;
  padding: 6px 9px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--el) 92%, #fff 8%), var(--eldeep));
  border-bottom: 1px solid rgba(0,0,0,.45);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.22), inset 0 -6px 12px rgba(0,0,0,.25);
}
.tc-name {
  font-family: var(--font-display); font-weight: 700; font-size: 12.5px; color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,.85), 0 0 8px color-mix(in srgb, var(--elglow) 50%, transparent);
  line-height: 1.05; letter-spacing: .2px;
}
.tc-hp {
  min-width: 28px; height: 28px; padding: 0 6px; border-radius: 9px;
  background: radial-gradient(circle at 38% 28%, #ffe2e2, #ff6a6a 55%, #b21622 100%);
  color: #fff; font-weight: 900; font-size: 13px; display: flex; align-items: center; justify-content: center; gap: 2px;
  box-shadow: 0 2px 5px rgba(0,0,0,.5), inset 0 1px 1px rgba(255,255,255,.55), inset 0 -2px 4px rgba(120,0,0,.5);
  text-shadow: 0 1px 1px rgba(0,0,0,.4); flex: 0 0 auto;
}
.tc-hp::after { content: "♥"; font-size: 10px; opacity: .9; }
.tc-cost {
  min-width: 26px; height: 26px; padding: 0 4px; border-radius: 8px;
  background: radial-gradient(circle at 38% 28%, #e3f1ff, #58a6ff 52%, #1f5bbf 100%);
  color: #fff; font-weight: 900; font-size: 12.5px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 5px rgba(0,0,0,.5), inset 0 1px 1px rgba(255,255,255,.6), inset 0 -2px 4px rgba(0,40,110,.55);
  text-shadow: 0 1px 1px rgba(0,0,0,.4); flex: 0 0 auto;
}

.art-window {
  position: relative; height: 92px; overflow: hidden;
  background: #070b13;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.6), inset 0 8px 18px rgba(0,0,0,.55), inset 0 -10px 18px rgba(0,0,0,.45);
}
.art-window::after { /* frame vignette — tucks ANY art (incl. light/white
   backgrounds) into a consistent dark edge so nothing bleeds white to the card
   sides; plus a top sheen + bottom fade for depth. */
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 2;
  background:
    linear-gradient(90deg, rgba(7,11,19,.62) 0%, rgba(7,11,19,0) 12%, rgba(7,11,19,0) 88%, rgba(7,11,19,.62) 100%),
    radial-gradient(135% 100% at 50% 42%, transparent 50%, rgba(7,11,19,.78) 100%),
    linear-gradient(180deg, rgba(255,255,255,.13) 0%, transparent 24%, transparent 58%, rgba(7,11,19,.5) 100%);
}
.art-fallback { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.art-sigil { font-size: 38px; filter: drop-shadow(0 3px 8px rgba(0,0,0,.6)); }
.art-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }

.tc-type {
  display: flex; justify-content: space-between; align-items: center; padding: 4px 9px;
  background: linear-gradient(180deg, rgba(0,0,0,.5), rgba(0,0,0,.28));
  font-size: 10px; color: var(--elglow); font-weight: 800; letter-spacing: .4px;
  text-shadow: 0 1px 2px rgba(0,0,0,.7); border-top: 1px solid rgba(255,255,255,.05);
}
.gems { display: inline-flex; gap: 3px; }
.gem { width: 8px; height: 8px; transform: rotate(45deg); border-radius: 2px; box-shadow: 0 0 6px rgba(255,255,255,.5), inset 0 0 2px rgba(255,255,255,.8); }

.tc-body { padding: 8px 9px 5px; }
.tc-stats { display: flex; gap: 6px; margin-top: 7px; }
.pill {
  font-size: 10px; font-weight: 800; padding: 3px 8px; border-radius: 7px;
  display: inline-flex; gap: 3px; align-items: center; border: 1px solid transparent;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}
.pill.atk { background: linear-gradient(180deg, #582424, #3a1818); color: #ffc0b4; border-color: #6e3030; }
.pill.def { background: linear-gradient(180deg, #213c58, #15273d); color: #a8d4ff; border-color: #2f5070; }
.pill.spd { background: linear-gradient(180deg, #1d4029, #123020); color: #a6efc2; border-color: #2f6a45; }

.hpbar { position: relative; height: 16px; background: #0a1020; border-radius: 9px; overflow: hidden; border: 1px solid #20304d; margin-top: 3px; box-shadow: inset 0 2px 4px rgba(0,0,0,.5); }
.hpbar.big { height: 20px; }
.hpfill { height: 100%; background: linear-gradient(180deg, #6fe39a, #34b76a); box-shadow: 0 0 10px rgba(80,220,140,.45); transition: width .35s var(--ease-out-quart); }
.hpfill.g { background: linear-gradient(180deg, #ffdf91, #e0a23c); box-shadow: 0 0 10px rgba(255,200,90,.45); }
.hptext { position: absolute; inset: 0; font-size: 10px; text-align: center; line-height: 16px; color: #fff; text-shadow: 0 1px 2px #000; font-weight: 800; letter-spacing: .3px; }
.hpbar.big .hptext { line-height: 20px; font-size: 11px; }

.chips { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 7px; min-height: 4px; }
.chip { font-size: 9px; padding: 2px 6px; border-radius: 5px; font-weight: 800; box-shadow: inset 0 1px 0 rgba(255,255,255,.08); }
.chip.item { background: #2a3a25; color: #c0eea8; }
.chip.buff { background: #3a3216; color: #ffe08a; }
.chip.debuff { background: #3a1f2a; color: #ff9db4; }
.chip.burn { background: #4a2410; color: #ffb27a; }
.chip.poison { background: #26143a; color: #c79bff; }
.chip.freeze { background: #13324a; color: #9fd8ff; }

.card-acts { display: flex; flex-direction: column; gap: 5px; padding: 7px 9px 9px; }
/* action buttons live in a side strip next to the active card. The wrap is a
 * RIGID two-track grid: the active card column + a fixed action column that is
 * ALWAYS reserved (a real panel when actions exist, else an inert .acts-spacer).
 * align-items:start keeps the card top-anchored so it never recenters when the
 * panel appears/disappears (opponent turn) or grows/shrinks (2↔4 buttons). */
.active-wrap { display: grid; grid-template-columns: 120px 84px; column-gap: 12px; align-items: start; justify-items: center; }
/* inert filler that holds the action column when there's nothing to show */
.acts-spacer { visibility: hidden; pointer-events: none; }
.side-acts {
  width: 132px; flex: 0 0 auto; padding: 8px; gap: 7px;
  background: linear-gradient(180deg, rgba(18,25,42,.5), rgba(10,14,24,.32));
  border: 1px solid rgba(255,255,255,.06); border-radius: 13px;
  box-shadow: 0 6px 16px rgba(0,0,0,.3); backdrop-filter: blur(2px);
}
.side-acts .mini { font-size: 11px; padding: 9px 8px; border-radius: 9px; }
.side-acts .mini .ic { width: 1.05em; height: 1.05em; }

/* icon-only action panel (click a field card to open it) */
.side-acts.icon-acts { width: 84px; padding: 8px 8px; gap: 6px; align-self: start; }
.sa-head { font-family: var(--font-display); font-size: 10px; line-height: 1.15; color: var(--gold); text-align: center; margin-bottom: 1px; }
.sa-btn {
  position: relative; width: 100%; height: 40px; display: flex; align-items: center; justify-content: center;
  border-radius: 12px; border: 1px solid var(--line2); cursor: pointer;
  background: linear-gradient(180deg, var(--panel3), var(--panel2)); color: var(--ink);
  transition: transform .1s, box-shadow .14s, border-color .14s, color .14s;
}
.sa-btn .ic { width: 23px; height: 23px; }
.sa-btn:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--gold); color: var(--gold); box-shadow: 0 0 14px rgba(255,210,125,.32); }
.sa-btn:active:not(:disabled) { transform: translateY(1px); }
.sa-btn:disabled { opacity: .38; cursor: default; }
/* placeholder button: reserves a row so the panel height stays constant whether
 * or not the card has an ability / can evolve (kills the 2↔4-button vertical jump) */
.sa-btn.sa-ph { opacity: .22; cursor: default; }
.sa-btn.sa-ph:hover { transform: none; border-color: var(--line2); color: var(--ink); box-shadow: none; }
.sa-btn.sa-attack { background: linear-gradient(180deg, #6a2a2a, #431a1a); border-color: #8a3a3a; color: #ffd0c6; }
.sa-btn.sa-attack:hover:not(:disabled) { border-color: #ff9a86; color: #fff; box-shadow: 0 0 16px rgba(255,90,70,.45); }
.sa-btn.sa-evolve { background: linear-gradient(180deg, #34301a, #221f10); border-color: #6a5524; color: var(--gold); }
.sa-btn.sa-info { background: transparent; border-style: dashed; }
.sa-badge {
  position: absolute; top: -5px; right: -5px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  background: linear-gradient(180deg, #ffe09a, var(--gold-deep)); color: var(--gold-ink);
  font-size: 9px; font-weight: 900; display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 3px rgba(0,0,0,.5);
}
/* the card whose actions are open */
.tcard.selected { box-shadow: 0 0 0 3px var(--gold), 0 0 26px rgba(255,210,125,.55), 0 14px 24px rgba(0,0,0,.55) !important; }
.mini {
  font-size: 10px; padding: 6px; border-radius: 8px; border: 1px solid var(--line2);
  background: linear-gradient(180deg, var(--panel3), var(--panel2)); color: var(--ink); cursor: pointer; font-weight: 800;
  transition: border-color .12s, color .12s, transform .08s, box-shadow .12s;
}
.mini:hover:not(:disabled) { border-color: var(--gold); color: var(--gold); box-shadow: 0 0 12px rgba(255,210,125,.25); }
.mini:active:not(:disabled) { transform: translateY(1px); }
.mini:disabled { opacity: .4; cursor: default; }
.mini.atk-btn { background: linear-gradient(180deg, #6a2a2a, #431a1a); border-color: #8a3a3a; color: #ffd0c6; }
.mini.atk-btn:hover:not(:disabled) { border-color: #ff9a86; color: #fff; box-shadow: 0 0 14px rgba(255,90,70,.4); }
.mini.evolve-btn { background: linear-gradient(180deg, #34301a, #221f10); border-color: #6a5524; color: var(--gold); }
.mini.evolve-btn:disabled { color: #6b7798; }

.tcard.targetable { cursor: pointer; animation: targetPulse 1.1s infinite; }
.tcard.targetable::after { content: ''; position: absolute; inset: 0; border-radius: 14px; border: 2px solid var(--gold); pointer-events: none; z-index: 5; }
@keyframes targetPulse { 0%,100% { box-shadow: 0 8px 22px rgba(0,0,0,.5), 0 0 0 0 rgba(255,210,125,.5); } 50% { box-shadow: 0 8px 22px rgba(0,0,0,.5), 0 0 0 9px rgba(255,210,125,0); } }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,209,102,.5); } 50% { box-shadow: 0 0 0 7px rgba(255,209,102,0); } }

.tc-ability { margin: 7px 9px; padding: 7px 9px; background: linear-gradient(180deg, rgba(6,10,18,.85), rgba(10,15,26,.7)); border: 1px solid rgba(255,255,255,.06); border-left: 2px solid var(--el); border-radius: 8px; }
.ab-name { font-weight: 800; font-size: 11px; color: var(--elglow); letter-spacing: .2px; }
.ab-text { font-size: 10px; color: #cdd6e8; line-height: 1.4; margin-top: 2px; }
.tc-flavor { font-size: 9px; font-style: italic; color: #818daa; padding: 0 9px 9px; line-height: 1.35; }

/* rarity treatment */
.r-rare       { box-shadow: 0 8px 22px rgba(0,0,0,.5), 0 0 0 1px rgba(76,201,240,.45), 0 0 16px rgba(76,201,240,.18); }
.r-epic       { box-shadow: 0 8px 24px rgba(0,0,0,.55), 0 0 0 1px rgba(176,107,255,.5), 0 0 20px rgba(176,107,255,.28); }
.r-legendary  { box-shadow: 0 8px 26px rgba(0,0,0,.55), 0 0 0 1px rgba(255,210,125,.6), 0 0 26px rgba(255,200,90,.34); }
.r-legendary .tc-name { color: #fff7df; }

/* holographic foil (cursor hotspot from anim.js: --mx/--my/--foil-o) */
.foil::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; mix-blend-mode: screen; z-index: 3;
  /* soft, wide sheen — no bright square hotspot under the cursor */
  background:
    radial-gradient(circle at var(--mx,50%) var(--my,50%), rgba(255,255,255,.22), transparent 62%),
    linear-gradient(115deg, transparent 34%, rgba(255,255,255,.08) 47%, rgba(180,220,255,.16) 50%, rgba(255,225,190,.08) 53%, transparent 66%);
  background-size: 100% 100%, 240% 240%;
  opacity: var(--foil-o,0); transition: opacity .2s ease;   /* only shows under the cursor (anim.js sets --foil-o), no auto-animation */
}
@keyframes foil { 0% { background-position: 50% 50%, 0% 0%; } 100% { background-position: 50% 50%, 200% 200%; } }
/* the guardian select cards have square art — the holo sheen reads as an ugly
 * square there, so no foil on them */
.pick.foil::after { display: none; }

/* ----- compact field cards ------------------------------------------------ */
.tcard.on-field { width: 120px; }
.tcard.on-field .tc-top { padding: 5px 7px; }
.tcard.on-field .tc-name { font-size: 11px; }
.tcard.on-field .tc-hp { display: none; }
.tcard.on-field .art-window { height: 62px; }
.tcard.on-field .art-sigil { font-size: 30px; }
.tcard.on-field .tc-type { padding: 2px 7px; font-size: 9px; }
.tcard.on-field .tc-body { padding: 6px 7px 4px; }
.tcard.on-field .pill { font-size: 9px; padding: 2px 6px; }
.tcard.on-field .card-acts { padding: 6px 7px 7px; gap: 4px; }
/* compact field cards: drop the (cosmetic) SPD pill and let stats wrap so they never clip */
.tcard.on-field .pill.spd { display: none; }
.tcard.on-field .tc-stats { flex-wrap: wrap; }
.tcard.on-field .mini { font-size: 9px; padding: 5px; }
.tcard.on-field.bench { width: 102px; }
.tcard.on-field.bench .art-window { height: 50px; }
.tcard.on-field.bench .art-sigil { font-size: 24px; }

/* ----- a player's row ----------------------------------------------------- */
/* flex-start (not center): with the 84px action column reserved on BOTH rows,
 * my row and the enemy row are width-identical, so active cards align across
 * rows and nothing recenters when the action panel toggles. */
.side { display: flex; align-items: flex-start; gap: 14px; padding: 8px 12px; border-radius: 16px; }
.side.enemy { background: linear-gradient(180deg, rgba(255,90,70,.10), transparent 80%); }
.side.you   { background: linear-gradient(0deg, rgba(70,150,255,.12), transparent 80%); }
.field-row { display: flex; gap: 18px; align-items: flex-start; }
.zone-label { font-size: 9px; text-transform: uppercase; letter-spacing: 1.4px; color: var(--muted); margin-bottom: 5px; font-weight: 700; }
.bench-row { display: flex; gap: 9px; }
.deckinfo { margin-left: auto; font-size: 11px; color: var(--muted); text-align: right; line-height: 1.6; white-space: nowrap; }
.active-zone .tcard { box-shadow: 0 0 26px rgba(255,210,125,.5), 0 14px 24px rgba(0,0,0,.6); }
.active-zone .tcard::after { content: ''; position: absolute; inset: 0; border-radius: 14px; border: 2px solid rgba(255,210,125,.85); pointer-events: none; z-index: 5; }
.side .tcard.on-field { box-shadow: 0 14px 22px rgba(0,0,0,.55), 0 5px 10px rgba(0,0,0,.45); }

.slot {
  width: 102px; height: 152px; border: 2px dashed var(--line2); border-radius: 12px;
  display: flex; align-items: center; justify-content: center; color: var(--faint); font-size: 11px; text-align: center;
  background: radial-gradient(120% 90% at 50% 30%, rgba(255,255,255,.04), transparent 70%);
  box-shadow: inset 0 0 24px rgba(0,0,0,.35);
}
.active-zone .slot { width: 120px; height: 198px; }
.slot-label { padding: 0 6px; font-weight: 700; letter-spacing: .3px; }

/* ----- guardian ----------------------------------------------------------- */
.guardian {
  width: 204px; flex: 0 0 auto; display: flex; gap: 11px; padding: 11px; border-radius: 16px; position: relative; overflow: hidden;
  background: linear-gradient(180deg, rgba(20,28,46,.96), rgba(11,16,27,.95));
  border: 1px solid color-mix(in srgb, var(--el, #2a3450) 50%, #0a0e18);
  box-shadow: 0 10px 26px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.05);
}
.guardian::before { content: ''; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(120% 80% at 0% 0%, color-mix(in srgb, var(--el) 30%, transparent), transparent 55%); }
.guardian.mine { box-shadow: 0 10px 26px rgba(0,0,0,.5), 0 0 0 2px var(--gold), 0 0 22px rgba(255,210,125,.3); }
.g-art { width: 74px !important; height: 74px !important; border-radius: 12px; flex: 0 0 auto; box-shadow: 0 4px 12px rgba(0,0,0,.5), inset 0 0 0 1px rgba(255,255,255,.1); }
.g-art .art-sigil { font-size: 30px; }
.g-art::after { border-radius: 12px; }
.g-info { flex: 1; min-width: 0; position: relative; z-index: 1; }
.g-name { font-family: var(--font-display); font-weight: 700; font-size: 14px; line-height: 1.1; }
.g-el { font-size: 10px; color: var(--elglow); margin-bottom: 7px; font-weight: 700; }
.g-shields { display: flex; gap: 4px; margin-top: 6px; }
.shield-pip { font-size: 13px; filter: drop-shadow(0 0 5px rgba(110,180,255,.85)); transition: opacity .3s, filter .3s; }
.shield-pip.broken { opacity: .2; filter: grayscale(1); }
.g-ability { margin-top: 8px; }
.g-btn { font-size: 11px; padding: 7px 11px; border-radius: 9px; border: 1px solid var(--gold-deep); background: linear-gradient(180deg, #3a3018, #241d0e); color: var(--gold); cursor: pointer; font-weight: 800; transition: filter .12s, transform .08s, box-shadow .12s; }
.g-btn:hover:not(:disabled) { filter: brightness(1.2); box-shadow: 0 0 14px rgba(255,210,125,.4); }
.g-btn:active:not(:disabled) { transform: translateY(1px); }
.g-btn:disabled { opacity: .45; cursor: default; }
.g-ab-text { font-size: 10px; color: var(--muted); }

/* ----- midbar (turn / energy HUD) ----------------------------------------- */
.midbar { position: relative; display: flex; align-items: center; justify-content: center; gap: 16px; padding: 6px 4px; flex-wrap: wrap; text-shadow: 0 2px 6px rgba(0,0,0,.7); }
.midbar::before { content: ''; position: absolute; left: 6%; right: 6%; top: 50%; height: 1px; background: linear-gradient(90deg, transparent, rgba(160,200,255,.3), transparent); z-index: -1; }
.turninfo { font-family: var(--font-display); font-weight: 700; letter-spacing: .4px; font-size: 15px; color: #f3f6ff; }
.turninfo b { color: var(--gold); }
.endturn {
  position: relative; overflow: hidden;
  background: linear-gradient(180deg, #54d089 0%, #2a9159 46%, #176b3d 100%); color: #fff; border: 1px solid #6ee0a0;
  padding: 12px 26px; border-radius: 12px; font-family: var(--font-display); font-weight: 800; font-size: 14px; cursor: pointer; letter-spacing: .8px; text-transform: uppercase;
  text-shadow: 0 1px 2px rgba(0,40,20,.6);
  box-shadow: 0 6px 18px rgba(20,100,55,.5), inset 0 1px 0 rgba(255,255,255,.38), inset 0 -4px 9px rgba(10,60,30,.5);
  transition: transform .1s, box-shadow .16s, filter .16s;
}
.endturn:hover { transform: translateY(-2px); filter: brightness(1.08); box-shadow: 0 10px 26px rgba(30,140,75,.6), inset 0 1px 0 rgba(255,255,255,.42), 0 0 24px rgba(95,227,155,.5); }
.endturn:active { transform: translateY(1px); }
.cancel { background: linear-gradient(180deg, #6a2a39, #441a26); color: #ffd9df; border: 1px solid #a0455a; padding: 9px 16px; border-radius: 10px; cursor: pointer; font-weight: 700; }
.cancel:hover { filter: brightness(1.12); }
.last-log { font-size: 11px; color: var(--muted); max-width: 460px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.last-log b { color: var(--ink); }
.adv { color: var(--gold); font-weight: 700; }
.resist { color: var(--muted); font-weight: 700; }

.energy-bar { font-size: 13px; color: #bfe2ff; font-weight: 800; display: inline-flex; align-items: center; gap: 5px; }
.energy-bar b { color: #fff; }
.epip { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #1a2840; border: 1px solid #2f4f6a; box-shadow: inset 0 1px 2px rgba(0,0,0,.6); }
.epip.on { background: radial-gradient(circle at 38% 30%, #d6ecff, #3a86e0); border-color: #6fb0ff; box-shadow: 0 0 7px rgba(110,180,255,.85); }

/* ----- hand --------------------------------------------------------------- */
/* margin-top:auto pins the hand to the board's bottom edge; combined with the
 * fixed board height, internal growth above (action dock, chips, card detail)
 * eats the middle slack instead of shifting the hand or resizing the board. */
.hand-wrap { padding-top: 6px; margin-top: auto; }
.hand-label { font-size: 10px; color: var(--muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 1.5px; text-align: center; font-weight: 700; }
.hand { display: flex; gap: 0; flex-wrap: nowrap; justify-content: center; padding: 6px 60px 2px; }
.empty-hand { color: var(--faint); font-style: italic; }
.hand-card { width: 150px; flex: 0 0 auto; margin: 0 -16px; transition: transform .16s var(--ease-out-back), margin .16s var(--ease-out-back), box-shadow .16s ease; }
.hand-card .art-window { height: 94px; }
.hand-card .art-sigil { font-size: 42px; }
.hand-card.playable { cursor: pointer; }
.hand:hover .hand-card { margin: 0 -8px; }
.hand-card.playable:hover { transform: translateY(-14px) scale(1.06); margin: 0 6px; z-index: 9; box-shadow: 0 22px 40px rgba(0,0,0,.65), 0 0 22px rgba(255,210,125,.35); }
.tcard.unaffordable { opacity: .52; filter: grayscale(.5); }

/* online opponent hand backs */
.card-back { display: flex; align-items: center; justify-content: center; background: repeating-linear-gradient(45deg, #14203c, #14203c 8px, #1b2a52 8px, #1b2a52 16px); border-color: #2f3f66; }
.card-back::before { background: linear-gradient(160deg, rgba(255,210,125,.4), transparent 50%); }
.card-back-sigil { font-size: 44px; filter: drop-shadow(0 2px 6px rgba(0,0,0,.6)); opacity: .85; }

/* ============================================================================
 *  TABLETOP  (flat, readable — depth comes from the 3D scene + shadows)
 * ==========================================================================*/
.table {
  position: relative; display: flex; flex-direction: column; gap: 8px;
  padding: 12px 16px 12px 150px;          /* room for the avatar rail */
  border-radius: 28px;
  background:
    radial-gradient(ellipse 80% 74% at 50% 50%, rgba(70,100,180,.18), rgba(20,30,60,.10) 56%, transparent 78%);
  box-shadow: inset 0 0 80px rgba(8,14,30,.45), inset 0 0 0 1px rgba(120,150,220,.08);
}
/* avatar rail */
.table-rail { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 22px; z-index: 6; }
.avatar-chip {
  display: flex; gap: 9px; align-items: center; width: 128px; padding: 7px 9px; border-radius: 14px;
  background: linear-gradient(180deg, rgba(22,32,56,.96), rgba(12,17,28,.96)); border: 1px solid var(--line);
  box-shadow: 0 6px 16px rgba(0,0,0,.45); transition: box-shadow .25s, border-color .25s, transform .25s;
}
.avatar-chip.active-turn { border-color: var(--gold); box-shadow: 0 0 20px rgba(255,210,125,.6); transform: scale(1.04); }
.avatar-art { width: 44px; height: 44px; border-radius: 50%; overflow: hidden; position: relative; flex: 0 0 auto; box-shadow: 0 0 0 2px rgba(255,255,255,.14), 0 3px 8px rgba(0,0,0,.5); }
.avatar-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar-info { min-width: 0; }
.avatar-name { font-weight: 800; font-size: 12px; line-height: 1.15; }
.avatar-sub { font-size: 9px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar-hp { font-size: 10px; color: #ff9db4; font-weight: 700; margin-top: 1px; }

/* deck / discard piles */
.pile { width: 58px; display: flex; flex-direction: column; align-items: center; gap: 3px; flex: 0 0 auto; }
.pile-stack { position: relative; width: 44px; height: 60px; }
.pile-card { position: absolute; inset: 0; border-radius: 7px; border: 1px solid #2f3f66; box-shadow: 0 1px 3px rgba(0,0,0,.5);
  background: repeating-linear-gradient(45deg, #14203c, #14203c 6px, #1b2a52 6px, #1b2a52 12px); }
.pile-discard .pile-card { background: repeating-linear-gradient(45deg, #2a1830, #2a1830 6px, #3a2440 6px, #3a2440 12px); border-color: #5a3a66; }
.pile-empty { position: absolute; inset: 0; border: 1px dashed var(--line2); border-radius: 7px; }
.pile-count { font-weight: 900; font-size: 13px; color: var(--ink); }
.pile-label { font-size: 8px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); }

/* ============================================================================
 *  COMBAT FX  (DOM animations driven by one-shot _fx* flags)
 * ==========================================================================*/
@keyframes hitShake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-5px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(3px); } }
.fx-hit { animation: hitShake .4s ease; }
.fx-hit::before { content: ""; position: absolute; inset: 0; z-index: 4; pointer-events: none; background: radial-gradient(circle, rgba(255,90,90,.6), transparent 70%); animation: hitFlash .45s ease; }
@keyframes hitFlash { 0% { opacity: .9; } 100% { opacity: 0; } }
@keyframes cardIn { 0% { transform: translateY(18px) scale(.78); opacity: 0; } 100% { transform: translateY(0) scale(1); opacity: 1; } }
.fx-enter { animation: cardIn .38s var(--ease-out-back); }
.tcard.fx-attacking { transform: translateY(-12px) scale(.96); transition: transform .13s var(--ease-in-wind); z-index: 7; box-shadow: 0 0 26px rgba(255,255,255,.3), 0 14px 24px rgba(0,0,0,.6); }
.tcard.dying { animation: dissolve .44s var(--ease-in-dissolve) forwards; }
@keyframes dissolve { to { opacity: 0; transform: scale(.68) rotate(-7deg); filter: blur(4px) brightness(2.2); } }
.dmg-pop { position: absolute; top: 26%; left: 50%; z-index: 8; pointer-events: none; font-family: var(--font-display); font-weight: 900; font-size: 24px; color: #ff6a6a; text-shadow: 0 2px 4px #000, 0 0 10px rgba(255,0,0,.7); animation: dmgFloat 1s ease forwards; }
@keyframes dmgFloat { 0% { opacity: 0; transform: translate(-50%, 8px) scale(.6); } 25% { opacity: 1; transform: translate(-50%, -4px) scale(1.25); } 100% { opacity: 0; transform: translate(-50%, -32px) scale(1); } }
.dmg-pop.fatigue { color: #c98bff; text-shadow: 0 2px 6px #000, 0 0 12px rgba(160,80,255,.8); font-size: 17px; }

/* ============================================================================
 *  START SCREEN
 * ==========================================================================*/
.start { text-align: center; padding: 8px 10px 14px; max-width: 1180px; }
.title {
  font-family: var(--font-display); font-size: 62px; margin: 0; letter-spacing: 3px; font-weight: 800; line-height: 1;
  background: linear-gradient(180deg, #fff6e0 0%, var(--gold) 55%, var(--gold-deep) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 18px rgba(255,200,90,.35));
}
.subtitle { font-family: var(--font-display); color: var(--gold); letter-spacing: 6px; text-transform: uppercase; font-size: 13px; margin: 8px 0 4px; text-shadow: 0 2px 8px rgba(0,0,0,.85), 0 1px 2px rgba(0,0,0,.9); }
.lead { color: #e7edf9; margin: 0 auto 24px; max-width: 640px; font-size: 14.5px; line-height: 1.55; text-shadow: 0 2px 8px rgba(0,0,0,.9), 0 1px 3px rgba(0,0,0,.95); }

/* ---- difficulty selector (start screen) -------------------------------- */
.start-diff { margin: 0 auto 24px; max-width: 640px; text-align: center; }
.sd-label { font-family: var(--font-display); font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: var(--gold); margin-bottom: 10px; text-shadow: 0 2px 6px rgba(0,0,0,.8); }
.sd-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.sd-tier {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-width: 92px; padding: 9px 14px; cursor: pointer;
  border-radius: 11px; border: 1px solid var(--line2);
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  color: var(--ink); font-weight: 700; transition: transform .12s, border-color .12s, box-shadow .12s, color .12s;
}
.sd-tier:hover { transform: translateY(-1px); border-color: var(--gold); color: var(--gold); box-shadow: 0 0 14px rgba(255,210,125,.28); }
.sd-tier.on { border-color: var(--gold); color: var(--gold-ink);
  background: linear-gradient(180deg, #ffe09a, var(--gold-deep));
  box-shadow: 0 0 0 2px var(--gold), 0 0 20px rgba(255,210,125,.5); }
.sd-name { font-family: var(--font-display); font-size: 13px; }
.sd-stars { font-size: 11px; letter-spacing: 1px; color: var(--gold); }
.sd-tier.on .sd-stars { color: var(--gold-ink); }
.sd-rec { font-size: 10px; font-weight: 700; letter-spacing: .3px; color: #aab6d0; margin-top: 2px; }
.sd-rec-none { color: #6b7798; font-weight: 600; font-style: italic; }
.sd-tier.on .sd-rec { color: var(--gold-ink); }
.sd-tier.on .sd-rec-none { color: #6a5320; }
.sd-blurb { margin: 11px auto 0; max-width: 560px; min-height: 32px; font-size: 12.5px; line-height: 1.45; color: #d6deef; text-shadow: 0 1px 4px rgba(0,0,0,.85); }

.guardian-grid { display: flex; gap: 20px; justify-content: center; align-items: stretch; flex-wrap: wrap; }
/* flex column + button pinned to the bottom → every Quick Play aligns on one baseline */
.pick { width: 236px; cursor: pointer; display: flex; flex-direction: column; transition: transform .18s var(--ease-out-back), box-shadow .18s ease; }
.pick .art-window { height: 164px; }
.pick .art-photo { object-position: center top; }
.pick .art-sigil { font-size: 60px; }
.pick .tc-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick .tc-ability { min-height: 84px; }      /* equalise the ability boxes */
.pick .tc-flavor { min-height: 30px; }
.pick:hover { transform: translateY(-10px) scale(1.02); box-shadow: 0 8px 26px rgba(0,0,0,.55), 0 0 32px color-mix(in srgb, var(--el) 45%, transparent); }
.pick-btn { margin-top: auto; }             /* pin to bottom of the flex column */

.start-menu { display: flex; gap: 16px; justify-content: center; margin-top: 28px; flex-wrap: wrap; }

/* ============================================================================
 *  EPIC BUTTONS  — beveled, glowing, with a sheen sweep on hover
 * ==========================================================================*/
/* gold primary CTAs */
.pick-btn, .big-btn, .db-start, .detail-btn:not(:last-child), .welcome-btn {
  position: relative; overflow: hidden; isolation: isolate;
  border: 1px solid #ffe6a0; border-radius: 12px; cursor: pointer;
  background: linear-gradient(180deg, #ffeaa6 0%, #f6c659 44%, #d2902c 100%);
  color: #3a2405; font-family: var(--font-display); font-weight: 800; letter-spacing: .8px; text-transform: uppercase;
  text-shadow: 0 1px 0 rgba(255,255,255,.45);
  box-shadow: 0 6px 18px rgba(170,110,25,.5), inset 0 1px 0 rgba(255,255,255,.75),
              inset 0 -4px 9px rgba(150,90,12,.45), 0 0 0 1px rgba(110,66,10,.5);
  transition: transform .1s, box-shadow .16s, filter .16s;
}
.pick-btn { width: calc(100% - 18px); margin: 6px 9px 12px; margin-top: auto; padding: 12px; font-size: 14px; }
.pick-btn .ic, .big-btn .ic, .detail-btn .ic { color: #5a3a08; }
.pick-btn::after, .big-btn::after, .db-start::after, .detail-btn:not(:last-child)::after {
  content: ''; position: absolute; top: -20%; left: -65%; width: 45%; height: 140%; z-index: -1;
  background: linear-gradient(105deg, transparent, rgba(255,255,255,.6), transparent);
  transform: skewX(-18deg); pointer-events: none;
}
.pick:hover .pick-btn::after, .pick-btn:hover::after, .big-btn:hover::after,
.db-start:hover::after, .detail-btn:not(:last-child):hover::after { animation: btnSheen .85s ease; }
@keyframes btnSheen { from { left: -65%; } to { left: 130%; } }
.pick-btn:hover, .big-btn:hover, .db-start:hover, .detail-btn:not(:last-child):hover {
  transform: translateY(-2px); filter: brightness(1.05);
  box-shadow: 0 10px 28px rgba(220,150,40,.6), inset 0 1px 0 rgba(255,255,255,.85),
              inset 0 -4px 9px rgba(150,90,12,.4), 0 0 26px rgba(255,200,90,.55), 0 0 0 1px rgba(110,66,10,.6);
}
.pick-btn:active, .big-btn:active, .db-start:active, .detail-btn:not(:last-child):active { transform: translateY(1px); }

/* navy secondary buttons (menu / lobby) */
.menu-btn, .net-btn:not(.primary) {
  position: relative; overflow: hidden;
  padding: 14px 26px; border-radius: 13px; cursor: pointer;
  border: 1px solid rgba(120,150,210,.42);
  background: linear-gradient(180deg, #26375a 0%, #16223c 100%);
  color: #eaf0fb; font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: .8px;
  text-shadow: 0 1px 2px rgba(0,0,0,.6);
  box-shadow: 0 6px 18px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.12), inset 0 -3px 8px rgba(0,0,0,.4);
  transition: transform .1s, box-shadow .16s, border-color .16s, color .16s;
}
.menu-btn .ic { color: var(--gold); }
.menu-btn:hover, .net-btn:not(.primary):hover {
  transform: translateY(-2px); color: #fff; border-color: var(--gold);
  box-shadow: 0 10px 24px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.18), 0 0 24px rgba(255,210,125,.4);
}
.menu-btn:active, .net-btn:not(.primary):active { transform: translateY(1px); }

/* ============================================================================
 *  OVERLAY PLANES & MODALS
 *  z: bg 0 < arena 1 < topbar 5 < fxgl 39 < fx 40 < win 50 < modals 60 < howto 65 < tutorial 70 < bubble 72 < welcome 200 < rotate-gate 1200
 * ==========================================================================*/
#board-shake { will-change: transform; }
.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 40; }
#fxgl.fx-layer { z-index: 39; }
.overlay-layer { position: fixed; inset: 0; z-index: 60; display: none; align-items: center; justify-content: center; background: rgba(4,7,14,.86); backdrop-filter: blur(4px); }
.overlay-layer.show { display: flex; }
#tutorial-layer { position: fixed; inset: 0; z-index: 70; pointer-events: none; }

/* pointer tilt + cursor holo (anim.js sets --rx/--ry/--mx/--my/--foil-o) */
.tcard.tilting { transform: perspective(760px) rotateX(var(--rx,0)) rotateY(var(--ry,0)); transition: transform .12s var(--ease-out-back); z-index: 6; }
.hand-card.tilting,
.hand-card.playable.tilting { transform: perspective(760px) rotateX(var(--rx,0)) rotateY(var(--ry,0)) translateY(-12px) scale(1.06); z-index: 9; }

/* win overlay */
.overlay { position: fixed; inset: 0; background: radial-gradient(circle at 50% 40%, rgba(10,16,30,.78), rgba(3,5,11,.92)); display: flex; align-items: center; justify-content: center; z-index: 50; backdrop-filter: blur(3px); animation: detailIn .3s var(--ease-out-quart); }
.win-box { background: linear-gradient(180deg, #161f33, #0c1019); border: 1px solid var(--gold); border-radius: 20px; padding: 38px 48px; text-align: center; max-width: 440px; box-shadow: 0 24px 70px rgba(0,0,0,.65), 0 0 40px rgba(255,200,90,.2); }
.win-box h2 { font-family: var(--font-display); font-size: 44px; margin: 0 0 10px; letter-spacing: 1px; }
.win-box .victory { color: var(--good); text-shadow: 0 0 24px rgba(80,220,140,.5); }
.win-box .defeat { color: var(--bad); text-shadow: 0 0 24px rgba(255,90,110,.5); }
.win-box p { color: var(--muted); line-height: 1.5; }
.big-btn { margin-top: 18px; background: linear-gradient(180deg, #ffe09a, var(--gold-deep)); color: var(--gold-ink); border: none; padding: 13px 28px; border-radius: 12px; font-weight: 900; font-size: 15px; cursor: pointer; box-shadow: 0 6px 16px rgba(180,120,30,.45), inset 0 1px 0 rgba(255,255,255,.5); transition: filter .12s, transform .08s; }
.big-btn:hover { filter: brightness(1.08); }
.big-btn:active { transform: translateY(1px); }

/* card-detail modal */
.detail-box { display: flex; flex-direction: column; align-items: center; gap: 16px; animation: detailIn .24s var(--ease-out-quart); }
@keyframes detailIn { from { opacity: 0; transform: scale(.92) translateY(10px); } to { opacity: 1; transform: none; } }
.detail-card { width: 320px; }
.detail-card .tc-top { padding: 9px 13px; }
.detail-card .tc-name { font-size: 18px; }
.detail-card .tc-hp { min-width: 36px; height: 36px; font-size: 16px; }
.detail-card .tc-cost { min-width: 32px; height: 32px; font-size: 15px; }
.detail-card .art-window { height: 230px; }
.detail-card .art-sigil { font-size: 100px; }
.detail-card .tc-type { font-size: 13px; padding: 6px 13px; }
.detail-card .tc-ability { margin: 10px 13px; padding: 10px 12px; }
.detail-card .ab-name { font-size: 14px; }
.detail-card .ab-text { font-size: 12.5px; }
.detail-card .tc-flavor { font-size: 11.5px; padding: 0 13px 12px; }
.detail-card .pill { font-size: 12px; padding: 4px 10px; }
.detail-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; max-width: 380px; }
.detail-btn { padding: 12px 19px; border-radius: 11px; border: 1px solid var(--gold); background: linear-gradient(180deg, #ffe09a, var(--gold-deep)); color: var(--gold-ink); font-weight: 900; font-size: 14px; cursor: pointer; box-shadow: inset 0 1px 0 rgba(255,255,255,.45); transition: filter .12s, transform .08s; }
.detail-btn:hover { filter: brightness(1.08); }
.detail-btn:active { transform: translateY(1px); }
.detail-btn.disabled, .detail-btn:disabled { background: var(--panel2); color: #6b7798; border-color: var(--line); cursor: default; filter: none; box-shadow: none; }
.detail-btn:last-child { background: linear-gradient(180deg, var(--panel2), var(--panel)); color: var(--ink); border-color: var(--line2); }

/* ============================================================================
 *  DECK BUILDER  (#deck-layer)
 * ==========================================================================*/
.db-panel { width: min(1240px, 96vw); height: min(90vh, 860px); background: radial-gradient(120% 80% at 50% -10%, #1a2740, #0c1220 60%, #080b13); border: 1px solid var(--line2); border-radius: 20px; display: flex; flex-direction: column; padding: 18px 20px; box-shadow: 0 30px 80px rgba(0,0,0,.7), inset 0 1px 0 rgba(255,255,255,.05); }
.db-head { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.db-head h2, .db-head .db-title { font-family: var(--font-display); font-size: 23px; color: var(--gold); margin: 0; letter-spacing: 1px; text-shadow: 0 2px 10px rgba(255,210,125,.25); }
.db-sub { font-size: 11.5px; color: var(--muted); text-align: right; }
.db-cols { display: grid; grid-template-columns: 238px 1fr 300px; gap: 16px; flex: 1; min-height: 0; }
.db-col { background: linear-gradient(180deg, rgba(13,19,32,.7), rgba(7,11,19,.55)); border: 1px solid var(--line); border-radius: 15px; padding: 13px; display: flex; flex-direction: column; min-height: 0; }
.db-col h3, .db-h { margin: 0 0 10px; font-size: 11.5px; text-transform: uppercase; letter-spacing: 1.4px; color: var(--muted); font-weight: 800; }
.db-group-h { font-size: 11px; color: var(--gold); }
.db-guardians, .db-pool, .db-list { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.db-guardian-list { display: flex; flex-direction: column; gap: 11px; overflow-y: auto; padding-right: 4px; }
.db-guardian-list .pick, .db-pick { width: 100%; cursor: pointer; transition: transform .12s var(--ease-out-back); }
.db-guardian-list .pick:hover, .db-pick:hover { transform: translateY(-2px); }
.db-guardian-list .pick.selected, .db-pick.selected { outline: 2px solid var(--gold); outline-offset: 1px; box-shadow: 0 0 22px rgba(255,210,125,.35); }
.db-pool-scroll { overflow-y: auto; flex: 1; padding-right: 4px; }
.db-group { margin: 4px 2px 2px; }
.db-group-h { text-transform: uppercase; letter-spacing: 1.3px; margin: 12px 2px 9px; font-weight: 800; }
.db-group:first-child .db-group-h { margin-top: 2px; }
.db-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(134px,1fr)); gap: 13px; }
.db-grid .tcard, .db-tile { width: 100%; cursor: pointer; transition: transform .13s var(--ease-out-back), box-shadow .15s ease, filter .15s ease; }
.db-tile { position: relative; }
.db-tile:hover { transform: translateY(-4px); box-shadow: 0 14px 30px rgba(0,0,0,.55), 0 0 22px rgba(255,210,125,.18); z-index: 2; }
.db-tile .tc-name { font-size: 11.5px; }
.db-tile .art-window { height: 116px; }
.db-tile .tc-type { padding: 3px 8px; font-size: 9.5px; }
.db-tile .tc-stats { padding: 5px 8px; gap: 6px; }
.db-tile .pill { font-size: 10px; padding: 2px 7px; }
.db-grid .tcard.at-limit, .db-tile.at-limit { opacity: .5; filter: grayscale(.55); }
.db-tile.in-deck { box-shadow: 0 0 0 2px var(--gold), 0 10px 24px rgba(0,0,0,.5); }
/* corner "in deck" count chip overlaid on the art */
.db-owned { position: absolute; top: 7px; right: 7px; z-index: 6; min-width: 22px; height: 22px; padding: 0 6px; display: none; align-items: center; justify-content: center; border-radius: 999px; font-size: 12px; font-weight: 900; color: var(--gold-ink); background: radial-gradient(circle at 38% 28%, #ffe9b8, var(--gold) 55%, var(--gold-deep) 100%); box-shadow: 0 2px 6px rgba(0,0,0,.55), inset 0 1px 1px rgba(255,255,255,.6); }
.db-owned.show { display: inline-flex; }
.db-ctl { display: flex; align-items: stretch; justify-content: space-between; margin: 7px 8px 9px; gap: 6px; }
.db-ctl button, .db-tile .db-minus, .db-tile .db-plus { flex: 1; height: 27px; border-radius: 8px; border: 1px solid var(--line2); background: linear-gradient(180deg, var(--panel3), var(--panel2)); color: var(--ink); cursor: pointer; font-weight: 900; font-size: 15px; line-height: 1; transition: border-color .12s, color .12s, background .12s; }
.db-ctl button:hover:not(:disabled) { border-color: var(--gold); color: var(--gold); }
.db-ctl .db-plus:hover:not(:disabled) { background: linear-gradient(180deg, #ffe09a, var(--gold-deep)); color: var(--gold-ink); border-color: var(--gold); }
.db-ctl button:disabled { opacity: .4; cursor: default; }
.db-badge { flex: 0 0 auto; align-self: center; font-size: 11px; color: var(--muted); font-weight: 800; min-width: 30px; text-align: center; }
.db-badge.full { color: var(--gold); }
.db-rows { overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 5px; padding-right: 4px; }
.db-rows .db-row, .db-rows .row { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 9px; background: rgba(255,255,255,.04); border: 1px solid transparent; border-left: 3px solid var(--el, var(--line2)); font-size: 12px; cursor: default; transition: background .12s, border-color .12s; }
.db-rows .db-row:hover { background: rgba(255,210,125,.08); border-color: rgba(255,210,125,.25); }
.db-row-n { color: var(--gold); font-weight: 900; flex: 0 0 auto; }
.db-row-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.db-rows .db-row button, .db-del { border: none; background: linear-gradient(180deg, #6a2a39, #441a26); color: #ffd9df; border-radius: 7px; cursor: pointer; padding: 3px 9px; font-weight: 800; flex: 0 0 auto; }
.db-rows .db-row button:hover { background: linear-gradient(180deg, #8a3548, #5a2230); }
.db-empty { color: var(--faint); font-style: italic; font-size: 12px; padding: 14px 8px; text-align: center; }
.db-counter { font-family: var(--font-display); font-weight: 900; font-size: 19px; text-align: center; margin: 4px 0 12px; letter-spacing: .5px; }
.db-counter.ok { color: var(--good); text-shadow: 0 0 14px rgba(95,227,155,.3); }
.db-counter.bad { color: var(--bad); }
.db-warn { font-size: 11px; color: #ffb27a; }
.db-warn:not(:empty) { margin-top: 8px; padding: 8px 10px; background: rgba(255,140,80,.08); border: 1px solid rgba(255,140,80,.2); border-radius: 9px; }
.db-warn-line { font-size: 11px; color: #ffb27a; line-height: 1.45; }
/* floating hover preview — a full card face beside the cursor */
.db-preview { position: fixed; left: 0; top: 0; z-index: 90; pointer-events: none; opacity: 0; transform: scale(.94); transform-origin: top left; transition: opacity .12s ease, transform .12s var(--ease-out-back); filter: drop-shadow(0 24px 50px rgba(0,0,0,.7)); }
.db-preview.show { opacity: 1; transform: scale(1); }
.db-preview .detail-card { width: 300px; }
/* themed thin scrollbars inside the builder */
.db-pool-scroll::-webkit-scrollbar, .db-rows::-webkit-scrollbar, .db-guardian-list::-webkit-scrollbar { width: 9px; }
.db-pool-scroll::-webkit-scrollbar-thumb, .db-rows::-webkit-scrollbar-thumb, .db-guardian-list::-webkit-scrollbar-thumb { background: linear-gradient(180deg, var(--line2), var(--line)); border-radius: 9px; border: 2px solid transparent; background-clip: padding-box; }
.db-pool-scroll::-webkit-scrollbar-thumb:hover, .db-rows::-webkit-scrollbar-thumb:hover, .db-guardian-list::-webkit-scrollbar-thumb:hover { background: var(--gold-deep); background-clip: padding-box; }
.db-pool-scroll, .db-rows, .db-guardian-list { scrollbar-width: thin; scrollbar-color: var(--line2) transparent; }
.db-io { display: flex; flex-direction: column; gap: 9px; margin-top: 9px; }
.db-io .db-row { display: flex; gap: 8px; background: none; padding: 0; }
.db-select, .db-io input, .db-io select { flex: 1; padding: 9px; border-radius: 9px; border: 1px solid var(--line2); background: #0c1424; color: var(--ink); }
.db-io button, .db-btn, .db-action { padding: 9px; border-radius: 9px; border: 1px solid var(--line2); background: linear-gradient(180deg, var(--panel2), var(--panel)); color: var(--ink); font-weight: 800; cursor: pointer; }
.db-btn:hover, .db-action:hover { border-color: var(--gold); color: var(--gold); }
.db-start { background: linear-gradient(180deg, #ffe09a, var(--gold-deep)) !important; color: var(--gold-ink) !important; border: none !important; font-weight: 900 !important; box-shadow: inset 0 1px 0 rgba(255,255,255,.45); }
.db-start:disabled { background: var(--panel2) !important; color: #6b7798 !important; cursor: default; box-shadow: none; }
.db-close, .howto-close, .net-close { background: none; border: 1px solid var(--line2); color: var(--muted); border-radius: 9px; padding: 7px 11px; cursor: pointer; font-weight: 800; }
.db-close:hover, .howto-close:hover, .net-close:hover { color: var(--gold); border-color: var(--gold); }

/* ============================================================================
 *  TUTORIAL COACHMARKS  (#tutorial-layer)
 * ==========================================================================*/
.spotlight, .tut-spotlight { position: fixed; border-radius: 16px; box-shadow: 0 0 0 9999px rgba(4,7,14,.78); transition: all .26s var(--ease-std); pointer-events: none; z-index: 70; }
.tut-spotlight { box-shadow: 0 0 0 9999px rgba(4,7,14,.78), 0 0 0 3px rgba(255,210,125,.7); }
.coach-bubble { position: fixed; pointer-events: auto; max-width: 330px; background: linear-gradient(180deg, #1b2640, #111a2b); border: 1px solid var(--gold); border-radius: 14px; padding: 15px 17px; z-index: 72; box-shadow: 0 16px 44px rgba(0,0,0,.65); transition: all .26s var(--ease-std); }
.coach-head { display: flex; align-items: center; justify-content: space-between; }
.coach-title { font-family: var(--font-display); font-weight: 700; color: var(--gold); font-size: 16px; margin-bottom: 6px; }
.coach-body { font-size: 13px; color: var(--ink); line-height: 1.5; }
.coach-nudge { font-size: 11px; color: #ffb27a; margin-top: 7px; }
.coach-steps { font-size: 11px; color: var(--muted); margin-top: 9px; }
.coach-acts { display: flex; gap: 8px; margin-top: 11px; justify-content: flex-end; }
.coach-acts button, .coach-btn { padding: 7px 13px; border-radius: 9px; border: 1px solid var(--line2); background: linear-gradient(180deg, var(--panel2), var(--panel)); color: var(--ink); font-weight: 800; cursor: pointer; font-size: 12px; }
.coach-acts button:hover, .coach-btn:hover { border-color: var(--gold); color: var(--gold); }
.coach-btn.is-disabled, .coach-acts button:disabled { opacity: .4; cursor: default; }
.coach-bubble.tut-centered { left: 50% !important; top: 50% !important; transform: translate(-50%,-50%); }

/* ============================================================================
 *  DRAWERS — battle log (#logpanel) & how-to (#howto)
 * ==========================================================================*/
.logpanel { position: fixed; top: var(--header); right: 0; width: 340px; height: calc(100vh - var(--header)); background: linear-gradient(180deg, rgba(17,24,40,.98), rgba(10,14,24,.98)); border-left: 1px solid var(--line2); padding: 14px; z-index: 20; transform: translateX(100%); transition: transform .26s var(--ease-out-quart); display: flex; flex-direction: column; box-shadow: -10px 0 40px rgba(0,0,0,.5); }
/* battle log opens ONLY the log panel (not #howto, which also has .logpanel) */
body.log-open #logpanel { transform: translateX(0); }
.log-head { display: flex; align-items: center; justify-content: space-between; }
.logpanel h3 { font-family: var(--font-display); margin: 0; font-size: 15px; color: var(--gold); text-transform: uppercase; letter-spacing: 1.2px; }
.log-close { background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; }
.log-close:hover { color: var(--gold); }
#log { overflow-y: auto; font-size: 13px; line-height: 1.5; margin-top: 10px; }
.log-line { padding: 6px 7px; border-bottom: 1px dashed #20294099; color: var(--muted); }
.log-line b { color: var(--ink); }

.howto { right: 0; z-index: 65; width: 360px; transform: translateX(100%); transition: transform .26s var(--ease-out-quart); }
#howto.show, body.howto-open #howto, .howto.howto-open { transform: translateX(0); }
.howto-body { overflow-y: auto; font-size: 13px; line-height: 1.55; color: var(--muted); margin-top: 10px; }
.howto-body h4 { font-family: var(--font-display); color: var(--gold); margin: 14px 0 5px; font-size: 14px; }
.howto-body b { color: var(--ink); }
.ht-chart { display: flex; flex-wrap: wrap; gap: 5px; margin: 7px 0; }
.ht-dim { opacity: .7; }

/* ============================================================================
 *  ONLINE LOBBY  (#net-layer)  +  blocker prompt
 * ==========================================================================*/
.net-panel { width: min(460px,94vw); background: linear-gradient(180deg, #121a2b, #0a0e17); border: 1px solid var(--line2); border-radius: 18px; padding: 24px; box-shadow: 0 24px 70px rgba(0,0,0,.65); }
.net-title { font-family: var(--font-display); font-size: 22px; color: var(--gold); margin: 0 0 5px; letter-spacing: 1px; }
.net-hint { font-size: 12px; color: var(--muted); margin-bottom: 16px; line-height: 1.5; }
.deck-hint { margin-top: -4px; min-height: 1.2em; }
.deck-hint.warn { color: #ff8d6b; }
.net-btn:disabled { opacity: 0.45; cursor: not-allowed; filter: grayscale(0.4); }
.net-row { display: flex; gap: 10px; margin: 11px 0; align-items: center; }
.net-label { font-size: 12px; color: var(--muted); }
.net-input { flex: 1; padding: 11px; border-radius: 10px; border: 1px solid var(--line2); background: #0c1424; color: var(--ink); font-size: 15px; letter-spacing: 2px; }
.net-input.code { text-align: center; letter-spacing: 8px; text-transform: uppercase; }
.net-btn { padding: 12px 17px; border-radius: 11px; border: 1px solid var(--line2); background: linear-gradient(180deg, var(--panel2), var(--panel)); color: var(--ink); font-weight: 800; cursor: pointer; transition: border-color .15s, color .15s; }
.net-btn:hover { border-color: var(--gold); color: var(--gold); }
.net-btn.primary { background: linear-gradient(180deg, #ffe09a, var(--gold-deep)); color: var(--gold-ink); border: none; }
.net-btn.ghost { background: transparent; }
.net-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.net-codewrap { text-align: center; margin: 14px 0; }
.net-code { font-family: var(--font-display); font-size: 36px; font-weight: 900; letter-spacing: 8px; color: var(--gold); background: #0c1424; border: 1px dashed var(--gold); border-radius: 12px; padding: 14px; display: inline-block; }
.net-status { font-size: 12px; color: var(--muted); margin-top: 9px; }
.net-status.err { color: var(--bad); }
.net-status.ok { color: var(--good); }
.net-banner { background: linear-gradient(180deg, #3a3018, #241d0e); border: 1px solid var(--gold-deep); color: var(--gold); padding: 9px 13px; border-radius: 10px; font-size: 12px; margin-top: 11px; }
.net-foot { margin-top: 16px; display: flex; justify-content: space-between; }
.blocker-panel { max-width: 480px; }
.blocker-actions { flex-direction: column; align-items: stretch; }

/* ----- defender's-choice "who blocks" panel ----- */
#blocker-layer .block-modal {
  width: min(720px, 95vw);
  background: linear-gradient(180deg, #151e35, #0b0f1a);
  border: 1px solid var(--line2); border-radius: 20px; padding: 22px 24px;
  box-shadow: 0 30px 80px rgba(0,0,0,.7), 0 0 44px rgba(0,0,0,.45);
  animation: detailIn .24s var(--ease-out-quart);
}
.block-attacker {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 14px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--el) 26%, transparent), transparent);
  border: 1px solid color-mix(in srgb, var(--el) 42%, var(--line));
}
.ba-art { width: 66px !important; height: 66px !important; flex: 0 0 auto; border-radius: 11px; box-shadow: 0 4px 12px rgba(0,0,0,.5), inset 0 0 0 1px rgba(255,255,255,.1); }
.ba-art .art-sigil { font-size: 30px; }
.ba-info { min-width: 0; }
.block-kicker { font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--bad); font-weight: 800; }
.ba-name { font-family: var(--font-display); font-size: 21px; font-weight: 700; color: #fff; line-height: 1.1; }
.ba-atk { display: inline-flex; align-items: center; gap: 5px; font-weight: 800; color: #ffc0b4; margin-top: 2px; }
.ba-atk .ic { width: 1em; height: 1em; }
.block-prompt { text-align: center; color: var(--muted); font-size: 13px; margin: 14px 0 16px; letter-spacing: .3px; }
.block-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(152px, 1fr)); gap: 13px; }
.block-card {
  position: relative; cursor: pointer; border-radius: 15px; padding: 12px; text-align: center;
  background: linear-gradient(180deg, rgba(26,36,60,.92), rgba(13,18,30,.92));
  border: 1px solid var(--line2); box-shadow: 0 6px 16px rgba(0,0,0,.4);
  transition: transform .12s var(--ease-out-back), box-shadow .15s, border-color .15s;
}
.block-card:hover { transform: translateY(-5px); border-color: var(--gold); box-shadow: 0 14px 28px rgba(0,0,0,.55), 0 0 24px rgba(255,210,125,.32); }
.block-card.recommended { border-color: color-mix(in srgb, var(--el) 65%, var(--gold)); box-shadow: 0 6px 16px rgba(0,0,0,.4), 0 0 18px color-mix(in srgb, var(--el) 40%, transparent); }
.block-card.lethal { border-color: #a0455a; }
.bc-art { width: 100% !important; height: 84px !important; border-radius: 11px; margin-bottom: 9px; }
.bc-tag { position: absolute; top: 9px; right: 9px; z-index: 3; font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; color: var(--gold-ink); background: linear-gradient(180deg, #ffe09a, var(--gold-deep)); padding: 2px 7px; border-radius: 6px; box-shadow: 0 2px 6px rgba(0,0,0,.4); }
.bc-name { font-family: var(--font-display); font-weight: 700; font-size: 14.5px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.block-card .hpbar { margin: 9px 0 7px; }
.bc-dmg { font-size: 11px; font-weight: 800; color: #a8d4ff; display: inline-flex; align-items: center; gap: 4px; }
.bc-dmg.is-lethal { color: #ff9db4; }
.bc-dmg .ic { width: 1em; height: 1em; }
.ba-matchup { font-size: 11px; color: var(--muted); margin-top: 3px; }
.ba-matchup .mx-strong { color: var(--gold); font-weight: 700; }
.bc-mult { font-size: 10px; margin-top: 3px; }
.mx-badge { display: inline-block; font-size: 9px; font-weight: 800; letter-spacing: .3px; padding: 2px 7px; border-radius: 6px; }
.mx-badge.weak { background: #4a1f2a; color: #ffb0c0; border: 1px solid #7a3346; }
.mx-badge.resist { background: #1f3147; color: #a8d4ff; border: 1px solid #2f5070; }
.block-guardian { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; background: linear-gradient(180deg, rgba(42,32,18,.88), rgba(22,16,10,.88)); border-color: #5a4a2a; }
.bc-shields { display: flex; gap: 6px; font-size: 21px; }
.bc-bigicon { line-height: 1; }
.bc-bigicon .ic { width: 36px; height: 36px; color: #ff8a9a; }
.bc-sub { font-size: 11px; color: var(--muted); line-height: 1.35; }

/* ============================================================================
 *  RESPONSIVE & REDUCED MOTION
 * ==========================================================================*/
/* ---- TABLET / PHONE-LANDSCAPE: keep the scale-to-fit board, reflow menus ---- */
@media (max-width: 1000px) {
  /* board still scales to fit via fitBoard(); just move the avatar rail inline */
  .table { padding-left: 16px; }
  .table-rail { position: static; transform: none; flex-direction: row; justify-content: center; margin-bottom: 8px; }

  /* start / guardian-select */
  .title { font-size: clamp(38px, 7vw, 62px); }
  .lead { font-size: 13.5px; max-width: 90vw; }
  .pick { width: 210px; }
  .pick .art-window { height: 150px; }

  /* deck builder */
  .db-panel { width: 96vw; height: 92vh; }
  .db-cols { grid-template-columns: 188px 1fr 240px; gap: 12px; }
  .db-grid { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }

  /* card detail modal */
  .detail-card { width: min(300px, 80vw); }
  .detail-card .art-window { height: 200px; }

  /* drawers */
  .logpanel, .howto { width: min(360px, 86vw); }
}

/* ---- NARROW (phones, either orientation): deck builder collapses to ONE column.
 * This is width-based (NOT orientation-gated) on purpose: a 3-column grid wider
 * than the phone would overflow device-width and make mobile browsers shrink-to-
 * fit (zoom out), which then defeats the portrait breakpoint. One column never
 * overflows, so the viewport stays at device-width. ------------------------- */
@media (max-width: 680px) {
  /* the closed log/how-to drawers sit off-screen via translateX(100%); on a
   * phone that expands the page rightward (mis-centring fixed modals). Clip at
   * the root — overflow-x:clip contains fixed descendants without making a
   * scroll container the way overflow:hidden would. */
  html { overflow-x: clip; }
  .db-panel { width: 100vw; height: 100vh; height: 100dvh; max-width: none; border-radius: 0; padding: 12px; }
  .db-cols { display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
  .db-col { min-height: auto; }
  .db-pool-scroll { max-height: 46vh; }
  .db-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
}

/* ---- PORTRAIT LOCK: phones are played upright. A phone held in landscape gets
 * a full-screen "rotate" gate instead of a squished sideways board (true JS
 * orientation-lock isn't available on iOS web). Detection is deliberate:
 *   - (pointer: coarse)  → a touch device, so a short/wide DESKTOP window is
 *     never told to rotate.
 *   - (max-height: 560px) gates by the SHORT side: every phone's short side is
 *     ≤ ~450px, so all phones in landscape match; tablets (short side ≥ 600px)
 *     and foldables-unfolded (≥ 580px) do NOT — they keep the scaled board.
 *   - height-only (NO max-width): an iPhone Pro Max is 932px wide in landscape,
 *     so any width cap would wrongly stop gating it.
 * Gate styles live entirely inside the media query so nothing computes/animates
 * when the gate is hidden (which is everywhere but a landscape phone). ------- */
#rotate-gate { display: none; }
@keyframes rg-rock { 0%, 16% { transform: rotate(-90deg); } 46%, 72% { transform: rotate(0deg); } 100% { transform: rotate(-90deg); } }
@media (orientation: landscape) and (max-height: 560px) and (pointer: coarse) {
  #rotate-gate {
    position: fixed; inset: 0; z-index: 1200; display: flex; align-items: center; justify-content: center;
    text-align: center; padding: 24px; pointer-events: auto; user-select: none; touch-action: none;
    background: radial-gradient(120% 100% at 50% 32%, #16213a, #0a0e18 68%, #06080f);
  }
  #rotate-gate:focus { outline: none; }
  .rg-inner { display: flex; flex-direction: column; align-items: center; gap: 16px; max-width: 340px; }
  .rg-phone { color: var(--gold); transform-origin: 50% 50%; animation: rg-rock 2.6s ease-in-out infinite; filter: drop-shadow(0 6px 18px rgba(255,200,90,.25)); }
  .rg-title { font-family: var(--font-display); font-size: 22px; font-weight: 800; color: var(--gold); letter-spacing: .5px; }
  .rg-sub { font-size: 14px; line-height: 1.55; color: #c3d2ec; }
  body { overflow: hidden; }   /* freeze the board behind the gate */
  #welcome { display: none; }  /* keep the audio splash from stacking under the gate (returns on rotate to portrait) */
}
@media (orientation: landscape) and (max-height: 560px) and (pointer: coarse) and (prefers-reduced-motion: reduce) {
  .rg-phone { animation: none; }
}

/* ---- PORTRAIT PHONE: dedicated fluid, stacked layout (no scale-to-fit) ----- */
@media (orientation: portrait) and (max-width: 560px) {
  /* block layout (not the desktop flex-center) so the board is exactly viewport
   * width; the page scrolls vertically and never sideways */
  .arena { display: block; height: auto; min-height: calc(100vh - var(--header)); overflow-x: hidden; overflow-y: auto; }
  #board-shake { width: 100%; }
  .board { width: 100%; max-width: 100%; height: auto; min-height: calc(100vh - var(--header)); transform: none !important; padding: 6px 4px 0; gap: 6px; }
  .board, .play-row, .table, .side, .midbar, .hand-wrap, .hand-label { max-width: 100%; }

  /* stack the tabletop + dock */
  .play-row { flex-direction: column; gap: 10px; width: 100%; align-items: stretch; }
  .table { flex-direction: column; padding: 8px; width: 100%; gap: 6px; align-items: center; }
  .table-rail { position: static; transform: none; flex-direction: row; justify-content: center; gap: 10px; margin-bottom: 4px; }
  .avatar-chip { width: auto; }

  /* piles fold away on phone (counts live in the hand label + avatar chips) */
  .side .pile { display: none; }
  .midbar { flex-wrap: wrap; gap: 8px; padding: 4px; width: 100%; }
  .last-log { max-width: 92vw; }

  /* both rows → vertical stacks so nothing forces the board wider than the phone */
  .side { flex-direction: column; align-items: center; gap: 8px; padding: 6px; width: 100%; }
  .guardian { width: min(320px, 92vw); }

  /* opponent → compact status strip (no bench, smaller active) */
  .side.enemy { gap: 6px; padding: 4px 6px; }
  .side.enemy .bench-zone { display: none; }
  .side.enemy .active-wrap { grid-template-columns: 96px; }
  .side.enemy .acts-spacer { display: none; }
  .side.enemy .tcard.on-field { width: 96px; }
  .side.enemy .tcard.on-field .art-window { height: 44px; }

  /* my row → big centered active with the action buttons as a row BELOW it
   * (single grid column keeps the card truly centred on the phone) */
  .side.you .field-row { flex-direction: column; align-items: center; gap: 10px; width: 100%; }
  .side.you .active-wrap { grid-template-columns: clamp(132px, 36vw, 160px); row-gap: 8px; justify-items: center; }
  .side.you .tcard.on-field { width: clamp(132px, 36vw, 160px); }
  .side.you .tcard.on-field .art-window { height: clamp(74px, 19vw, 92px); }
  .side.you .side-acts.icon-acts { flex-direction: row; flex-wrap: wrap; width: auto; max-width: 92vw; height: auto; align-self: center; justify-content: center; gap: 8px; }
  .side.you .side-acts .sa-head { display: none; }
  .side.you .side-acts .sa-btn { width: 46px; height: 46px; }
  .side.you .acts-spacer { display: none; }
  .side.you .tcard.on-field.bench { width: clamp(100px, 26vw, 116px); }
  .side.you .bench-row { flex-wrap: wrap; justify-content: center; gap: 8px; }
  .zone.bench-zone { width: 100%; }
  .zone.bench-zone .zone-label { text-align: center; }

  /* turn dock → horizontal bar */
  .turn-dock { width: 100%; flex-direction: row; justify-content: center; align-items: center; gap: 12px; padding: 10px; }
  .dock-btn { width: auto; }
  .turn-dock .endturn { padding: 14px 22px; }

  /* hand → horizontal scroll tray pinned to the bottom of the screen */
  .hand-wrap { margin-top: 8px; position: sticky; bottom: 0; z-index: 8; padding-top: 6px;
    background: linear-gradient(0deg, rgba(6,9,16,.94) 60%, transparent); }
  .hand { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; justify-content: flex-start;
    padding: 6px 10px 8px; gap: 6px; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity; }
  .hand-card { margin: 0 !important; flex: 0 0 auto; width: clamp(106px, 29vw, 132px); scroll-snap-align: center; }
  .hand:hover .hand-card { margin: 0; }
  .hand-card.playable:hover { transform: none; margin: 0; box-shadow: 0 8px 22px rgba(0,0,0,.55); }

  /* start / guardian-select → single column */
  .start { padding: 8px 8px 16px; }
  .title { font-size: clamp(30px, 9vw, 42px); }
  .subtitle { letter-spacing: 4px; }
  .lead { font-size: 13px; max-width: 92vw; }
  .guardian-grid { flex-direction: column; align-items: center; gap: 12px; }
  .pick { width: min(340px, 92vw); }
  .pick .art-window { height: clamp(150px, 42vw, 200px); }
  .sd-row { flex-wrap: wrap; }
  .start-menu { flex-direction: column; align-items: center; gap: 12px; }
  .start-menu > * { width: min(320px, 90vw); }

  /* card detail modal */
  .detail-card { width: min(300px, 86vw); }
  .detail-card .art-window { height: clamp(180px, 50vw, 230px); }
  .detail-actions { width: 92vw; max-width: 360px; }
  .detail-actions > * { flex: 1 1 auto; }

  /* drawers → near full-width */
  .logpanel, .howto { width: min(360px, 92vw); }
}
@media (prefers-reduced-motion: reduce) {
  .tcard { transform: none !important; transition: none !important; }
  .fx-hit, .fx-enter, .dmg-pop, .fx-attacking, .dying, .foil::after, .avatar-chip, .hand-card { animation: none !important; }
  .spotlight, .tut-spotlight, .coach-bubble { transition: none !important; }
}
body.reduced-motion .tcard { transform: none !important; }
body.reduced-motion .foil::after { animation: none !important; }

/* ============================================================================
 *  SVG ICONS  (window.TMIcon)  — replace cross-platform emoji on buttons
 * ==========================================================================*/
.ic { width: 1.05em; height: 1.05em; display: inline-block; vertical-align: -0.16em; flex: 0 0 auto; fill: currentColor; }
/* buttons that mix an icon with a label sit them on one baseline with a gap */
.topbar button, .menu-btn, .endturn, .cancel, .mini, .g-btn, .detail-btn,
.pick-btn, .big-btn, .db-start, .net-btn, .coach-btn, .coach-acts button {
  display: inline-flex; align-items: center; justify-content: center; gap: .42em;
}
.mini { gap: .35em; }
.mini .ic { width: 1em; height: 1em; }
/* icon-only square button (mute) */
.icon-btn { width: 38px; height: 38px; padding: 0 !important; }
.icon-btn .ic { width: 18px; height: 18px; }

/* ----- topbar popovers (settings) + toggle switches ----- */
.popover-panel {
  position: fixed; z-index: 66; min-width: 224px; display: none;
  background: linear-gradient(180deg, #141d33, #0c1019);
  border: 1px solid var(--line2); border-radius: 14px; padding: 12px 14px;
  box-shadow: 0 18px 50px rgba(0,0,0,.6);
}
.popover-panel.open { display: block; animation: detailIn .16s var(--ease-out-quart); }
.pop-head { font-family: var(--font-display); font-size: 12px; color: var(--gold); text-transform: uppercase; letter-spacing: 1.4px; margin-bottom: 8px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 8px 2px; }
.set-label { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; font-size: 13px; }
.set-label .ic { width: 1.15em; height: 1.15em; color: var(--muted); }
.toggle { width: 46px; height: 26px; border-radius: 14px; border: 1px solid var(--line2); background: #19223a; cursor: pointer; position: relative; transition: background .18s, border-color .18s; padding: 0; flex: 0 0 auto; }
.toggle .knob { position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #6b7798; box-shadow: 0 1px 3px rgba(0,0,0,.5); transition: left .18s var(--ease-out-back), background .18s; }
.toggle.on { background: linear-gradient(180deg, #3aa564, #1f6b3f); border-color: #4cc07d; box-shadow: inset 0 1px 3px rgba(0,0,0,.3); }
.toggle.on .knob { left: 22px; background: #eafff0; }
/* icons inside stat pills / cost-energy / HP badges */
.pill { gap: 2px; }
.pill .ic { width: .95em; height: .95em; vertical-align: -0.1em; }
.tc-cost { gap: 1px; }
.tc-cost .ic { width: .82em; height: .82em; }
.detail-card .pill .ic { width: 1em; height: 1em; }

/* ============================================================================
 *  DRAG-TO-PLAY  (drag.js)
 * ==========================================================================*/
.hand-card.playable { cursor: grab; }
body.dragging, body.dragging * { cursor: grabbing !important; }
body.dragging { user-select: none; }
.hand-card, .hand-card img, .drag-clone, .drag-clone img { -webkit-user-drag: none; user-drag: none; }
.drag-clone {
  position: fixed; left: 0; top: 0; z-index: 95; pointer-events: none; margin: 0 !important;
  opacity: .97; filter: drop-shadow(0 24px 36px rgba(0,0,0,.6)); transition: none; will-change: transform;
}
.drag-clone.drag-cancel { transition: transform .22s var(--ease-out-quart), opacity .22s ease; opacity: .6; }
.drag-source { opacity: .32 !important; filter: grayscale(.4) brightness(.85); transform: none !important; }
.drop-zone { outline: 2px dashed rgba(95,227,155,.55); outline-offset: 4px; border-radius: 16px; transition: outline-color .12s, box-shadow .12s; }
.drop-zone.drop-hover { outline: 2px solid var(--good); box-shadow: 0 0 28px rgba(95,227,155,.45); }
@media (prefers-reduced-motion: reduce) { .drag-clone.drag-cancel { transition: none; } }

/* ============================================================================
 *  FLYING ATTACK  (anim.js sequenceAttack) — the attacker lunges into its target
 * ==========================================================================*/
.atk-flight {
  position: fixed; z-index: 92; pointer-events: none; margin: 0 !important;
  transform-origin: center center; will-change: transform;
  box-shadow: 0 24px 44px rgba(0,0,0,.62), 0 0 28px rgba(255,255,255,.2);
}
.atk-ghost { opacity: .28 !important; filter: grayscale(.4) brightness(.85); transition: opacity .12s ease; }

/* ============================================================================
 *  WELCOME / "ENTER" SPLASH  (gates browser audio autoplay)
 * ==========================================================================*/
.welcome {
  position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; cursor: pointer;
  background: radial-gradient(circle at 50% 38%, rgba(12,18,34,.8), rgba(3,5,11,.97));
  backdrop-filter: blur(3px); opacity: 1; transition: opacity .5s ease;
}
.welcome.hide { opacity: 0; pointer-events: none; }
.welcome-inner { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; animation: detailIn .5s var(--ease-out-quart); }
.welcome-emblem { font-size: 52px; filter: drop-shadow(0 4px 16px rgba(0,0,0,.6)); margin-bottom: 4px; }
.welcome-title {
  font-family: var(--font-display); font-size: clamp(48px, 10vw, 78px); margin: 0; letter-spacing: 3px; font-weight: 800; line-height: 1;
  background: linear-gradient(180deg, #fff6e0 0%, var(--gold) 55%, var(--gold-deep) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 22px rgba(255,200,90,.4));
}
.welcome-sub { font-family: var(--font-display); color: var(--gold); letter-spacing: 5px; text-transform: uppercase; font-size: 13px; margin-bottom: 22px; }
.welcome-btn { padding: 15px 34px; font-size: 17px; border-radius: 14px; }
.welcome-btn:hover { transform: translateY(-2px); filter: brightness(1.06); }
.welcome-hint { color: var(--muted); font-size: 12px; margin-top: 10px; letter-spacing: .3px; }

/* ============================================================================
 *  SOCIAL: account / friends / chat / toasts / invites / in-match chat
 * ==========================================================================*/
.icon-btn.signed-in { border-color: var(--good); color: var(--good); }
.social-input {
  width: 100%; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--line2);
  background: #0c1424; color: var(--ink); font-size: 13px; margin-bottom: 8px;
}
.social-input:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.social-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 14px; border-radius: 10px; cursor: pointer; font-weight: 800; font-size: 13px;
  border: 1px solid var(--line2); background: linear-gradient(180deg, var(--panel2), var(--panel)); color: var(--ink);
  transition: filter .12s, border-color .12s, color .12s, transform .08s;
}
.social-btn:hover { border-color: var(--gold); color: var(--gold); }
.social-btn:active { transform: translateY(1px); }
.social-btn.primary { background: linear-gradient(180deg, #ffe09a, var(--gold-deep)); color: var(--gold-ink); border: none; }
.social-btn.primary:hover { filter: brightness(1.07); color: var(--gold-ink); }
.social-btn.ghost { background: transparent; }
.social-btn.small { padding: 6px 9px; font-size: 12px; }
.social-btn.wide { width: 100%; margin-top: 6px; }
.social-btn .ic { width: 1.05em; height: 1.05em; }

/* account popover */
.account-pop { min-width: 248px; }
.acct-who { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 10px; color: var(--ink); }
.acct-who .ic { width: 1.2em; height: 1.2em; color: var(--gold); }
.acct-note { font-size: 11.5px; color: var(--muted); min-height: 14px; margin: 2px 0 4px; }
.acct-note.bad { color: var(--bad); }

/* friends & chat modal (#social-layer.show) */
#social-layer { position: fixed; inset: 0; z-index: 64; display: none; align-items: center; justify-content: center; background: rgba(4,7,14,.84); backdrop-filter: blur(4px); }
#social-layer.show { display: flex; }
.social-modal { width: min(820px, 95vw); height: min(78vh, 640px); display: flex; flex-direction: column; background: linear-gradient(180deg, #121a2b, #0a0e17); border: 1px solid var(--line2); border-radius: 18px; box-shadow: 0 24px 70px rgba(0,0,0,.65); overflow: hidden; }
.social-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.social-title { font-family: var(--font-display); font-size: 18px; color: var(--gold); display: inline-flex; align-items: center; gap: 9px; }
.social-title .ic { width: 1.1em; height: 1.1em; }
.social-close { background: none; border: 1px solid var(--line2); color: var(--muted); border-radius: 9px; width: 34px; height: 34px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.social-close:hover { color: var(--gold); border-color: var(--gold); }
.social-close .ic { width: 16px; height: 16px; }
.social-cols { display: grid; grid-template-columns: 260px 1fr; flex: 1; min-height: 0; }
.social-side { border-right: 1px solid var(--line); padding: 12px; overflow-y: auto; }
.social-main { display: flex; flex-direction: column; min-height: 0; }

.fr-add { display: flex; gap: 7px; margin-bottom: 10px; }
.fr-add .social-input { margin: 0; }
.fr-group { font-size: 10px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); font-weight: 800; margin: 12px 2px 6px; }
.fr-row { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-radius: 9px; cursor: pointer; transition: background .12s; }
.fr-row:hover { background: rgba(255,255,255,.04); }
.fr-row.active { background: rgba(255,210,125,.12); outline: 1px solid rgba(255,210,125,.4); }
.fr-row.req, .fr-row.pending { cursor: default; }
.fr-row.pending { opacity: .6; }
.fr-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.fr-dot.online { background: var(--good); box-shadow: 0 0 7px rgba(95,227,155,.8); }
.fr-dot.offline { background: #45506e; }
.fr-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.fr-name .ic { width: 1.05em; height: 1.05em; color: var(--muted); }
.fr-empty { color: var(--faint); font-style: italic; font-size: 12px; padding: 4px 9px; }

.conv-tabs { display: flex; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.conv-tab { padding: 6px 12px; border-radius: 9px; border: 1px solid var(--line2); background: var(--panel); color: var(--muted); font-weight: 700; font-size: 12px; cursor: pointer; white-space: nowrap; }
.conv-tab.active { color: var(--gold); border-color: var(--gold); background: rgba(255,210,125,.08); }
.chat-scroll { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.chat-empty { color: var(--faint); font-style: italic; text-align: center; margin: auto; }
.chat-msg { max-width: 78%; padding: 7px 11px; border-radius: 12px; background: var(--panel2); align-self: flex-start; font-size: 13px; line-height: 1.35; }
.chat-msg.mine { align-self: flex-end; background: linear-gradient(180deg, #2a6cae, #1f5288); color: #fff; }
.chat-from { display: block; font-size: 10px; color: var(--gold); font-weight: 800; margin-bottom: 1px; }
.chat-input-row { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.chat-input-row .social-input { margin: 0; }

/* toasts */
#toast-layer { position: fixed; right: 16px; bottom: 16px; z-index: 90; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 9px; max-width: 320px; padding: 11px 14px; border-radius: 12px; background: linear-gradient(180deg, #1b2640, #111a2b); border: 1px solid var(--line2); box-shadow: 0 10px 28px rgba(0,0,0,.5); font-size: 13px; color: var(--ink); animation: toastIn .28s var(--ease-out-back); }
.toast.out { opacity: 0; transform: translateX(20px); transition: opacity .3s, transform .3s; }
.toast.ok { border-color: #2f6a45; } .toast.error { border-color: #7a3346; } .toast.friend { border-color: var(--gold-deep); } .toast.dm { border-color: #2f5070; cursor: pointer; }
.toast-ic .ic { width: 17px; height: 17px; color: var(--gold); }
.toast-text { min-width: 0; }
@keyframes toastIn { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }

/* game invite prompt (#invite-layer.overlay-layer) */
.invite-box { width: min(360px, 92vw); background: linear-gradient(180deg, #161f33, #0c1019); border: 1px solid var(--gold); border-radius: 16px; padding: 22px; text-align: center; box-shadow: 0 24px 60px rgba(0,0,0,.6); animation: detailIn .24s var(--ease-out-quart); }
.invite-title { font-family: var(--font-display); font-size: 18px; color: var(--gold); display: inline-flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.invite-text { color: var(--ink); margin-bottom: 16px; }
.invite-acts { display: flex; gap: 10px; justify-content: center; }

/* in-match chat (#ingame-chat) */
#ingame-chat { position: fixed; left: 14px; bottom: 14px; z-index: 55; width: 264px; display: none; flex-direction: column; background: linear-gradient(180deg, rgba(20,28,46,.96), rgba(11,16,27,.96)); border: 1px solid var(--line2); border-radius: 13px; box-shadow: 0 12px 30px rgba(0,0,0,.5); overflow: hidden; }
#ingame-chat.active { display: flex; }
#ingame-chat.flash { animation: igcFlash .6s ease; }
@keyframes igcFlash { 0%,100% { box-shadow: 0 12px 30px rgba(0,0,0,.5); } 40% { box-shadow: 0 12px 30px rgba(0,0,0,.5), 0 0 0 2px var(--gold); } }
.igc-head { padding: 9px 12px; font-weight: 800; font-size: 12px; color: var(--gold); cursor: pointer; display: flex; align-items: center; gap: 7px; background: rgba(255,255,255,.03); }
.igc-head .ic { width: 1.1em; height: 1.1em; }
#ingame-chat.collapsed .igc-log, #ingame-chat.collapsed .igc-row { display: none; }
.igc-log { max-height: 180px; overflow-y: auto; padding: 9px 11px; display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; }
.igc-msg { line-height: 1.3; } .igc-msg.mine { color: #9fd8ff; text-align: right; }
.igc-from { color: var(--gold); font-weight: 700; }
.igc-row { display: flex; gap: 6px; padding: 9px; border-top: 1px solid var(--line); }
.igc-row .social-input { margin: 0; }

/* ============================================================================
 *  WIN SCREEN (full-screen, MVP + match stats) — #win-layer
 * ==========================================================================*/
.win-layer { z-index: 80; }
.win-layer .win-box {
  width: min(560px, 94vw); max-width: none; text-align: center;
  background: radial-gradient(circle at 50% 0%, rgba(40,32,18,.5), transparent 60%), linear-gradient(180deg, #161f33, #0a0e17);
  border: 1px solid var(--gold); border-radius: 22px; padding: 30px 34px;
  box-shadow: 0 30px 80px rgba(0,0,0,.7), 0 0 50px rgba(255,200,90,.18);
  animation: detailIn .34s var(--ease-out-quart);
}
.win-box.lost { border-color: #7a3346; box-shadow: 0 30px 80px rgba(0,0,0,.7), 0 0 50px rgba(255,90,110,.18); }
.win-emblem { font-size: 54px; line-height: 1; filter: drop-shadow(0 4px 14px rgba(0,0,0,.6)); }
.win-box h2 { font-family: var(--font-display); font-size: 46px; margin: 6px 0 4px; letter-spacing: 1px; }
.win-box .victory { color: var(--good); text-shadow: 0 0 26px rgba(80,220,140,.5); }
.win-box .defeat { color: var(--bad); text-shadow: 0 0 26px rgba(255,90,110,.5); }
.win-sub { color: var(--muted); line-height: 1.5; margin: 0 auto 18px; max-width: 420px; }
.win-mvp { margin: 4px auto 18px; }
.mvp-label { font-family: var(--font-display); font-size: 12px; letter-spacing: 2px; text-transform: uppercase; color: var(--gold); display: inline-flex; align-items: center; gap: 7px; margin-bottom: 8px; }
.mvp-label .ic { width: 1.2em; height: 1.2em; }
.mvp-card { display: inline-flex; align-items: center; gap: 14px; text-align: left; padding: 12px 16px 12px 12px; border-radius: 16px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--el, #345) 26%, #141d30), #0e1626);
  border: 1px solid color-mix(in srgb, var(--el, #345) 55%, #0a0e18); box-shadow: 0 10px 26px rgba(0,0,0,.5); }
.mvp-art { width: 78px !important; height: 78px !important; border-radius: 12px; flex: 0 0 auto; box-shadow: 0 4px 12px rgba(0,0,0,.5), inset 0 0 0 1px rgba(255,255,255,.1); }
.mvp-art .art-sigil { font-size: 30px; }
.mvp-name { font-family: var(--font-display); font-size: 19px; font-weight: 700; color: #fff; }
.mvp-dmg { display: inline-flex; align-items: center; gap: 6px; color: #ffc0b4; font-weight: 800; margin-top: 4px; font-size: 13px; }
.mvp-dmg .ic { width: 1.05em; height: 1.05em; }
.win-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 4px 0 22px; }
.win-stat { background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 12px; padding: 10px 6px; }
.ws-val { font-family: var(--font-display); font-size: 19px; font-weight: 800; color: var(--gold); line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-label { font-size: 9.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin-top: 3px; }
.win-acts { display: flex; gap: 10px; justify-content: center; }
@media (max-width: 560px) { .win-stats { grid-template-columns: repeat(2, 1fr); } }
.db-sync-note { font-size: 10.5px; color: var(--muted); text-align: center; margin-top: 8px; }
