/* Windmill — application styles
   Aesthetic: "midnight study" — ink black, warm cream text, amber accent, walnut board.
   Fonts: Fraunces (display), Instrument Sans (UI), JetBrains Mono (numbers). */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,300..700;1,9..144,300..700&family=Instrument+Sans:ital,wght@0,400..700;1,400..700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --font-display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --font-ui: 'Instrument Sans', 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Menlo, monospace;

  --bg: #0a0c11;
  --bg-2: #10131a;
  --panel: #151922;
  --panel-2: #1b2029;
  --line: rgba(236, 230, 218, 0.08);
  --line-strong: rgba(236, 230, 218, 0.16);
  --text: #ece6da;
  --text-2: #b7b1a6;
  --muted: #7d8290;
  --accent: #e8b04b;
  --accent-ink: #1a1305;
  --accent-soft: rgba(232, 176, 75, 0.14);
  --danger: #e25c5c;
  --ok: #6cc070;

  --c-brilliant: #3dd3e4;
  --c-best: #62c56c;
  --c-excellent: #94c65f;
  --c-good: #b6c48a;
  --c-book: #b59a6b;
  --c-inaccuracy: #e6c14a;
  --c-mistake: #ee8a3c;
  --c-blunder: #e04f4f;

  --sq-light: #e8dabc;
  --sq-dark: #9a7451;
  --sq-last: rgba(232, 176, 75, 0.45);
  --sq-sel: rgba(232, 176, 75, 0.65);
  --sq-check: radial-gradient(circle, rgba(224, 79, 79, 0.9) 0%, rgba(224, 79, 79, 0.35) 55%, transparent 75%);

  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.8), 0 2px 6px rgba(0, 0, 0, 0.4);
  --rail-w: 84px;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f4efe4;
  --bg-2: #ebe4d5;
  --panel: #fffdf8;
  --panel-2: #f3eee2;
  --line: rgba(20, 16, 8, 0.09);
  --line-strong: rgba(20, 16, 8, 0.18);
  --text: #17130c;
  --text-2: #4b463c;
  --muted: #7d766a;
  --accent: #b9791a;
  --accent-ink: #fff;
  --accent-soft: rgba(185, 121, 26, 0.12);
  --shadow: 0 30px 60px -30px rgba(40, 30, 10, 0.35), 0 2px 6px rgba(40, 30, 10, 0.08);
  --sq-light: #efe2c4;
  --sq-dark: #a77c56;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
body::before {
  /* subtle grain */
  content: '';
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 500; }
::selection { background: var(--accent); color: var(--accent-ink); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--rail-w) 1fr; height: 100vh; position: relative; z-index: 1; }

.rail {
  display: flex; flex-direction: column; align-items: center;
  padding: 18px 0 14px; gap: 6px;
  background: var(--bg-2); border-right: 1px solid var(--line);
}
.brand { display: flex; flex-direction: column; align-items: center; gap: 2px; margin-bottom: 18px; text-decoration: none; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center;
  font-family: var(--font-display); font-style: italic; font-weight: 600; font-size: 24px;
  box-shadow: 0 8px 20px -8px var(--accent);
}
.brand-name { font-family: var(--font-display); font-style: italic; font-size: 15px; color: var(--text-2); letter-spacing: 0.01em; }
.rail-nav { display: flex; flex-direction: column; gap: 4px; width: 100%; padding: 0 10px; }
.rail-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  width: 100%; padding: 10px 4px; border: 0; border-radius: 10px;
  background: transparent; color: var(--muted); font-size: 11px; letter-spacing: 0.02em;
  transition: background 0.15s, color 0.15s;
}
.rail-btn svg { width: 22px; height: 22px; }
.rail-btn:hover { color: var(--text); background: var(--panel); }
.rail-btn.active { color: var(--accent); background: var(--accent-soft); }
.rail-spacer { flex: 1; }
.rail-foot { display: flex; flex-direction: column; gap: 4px; width: 100%; padding: 0 10px; }

.stage { min-width: 0; overflow: auto; }
.view { display: none; min-height: 100%; }
.view.active { display: block; }

.workspace {
  display: grid; grid-template-columns: minmax(320px, calc(100vh - 150px)) minmax(360px, 500px);
  gap: 22px; padding: 22px 24px; align-items: start; justify-content: center;
  max-width: 1440px; margin: 0 auto;
}
@media (max-width: 1080px) {
  .workspace { grid-template-columns: 1fr; }
  .board-col { max-width: 720px; margin: 0 auto; width: 100%; }
}
@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .rail { flex-direction: row; order: 2; padding: 6px 8px; border-right: 0; border-top: 1px solid var(--line); }
  .brand, .rail-foot { display: none; }
  .rail-nav { flex-direction: row; }
  .workspace { padding: 12px; gap: 14px; }
}

/* ---------- board column ---------- */
.board-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.board-frame { display: grid; grid-template-columns: 18px 1fr; gap: 10px; align-items: stretch; }
.evalbar {
  position: relative; border-radius: 6px; overflow: hidden;
  background: #1f1f22; border: 1px solid var(--line-strong);
}
.evalbar .white { position: absolute; left: 0; right: 0; bottom: 0; background: #f2ede2; transition: height 0.5s cubic-bezier(.4,0,.2,1); }
.evalbar.flipped .white { bottom: auto; top: 0; }
.evalbar .lbl {
  position: absolute; left: 0; right: 0; text-align: center;
  font-family: var(--font-mono); font-size: 9px; font-weight: 600; writing-mode: vertical-rl; transform: rotate(180deg);
}
.evalbar .lbl.top { top: 6px; color: #f2ede2; }
.evalbar .lbl.bottom { bottom: 6px; color: #1f1f22; }

.pboard {
  position: relative; width: 100%; aspect-ratio: 1 / 1;
  border-radius: 10px; overflow: hidden; user-select: none; touch-action: none;
  box-shadow: var(--shadow);
  background: var(--sq-dark);
}
.pboard-squares { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); }
.psq { position: relative; }
.psq.light { background: var(--sq-light); }
.psq.dark { background: var(--sq-dark); }
.psq.hl-last::after, .psq.hl-sel::after, .psq.hl-check::after, .psq.hl-dot::after, .psq.hl-capture::after,
.psq.hl-blunder::after, .psq.hl-mistake::after, .psq.hl-inaccuracy::after, .psq.hl-best::after, .psq.hl-brilliant::after, .psq.hl-mark::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
}
.psq.hl-last::after { background: var(--sq-last); }
.psq.hl-sel::after { background: var(--sq-sel); }
.psq.hl-check::after { background: var(--sq-check); }
.psq.hl-dot::after { background: radial-gradient(circle, rgba(0,0,0,0.28) 0 17%, transparent 18%); }
.psq.hl-capture::after { background: radial-gradient(circle, transparent 0 58%, rgba(0,0,0,0.3) 60% 100%); }
.psq.hl-blunder::after { box-shadow: inset 0 0 0 4px var(--c-blunder); }
.psq.hl-mistake::after { box-shadow: inset 0 0 0 4px var(--c-mistake); }
.psq.hl-inaccuracy::after { box-shadow: inset 0 0 0 4px var(--c-inaccuracy); }
.psq.hl-best::after { box-shadow: inset 0 0 0 4px var(--c-best); }
.psq.hl-brilliant::after { box-shadow: inset 0 0 0 4px var(--c-brilliant); }
.psq.hl-mark::after { box-shadow: inset 0 0 0 4px var(--accent); }

.pboard-coords { position: absolute; inset: 0; pointer-events: none; font-family: var(--font-mono); font-size: 10px; font-weight: 600; }
.pcoord { position: absolute; opacity: 0.55; }
.pcoord.file { bottom: 2px; width: 12.5%; text-align: right; padding-right: 4px; color: rgba(50, 32, 14, 0.7); }
.pcoord.rank { left: 3px; height: 12.5%; color: rgba(50, 32, 14, 0.7); }
.pboard-pieces { position: absolute; inset: 0; pointer-events: none; }
.ppiece {
  position: absolute; top: 0; left: 0; width: 12.5%; height: 12.5%;
  background-size: 100% 100%; background-repeat: no-repeat;
  transition: transform 0.18s cubic-bezier(.3,.1,.2,1);
  will-change: transform;
}
.pboard-arrows { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.parrow { stroke-linecap: round; }
.arrow-best { stroke: var(--c-best); fill: var(--c-best); }
.arrow-good { stroke: var(--c-good); fill: var(--c-good); }
.arrow-ok { stroke: var(--c-inaccuracy); fill: var(--c-inaccuracy); }
.arrow-meh { stroke: var(--c-mistake); fill: var(--c-mistake); }
.arrow-bad { stroke: var(--c-blunder); fill: var(--c-blunder); }
.arrow-user { stroke: var(--accent); fill: var(--accent); }
.arrow-threat { stroke: #b46cff; fill: #b46cff; }
.parrow { opacity: 0.85; }
.parrow-label rect { fill: #0b0d12; stroke-width: 0.02; }
.parrow-label text { fill: #fff; font-family: var(--font-mono); font-weight: 600; }
.label-best rect { stroke: var(--c-best); }
.label-good rect { stroke: var(--c-good); }
.label-ok rect { stroke: var(--c-inaccuracy); }
.label-meh rect { stroke: var(--c-mistake); }
.label-bad rect { stroke: var(--c-blunder); }
.pboard-drag { position: absolute; top: 0; left: 0; display: none; pointer-events: none; background-size: 100% 100%; z-index: 5; filter: drop-shadow(0 6px 8px rgba(0,0,0,0.4)); }

/* board toolbar */
.board-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.nav-group { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.nav-group button { border: 0; background: transparent; color: var(--text-2); padding: 8px 12px; display: grid; place-items: center; }
.nav-group button:hover { background: var(--panel-2); color: var(--text); }
.nav-group button svg { width: 16px; height: 16px; }
.tool-spacer { flex: 1; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 13px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-weight: 500; font-size: 13px;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover { background: var(--panel-2); border-color: var(--line-strong); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 15px; height: 15px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.06); background: var(--accent); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--panel); color: var(--text); }
.btn.sm { padding: 5px 9px; font-size: 12px; border-radius: 8px; }
.btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn.danger { color: var(--danger); }

/* player strips */
.player-strip { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px; font-size: 13px; }
.player-strip .name { font-weight: 600; }
.player-strip .rating { color: var(--muted); font-family: var(--font-mono); font-size: 12px; margin-left: 6px; }
.player-strip .acc { font-family: var(--font-mono); font-size: 12px; color: var(--accent); }

/* ---------- side panel ---------- */
.panel { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.card-h { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.card-h h3 { font-family: var(--font-display); font-weight: 500; font-size: 16px; letter-spacing: -0.01em; }
.card-h .sub { color: var(--muted); font-size: 12px; }
.card-b { padding: 12px 14px; }

/* engine block */
.engine-top { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 14px 14px 8px; }
.eval-big { font-family: var(--font-display); font-size: 40px; line-height: 1; font-weight: 500; letter-spacing: -0.03em; min-width: 92px; font-variant-numeric: tabular-nums; }
.eval-big.mate { color: var(--accent); }
.engine-meta { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); }
.engine-meta b { color: var(--text-2); font-weight: 500; }
.engine-meta .cloud { color: var(--c-brilliant); }
.engine-ctl { display: flex; gap: 4px; }
.icon-btn { width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--line); background: transparent; color: var(--text-2); display: grid; place-items: center; }
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn.active { color: var(--accent); border-color: var(--accent); }
.icon-btn svg { width: 15px; height: 15px; }
.depth-track { height: 3px; background: var(--line); margin: 0 14px 8px; border-radius: 2px; overflow: hidden; }
.depth-track i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.3s; }
.lines { display: flex; flex-direction: column; }
.line {
  display: grid; grid-template-columns: 56px 1fr; gap: 10px; align-items: baseline;
  padding: 7px 14px; border-top: 1px solid var(--line); cursor: pointer; font-size: 13px;
}
.line:hover { background: var(--panel-2); }
.line .sc { font-family: var(--font-mono); font-weight: 600; font-size: 12px; padding: 2px 6px; border-radius: 6px; text-align: center; background: var(--panel-2); }
.line .sc.w { background: #efe9dc; color: #111; }
.line .sc.b { background: #2a2a2e; color: #eee; }
.line .pv { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--font-mono); font-size: 12px; }
.line .pv b { color: var(--text); font-weight: 600; }
.engine-settings { display: none; padding: 10px 14px; border-top: 1px solid var(--line); gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); }
.engine-settings.open { display: flex; }
.engine-settings label { display: flex; align-items: center; gap: 6px; }
.engine-settings select, .engine-settings input[type=number] { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; }

/* tabs */
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tab { flex: 1; padding: 10px 6px; border: 0; background: transparent; color: var(--muted); font-weight: 500; font-size: 13px; position: relative; }
.tab.active { color: var(--text); }
.tab.active::after { content: ''; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; background: var(--accent); border-radius: 2px; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* move list */
.movelist { max-height: 44vh; overflow: auto; padding: 6px 8px; font-family: var(--font-mono); font-size: 13px; }
.mv-row { display: grid; grid-template-columns: 36px 1fr 1fr; align-items: stretch; }
.mv-num { color: var(--muted); padding: 5px 6px; font-size: 11px; }
.mv { padding: 4px 8px; border-radius: 6px; cursor: pointer; display: flex; align-items: center; gap: 6px; }
.mv:hover { background: var(--panel-2); }
.mv.cur { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.mv .g { font-size: 10px; font-weight: 700; min-width: 16px; text-align: center; font-family: var(--font-ui); }
.mv.c-brilliant .g { color: var(--c-brilliant); } .mv.c-best .g { color: var(--c-best); } .mv.c-excellent .g { color: var(--c-excellent); }
.mv.c-good .g { color: var(--c-good); } .mv.c-book .g { color: var(--c-book); } .mv.c-inaccuracy .g { color: var(--c-inaccuracy); }
.mv.c-mistake .g { color: var(--c-mistake); } .mv.c-blunder .g { color: var(--c-blunder); } .mv.c-forced .g { color: var(--muted); }
.mv.c-blunder { color: var(--c-blunder); } .mv.c-mistake { color: var(--c-mistake); } .mv.c-brilliant { color: var(--c-brilliant); }
.variation-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--accent-soft); color: var(--accent); font-size: 12px; }
.empty { padding: 26px 14px; color: var(--muted); text-align: center; font-size: 13px; }
.empty b { color: var(--text-2); font-weight: 500; }

/* move detail / coach */
.coach { padding: 12px 14px; border-top: 1px solid var(--line); display: flex; gap: 12px; align-items: flex-start; }
.coach .badge { font-family: var(--font-mono); font-weight: 700; font-size: 12px; padding: 4px 8px; border-radius: 7px; background: var(--panel-2); white-space: nowrap; }
.coach p { margin: 0; color: var(--text-2); font-size: 13px; }
.coach p b { color: var(--text); font-weight: 600; }
.coach .best { font-family: var(--font-mono); font-size: 12px; color: var(--muted); margin-top: 4px; }

/* report */
.report-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px 14px; }
.acc-card { background: var(--panel-2); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.acc-card .who { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.acc-card .who i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; border: 1px solid var(--line-strong); }
.acc-card .val { font-family: var(--font-display); font-size: 34px; font-weight: 500; letter-spacing: -0.03em; line-height: 1.05; }
.acc-card .val small { font-size: 14px; color: var(--muted); margin-left: 2px; }
.acc-card .est { font-size: 11px; color: var(--muted); }
.acc-card .est b { color: var(--text-2); font-family: var(--font-mono); font-weight: 500; }
.cls-table { padding: 0 14px 12px; display: grid; gap: 4px; }
.cls-row { display: grid; grid-template-columns: 34px 1fr 34px; align-items: center; gap: 8px; font-size: 13px; }
.cls-row .n { font-family: var(--font-mono); text-align: center; font-weight: 600; }
.cls-row .lab { display: flex; align-items: center; gap: 8px; color: var(--text-2); }
.cls-row .lab i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.phase-row { display: grid; grid-template-columns: 90px 1fr 1fr; gap: 8px; align-items: center; font-size: 12px; padding: 3px 0; }
.phase-row .bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; position: relative; }
.phase-row .bar i { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 3px; }
.phase-row .bar.w i { background: #efe9dc; } .phase-row .bar.b i { background: #6b6f7a; }
.graph { display: block; width: 100%; height: 110px; cursor: pointer; }
.key-moments { padding: 6px 8px 10px; display: flex; flex-direction: column; gap: 4px; }
.km { display: grid; grid-template-columns: 52px 1fr auto; gap: 10px; align-items: center; padding: 7px 8px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.km:hover { background: var(--panel-2); }
.km .san { font-family: var(--font-mono); font-weight: 600; }
.km .cls { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.km .why { color: var(--muted); font-size: 12px; }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 8px 14px 12px; }
.progress i { display: block; height: 100%; background: var(--accent); width: 0; transition: width 0.2s; }

/* opening / explorer */
.opening-name { font-family: var(--font-display); font-size: 17px; padding: 12px 14px 4px; }
.opening-name small { display: block; font-family: var(--font-mono); color: var(--muted); font-size: 11px; margin-top: 2px; }
.book-moves { display: flex; flex-direction: column; }
.bm { display: grid; grid-template-columns: 70px 1fr auto; gap: 10px; align-items: center; padding: 7px 14px; border-top: 1px solid var(--line); cursor: pointer; font-size: 13px; }
.bm:hover { background: var(--panel-2); }
.bm .san { font-family: var(--font-mono); font-weight: 600; }
.bm .nm { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bm .wdl { display: flex; width: 120px; height: 8px; border-radius: 4px; overflow: hidden; background: var(--line); }
.bm .wdl i { display: block; height: 100%; }
.bm .wdl .w { background: #efe9dc; } .bm .wdl .d { background: #7d8290; } .bm .wdl .b { background: #2a2a2e; }
.bm .games { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.token-row { display: flex; gap: 6px; padding: 10px 14px; border-top: 1px solid var(--line); }
.token-row input { flex: 1; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; font-size: 12px; }
.hint { padding: 8px 14px 12px; color: var(--muted); font-size: 12px; line-height: 1.5; }

/* guess mode */
.guess-box { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.guess-score { display: flex; gap: 18px; font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.guess-score b { color: var(--text); font-size: 20px; font-family: var(--font-display); }
.guess-msg { padding: 10px 12px; border-radius: 10px; background: var(--panel-2); font-size: 13px; min-height: 40px; }
.guess-msg.good { border-left: 3px solid var(--c-best); }
.guess-msg.bad { border-left: 3px solid var(--c-blunder); }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(4, 5, 8, 0.7); backdrop-filter: blur(6px); display: none; place-items: center; z-index: 50; padding: 20px; }
.modal-bg.open { display: grid; }
.modal { width: min(680px, 100%); background: var(--panel); border: 1px solid var(--line-strong); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; animation: pop 0.2s cubic-bezier(.2,.8,.2,1); }
@keyframes pop { from { transform: translateY(10px) scale(0.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 0; }
.modal-h h2 { font-family: var(--font-display); font-weight: 500; font-size: 22px; }
.modal-b { padding: 14px 18px 18px; }
textarea.paste { width: 100%; min-height: 150px; resize: vertical; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-family: var(--font-mono); font-size: 12px; }
textarea.paste:focus, input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.err { color: var(--danger); font-size: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.field input, .field select { background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; color: var(--text); font-size: 13px; }
.games-list { max-height: 44vh; overflow: auto; display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.game-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); cursor: pointer; }
.game-row:hover { background: var(--panel-2); }
.game-row .players { font-weight: 600; font-size: 13px; }
.game-row .meta { color: var(--muted); font-size: 11px; }
.game-row .res { font-family: var(--font-mono); font-weight: 600; }

/* toasts */
.toast-wrap { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 60; pointer-events: none; }
.toast { background: var(--panel); border: 1px solid var(--line-strong); color: var(--text); padding: 10px 14px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow); animation: pop 0.2s; }
.toast.err { border-color: var(--danger); }

/* ---------- puzzles ---------- */
.puzzle-head { display: flex; align-items: center; gap: 14px; padding: 14px; }
.stat { display: flex; flex-direction: column; }
.stat .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; }
.stat .v { font-family: var(--font-display); font-size: 26px; line-height: 1.1; }
.turn-banner { display: flex; align-items: center; gap: 10px; padding: 12px 14px; font-size: 15px; font-weight: 500; border-top: 1px solid var(--line); }
.turn-banner i { width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--line-strong); }
.turn-banner.win { color: var(--c-best); } .turn-banner.fail { color: var(--c-blunder); }
.theme-select { padding: 10px 14px; border-top: 1px solid var(--line); display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.theme-select select { flex: 1; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.drill-list { display: flex; flex-direction: column; }
.drill { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 8px 14px; border-top: 1px solid var(--line); font-size: 13px; cursor: pointer; }
.drill:hover { background: var(--panel-2); }
.drill .n { font-family: var(--font-mono); color: var(--muted); }
.drill .st { font-size: 11px; font-family: var(--font-mono); }

/* ---------- play ---------- */
.play-setup { padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.rating-pick { display: flex; flex-direction: column; gap: 6px; }
.rating-pick .val { font-family: var(--font-display); font-size: 42px; line-height: 1; letter-spacing: -0.03em; }
.rating-pick .val small { font-size: 13px; color: var(--muted); font-family: var(--font-ui); margin-left: 8px; letter-spacing: 0; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.seg { display: inline-flex; background: var(--panel-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 6px 12px; border-radius: 8px; font-weight: 500; }
.seg button.active { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,0.3); }
.persona { display: grid; grid-template-columns: 44px 1fr; gap: 10px; align-items: center; padding: 10px; border-radius: 10px; background: var(--panel-2); }
.persona .av { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-family: var(--font-display); font-size: 22px; background: var(--accent-soft); color: var(--accent); }
.persona .nm { font-weight: 600; }
.persona .desc { font-size: 12px; color: var(--muted); }
.clock { font-family: var(--font-mono); font-size: 22px; padding: 4px 10px; border-radius: 8px; background: var(--panel-2); }
.clock.active { background: var(--accent); color: var(--accent-ink); }
.play-status { padding: 12px 14px; font-size: 14px; border-top: 1px solid var(--line); }
.play-status b { color: var(--accent); }

/* ---------- setup ---------- */
.palette { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; padding: 12px 14px; }
.pal { aspect-ratio: 1; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2) center / 80% no-repeat; cursor: pointer; }
.pal:hover { border-color: var(--line-strong); }
.pal.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.pal.trash { display: grid; place-items: center; color: var(--danger); }
.setup-opts { padding: 0 14px 12px; display: flex; flex-direction: column; gap: 10px; font-size: 13px; }
.setup-opts label { display: flex; gap: 8px; align-items: center; }
.setup-opts input[type=text] { width: 100%; background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-family: var(--font-mono); font-size: 12px; }
.chk-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

/* shortcuts footer */
.kbd-hint { color: var(--muted); font-size: 11px; padding: 4px 6px; }
kbd { font-family: var(--font-mono); font-size: 10px; background: var(--panel-2); border: 1px solid var(--line-strong); border-radius: 4px; padding: 1px 5px; }

.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 5px; border: 2px solid transparent; background-clip: padding-box; }
