/* ============================================================================
 * 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 */
.board { position: relative; width: fit-content; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 6px; transform-origin: center center; }
.board.start-mode { width: 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 { /* glossy vignette */
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 2;
  background: radial-gradient(120% 80% at 50% 0%, rgba(255,255,255,.14), transparent 55%),
              linear-gradient(180deg, transparent 60%, rgba(0,0,0,.4) 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 now live in a side strip next to the active card */
.active-wrap { display: flex; align-items: center; gap: 12px; }
.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: 86px; padding: 10px 9px; gap: 9px; }
.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: 48px; 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; }
.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 ----------------------------------------------------- */
.side { display: flex; align-items: center; 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 --------------------------------------------------------------- */
.hand-wrap { padding-top: 6px; }
.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); }
.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
 * ==========================================================================*/
#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(1200px, 96vw); height: min(88vh, 840px); background: linear-gradient(180deg, #121a2b, #0a0e17); border: 1px solid var(--line2); border-radius: 18px; display: flex; flex-direction: column; padding: 16px 18px; box-shadow: 0 24px 70px rgba(0,0,0,.65); }
.db-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.db-head h2, .db-head .db-title { font-family: var(--font-display); font-size: 22px; color: var(--gold); margin: 0; letter-spacing: 1px; }
.db-sub, .db-h, .db-group-h { font-size: 11px; color: var(--muted); }
.db-cols { display: grid; grid-template-columns: 230px 1fr 290px; gap: 16px; flex: 1; min-height: 0; }
.db-col { background: rgba(7,11,19,.55); border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; min-height: 0; }
.db-col h3, .db-h { margin: 0 0 9px; font-size: 12px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); }
.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; }
.db-guardian-list .pick, .db-pick { width: 100%; cursor: pointer; }
.db-guardian-list .pick.selected, .db-pick.selected { outline: 2px solid var(--gold); outline-offset: 1px; }
.db-pool-scroll { overflow-y: auto; flex: 1; }
.db-group, .db-group-h { font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--gold); margin: 10px 2px 7px; }
.db-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(122px,1fr)); gap: 11px; }
.db-grid .tcard, .db-tile { width: 100%; cursor: pointer; }
.db-grid .tcard.at-limit, .db-tile.at-limit { opacity: .45; filter: grayscale(.6); }
.db-tile.in-deck { outline: 1px solid var(--gold); outline-offset: 1px; }
.db-ctl { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; gap: 6px; }
.db-ctl button, .db-minus, .db-plus { width: 28px; height: 26px; border-radius: 7px; border: 1px solid var(--line2); background: linear-gradient(180deg, var(--panel3), var(--panel2)); color: var(--ink); cursor: pointer; font-weight: 900; }
.db-ctl button:hover, .db-minus:hover, .db-plus:hover { border-color: var(--gold); color: var(--gold); }
.db-badge, .db-ctl .badge { font-size: 11px; color: var(--muted); font-weight: 800; }
.db-badge.full { color: var(--gold); }
.db-rows { overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 5px; }
.db-rows .db-row, .db-rows .row { display: flex; align-items: center; justify-content: space-between; padding: 6px 9px; border-radius: 8px; background: rgba(255,255,255,.035); font-size: 12px; }
.db-row-n { color: var(--gold); font-weight: 900; margin-right: 6px; }
.db-row-name { 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: 6px; cursor: pointer; padding: 3px 8px; font-weight: 800; }
.db-empty { color: var(--faint); font-style: italic; font-size: 12px; padding: 8px; }
.db-counter { font-family: var(--font-display); font-weight: 900; font-size: 17px; text-align: center; margin: 10px 0; }
.db-counter.ok { color: var(--good); }
.db-counter.bad { color: var(--bad); }
.db-warn { font-size: 11px; color: #ffb27a; min-height: 14px; }
.db-warn-line { font-size: 11px; color: #ffb27a; }
.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; }
.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
 * ==========================================================================*/
@media (max-width: 1000px) {
  .table { padding-left: 16px; }
  .table-rail { position: static; transform: none; flex-direction: row; justify-content: center; margin-bottom: 8px; }
}
@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; }
