:root {
  --bg: #0c0e15;
  --bg-2: #11141d;
  --panel: #161a24;
  --panel-2: #1d2330;
  --line: #272e3e;
  --line-soft: #1f2533;
  --text: #e9ecf4;
  --muted: #8b93a7;
  --muted-2: #6a7287;
  --accent: #8b6dff;
  --accent-2: #46c2ff;
  --gold: #ffcf5e;
  --blue: #5b8cff;
  --light: #e9edcc;
  --dark: #58794c;
  --light-sel: #f4f17e;
  --dark-sel: #b9c64a;
  --move-hl: rgba(244, 241, 126, 0.38);
  --target: rgba(15, 18, 28, 0.32);
  --check: #ff5163;
  --white-piece: #fbfbfd;
  --black-piece: #20242e;
  --radius: 14px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background:
    radial-gradient(1100px 720px at 78% -12%, #1d2336 0%, rgba(29,35,54,0) 60%),
    radial-gradient(900px 600px at 0% 110%, #17202e 0%, rgba(23,32,46,0) 55%),
    var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ─── Topbar ─────────────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: baseline; gap: 16px;
  padding: 15px 24px; border-bottom: 1px solid var(--line-soft);
  background: rgba(12, 14, 21, 0.7); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 21px; font-weight: 800; letter-spacing: 0.2px; }
.brand-mark { color: var(--accent); filter: drop-shadow(0 0 10px var(--accent)); font-size: 18px; }
.brand-accent { background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-tag { color: var(--muted-2); font-size: 12.5px; letter-spacing: 0.3px; }
.brand-credit { margin-left: auto; color: var(--accent-2); font-size: 13px; font-weight: 600; text-decoration: none; letter-spacing: 0.3px; }
.brand-credit:hover { text-decoration: underline; }

/* ─── Layout ─────────────────────────────────────────────────────────────── */
.layout {
  display: grid; grid-template-columns: minmax(340px, 1fr) 344px;
  gap: 30px; padding: 30px; max-width: 1200px; margin: 0 auto; align-items: start;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; gap: 18px; padding: 14px; }
  /* Let the board fill the screen width (minus the eval bar), capped so it
     never grows taller than the viewport. */
  .board-area { gap: 12px; }
  .board-stage { width: 100%; gap: 8px; }
  .board-wrap { width: auto; flex: 1 1 auto; max-width: 100%; max-height: 86vh; }
  .evalbar { width: 22px; }
  .evalbar-track { width: 14px; }
}
@media (max-width: 560px) {
  .layout { padding: 5px; gap: 14px; }
  .topbar { padding: 10px 12px; gap: 10px; }
  .brand-tag { display: none; }
  .board { border-width: 3px; border-radius: 7px; }
  .board-stage { gap: 5px; }
  .evalbar { width: 16px; }
  .evalbar-track { width: 10px; }
  .evalbar-text { font-size: 9px; padding: 3px 0; }
  .panel-block { padding: 14px; }
  /* board fills the viewport width minus the slim eval bar + small margins */
  .board-wrap { max-height: 92vh; }
}

.board-area { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.board-stage { display: flex; gap: 12px; align-items: stretch; width: 100%; justify-content: center; }

/* ─── Vertical eval bar ──────────────────────────────────────────────────── */
.evalbar {
  width: 30px; display: flex; flex-direction: column; align-items: center;
  flex: none; align-self: stretch;
}
.evalbar-track {
  position: relative; flex: 1; width: 18px; border-radius: 9px; overflow: hidden;
  background: linear-gradient(#2b3142, #20252f); /* black's share (top) */
  border: 1px solid var(--line); box-shadow: inset 0 0 12px rgba(0,0,0,0.5);
}
.evalbar-fill {
  position: absolute; left: 0; right: 0; bottom: 0; height: 50%;
  background: linear-gradient(#ffffff, #d7dceb);
  transition: height 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.evalbar-mid { position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--accent); opacity: 0.8; }
.evalbar-text {
  font: 700 11px/1 ui-monospace, "SF Mono", Menlo, monospace; color: var(--muted);
  font-variant-numeric: tabular-nums; padding: 4px 0; min-height: 18px;
}

/* ─── Board ──────────────────────────────────────────────────────────────── */
.board-wrap { position: relative; width: min(70vh, 100%); aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center; }
.board {
  position: relative;
  /* --cols/--rows are set by the client; 8×8 normally, wider when the Knightmare
     ghost realm is revealed. The grid keeps square cells and fits the wrap. */
  display: grid;
  grid-template-columns: repeat(var(--cols, 8), 1fr);
  grid-template-rows: repeat(var(--rows, 8), 1fr);
  width: 100%; aspect-ratio: var(--cols, 8) / var(--rows, 8);
  max-width: 100%; max-height: 100%;
  border-radius: 10px; overflow: hidden;
  box-shadow: var(--shadow); outline: 1px solid rgba(255,255,255,0.05);
  border: 6px solid #20140e;
  background-image: linear-gradient(135deg, #2a1a10, #160d08);
}
/* Ghost-realm cells (the Knightmare's off-board ring): a dim "ether/void" tone,
   visually distinct from the green board, with a faint dotted texture. Kept
   subordinate so the 8×8 board reads as the focus. (Transparency is baked into
   the background, NOT `opacity`, so target dots/highlights stay crisp.) */
/* Ghost realm = clear, light "frosted glass" so it reads as open space (not a
   solid fill) and a dark Knightmare sitting in it stays high-contrast. Uses the
   .ghost.light/.dark pair to out-specify .sq.light/.sq.dark (defined later). */
.sq.ghost.light, .sq.ghost.dark {
  background: rgba(226, 234, 255, 0.17);
  box-shadow: inset 0 0 0 1px rgba(220, 230, 255, 0.22);
}
/* Bright frame around the real 8×8 board, drawn only when the ghost ring shows,
   positioned by --onL/--onT/--onW/--onH (set per-render from the view window). */
.board-frame {
  position: absolute; pointer-events: none; z-index: 3;   /* above the piece layer's ring, below dragged ghost */
  left: var(--onL, 0); top: var(--onT, 0); width: var(--onW, 100%); height: var(--onH, 100%);
  border-radius: 2px;
  box-shadow:
    inset 0 0 0 2px rgba(255,255,255,0.85),
    0 0 0 3px rgba(120,150,255,0.55),
    0 0 16px 4px rgba(120,150,255,0.45);
}
/* Pieces live in one absolutely-positioned overlay above the static square grid.
   A move just changes a piece's transform, so the browser tweens it (GPU) with no
   DOM rebuild. The layer ignores pointer events so clicks/drags hit the squares. */
.piece-layer { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.sq { position: relative; display: flex; align-items: center; justify-content: center; user-select: none; touch-action: none; }
.sq.light { background: var(--light); }
.sq.dark { background: var(--dark); }
.sq.sel.light { background: var(--light-sel); }
.sq.sel.dark { background: var(--dark-sel); }
.sq.lastmove::after { content: ""; position: absolute; inset: 0; background: var(--move-hl); pointer-events: none; }
.sq.check::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle at center, rgba(255,81,99,0.85) 0%, rgba(255,81,99,0.35) 45%, transparent 72%);
}
.coord { position: absolute; font: 700 10px/1 sans-serif; opacity: 0.6; pointer-events: none; }
.coord.file { right: 4px; bottom: 3px; }
.coord.rank { left: 4px; top: 3px; }
.sq.light .coord { color: var(--dark); }
.sq.dark .coord { color: var(--light); }

.target-dot {
  position: absolute; width: 30%; height: 30%; border-radius: 50%;
  background: var(--target); pointer-events: none; transition: transform 0.1s ease;
}
.sq:hover .target-dot { transform: scale(1.15); }
.sq.capturable .target-dot {
  width: 88%; height: 88%; background: transparent; border: 6px solid var(--target); box-sizing: border-box;
}

/* Horde Mother spawn-placement highlight (green) */
.sq.place-target { box-shadow: inset 0 0 0 3px rgba(111,174,58,0.85); cursor: pointer; }
.place-dot {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: 34%; height: 34%; border-radius: 50%;
  background: radial-gradient(circle, rgba(111,174,58,0.95), rgba(111,174,58,0.45)); pointer-events: none;
}

/* ─── Pieces (artwork from pixiechessboard.xyz) ──────────────────────────── */
.piece {
  position: absolute; top: 0; left: 0;
  width: calc(100% / var(--cols, 8)); height: calc(100% / var(--rows, 8)); cursor: pointer;
  display: flex; align-items: flex-end; justify-content: center;
  /* transform = grid position; CSS tweens it on every move */
  transition: transform 0.16s cubic-bezier(0.22, 0.61, 0.36, 1);
  will-change: transform;
}
.piece.dragging { opacity: 0.3; }
.drag-ghost { position: fixed; transform: translate(-50%, -50%); z-index: 60; pointer-events: none; }
.drag-ghost img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; filter: drop-shadow(0 5px 7px rgba(0,0,0,0.55)); }
.piece .art {
  width: 94%; height: 94%; object-fit: contain; pointer-events: none;
  image-rendering: pixelated;
  filter: drop-shadow(0 3px 3px rgba(0,0,0,0.45));
}
/* Most magic pieces share ONE thematic artwork for both players (e.g. Basilisk is
   green for everyone), so the OWNER is shown by a crisp white/black outline around
   the sprite plus a small base coin. Each carries a CONTRASTING edge so it stays
   visible on both light and dark board squares. (Pawn-with-Knife is recoloured.) */
.piece.magic::before { content: none; }     /* no big aura — keep it clean */
.piece.magic::after {   /* small base coin under the piece */
  content: ""; position: absolute; bottom: 2%; left: 50%; transform: translateX(-50%);
  width: 52%; height: 11%; border-radius: 50%; z-index: 0; pointer-events: none;
}
.piece.magic.owner-w::after { background: radial-gradient(ellipse, rgba(248,249,252,0.9), rgba(206,210,220,0.82)); border: 1px solid rgba(0,0,0,0.3); }
.piece.magic.owner-b::after { background: radial-gradient(ellipse, rgba(52,56,68,0.9), rgba(18,20,28,0.88)); border: 1px solid rgba(255,255,255,0.45); }
/* Owner cue: a soft same-colour glow + a faint contrasting contour — gentle but clear. */
.piece.magic.owner-w .art {
  filter: drop-shadow(0 0 1px rgba(0,0,0,0.35)) drop-shadow(0 0 5px rgba(255,255,255,0.5)) drop-shadow(0 2px 2px rgba(0,0,0,0.3));
}
.piece.magic.owner-b .art {
  filter: drop-shadow(0 0 1px rgba(255,255,255,0.4)) drop-shadow(0 0 5px rgba(0,0,0,0.5)) drop-shadow(0 2px 2px rgba(0,0,0,0.4));
}
/* Live count badge on stateful magic pieces (charge, range, captures…) */
.count-badge {
  position: absolute; top: -2%; left: -2%; z-index: 2; pointer-events: none;
  min-width: 1.45em; height: 1.45em; padding: 0 0.18em;
  display: flex; align-items: center; justify-content: center;
  font: 800 clamp(9px, 1.7vh, 14px)/1 ui-monospace, "SF Mono", Menlo, monospace;
  color: #fff; border-radius: 0.8em; border: 1.5px solid rgba(255,255,255,0.92);
  box-shadow: 0 1px 3px rgba(0,0,0,0.5);
}
.count-badge.c-charge   { background: linear-gradient(135deg, #2bb6ff, #1577e6); }
.count-badge.c-range    { background: linear-gradient(135deg, #ff9d3d, #f06a1a); }
.count-badge.c-cap      { background: linear-gradient(135deg, #ff5d6c, #d62f43); }
.count-badge.c-travel   { background: linear-gradient(135deg, #46c98a, #1f9e63); }
.count-badge.c-standoff { background: linear-gradient(135deg, #b98cff, #7c4bf0); }

/* Marker on Horde Mother's spawned hordelings, to tell them from normal pawns */
.horde-mark {
  position: absolute; top: -3%; right: -3%; z-index: 2; pointer-events: none;
  width: 1.35em; height: 1.35em; display: flex; align-items: center; justify-content: center;
  font: 800 clamp(8px, 1.5vh, 12px)/1 ui-monospace, Menlo, monospace; border-radius: 50%;
  background: linear-gradient(135deg, #6fae3a, #3f7d24); color: #fff;
  border: 1.5px solid rgba(255,255,255,0.9); box-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* Status effects on affected pieces */
.fx { position: absolute; inset: 0; z-index: 3; pointer-events: none; border-radius: 3px; }
.fx-frozen {
  background: linear-gradient(150deg, rgba(150,215,255,0.42), rgba(90,160,230,0.22));
  box-shadow: inset 0 0 0 3px rgba(160,225,255,0.9), inset 0 0 14px rgba(120,200,255,0.7);
}
.fx-frozen::after {  /* frost crystal in corner */
  content: "❄"; position: absolute; top: 2%; left: 6%; font-size: clamp(10px, 2vh, 16px);
  color: #eaf7ff; text-shadow: 0 0 4px #4aa8ff;
}
.fx-paralyzed {
  background: radial-gradient(circle at 50% 45%, rgba(120,225,140,0.40), rgba(60,150,90,0.18) 70%);
  box-shadow: inset 0 0 0 3px rgba(120,225,140,0.85);
}
.fx-paralyzed::after {  /* basilisk gaze mark */
  content: "◉"; position: absolute; top: 1%; left: 5%; font-size: clamp(10px, 2vh, 15px);
  color: #d6ffe0; text-shadow: 0 0 5px #2fae5a;
}
.piece.frozen-p .art { filter: brightness(1.12) saturate(0.45) drop-shadow(0 0 3px #8fd6ff); }
.piece.paralyzed-p .art { filter: grayscale(0.65) brightness(0.92) sepia(0.35) hue-rotate(58deg); }

.piece .glyph { font-size: clamp(26px, 6.4vh, 56px); line-height: 1; }
.piece .glyph.w { color: var(--white-piece); -webkit-text-stroke: 1.4px #4a4f5e; }
.piece .glyph.b { color: var(--black-piece); -webkit-text-stroke: 1.4px #c7ccd8; }

.status-line { color: var(--muted); min-height: 20px; text-align: center; font-size: 13.5px; }
.status-line b { color: var(--text); }

/* ─── Side panel ─────────────────────────────────────────────────────────── */
.panel { display: flex; flex-direction: column; gap: 16px; }
.panel-block {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}
.panel-block.grow { display: flex; flex-direction: column; min-height: 150px; }
.panel-block h2 {
  margin: 0 0 14px; font-size: 11.5px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted-2);
  display: flex; align-items: center; gap: 8px;
}
.panel-block h2::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }

.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; font-size: 12.5px; color: var(--muted); }
.field > span { font-weight: 600; }
.field b { color: var(--accent-2); }
select, input[type=range] { width: 100%; }
select {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 9px; padding: 10px 11px; font-size: 14px; cursor: pointer;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
select:hover { border-color: var(--accent); }
.preset-desc { margin: -4px 0 14px; font-size: 12.5px; color: var(--muted); min-height: 34px; line-height: 1.45; }

input[type=range] { -webkit-appearance: none; height: 6px; border-radius: 3px; background: var(--panel-2); border: 1px solid var(--line); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: 2px solid #fff2; cursor: pointer; box-shadow: 0 0 8px var(--accent);
}

/* ─── Custom draft editor ────────────────────────────────────────────────── */
.custom-editor { margin: -2px 0 12px; }
.custom-editor.hidden { display: none; }
.custom-hint { font-size: 12px; color: var(--muted); margin: 0 0 8px; }
.draft-rank { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; margin-bottom: 4px; }
.draft-cell {
  position: relative; aspect-ratio: 1; border-radius: 7px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; padding: 2px;
  transition: border-color 0.12s, transform 0.08s;
}
.draft-cell:hover { border-color: var(--accent); transform: translateY(-1px); }
.draft-cell.is-magic { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.draft-cell.is-empty { background: repeating-linear-gradient(45deg, #14161e, #14161e 5px, #1a1d27 5px, #1a1d27 10px); opacity: 0.7; }
.draft-cell img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.draft-cell .sqlabel { position: absolute; bottom: 1px; right: 3px; font-size: 8px; font-weight: 700; color: var(--muted-2); }

/* Lab mode: magic-piece selector grid */
.lab-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); gap: 6px; max-height: 300px; overflow-y: auto; }
.lab-pick {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 3px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--panel-2); cursor: pointer; transition: all 0.12s; position: relative;
}
.lab-pick:hover { border-color: var(--accent); }
.lab-pick.sel { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; background: var(--panel); }
.lab-pick.sel::after { content: "✓"; position: absolute; top: 2px; right: 4px; font-size: 10px; font-weight: 800; color: var(--gold); }
.lab-pick img { width: 34px; height: 34px; object-fit: contain; image-rendering: pixelated; }
.lab-pick .lab-name { font-size: 9px; line-height: 1.1; text-align: center; color: var(--muted); }
.lab-selected { font-size: 12px; color: var(--accent-2); margin: 10px 0 2px; min-height: 16px; }
.custom-count { font-size: 12px; color: var(--accent-2); margin: 8px 0; font-weight: 600; }
.online-info { margin: 4px 0 12px; }
.room-code { font-size: 15px; }
.room-code b { font-family: ui-monospace, Menlo, monospace; letter-spacing: 2px; color: var(--accent-2); font-size: 18px; }
.room-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.join-row { display: flex; gap: 6px; }
.join-row input { flex: 1; text-transform: uppercase; letter-spacing: 2px; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; }

/* Access-code field (Play vs Engine) — a gentle "locked feature" card that fits
   the purple/cyan accent theme, with a clear dark, readable input. */
#engineCodeField {
  background: linear-gradient(180deg, rgba(139,109,255,0.12), rgba(70,194,255,0.06));
  border: 1px solid rgba(139,109,255,0.32);
  border-radius: 11px;
  padding: 11px 12px;
  gap: 8px;
}
#engineCodeField > span {
  display: flex; align-items: center; gap: 6px;
  color: #c8bdff; font-weight: 700; letter-spacing: 0.2px;
}
#engineCodeField > span::before { content: "🔒"; font-size: 11px; opacity: 0.9; }
#engineCode {
  width: 100%; box-sizing: border-box;
  background: rgba(10,12,18,0.55); color: var(--text);
  border: 1px solid rgba(139,109,255,0.30); border-radius: 8px;
  padding: 9px 11px;
  font: 600 13px/1.2 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.6px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
#engineCode::placeholder { color: var(--muted-2); font-weight: 400; letter-spacing: 0.2px; }
#engineCode:hover { border-color: rgba(139,109,255,0.55); }
#engineCode:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(139,109,255,0.22); }
.custom-count.count-bad { color: var(--gold); }

.chooser-list { display: flex; flex-direction: column; gap: 8px; padding: 14px; }
.chooser-list .btn { text-align: left; }

.picker-overlay {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: rgba(6, 8, 14, 0.72); backdrop-filter: blur(4px); padding: 16px;
}
.picker-overlay.hidden { display: none; }
.picker-card {
  width: min(560px, 100%); max-height: 84vh; display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden;
}
.picker-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); font-weight: 700; }
.picker-close { background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 8px; width: 30px; height: 30px; cursor: pointer; font-size: 14px; }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; padding: 14px; overflow-y: auto; }
.pick {
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 4px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); cursor: pointer; transition: all 0.12s;
}
.pick:hover { border-color: var(--accent); transform: translateY(-2px); }
.pick.pick-disabled { opacity: 0.32; filter: grayscale(0.8); cursor: not-allowed; }
.pick.pick-disabled:hover { border-color: var(--line); transform: none; }
.pick img { width: 40px; height: 40px; object-fit: contain; image-rendering: pixelated; }
.pick .pick-name { font-size: 10px; line-height: 1.15; text-align: center; color: var(--muted); }
.pick.pick-std { background: var(--panel); }
.pick.pick-empty { background: var(--panel); }
.pick .pick-x { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; font-size: 24px; color: var(--muted); }

.seg { display: flex; gap: 6px; }
.seg-btn {
  flex: 1; padding: 9px; border: 1px solid var(--line); background: var(--panel-2);
  color: var(--muted); border-radius: 9px; cursor: pointer; font-weight: 600; font-size: 13.5px; transition: all 0.12s;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: linear-gradient(135deg, var(--accent), #6a4bf0); color: #fff; border-color: transparent; box-shadow: 0 4px 14px rgba(139,109,255,0.4); }

.btn {
  width: auto; padding: 11px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); cursor: pointer; font-weight: 600; font-size: 14px; transition: all 0.12s;
}
.btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.btn.full { width: 100%; }
.draft-actions { display: flex; gap: 8px; }
.draft-actions .btn { flex: 1; }
.btn-primary { background: linear-gradient(135deg, var(--accent), #6a4bf0); border: none; color: #fff; box-shadow: 0 6px 18px rgba(139,109,255,0.38); }
.btn-primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.legend { display: flex; flex-direction: column; gap: 4px; max-height: 252px; overflow-y: auto; margin: 0 -6px; padding: 0 6px; }
.legend-row { display: flex; align-items: center; gap: 11px; font-size: 13px; padding: 6px; border-radius: 9px; transition: background 0.12s; }
.legend-row:hover { background: var(--panel-2); }
.legend-dot { width: 30px; height: 30px; border-radius: 8px; flex: none; background: var(--panel-2); }
.legend-img { width: 32px; height: 32px; object-fit: contain; flex: none; image-rendering: pixelated; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4)); }
.legend-name { font-weight: 700; }
.legend-desc { color: var(--muted); font-size: 12px; }
.legend-empty { color: var(--muted); font-size: 13px; }

.move-list {
  margin: 0; padding-left: 28px; overflow-y: auto; flex: 1; max-height: 260px;
  font-variant-numeric: tabular-nums; font-size: 13.5px; color: var(--text);
}
.move-list li { padding: 2px 0; }
.move-list li::marker { color: var(--muted-2); }
.move-list li .ability { color: var(--accent-2); font-weight: 600; }

.hint { color: var(--muted-2); font-size: 11.5px; margin: 12px 0 0; line-height: 1.5; }

/* ─── Overlay ────────────────────────────────────────────────────────────── */
.overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(8, 10, 16, 0.7); backdrop-filter: blur(4px); border-radius: 10px; z-index: 5;
}
.overlay.hidden { display: none; }
.overlay-card {
  text-align: center; padding: 28px 34px; background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
}
.overlay-title { font-size: 26px; font-weight: 800; margin-bottom: 6px; }
.overlay-sub { color: var(--muted); margin-bottom: 20px; }

::-webkit-scrollbar { width: 9px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }
