/* RadMate. Header and accents follow the board style; one focal point per screen. */
:root { --ts: 1; }
html[data-text="s"] { --ts: .9; }
html[data-text="l"] { --ts: 1.12; }
html[data-text="xl"] { --ts: 1.25; }
:root, [data-theme="light"] {
  --bg: #F4F6FB;
  --bg-elevated: #FFFFFF;
  --bg-soft: #EEF2FF;
  --text: #0F172A;
  --text-muted: #475569;
  --border: #D6DCE8;
  --accent: #1E3A8A;
  --accent-hover: #1B347C;
  --accent-text: #FFFFFF;
  --link: #1D4ED8;
  --header-bg: #1E3A8A;
  --header-text: #FFFFFF;
  --row-band: #EEF2FF;
  --sq-light: #E9EDF7;
  --sq-dark: #8197C7;
  --coord-on-light: #22305A;
  --coord-on-dark: #0B1530;
  --chart: #2F5BD3;
  --grid: #E2E8F0;
  --g-best: #166534; --g-best-bg: #DCFCE7;
  --g-good: #1E40AF; --g-good-bg: #DBEAFE;
  --g-inaccuracy: #854D0E; --g-inaccuracy-bg: #FEF3C7;
  --g-mistake: #9A3412; --g-mistake-bg: #FFEDD5;
  --g-blunder: #991B1B; --g-blunder-bg: #FEE2E2;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 16px rgba(15, 23, 42, 0.06);
  --table-header-bg: #1E3A8A;
  --table-row-even: #EEF2FF;
  --table-row-hover: #DBEAFE;
  --table-row-selected: #C7D7FE;
  --menu-bg: #FFFFFF;
  --menu-line: #8391A7;
  --scrim: rgba(15, 23, 42, .55);
}
[data-theme="dark"] {
  --bg: #0E1424;
  --bg-elevated: #161E33;
  --bg-soft: #1C2640;
  --text: #E8ECF5;
  --text-muted: #B4BED3;
  --border: #2B3654;
  --accent: #5B8DEF;
  --accent-hover: #7AA3F3;
  --accent-text: #0B1222;
  --link: #93B4F5;
  --header-bg: #111A33;
  --header-text: #F1F4FB;
  --row-band: #1C2640;
  --sq-light: #C9D3EA;
  --sq-dark: #6A80B2;
  --coord-on-light: #15203F;
  --coord-on-dark: #000000;
  --chart: #5B8DEF;
  --grid: #2B3654;
  --g-best: #86EFAC; --g-best-bg: #12301F;
  --g-good: #93C5FD; --g-good-bg: #172A4D;
  --g-inaccuracy: #FDE68A; --g-inaccuracy-bg: #3A2E0B;
  --g-mistake: #FDBA74; --g-mistake-bg: #3D2410;
  --g-blunder: #FCA5A5; --g-blunder-bg: #401818;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
  --table-header-bg: #24345E;
  --table-header-text: #F1F4FB;
  --table-row-odd: #161E33;
  --table-row-even: #1C2640;
  --table-row-hover: #24304F;
  --table-row-selected: #2E3F6B;
  --table-cell-text: #E8ECF5;
  --menu-bg: #24304F;
  --menu-line: #6B7BA6;
  --scrim: rgba(2, 4, 10, .7);
  --table-border: rgba(255, 255, 255, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: calc(16px * var(--ts)); line-height: 1.5; color: var(--text); background: var(--bg);
}
[hidden] { display: none !important; }
a { color: var(--link); }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.25; }
h2 { font-size: calc(20px * var(--ts)); }
h3 { font-size: calc(17px * var(--ts)); }
.muted { color: var(--text-muted); }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- buttons + inputs ---------- */
.btn {
  border: 1px solid var(--border); background: var(--bg-elevated); color: var(--text);
  padding: 9px 16px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: calc(15px * var(--ts));
  transition: background .15s, border-color .15s;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--bg-soft); border-color: transparent; }
.btn-danger { color: var(--g-blunder); }
.btn-wide { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: calc(14px * var(--ts)); }
input[type=email], input[type=password], input[type=text], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg-elevated); font-size: calc(15px * var(--ts));
}
textarea { min-height: 180px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: calc(14px * var(--ts)); }
label { display: block; font-weight: 600; font-size: calc(14px * var(--ts)); margin: 10px 0 0; }
label input, label select, label textarea { margin-top: 6px; font-weight: 400; }
.form-error { color: var(--g-blunder); min-height: 22px; font-size: calc(14px * var(--ts)); margin-top: 8px; }

/* ---------- sign in ---------- */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.signin-card {
  width: 100%; max-width: 380px; background: var(--bg-elevated); border-radius: 16px;
  padding: 32px; box-shadow: var(--shadow); text-align: left;
}
.signin-card h1 { font-size: calc(26px * var(--ts)); }
.signin-logo { width: 56px; height: 56px; display: block; margin-bottom: 8px; border-radius: 12px; }

/* ---------- shell ---------- */
.app { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
/* iOS 26 Home Screen apps blur the top edge unless a pinned, solid bar sits there. */
.topbar {
  position: sticky; top: 0; z-index: 50;
  flex-shrink: 0; display: flex; align-items: center; gap: 24px; padding: 0 20px; height: 60px;
  background: var(--header-bg); color: var(--header-text);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--header-text); text-decoration: none; font-weight: 800; font-size: calc(18px * var(--ts)); white-space: nowrap; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; }
.tabs a {
  color: var(--header-text); text-decoration: none; padding: 8px 14px; border-radius: 8px;
  font-weight: 600; font-size: calc(15px * var(--ts)); white-space: nowrap; opacity: .92;
}
.tabs a:hover { background: rgba(255, 255, 255, .12); opacity: 1; }
.tabs a.active { background: rgba(255, 255, 255, .2); opacity: 1; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.theme-toggle {
  background: transparent; border: 1px solid rgba(255, 255, 255, .35); color: var(--header-text);
  border-radius: 8px; width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer;
}
.usermenu { position: relative; }
.user-btn {
  background: rgba(255, 255, 255, .14); border: 0; color: var(--header-text); padding: 8px 12px;
  border-radius: 8px; cursor: pointer; font-weight: 600; font-size: calc(15px * var(--ts)); white-space: nowrap;
}
.menu {
  position: absolute; right: 0; top: 44px; background: var(--bg-elevated); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); min-width: 190px; z-index: 50; padding: 6px;
}
.menu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 10px 12px; border-radius: 6px; cursor: pointer; font-size: calc(15px * var(--ts)); }
.menu button:hover { background: var(--bg-soft); }
.view { flex: 1; min-height: 0; overflow: auto; padding: 18px; }
.view.fill { overflow: hidden; display: flex; flex-direction: column; }

/* ---------- board screen layout ---------- */
.board-screen {
  display: grid; grid-template-columns: minmax(0, auto) minmax(320px, 440px); gap: 28px;
  justify-content: center; align-items: start; max-width: 1180px; margin: 0 auto;
}
.board-col { display: flex; flex-direction: column; gap: 12px; }
.board-wrap { display: flex; gap: 10px; align-items: stretch; }
.board {
  position: relative; width: min(calc(100vh - 210px), 620px, calc(100vw - 560px)); min-width: 300px;
  aspect-ratio: 1; border-radius: 6px; overflow: hidden; box-shadow: var(--shadow); user-select: none; touch-action: none;
}
.board-squares, .board-pieces { position: absolute; inset: 0; }
.board-arrows { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }
.board-pieces { z-index: 2; pointer-events: none; }
.sq { position: absolute; width: 12.5%; height: 12.5%; }
.sq.light { background: var(--sq-light); }
.sq.dark { background: var(--sq-dark); }
.sq.last::after, .sq.selected::after, .sq.ghost-from::after, .sq.ghost-to::after, .sq.hint::after, .sq.check::after {
  content: ""; position: absolute; inset: 0;
}
.sq.last::after { background: rgba(250, 204, 21, .38); }
.sq.selected::after { background: rgba(37, 99, 235, .42); }
.sq.ghost-from::after { background: rgba(37, 99, 235, .22); }
.sq.ghost-to::after { background: rgba(37, 99, 235, .45); }
.sq.hint::after { box-shadow: inset 0 0 0 5px #15803D; background: rgba(21, 128, 61, .18); }
.sq.check::after { background: radial-gradient(circle, rgba(220, 38, 38, .85) 0%, rgba(220, 38, 38, .35) 45%, transparent 72%); }
.sq.dot::before { content: ""; position: absolute; left: 36%; top: 36%; width: 28%; height: 28%; border-radius: 50%; background: rgba(15, 23, 42, .28); z-index: 1; }
.sq.capture-dot::before { content: ""; position: absolute; inset: 4%; border-radius: 50%; border: 5px solid rgba(15, 23, 42, .28); z-index: 1; }
.coord { position: absolute; font-size: 12px; font-weight: 700; z-index: 1; }
.coord.file { right: 4px; bottom: 1px; }
.coord.rank { left: 4px; top: 1px; }
.sq.light .coord { color: var(--coord-on-light); }
.sq.dark .coord { color: var(--coord-on-dark); }
.pc { position: absolute; width: 12.5%; height: 12.5%; transition: left .12s, top .12s; }
.pc.dragging { transition: none; z-index: 10; width: 12.5%; filter: drop-shadow(0 6px 8px rgba(0, 0, 0, .35)); }
.pc.ghost-origin { opacity: .32; }
.pc.previewing { filter: drop-shadow(0 0 6px rgba(37, 99, 235, .9)); }
.board.locked { cursor: progress; }
.promo {
  position: absolute; inset: 0; z-index: 20; background: rgba(15, 23, 42, .65); display: flex;
  align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; padding: 20%;
}
.promo-title { width: 100%; text-align: center; color: #fff; font-weight: 700; }
.promo button { width: 22%; aspect-ratio: 1; border-radius: 12px; border: 0; background: #F1F4FB; cursor: pointer; }
.promo img { width: 100%; height: 100%; }

.evalbar { width: 16px; border-radius: 6px; overflow: hidden; background: #2B2B2B; position: relative; box-shadow: var(--shadow); }
.evalbar-fill { position: absolute; left: 0; right: 0; bottom: 0; background: #F5F5F4; transition: height .35s; }
.board-controls { display: flex; gap: 8px; flex-wrap: wrap; }
.players { display: flex; justify-content: space-between; font-weight: 600; font-size: calc(15px * var(--ts)); color: var(--text-muted); }

/* ---------- coach panel ---------- */
.panel { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.card-title { font-weight: 700; font-size: calc(15px * var(--ts)); text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.coach-verdict { font-size: calc(19px * var(--ts)); font-weight: 700; line-height: 1.3; margin: 2px 0 6px; }
.coach-row { margin: 8px 0 0; }
.coach-row b { display: block; font-size: calc(14px * var(--ts)); text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-bottom: 2px; }
.coach-row p { margin: 0; }
.coach-actions { display: flex; gap: 8px; margin-top: 12px; }
.coach-actions .btn { flex: 1; }
.thinking { display: flex; align-items: center; gap: 10px; color: var(--text-muted); }
.spinner { width: 18px; height: 18px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { height: 12px; border-radius: 6px; background: var(--bg-soft); margin: 10px 0; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; } }
.chip { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: calc(13px * var(--ts)); font-weight: 700; white-space: nowrap; }
.chip.best { color: var(--g-best); background: var(--g-best-bg); }
.chip.good, .chip.book { color: var(--g-good); background: var(--g-good-bg); }
.chip.inaccuracy { color: var(--g-inaccuracy); background: var(--g-inaccuracy-bg); }
.chip.mistake { color: var(--g-mistake); background: var(--g-mistake-bg); }
.chip.blunder { color: var(--g-blunder); background: var(--g-blunder-bg); }
.eval-line { font-weight: 600; }
.switch { display: flex; align-items: center; gap: 8px; font-size: calc(14px * var(--ts)); font-weight: 600; margin: 0; cursor: pointer; color: var(--text-muted); }
.switch input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.source-note { font-size: calc(13px * var(--ts)); color: var(--text-muted); margin-top: 10px; }

.movelist { display: grid; grid-template-columns: 40px 1fr 1fr; gap: 2px 6px; max-height: 220px; overflow: auto; font-size: calc(15px * var(--ts)); }
.movelist .num { color: var(--text-muted); text-align: right; padding: 3px 0; }
.movelist .mv { padding: 2px 8px; border-radius: 6px; cursor: default; display: flex; align-items: center; gap: 6px; }
.movelist .mv.clickable { cursor: pointer; }
.movelist .mv.clickable:hover { background: var(--bg-soft); }
.movelist .mv.current { background: var(--bg-soft); outline: 2px solid var(--accent); }
.dotg { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.dotg.best { background: #16A34A; } .dotg.good { background: #3B82F6; } .dotg.inaccuracy { background: #CA8A04; }
.dotg.mistake { background: #EA580C; } .dotg.blunder { background: #DC2626; }

.setup-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 6px; }
.seg { border: 1px solid var(--border); background: var(--bg-elevated); border-radius: 8px; padding: 10px; cursor: pointer; font-weight: 600; text-align: center; }
.seg.on { border-color: var(--accent); background: var(--bg-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.range-row { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.range-row input[type=range] { flex: 1; accent-color: var(--accent); }
.level-num { font-weight: 800; font-size: calc(20px * var(--ts)); width: 32px; text-align: center; }
.banner { border-radius: 10px; padding: 12px 14px; background: var(--bg-soft); border: 1px solid var(--border); }
.banner h3 { margin: 0 0 4px; }
.lesson { background: var(--bg-soft); border-radius: 8px; padding: 10px 12px; margin-top: 8px; }
.lesson b { display: block; }
.progressbar { height: 8px; border-radius: 999px; background: var(--bg-soft); overflow: hidden; margin-top: 8px; }
.progressbar span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }
.result-good { color: var(--g-best); font-weight: 700; }
.result-bad { color: var(--g-blunder); font-weight: 700; }
.list-plain { margin: 6px 0 0; padding-left: 20px; }
.list-plain li { margin: 4px 0; }
.moments button { display: block; width: 100%; text-align: left; border: 1px solid var(--border); background: var(--bg-elevated); border-radius: 10px; padding: 8px 12px; margin-top: 6px; cursor: pointer; }
.moments button:hover { border-color: var(--accent); }

/* ---------- pages ---------- */
.page { max-width: 1100px; margin: 0 auto; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-shrink: 0; }
.page-header h1 { font-size: calc(24px * var(--ts)); margin: 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.tile { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); }
.tile .label { font-size: calc(14px * var(--ts)); font-weight: 600; color: var(--text-muted); }
.tile .value { font-size: calc(28px * var(--ts)); font-weight: 800; line-height: 1.15; margin-top: 2px; }
.tile .sub { font-size: calc(14px * var(--ts)); color: var(--text-muted); }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 10px; margin-bottom: 12px; }
.chart-card h3 { margin-bottom: 2px; }
.chart { position: relative; }
.chart svg { width: 100%; height: 200px; display: block; overflow: visible; }
.chart .axis { fill: var(--text-muted); font-size: calc(13px * var(--ts)); }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--chart); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .pt { fill: var(--chart); stroke: var(--bg-elevated); stroke-width: 2; }
.chart .cross { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .hit { fill: transparent; }
.tip { position: absolute; pointer-events: none; background: var(--text); color: var(--bg-elevated); padding: 6px 10px; border-radius: 8px; font-size: calc(14px * var(--ts)); font-weight: 600; white-space: nowrap; transform: translate(-50%, -120%); z-index: 5; }
.empty-chart { height: 200px; display: grid; place-items: center; color: var(--text-muted); text-align: center; padding: 0 20px; }
.bars { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.bar-row { display: grid; grid-template-columns: 190px 1fr 40px; align-items: center; gap: 10px; font-size: calc(15px * var(--ts)); }
.bar-track { height: 14px; background: var(--bg-soft); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--chart); border-radius: 0 4px 4px 0; }
.bar-n { text-align: center; font-weight: 700; }

.table-page { flex: 1; min-height: 0; display: flex; flex-direction: column; max-width: 1300px; width: 100%; margin: 0 auto; }
.table-page .data-table-wrap { flex: 1; min-height: 0; }
.table-page .data-table tbody tr { cursor: pointer; }
.data-table td, .data-table th { font-size: calc(15px * var(--ts)); }
.data-table th { font-size: calc(16px * var(--ts)); }
.add-user { display: grid; grid-template-columns: 1fr 1fr auto auto; gap: 10px; align-items: end; margin-bottom: 14px; }
.add-user label { margin: 0; }
.add-user .chk { display: flex; align-items: center; gap: 8px; padding-bottom: 10px; }
.add-user .chk input { width: 18px; height: 18px; margin: 0; }
.secret { font-family: ui-monospace, Menlo, monospace; background: var(--bg-soft); padding: 2px 8px; border-radius: 6px; font-weight: 700; }

.dialog { border: 0; border-radius: 14px; padding: 20px; width: min(420px, 92vw); background: var(--bg-elevated); color: var(--text); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(15, 23, 42, .5); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg-elevated); padding: 12px 18px; border-radius: 10px; font-weight: 600; z-index: 100; box-shadow: var(--shadow); max-width: 90vw; }

@media (max-width: 960px) {
  .board-screen { grid-template-columns: 1fr; }
  .board { width: min(calc(100vw - 74px), 620px); }
  .topbar { gap: 12px; padding: 0 12px; }
  .brand span { display: none; }
  .view { padding: 12px; }
  .add-user { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 130px 1fr 36px; }
}

/* ---------- board colors (Blue is the default set above) ---------- */
html[data-board="green"] { --sq-light: #EEEED2; --sq-dark: #769656; }
html[data-board="wood"] { --sq-light: #F0D9B5; --sq-dark: #B58863; }
html[data-board="gray"] { --sq-light: #E4E4E7; --sq-dark: #A1A1AA; }
html[data-board="purple"] { --sq-light: #ECE6F5; --sq-dark: #9F8CC6; }
html[data-board="teal"] { --sq-light: #E3F0EE; --sq-dark: #6FA5A0; }
html[data-board]:not([data-board="blue"]) { --coord-on-light: #0B1220; --coord-on-dark: #000000; }

/* ---------- app colors follow the board style (Blue is the default set above) ---------- */
html[data-board="green"]:not([data-theme="dark"]) {
  --bg: #F3F6EF; --bg-soft: #E7EFDD; --row-band: #E7EFDD; --border: #D2DCC5;
  --accent: #355D20; --accent-hover: #2C4F1A; --link: #2F6B1F; --header-bg: #2F5220; --chart: #4A7A2F;
  --table-header-bg: #2F5220; --table-header-hover: var(--accent); --table-row-even: #EEF3E7; --table-row-hover: #E0EAD3; --table-row-selected: #CFE0BD; --menu-line: #7F9470;
}
html[data-board="green"][data-theme="dark"] {
  --bg: #0F1610; --bg-elevated: #172117; --bg-soft: #1E2B1E; --row-band: #1E2B1E; --border: #2E3F2C; --text-muted: #BCC8B6;
  --accent: #8DBF6A; --accent-hover: #A3CF84; --accent-text: #0C140A; --link: #A8D48A; --header-bg: #142014; --chart: #8DBF6A; --grid: #2E3F2C;
  --table-header-bg: #2A3D26; --table-header-hover: var(--table-row-selected); --table-row-odd: #172117; --table-row-even: #1E2B1E; --table-row-hover: #253524; --table-row-selected: #33492F;
  --menu-bg: #233122; --menu-line: #6A8762;
}
html[data-board="wood"]:not([data-theme="dark"]) {
  --bg: #F8F4EE; --bg-soft: #F1E7DA; --row-band: #F1E7DA; --border: #E0D2BF;
  --accent: #7A4B26; --accent-hover: #663E1F; --link: #874A17; --header-bg: #5C3A1E; --chart: #94602F;
  --table-header-bg: #5C3A1E; --table-header-hover: var(--accent); --table-row-even: #F6EEE3; --table-row-hover: #EEDFCB; --table-row-selected: #E5D0B3; --menu-line: #A08A72;
}
html[data-board="wood"][data-theme="dark"] {
  --bg: #17120D; --bg-elevated: #211A13; --bg-soft: #2B2219; --row-band: #2B2219; --border: #403326; --text-muted: #CDBFAE;
  --accent: #D9A66E; --accent-hover: #E6BC8C; --accent-text: #1A1008; --link: #E8BE8C; --header-bg: #1E160F; --chart: #D9A66E; --grid: #403326;
  --table-header-bg: #4A3826; --table-header-hover: var(--table-row-selected); --table-row-odd: #211A13; --table-row-even: #2B2219; --table-row-hover: #352A1F; --table-row-selected: #48392A;
  --menu-bg: #30261C; --menu-line: #8A7259;
}
html[data-board="gray"]:not([data-theme="dark"]) {
  --bg: #F4F4F5; --bg-soft: #EAEAEC; --row-band: #EAEAEC; --border: #D7D7DB;
  --accent: #3F3F46; --accent-hover: #27272A; --link: #27272A; --header-bg: #27272A; --chart: #52525B;
  --table-header-bg: #27272A; --table-header-hover: var(--accent); --table-row-even: #F1F1F3; --table-row-hover: #E4E4E7; --table-row-selected: #D4D4D8; --menu-line: #8E8E96;
}
html[data-board="gray"][data-theme="dark"] {
  --bg: #121214; --bg-elevated: #1B1B1E; --bg-soft: #242428; --row-band: #242428; --border: #36363C; --text-muted: #C2C2CA;
  --accent: #C9C9D1; --accent-hover: #DDDDE2; --accent-text: #111113; --link: #D9D9DE; --header-bg: #18181B; --chart: #C9C9D1; --grid: #36363C;
  --table-header-bg: #3A3A40; --table-header-hover: var(--table-row-selected); --table-row-odd: #1B1B1E; --table-row-even: #242428; --table-row-hover: #2C2C31; --table-row-selected: #3B3B42;
  --menu-bg: #2A2A2F; --menu-line: #73737D;
}
html[data-board="purple"]:not([data-theme="dark"]) {
  --bg: #F6F4FA; --bg-soft: #ECE6F6; --row-band: #ECE6F6; --border: #DAD1EA;
  --accent: #5B3A9E; --accent-hover: #4C2F86; --link: #5B3A9E; --header-bg: #4A2E80; --chart: #6E4DB8;
  --table-header-bg: #4A2E80; --table-header-hover: var(--accent); --table-row-even: #F1ECF9; --table-row-hover: #E4DAF3; --table-row-selected: #D6C8EE; --menu-line: #9886BB;
}
html[data-board="purple"][data-theme="dark"] {
  --bg: #120F1C; --bg-elevated: #1B1629; --bg-soft: #241D36; --row-band: #241D36; --border: #372D50; --text-muted: #C3BAD8;
  --accent: #B39DF0; --accent-hover: #C6B5F5; --accent-text: #140C26; --link: #C4B2F6; --header-bg: #171226; --chart: #B39DF0; --grid: #372D50;
  --table-header-bg: #3B2E63; --table-header-hover: var(--table-row-selected); --table-row-odd: #1B1629; --table-row-even: #241D36; --table-row-hover: #2C2443; --table-row-selected: #3D3260;
  --menu-bg: #2B2340; --menu-line: #7A6AA8;
}
html[data-board="teal"]:not([data-theme="dark"]) {
  --bg: #F2F7F6; --bg-soft: #E2EFEC; --row-band: #E2EFEC; --border: #CCDFDB;
  --accent: #1F625C; --accent-hover: #1A524D; --link: #1B665F; --header-bg: #1C514D; --chart: #2A7A71;
  --table-header-bg: #1C514D; --table-header-hover: var(--accent); --table-row-even: #EAF4F2; --table-row-hover: #D8EBE7; --table-row-selected: #C3E0DA; --menu-line: #769994;
}
html[data-board="teal"][data-theme="dark"] {
  --bg: #0C1716; --bg-elevated: #132120; --bg-soft: #1A2C2A; --row-band: #1A2C2A; --border: #29403D; --text-muted: #B5CCC8;
  --accent: #6FC7BC; --accent-hover: #8FD6CD; --accent-text: #06201D; --link: #8ADBD0; --header-bg: #102120; --chart: #6FC7BC; --grid: #29403D;
  --table-header-bg: #24423F; --table-header-hover: var(--table-row-selected); --table-row-odd: #132120; --table-row-even: #1A2C2A; --table-row-hover: #213634; --table-row-selected: #2E4A47;
  --menu-bg: #1F3331; --menu-line: #5F8A84;
}

.look-dialog { width: min(460px, 94vw); }
.look-label { font-weight: 700; font-size: calc(14px * var(--ts)); color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin: 14px 0 8px; }
.look-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.look-grid.four { grid-template-columns: repeat(4, 1fr); }
.look-aa { font-weight: 800; line-height: 1; height: 28px; display: flex; align-items: flex-end; }
.look-opt {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 10px; background: var(--bg-elevated); font-weight: 600; font-size: calc(14px * var(--ts));
}
.look-opt.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--bg-soft); }
.look-mini { display: grid; grid-template-columns: 1fr 1fr; width: 40px; height: 40px; border-radius: 6px; overflow: hidden; }
.look-mini i { display: block; }
.look-pcs { display: flex; height: 40px; }
.look-pcs img { width: 40px; height: 40px; }

/* ---------- menu: sections only appear here on phones ---------- */
.menu-icon { display: none; flex-direction: column; justify-content: center; gap: 4px; width: 20px; height: 20px; }
.menu-icon i { display: block; height: 2px; border-radius: 2px; background: currentColor; }
.menu-head, .menu-go, .menu-scrim { display: none; }
.menu-label { font-size: calc(13px * var(--ts)); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); padding: 8px 12px 4px; }
.menu-nav a { display: block; padding: 11px 12px; border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 600; font-size: calc(16px * var(--ts)); }
.menu-nav a:hover { background: var(--bg-soft); }
.menu-nav a.active { background: var(--accent); color: var(--accent-text); }
.menu .menu-signout { color: var(--g-blunder); }
.show-sm { display: none; }

/* iOS Home Screen app: a solid status bar takes the page background, so make that the header color. */
@media (display-mode: standalone) {
  html { background: var(--header-bg); }
}

/* ---------- phones: board stays put, the coach scrolls under it ---------- */
@media (max-width: 760px) {
  .app { height: 100dvh; }
  .topbar { height: 52px; padding: 0 12px; gap: 10px; }
  .brand { font-size: calc(17px * var(--ts)); }
  .tabs { display: none; }
  .menu-icon { display: flex; }
  #userName { display: none; }
  .user-btn { padding: 8px 10px; }
  .menu-scrim { display: block; position: fixed; inset: 0; background: var(--scrim); z-index: 40; animation: fade .15s ease-out; }
  .menu-scrim[hidden] { display: none; }
  .menu {
    position: fixed; top: 8px; right: 8px; left: 8px; z-index: 60; max-height: calc(100dvh - 16px); overflow: auto;
    background: var(--menu-bg); border: 0; border-radius: 16px; padding: 4px 10px 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .45); animation: drop .18s ease-out;
  }
  .menu-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 2px 4px 12px; font-weight: 800; font-size: calc(18px * var(--ts)); }
  .menu .menu-close, .menu .menu-close:hover { flex: none; width: 44px; padding: 0; text-align: center; height: 44px; border: 0; background: none; color: var(--text); font-size: calc(30px * var(--ts)); line-height: 1; cursor: pointer; border-radius: 10px; }
  .menu-go { display: block; }
  .menu-group + .menu-group { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--menu-line); }
  .menu button:not(.menu-close) { font-size: calc(16px * var(--ts)); padding: 11px 12px; font-weight: 600; }
  .hide-sm { display: none; }
  .show-sm { display: inline; }
  @keyframes drop { from { opacity: 0; transform: translateY(-8px); } }
  @keyframes fade { from { opacity: 0; } }
  .players-bottom { display: none; }

  .view:has(> .board-screen) { overflow: hidden; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
  .board-screen { display: flex; flex-direction: column; align-items: stretch; gap: 8px; height: 100%; }
  .board-col { flex-shrink: 0; gap: 6px; }
  .board-wrap { gap: 6px; justify-content: center; }
  .board { width: min(calc(100vw - 36px), 56dvh); min-width: 0; }
  .board-wrap:not(:has(.evalbar)) .board { width: min(calc(100vw - 20px), 56dvh); }
  .evalbar { width: 10px; }
  .players { font-size: calc(14px * var(--ts)); line-height: 1.3; }
  .board-controls { flex-wrap: nowrap; gap: 6px; }
  .board-controls .btn { flex: 1; padding: 8px 4px; font-size: calc(14px * var(--ts)); white-space: nowrap; }
  .panel { flex: 1; min-height: 0; overflow-y: auto; gap: 10px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
  .panel .card, .card, .tile { padding: 12px 14px; }
  .page-header h1 { font-size: calc(22px * var(--ts)); }
  .page-header .btn { padding: 8px 12px; font-size: calc(14px * var(--ts)); }
  .tiles { grid-template-columns: 1fr 1fr; gap: 8px; }
  .tile .value { font-size: calc(24px * var(--ts)); }
  .charts { grid-template-columns: 1fr; gap: 8px; }
  .coach-verdict { font-size: calc(17px * var(--ts)); margin: 2px 0 4px; }
  .coach-row { margin-top: 6px; }
  .toast { bottom: calc(16px + env(safe-area-inset-bottom)); }
}
