/* ───────────── Knightly · bright, playful theme (matches the ads) ───────────── */
:root {
  --bg: #ffffff;
  --bg-2: #f7f7f7;
  --panel: #ffffff;
  --panel-2: #f7f7f7;
  --panel-3: #eef1f4;
  --surface: #ffffff;
  --line: #e5e5e5;
  --line-2: #d7d7d7;
  --text: #3c3c3c;
  --text-2: #4b4b4b;
  --text-3: #8a8a8a;

  --green: #58cc02; --green-d: #46a302;
  --yellow: #ffc800; --yellow-d: #e0a800;
  --blue: #1cb0f6; --blue-d: #1899d6;
  --red: #ff4b4b; --red-d: #ea2b2b;
  --purple: #ce82ff; --purple-d: #a560e8;
  --orange: #ff9600; --orange-d: #e08600;

  --accent: var(--yellow);
  --accent-2: #ffd84d;
  --accent-ink: #4a3500;
  --accent-shadow: var(--yellow-d);
  --good: var(--green);
  --bad: var(--red);
  --warn: var(--orange);

  --sq-light: #e6e9f2;
  --sq-dark: #3c4a6c;
  --sq-last: rgba(255, 200, 0, .5);
  --radius: 20px;
  --radius-sm: 14px;
  --font: 'Nunito', ui-rounded, system-ui, 'Segoe UI', sans-serif;
  --mono: 'Nunito', ui-rounded, system-ui, sans-serif;
  --shadow: 0 10px 30px rgba(0, 0, 0, .12);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-weight: 700; }
body { display: flex; overflow: hidden; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; color: var(--text); }
.hidden { display: none !important; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 900; }
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-thumb { background: #dcdcdc; border-radius: 10px; border: 3px solid #fff; }
::-webkit-scrollbar-track { background: transparent; }

/* ───────────── Sidebar ───────────── */
.sidebar {
  width: 256px; flex: none; display: flex; flex-direction: column; gap: 14px;
  padding: 22px 16px; background: var(--surface); border-right: 2px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 12px 16px; color: var(--green); }
.brand-mark {
  width: 36px; height: 36px; background: var(--green);
  -webkit-mask: url(/pieces/wN.svg) center / contain no-repeat; mask: url(/pieces/wN.svg) center / contain no-repeat;
}
.brand-name { font-weight: 900; letter-spacing: .02em; font-size: 30px; text-transform: lowercase; }
.nav { display: flex; flex-direction: column; gap: 6px; }
.nav a {
  display: flex; align-items: center; gap: 16px; padding: 10px 14px; border-radius: 14px;
  border: 2px solid transparent; font-weight: 800; font-size: 14px; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap;
  color: #777; transition: background .12s, color .12s;
}
.nav a:hover { background: var(--bg-2); }
.nav a.active { color: var(--blue-d); background: #ddf4ff; border-color: #84d8ff; }
.ni { width: 34px; height: 34px; border-radius: 10px; flex: none; position: relative; box-shadow: inset 0 -4px 0 rgba(0,0,0,.15); }
.ni::after { content: ''; position: absolute; inset: 5px 5px 8px; background: #fff; -webkit-mask: var(--m) center / contain no-repeat; mask: var(--m) center / contain no-repeat; }
.ni-home { background: var(--green); --m: url(/pieces/wK.svg); }
.ni-review { background: var(--blue); --m: url(/pieces/wB.svg); }
.ni-blunder { background: var(--red); --m: url(/pieces/wP.svg); }
.ni-spar { background: var(--purple); --m: url(/pieces/wN.svg); }
.ni-puzzle { background: var(--yellow); --m: url(/pieces/wQ.svg); }
.ni-board { background: var(--orange); --m: url(/pieces/wR.svg); }
.ni-openings { background: #2ec4b6; --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M2 5.5C4.5 4 8.5 4 11 5.5V20c-2.5-1.5-6.5-1.5-9 0zM13 5.5c2.5-1.5 6.5-1.5 9 0V20c-2.5-1.5-6.5-1.5-9 0z'/%3E%3C/svg%3E"); }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.streak-card { background: var(--surface); border: 2px solid var(--line); border-radius: 18px; padding: 14px; }
.streak-top { display: flex; align-items: center; gap: 10px; }
.streak-num { font-size: 30px; font-weight: 900; color: var(--orange); line-height: 1; }
.streak-lbl { font-size: 11px; letter-spacing: .14em; color: var(--text-3); font-weight: 900; }
.streak-days { display: flex; justify-content: space-between; margin-top: 12px; }
.streak-days span { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 10px; color: var(--text-3); font-weight: 900; }
.streak-days i { width: 16px; height: 16px; border-radius: 50%; background: var(--line); display: block; }
.streak-days i.on { background: var(--orange); box-shadow: inset 0 -3px 0 var(--orange-d); }
.profile-chip {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 16px; text-align: left;
  background: var(--surface); border: 2px solid var(--line); border-bottom-width: 4px; font-weight: 800; font-size: 14px;
}
.profile-chip .av { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; font-size: 14px; color: #fff; background: var(--purple); }
.profile-chip small { display: block; color: var(--text-3); font-weight: 700; font-size: 12px; }
.feedback-btn {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 16px; font-weight: 900; font-size: 14px;
  text-transform: uppercase; letter-spacing: .06em; background: var(--surface); color: var(--blue-d);
  border: 2px solid var(--line); border-bottom-width: 4px; transition: transform .08s;
}
.feedback-btn:hover { background: var(--bg-2); }
.feedback-btn:active { transform: translateY(2px); border-bottom-width: 2px; }
.engine-status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-3); padding: 0 6px; font-weight: 800; }
.led { width: 9px; height: 9px; border-radius: 50%; background: #ccc; }
.led.on { background: var(--green); }
.led.busy { background: var(--yellow); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.stars { display: flex; gap: 4px; }
.stars button { border: 0; background: none; font-size: 34px; line-height: 1; color: var(--line); padding: 0 2px; transition: transform .1s, color .1s; }
.stars button:hover { transform: scale(1.15); }
.stars button.on { color: var(--yellow); }
#fb-kind { flex-wrap: wrap; }

/* ───────────── Main / layout ───────────── */
.main { flex: 1; overflow: auto; padding: 30px 34px 56px; background: var(--surface); }
.page { max-width: 1280px; margin: 0 auto; animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-title { font-size: 34px; font-weight: 900; margin: 0; letter-spacing: -.01em; }
.page-sub { color: var(--text-3); margin: 4px 0 0; font-size: 16px; font-weight: 700; }
.panel { background: var(--surface); border: 2px solid var(--line); border-bottom-width: 4px; border-radius: var(--radius); padding: 20px; }
.panel-title { font-weight: 900; font-size: 20px; margin: 0 0 14px; display: flex; align-items: center; gap: 10px; }
.grid { display: grid; gap: 18px; }
.cols-2 { grid-template-columns: 1fr 1fr; }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.row { display: flex; align-items: center; gap: 10px; }
.spacer { flex: 1; }
.muted { color: var(--text-3); }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 900; letter-spacing: .08em; padding: 4px 10px; border-radius: 999px; background: #fff4cc; color: #a77800; text-transform: uppercase; }

.train-layout { display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 26px; align-items: start; }
.board-col { display: flex; flex-direction: column; gap: 12px; max-width: min(78vh, 760px); width: 100%; margin: 0 auto; }
.board-row { display: flex; gap: 10px; }
.board-row > .board-wrap { flex: 1; }
.player-bar { display: flex; align-items: center; gap: 10px; }
.player-tag { display: flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; background: var(--surface); border: 2px solid var(--line); border-radius: 999px; font-weight: 900; font-size: 15px; }
.player-tag.turn { border-color: var(--green); background: #f0fbe6; }
.player-tag .elo { color: var(--text-3); font-size: 13px; font-weight: 800; }
.player-tag .av { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 900; background: var(--panel-3); overflow: hidden; }
.player-tag .av img { width: 120%; margin-top: 10%; }
.clock { font-family: var(--mono); font-weight: 900; font-size: 18px; padding: 6px 16px; background: var(--surface); border-radius: 14px; border: 2px solid var(--line); border-bottom-width: 4px; font-variant-numeric: tabular-nums; }
.side-panel { position: sticky; top: 0; display: flex; flex-direction: column; gap: 14px; max-height: calc(100vh - 86px); }

/* ───────────── Buttons (chunky, 3D) ───────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: 16px; border: 2px solid var(--line); border-bottom-width: 5px; background: var(--surface);
  font-weight: 900; font-size: 15px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3);
  transition: transform .06s, filter .15s; white-space: nowrap;
}
.btn:hover { filter: brightness(.98); background: var(--bg-2); }
.btn:active { transform: translateY(3px); border-bottom-width: 2px; margin-bottom: 3px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--green); color: #fff; border-color: var(--green-d); }
.btn-primary:hover { background: #61e002; filter: none; }
.btn-good { background: var(--blue); color: #fff; border-color: var(--blue-d); }
.btn-good:hover { background: #20bfff; }
.btn-ghost { background: transparent; border-color: transparent; border-bottom-width: 2px; color: var(--blue-d); }
.btn-ghost:hover { background: var(--bg-2); }
.btn-ghost:active { transform: none; margin-bottom: 0; }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 13px; border-bottom-width: 4px; }
.btn-block { width: 100%; }
.icon-btn { width: 44px; height: 44px; padding: 0; }

.input, .textarea, .select {
  width: 100%; padding: 12px 14px; border-radius: 14px; background: var(--bg-2); border: 2px solid var(--line);
  font-size: 15px; font-weight: 700; outline: none; transition: border-color .15s;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--blue); background: var(--surface); }
.textarea { min-height: 120px; resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: 12px; font-weight: 500; }
.seg { display: inline-flex; background: var(--surface); border: 2px solid var(--line); border-radius: 16px; padding: 4px; gap: 4px; }
.seg { flex-wrap: wrap; }
.seg button { white-space: nowrap; border: 2px solid transparent; background: transparent; padding: 7px 14px; border-radius: 11px; font-weight: 900; font-size: 13px; color: var(--text-3); }
.seg button:hover { background: var(--bg-2); }
.seg button.on { background: #ddf4ff; color: var(--blue-d); border-color: #84d8ff; }

/* ───────────── Board ───────────── */
.board-wrap { position: relative; width: 100%; aspect-ratio: 1; border-radius: 18px; overflow: hidden; border: 6px solid #fff; box-shadow: 0 0 0 2px var(--line), 0 8px 0 2px var(--line); user-select: none; touch-action: none; }
.board { display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); width: 100%; height: 100%; position: relative; }
.sq { position: relative; display: grid; place-items: center; }
.sq.light { background: var(--sq-light); }
.sq.dark { background: var(--sq-dark); }
.sq.last::before { content: ''; position: absolute; inset: 0; background: var(--sq-last); }
.sq.sel::before { content: ''; position: absolute; inset: 0; background: rgba(28,176,246,.55); }
.sq.check::before { content: ''; position: absolute; inset: 0; background: radial-gradient(circle, rgba(255,75,75,.95) 0%, rgba(255,75,75,.5) 45%, transparent 75%); }
.sq.hint::before { content: ''; position: absolute; inset: 0; box-shadow: inset 0 0 0 5px var(--green); background: rgba(88,204,2,.3); animation: pulse 1.2s infinite; }
.pc { width: 92%; height: 92%; position: relative; z-index: 2; cursor: grab; pointer-events: auto; filter: drop-shadow(0 3px 1px rgba(0,0,0,.2)); }
.pc.dragging { cursor: grabbing; pointer-events: none; filter: drop-shadow(0 10px 6px rgba(0,0,0,.3)); }
.coord { position: absolute; font-size: 12px; font-weight: 900; z-index: 1; pointer-events: none; }
.coord.rank { top: 3px; left: 5px; }
.coord.file { bottom: 2px; right: 6px; }
.sq.light .coord { color: var(--sq-dark); }
.sq.dark .coord { color: var(--sq-light); }
.dot { position: absolute; width: 28%; height: 28%; border-radius: 50%; background: rgba(15, 20, 35, .25); z-index: 3; pointer-events: none; }
.cap-ring { position: absolute; inset: 4%; border-radius: 50%; border: 6px solid rgba(15, 20, 35, .25); z-index: 3; pointer-events: none; }
.board-arrows { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 20; }
.sq-badge {
  position: absolute; top: -6%; right: -6%; z-index: 30; width: 44%; height: 44%; max-width: 32px; max-height: 32px;
  border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 900; color: #fff;
  box-shadow: 0 3px 0 rgba(0,0,0,.25); border: 3px solid #fff; transform: scale(.9);
  animation: pop .3s cubic-bezier(.3,1.6,.6,1);
}
@keyframes pop { from { transform: scale(0); } }
.promo-picker { position: absolute; top: 0; width: 12.5%; display: flex; flex-direction: column; z-index: 60; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; border: 2px solid var(--line); }
.promo-picker button { border: 0; background: var(--surface); aspect-ratio: 1; padding: 6px; }
.promo-picker button:hover { background: #fff4cc; }
.promo-picker img { width: 100%; }
.promo-x { color: #777 !important; font-weight: 900; aspect-ratio: auto !important; }

.eval-bar { width: 28px; border-radius: 14px; overflow: hidden; background: var(--sq-dark); position: relative; flex: none; border: 3px solid #fff; box-shadow: 0 0 0 2px var(--line); }
.eval-bar .fill { position: absolute; left: 0; right: 0; bottom: 0; background: #fff; transition: height .45s cubic-bezier(.2,.8,.2,1); }
.eval-bar .val { position: absolute; left: 0; right: 0; font: 900 9px var(--font); text-align: center; z-index: 2; }
.eval-bar.flipped { transform: rotate(180deg); }
.eval-bar.flipped .val { transform: rotate(180deg); }

/* classification colours */
.cls-brilliant { background: #1fc7b6 !important; }
.cls-great { background: #5b8def !important; }
.cls-best { background: #58cc02 !important; }
.cls-excellent { background: #8bd14f !important; }
.cls-good { background: #8fb19a !important; }
.cls-book { background: #b08d6a !important; }
.cls-forced { background: #9aa3b5 !important; }
.cls-inaccuracy { background: #ffc800 !important; color: #4a3500 !important; }
.cls-mistake { background: #ff9600 !important; }
.cls-miss { background: #ff7b7b !important; }
.cls-blunder { background: #ff4b4b !important; }
.ctext-brilliant { color: #13a89a; } .ctext-great { color: #4a7ae0; } .ctext-best { color: #46a302; }
.ctext-excellent { color: #6fb12f; } .ctext-good { color: #6d9179; } .ctext-book { color: #9a7552; }
.ctext-forced { color: #8a93a6; } .ctext-inaccuracy { color: #d19c00; } .ctext-mistake { color: #e08600; }
.ctext-miss { color: #ea5a5a; } .ctext-blunder { color: #ea2b2b; }
.cdot { width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 9px; font-weight: 900; color: #fff; flex: none; box-shadow: inset 0 -2px 0 rgba(0,0,0,.18); }

/* ───────────── Coach (Pawnie) ───────────── */
.coach { display: flex; gap: 10px; align-items: flex-end; }
.coach-av {
  width: 78px; height: 96px; flex: none;
  background: url(/characters/pawnie-happy.webp) center bottom / contain no-repeat;
  animation: bob 3s ease-in-out infinite; transform-origin: bottom center;
}
@keyframes bob { 50% { transform: translateY(-4px) rotate(-2deg); } }
.coach-av[data-mood="think"] { background-image: url(/characters/pawnie-think.webp); }
.coach-av[data-mood="determined"] { background-image: url(/characters/pawnie-determined.webp); }
.coach-av[data-mood="sad"] { background-image: url(/characters/pawnie-sad.webp); }
.coach-av[data-mood="cheer"] { background-image: url(/characters/pawnie-cheer.webp); animation: hop .6s ease-in-out 2; }
@keyframes hop { 50% { transform: translateY(-12px); } }
.coach-av.bot { background-image: var(--char); }
.bubble {
  position: relative; background: var(--surface); color: var(--text); padding: 14px 16px; border-radius: 18px;
  border: 2px solid var(--line); border-bottom-width: 4px; font-size: 15px; line-height: 1.45; font-weight: 700; flex: 1; margin-bottom: 18px;
}
.bubble::before { content: ''; position: absolute; left: -10px; bottom: 18px; width: 16px; height: 16px; background: var(--surface); border-left: 2px solid var(--line); border-bottom: 2px solid var(--line); transform: rotate(45deg); }
.bubble b { font-weight: 900; }
.bubble .hl { color: var(--green-d); font-weight: 900; }

/* ───────────── Review panel ───────────── */
.tabs { display: flex; gap: 8px; }
.tabs .btn { flex: 1; }
.acc-grid { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px 14px; text-align: center; }
.acc-box { font: 900 26px var(--font); background: var(--surface); border: 2px solid var(--line); border-bottom-width: 4px; border-radius: 16px; padding: 10px 0; }
.acc-box.me { border-color: var(--green); color: var(--green-d); }
.acc-name { font-weight: 900; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cls-table { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px 14px; align-items: center; font-size: 15px; }
.cls-table .n { font: 900 16px var(--font); text-align: center; }
.cls-table .lbl { display: flex; align-items: center; gap: 8px; font-weight: 800; justify-content: flex-start; min-width: 130px; }
.graph { width: 100%; height: 90px; border-radius: 14px; background: var(--sq-dark); display: block; cursor: pointer; }
.movelist { display: grid; grid-template-columns: 38px 1fr 1fr; align-content: start; align-items: center; gap: 3px; font-size: 15px; overflow: auto; max-height: 260px; padding-right: 4px; }
.movelist .no { color: var(--text-3); font-size: 13px; padding: 6px 0; font-weight: 800; }
.movelist .mv { padding: 5px 8px; border-radius: 10px; cursor: pointer; display: flex; align-items: center; gap: 6px; font-weight: 800; border: 2px solid transparent; }
.movelist .mv:hover { background: var(--bg-2); }
.movelist .mv.cur { background: #fff4cc; border-color: var(--yellow); }
.movelist .mv .cdot { width: 16px; height: 16px; font-size: 7px; }
.nav-strip { display: flex; gap: 8px; }
.nav-strip .btn { flex: 1; padding: 10px 0; font-size: 16px; }
.progress { height: 16px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress > div { height: 100%; background: var(--green); border-radius: 999px; transition: width .2s; box-shadow: inset 0 -4px 0 rgba(0,0,0,.12), inset 0 4px 0 rgba(255,255,255,.3); }
.phase-grid { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px 12px; text-align: center; font-size: 14px; align-items: center; }
.phase-pill { font: 900 15px var(--font); padding: 5px 0; border-radius: 12px; background: var(--bg-2); border: 2px solid var(--line); }
.engine-lines { display: flex; flex-direction: column; gap: 6px; }
.eline { display: flex; gap: 10px; align-items: center; font-size: 13px; padding: 7px 10px; background: var(--bg-2); border-radius: 12px; cursor: pointer; border: 2px solid transparent; }
.eline:hover { border-color: #84d8ff; background: #f2fbff; }
.eline .sc { font: 900 13px var(--font); min-width: 56px; text-align: center; padding: 3px 0; border-radius: 8px; background: var(--surface); color: var(--text); border: 2px solid var(--line); }
.eline .sc.neg { background: var(--sq-dark); color: #fff; border-color: var(--sq-dark); }
.eline .pv { color: var(--text-2); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 700; }

/* ───────────── Home ───────────── */
.hero {
  position: relative; overflow: hidden; border-radius: 28px; padding: 38px 40px; margin-bottom: 26px; min-height: 300px;
  background: var(--green); color: #fff; border-bottom: 8px solid var(--green-d);
}
.hero::after { content: ''; position: absolute; right: 50px; bottom: -14px; width: 250px; height: 300px; background: url(/characters/pawnie-cheer.webp) center bottom / contain no-repeat; }
.hero .tag { background: rgba(255,255,255,.22); color: #fff; }
.hero h1 { margin: 0; font-size: 44px; font-weight: 900; letter-spacing: -.02em; max-width: 640px; line-height: 1.05; }
.hero p { margin: 12px 0 22px; color: #eaffd8; max-width: 560px; font-size: 18px; font-weight: 800; }
.hero .btn { border-color: #fff; color: var(--green-d); background: #fff; border-bottom-color: #d6f5bf; }
.hero .btn-primary { background: var(--yellow); color: var(--accent-ink); border-color: var(--yellow-d); }
.hero .btn-primary:hover { background: #ffd84d; }
.import-row { display: flex; gap: 12px; flex-wrap: wrap; position: relative; z-index: 1; }
.import-row .input { max-width: 260px; }
.stat-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 26px; }
.tile { background: var(--surface); border: 2px solid var(--line); border-bottom-width: 4px; border-radius: 20px; padding: 16px 20px; }
.tile .k { font-size: 13px; color: var(--text-3); font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.tile .v { font: 900 34px var(--font); margin-top: 4px; }
.tile .s { font-size: 13px; color: var(--text-3); margin-top: 2px; font-weight: 700; }
.results-strip { display: flex; gap: 5px; margin-bottom: 14px; }
.results-strip i { flex: 1; height: 22px; border-radius: 8px; background: var(--line); box-shadow: inset 0 -4px 0 rgba(0,0,0,.1); }
.results-strip i.win { background: var(--green); } .results-strip i.loss { background: var(--red); } .results-strip i.draw { background: #afafaf; }
.game-list { display: flex; flex-direction: column; }
.game-row { display: grid; grid-template-columns: 6px 36px 1fr auto auto; gap: 14px; align-items: center; padding: 12px 10px; border-radius: 16px; cursor: pointer; transition: background .12s; }
.game-row:hover { background: var(--bg-2); }
.game-row .bar { height: 38px; border-radius: 6px; background: #afafaf; }
.game-row .bar.win { background: var(--green); } .game-row .bar.loss { background: var(--red); } .game-row .bar.draw { background: #afafaf; }
.game-row .opp { font-weight: 900; }
.game-row .meta { font-size: 13px; color: var(--text-3); margin-top: 2px; font-weight: 700; }
.game-row .accp { font: 900 17px var(--font); }
.badge-ring { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-size: 9px; font-weight: 900; letter-spacing: .05em; border: 3px solid; background: var(--surface); }
.day-head { font-size: 13px; color: var(--text-3); font-weight: 900; padding: 14px 10px 6px; border-top: 2px solid var(--line); text-transform: uppercase; letter-spacing: .06em; }
.day-head:first-child { border-top: 0; }
.empty { text-align: center; padding: 30px 20px 40px; color: var(--text-3); font-weight: 800; font-size: 16px; }
.empty .big { width: 140px; height: 170px; margin: 0 auto 10px; font-size: 0; background: url(/characters/pawnie-think.webp) center / contain no-repeat; }

.feature-cards { display: grid; grid-template-columns: repeat(6, 1fr); gap: 16px; margin-bottom: 26px; }
.fcard { border-radius: 24px; padding: 18px; min-height: 200px; display: flex; flex-direction: column; justify-content: flex-start; position: relative; overflow: hidden; color: #fff; border-bottom: 7px solid rgba(0,0,0,.18); transition: transform .12s; }
.fcard:hover { transform: translateY(-4px) rotate(-.5deg); }
.fcard h3 { margin: 0; font-size: 20px; font-weight: 900; position: relative; z-index: 1; line-height: 1.1; }
.fcard p { margin: 6px 0 0; font-size: 14px; font-weight: 800; opacity: .92; position: relative; z-index: 1; }
.fcard::after { content: ''; position: absolute; right: -4px; bottom: -6px; width: 92px; height: 112px; background: var(--img) center bottom / contain no-repeat; transition: transform .2s; }
.fcard:hover::after { transform: translateY(-6px) rotate(6deg); }

/* ───────────── Sparring ───────────── */
.bot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.bot-card { position: relative; border-radius: 22px; overflow: hidden; background: var(--surface); border: 2px solid var(--line); border-bottom-width: 5px; cursor: pointer; transition: transform .12s, border-color .15s; }
.bot-card:hover { transform: translateY(-3px); }
.bot-card.on { border-color: #84d8ff; background: #ddf4ff; }
.bot-art { aspect-ratio: 1.15; display: grid; place-items: end center; position: relative; overflow: hidden; }
.bot-art img { width: 64%; margin-bottom: -4%; transition: transform .2s; filter: drop-shadow(0 6px 0 rgba(0,0,0,.12)); }
.bot-card:hover .bot-art img { transform: translateY(-6px) rotate(-3deg); }
.bot-art .emoji { position: absolute; top: 10px; left: 12px; font-size: 24px; }
.bot-meta { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; font-weight: 900; font-size: 15px; }
.bot-meta .elo { color: var(--orange); font-size: 15px; }
.bot-card .rec { position: absolute; top: 10px; right: 10px; font: 900 11px var(--font); background: rgba(255,255,255,.9); color: var(--text); padding: 3px 8px; border-radius: 999px; }
.bot-card.locked { filter: grayscale(1); opacity: .55; }
.bot-detail .bot-art { border-radius: 20px; margin-bottom: 14px; aspect-ratio: 1.3; }
.bot-detail .bot-art img { width: 50%; }
.bot-detail ul { list-style: none; padding: 0; margin: 0 0 10px; font-size: 15px; color: var(--text-2); }
.bot-detail li { padding: 4px 0; }
.bot-detail li::before { content: '✓ '; color: var(--green); font-weight: 900; }
.quote { font-style: italic; color: var(--text-3); font-size: 14px; margin-bottom: 14px; }
.result-banner { text-align: center; padding: 20px; border-radius: 20px; background: #fff4cc; border: 2px solid var(--yellow); border-bottom-width: 5px; }
.result-banner h3 { margin: 0 0 4px; font-size: 26px; font-weight: 900; }

/* ───────────── Puzzles / blunders ───────────── */
.status-card { text-align: center; padding: 16px; border-radius: 18px; background: var(--bg-2); border: 2px solid var(--line); border-bottom-width: 4px; }
.status-card .big { font-size: 22px; font-weight: 900; }
.status-card.ok { border-color: var(--green); background: #d7ffb8; color: var(--green-d); }
.status-card.fail { border-color: var(--red); background: #ffdfe0; color: var(--red-d); }
.turn-chip { display: inline-flex; align-items: center; gap: 8px; font-weight: 900; }
.turn-chip i { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--line-2); }
.turn-chip i.w { background: #fff; } .turn-chip i.b { background: #3c3c3c; border-color: #3c3c3c; }
.rating-big { font: 900 44px var(--font); color: var(--orange); }
.delta { font: 900 16px var(--font); }
.delta.up { color: var(--green); } .delta.down { color: var(--red); }
.hist-dots { display: flex; flex-wrap: wrap; gap: 6px; }
.hist-dots i { width: 16px; height: 16px; border-radius: 50%; box-shadow: inset 0 -3px 0 rgba(0,0,0,.15); }
.hist-dots i.ok { background: var(--green); } .hist-dots i.no { background: var(--red); }
.blunder-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.thumb { border-radius: 18px; overflow: hidden; border: 2px solid var(--line); border-bottom-width: 5px; cursor: pointer; background: var(--surface); transition: transform .12s; }
.thumb:hover { border-color: #84d8ff; transform: translateY(-3px); }
.thumb.solved { border-color: var(--green); }
.thumb .mini { display: grid; grid-template-columns: repeat(8, 1fr); aspect-ratio: 1; }
.thumb .mini div { display: grid; place-items: center; }
.thumb .mini img { width: 90%; }
.thumb .cap { font-size: 13px; padding: 8px 10px; display: flex; justify-content: space-between; color: var(--text-2); font-weight: 900; }

/* ───────────── Toasts / modal ───────────── */
.toast-host { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 1000; }
.toast { background: var(--surface); border: 2px solid var(--line); border-bottom-width: 5px; padding: 12px 18px; border-radius: 16px; box-shadow: var(--shadow); font-size: 15px; font-weight: 800; animation: fadeIn .2s; max-width: 360px; }
.toast.err { border-color: var(--red); background: #ffdfe0; color: var(--red-d); }
.toast.ok { border-color: var(--green); background: #d7ffb8; color: var(--green-d); }
.modal-host { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 900; }
.modal { width: min(560px, 92vw); background: var(--surface); border: 2px solid var(--line); border-bottom-width: 6px; border-radius: 26px; padding: 26px; box-shadow: var(--shadow); animation: fadeIn .2s; }
.modal h2 { margin: 0 0 6px; font-weight: 900; font-size: 26px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.label { font-size: 13px; font-weight: 900; color: var(--text-3); letter-spacing: .06em; text-transform: uppercase; margin: 16px 0 6px; display: block; }

.coach-banner { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; padding: 12px 20px; border-radius: 20px; background: var(--green); color: #fff; border-bottom: 6px solid var(--green-d); }
.coach-banner img { width: 56px; }
.coach-banner > span:nth-child(2) { flex: 1; min-width: 0; }
.coach-banner b { display: block; font-size: 20px; font-weight: 900; }
.coach-banner small { font-size: 14px; }

/* ───────────── Openings ───────────── */
.op-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.op-card { display: flex; gap: 14px; padding: 14px; border-radius: 20px; background: var(--panel); border: 2px solid var(--line); border-bottom-width: 5px; }
.op-thumb { flex: none; width: 112px; height: 112px; border-radius: 12px; overflow: hidden; align-self: flex-start; transition: transform .12s; }
.op-thumb:hover { transform: rotate(-2deg) scale(1.03); }
.op-thumb .mini { display: grid; grid-template-columns: repeat(8, 1fr); width: 100%; height: 100%; }
.op-thumb .mini div { display: grid; place-items: center; }
.op-thumb .mini img { width: 92%; }
.op-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.op-body h3 { margin: 0; font-size: 18px; font-weight: 900; line-height: 1.15; }
.op-body p { margin: 0; font-size: 13px; color: var(--text-3); line-height: 1.4; flex: 1; }
.op-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; }
.op-meta .turn-chip { font-size: 12px; }
.op-stars { color: var(--yellow); font-size: 18px; letter-spacing: 1px; white-space: nowrap; }
.op-stars i { color: var(--line); font-style: normal; }
.result-banner .op-stars { font-size: 26px; }
.movelist .mv.mine { color: var(--green-d); }

@media (max-width: 1400px) { .feature-cards { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 1100px) {
  .train-layout { grid-template-columns: minmax(0, 1fr) !important; }
  .side-panel { position: static; max-height: none; }
  .feature-cards { grid-template-columns: repeat(2, 1fr); }
  .stat-tiles { grid-template-columns: repeat(2, 1fr); }
  .hero::after { width: 160px; height: 190px; right: 10px; opacity: .9; }
}
/* ───────────── Phone layout ───────────── */
.topbar { display: none; }
.nl::after { content: none; }

@media (max-width: 760px) {
  :root { --tabbar-h: 68px; }
  html, body { height: auto; min-height: 100%; }
  html, body { overflow-x: clip; }
  body { display: block; overflow: visible; overflow-x: clip; }

  /* top bar: logo + streak + feedback + profile */
  .topbar {
    display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 50;
    padding: calc(8px + env(safe-area-inset-top)) 14px 8px; background: var(--surface); border-bottom: 2px solid var(--line);
  }
  .topbar .brand { padding: 0; gap: 6px; }
  .topbar .brand-mark { width: 26px; height: 26px; }
  .topbar .brand-name { font-size: 24px; }
  .top-pill {
    display: inline-flex; align-items: center; gap: 4px; height: 36px; padding: 0 12px; border-radius: 999px;
    background: var(--surface); border: 2px solid var(--line); border-bottom-width: 4px; font: 900 15px var(--font); color: var(--text-3);
  }
  .top-pill.streak.on { color: var(--orange); border-color: #ffd29a; background: #fff6e8; }
  .top-av { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--purple); color: #fff; font: 900 15px var(--font); box-shadow: inset 0 -3px 0 var(--purple-d); }

  /* sidebar becomes the bottom tab bar */
  .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; width: 100%; height: auto;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); gap: 0; flex-direction: row;
    border-right: 0; border-top: 2px solid var(--line); background: var(--surface);
  }
  .sidebar > .brand, .sidebar-foot { display: none; }
  .nav { flex-direction: row; width: 100%; gap: 2px; }
  .nav a {
    flex: 1; flex-direction: column; gap: 3px; padding: 6px 0 4px; border-radius: 14px; min-width: 0;
    font-size: 10px; letter-spacing: .02em; justify-content: center;
  }
  .nav a.active { background: #ddf4ff; }
  .nav a:hover { background: none; }
  .nav a.active:hover { background: #ddf4ff; }
  .nl { font-size: 0; }
  .nl::after { content: attr(data-short); font-size: 10px; }
  .ni { width: 30px; height: 30px; border-radius: 9px; }
  .nav a:not(.active) .ni { filter: saturate(.7); }

  .main { padding: 16px 14px calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom)); overflow: visible; }
  .page-head { flex-direction: column; align-items: stretch; gap: 12px; margin-bottom: 16px; }
  .page-head .row { flex-wrap: wrap; }
  .page-head .row .btn, .page-head > .btn { flex: 1; }
  .page-title { font-size: 26px; }
  .page-sub { font-size: 14px; }
  .panel { padding: 16px; border-radius: 18px; }

  /* home */
  .hero { padding: 22px 20px 24px; border-radius: 22px; min-height: 0; margin-bottom: 18px; }
  .hero::after { display: block; width: 96px; height: 116px; right: 10px; top: 14px; bottom: auto; }
  .hero h1 { font-size: 27px; max-width: calc(100% - 96px); }
  .hero p { font-size: 15px; margin: 10px 0 16px; }
  .hero .tag { font-size: 10px; }
  .import-row { flex-direction: column; gap: 10px; }
  .import-row .btn { width: 100%; }
  .feature-cards {
    display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 12px;
    margin: 0 -14px 18px; padding: 2px 14px 10px; scrollbar-width: none;
  }
  .feature-cards::-webkit-scrollbar { display: none; }
  .fcard { flex: 0 0 150px; min-height: 170px; scroll-snap-align: start; padding: 14px; border-radius: 20px; }
  .fcard h3 { font-size: 17px; }
  .fcard p { font-size: 12px; }
  .fcard::after { width: 72px; height: 88px; }
  .stat-tiles { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
  .tile { padding: 12px 14px; border-radius: 16px; }
  .tile .k { font-size: 11px; }
  .tile .v { font-size: 26px; }
  .tile .s { font-size: 11px; }
  .game-row { grid-template-columns: 5px 1fr auto; gap: 10px; padding: 10px 6px; }
  .game-row > span:nth-child(2), .game-row > span:last-child { display: none; }
  .game-row .meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 62vw; }

  /* training screens: board on top, panel below */
  .train-layout { grid-template-columns: minmax(0, 1fr) !important; gap: 14px; }
  .train-layout > *, .side-panel > *, .board-col > * { min-width: 0; max-width: 100%; }
  .side-panel .row { min-width: 0; }
  .side-panel .input { min-width: 0; }
  .board-col { max-width: none; gap: 8px; }
  .board-row { gap: 6px; }
  .board-wrap { border-width: 3px; border-radius: 12px; }
  .eval-bar { width: 16px; border-width: 2px; border-radius: 9px; }
  .eval-bar .val { font-size: 7px; }
  .coord { font-size: 9px; }
  .player-tag { font-size: 13px; padding: 4px 10px 4px 4px; }
  .player-tag .av { width: 24px; height: 24px; }
  .clock { font-size: 16px; padding: 4px 12px; }
  .nav-strip .btn { padding: 9px 0; }
  .side-panel { position: static; max-height: none; overflow: visible !important; }
  .movelist { max-height: 200px; }
  .coach-av { width: 60px; height: 74px; }
  .bubble { font-size: 14px; padding: 12px 14px; }
  .acc-box { font-size: 22px; }
  .cls-table .lbl { min-width: 0; }
  .sq-badge { max-width: 24px; max-height: 24px; font-size: 10px; border-width: 2px; }

  /* sparring: pick a bot first, details below */
  .bot-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .bot-meta { padding: 8px 10px; font-size: 13px; }
  .bot-art .emoji { font-size: 18px; top: 6px; left: 8px; }
  .bot-card .rec { font-size: 10px; top: 6px; right: 6px; }
  .train-layout > .bot-detail { order: 2; scroll-margin-top: 70px; }
  .bot-detail .bot-art { aspect-ratio: 1.8; }
  .bot-detail .bot-art img { width: 30%; }

  /* blunder thumbnails */
  .blunder-thumbs { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .rating-big { font-size: 36px; }

  /* modal becomes a bottom sheet */
  .modal-host { place-items: end stretch; }
  .modal {
    width: 100%; max-height: 92vh; overflow-y: auto; border-radius: 26px 26px 0 0; border-bottom-width: 0;
    padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); animation: sheetUp .25s cubic-bezier(.2,.8,.2,1);
  }
  .modal::before { content: ''; display: block; width: 44px; height: 5px; border-radius: 9px; background: var(--line); margin: -8px auto 14px; }
  .modal .actions { flex-direction: column-reverse; }
  .modal .actions .btn { width: 100%; }
  .seg { display: flex; }
  .seg button { flex: 1; padding: 8px 6px; }

  .toast-host { left: 12px; right: 12px; top: calc(64px + env(safe-area-inset-top)); bottom: auto; }
  .toast { max-width: none; }
}
@keyframes sheetUp { from { transform: translateY(100%); } }
@media (max-width: 760px) {
  .nav a { letter-spacing: 0; }
  .nl::after { font-size: 9px; }
  .op-card { padding: 12px; gap: 12px; }
  .op-thumb { width: 84px; height: 84px; }
  .op-card .grid { gap: 8px; }
  .op-card .btn { padding: 8px 4px; font-size: 12px; letter-spacing: 0; }
}

/* ───────────── Accounts (multiple linked usernames) ───────────── */
.acc-row { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.acc-row .seg { flex: none; }
.acc-row .acc-user { flex: 1; min-width: 140px; }

/* ───────────── Dark mode ───────────── */
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15191f; --bg-2: #1c222b; --panel: #1c222b; --panel-2: #232b36; --panel-3: #2a3340;
  --surface: #1c222b;
  --line: #303a48; --line-2: #3d4858;
  --text: #e6e9ef; --text-2: #cfd5de; --text-3: #8f99a8;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
}
html[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #3d4858; border-color: #1c222b; }
html[data-theme="dark"] .nav a { color: #a4adbb; }
html[data-theme="dark"] .nav a.active,
html[data-theme="dark"] .nav a.active:hover { color: #7fd4ff; background: #17354a; border-color: #2a6f96; }
html[data-theme="dark"] .seg button.on { background: #17354a; color: #7fd4ff; border-color: #2a6f96; }
html[data-theme="dark"] .bot-card.on { background: #17354a; border-color: #2a6f96; }
html[data-theme="dark"] .eline:hover { background: #17354a; border-color: #2a6f96; }
html[data-theme="dark"] .tag { background: #3d3414; color: #ffd866; }
html[data-theme="dark"] .player-tag.turn { background: #1f3316; border-color: var(--green); }
html[data-theme="dark"] .movelist .mv.cur,
html[data-theme="dark"] .promo-picker button:hover { background: #3d3414; }
html[data-theme="dark"] .result-banner { background: #3d3414; }
html[data-theme="dark"] .ctext-forced { color: #8f99a8; }
html[data-theme="dark"] .promo-x { color: #8f99a8 !important; }
html[data-theme="dark"] .input:focus, html[data-theme="dark"] .textarea:focus, html[data-theme="dark"] .select:focus { background: var(--bg-2); }
html[data-theme="dark"] .feedback-btn { color: #7fd4ff; }
html[data-theme="dark"] .profile-chip { color: var(--text); }
html[data-theme="dark"] .modal-host { background: rgba(0, 0, 0, .65); }

.acc-row .seg { display: inline-flex; }
