/* ChessClub — appearance, following Apple's Human Interface Guidelines for iPadOS.
   System colors (light, dark, increased contrast), SF text styles with Dynamic Type,
   Liquid Glass-style functional layer, iOS controls, 44pt touch targets, Reduce Motion. */

/* ───────────── Color tokens (iOS system values) ───────────── */
:root {
  color-scheme: light dark;
  --tint: #5856D6;               /* systemIndigo — the app's accent */
  --tint-pressed: #4644b8;
  --on-tint: #fff;
  --green: #34C759; --teal: #30B0C7; --yellow: #FFCC00; --orange: #FF9500; --red: #FF3B30; --gray: #8E8E93;

  --bg: #F2F2F7;                 /* systemGroupedBackground */
  --bg2: #FFFFFF;                /* secondarySystemGroupedBackground */
  --bg3: #F2F2F7;                /* tertiarySystemGroupedBackground */
  --label: #000000;
  --label2: rgba(60,60,67,.62);  /* secondaryLabel */
  --label3: rgba(60,60,67,.32);  /* tertiaryLabel */
  --separator: rgba(60,60,67,.18);
  --fill: rgba(120,120,128,.2);  /* systemFill */
  --fill2: rgba(120,120,128,.16);
  --fill3: rgba(118,118,128,.12);/* tertiarySystemFill */
  --seg-thumb: #FFFFFF;
  --glass: rgba(255,255,255,.62);
  --glass-edge: rgba(255,255,255,.75);
  --glass-shadow: 0 8px 32px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --card-shadow: 0 1px 2px rgba(0,0,0,.04);
  --board-shadow: 0 20px 50px rgba(0,0,0,.18), 0 2px 6px rgba(0,0,0,.08);
  --eval-dark: #3A3A3C; --eval-light: #FFFFFF;

  /* move-quality colors: background for badges, text-safe variants for labels */
  --q-best: #34C759; --q-exc: #30B0C7; --q-good: #8E8E93; --q-inacc: #FFCC00; --q-mist: #FF9500; --q-blun: #FF3B30;
  --q-on: #fff; --q-on-inacc: #000;

  --sq-light: #f0d9b5; --sq-dark: #b58863;
  --board: 560px; --panel-w: 400px;
  --r-card: 22px; --r-ctl: 12px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --rounded: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, sans-serif;
  --ease: cubic-bezier(.32,.72,0,1);   /* iOS spring-like curve */
}
/* Appearance: follows the iPad (Auto) unless Settings → Appearance forces Light or Dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-appearance="light"]) {
    --tint: #5E5CE6; --tint-pressed: #7a78ee;
    --green: #30D158; --teal: #40C8E0; --yellow: #FFD60A; --orange: #FF9F0A; --red: #FF453A; --gray: #8E8E93;
    --bg: #000000; --bg2: #1C1C1E; --bg3: #2C2C2E;
    --label: #FFFFFF; --label2: rgba(235,235,245,.62); --label3: rgba(235,235,245,.32);
    --separator: rgba(84,84,88,.62);
    --fill: rgba(120,120,128,.36); --fill2: rgba(120,120,128,.32); --fill3: rgba(118,118,128,.24);
    --seg-thumb: #636366;
    --glass: rgba(30,30,32,.62); --glass-edge: rgba(255,255,255,.10);
    --glass-shadow: 0 10px 36px rgba(0,0,0,.5), 0 1px 2px rgba(0,0,0,.4);
    --card-shadow: none;
    --board-shadow: 0 22px 60px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.05);
    --q-best: #30D158; --q-exc: #40C8E0; --q-inacc: #FFD60A; --q-mist: #FF9F0A; --q-blun: #FF453A;
  }
}
:root[data-appearance="dark"] {
  color-scheme: dark;
    --tint: #5E5CE6; --tint-pressed: #7a78ee;
    --green: #30D158; --teal: #40C8E0; --yellow: #FFD60A; --orange: #FF9F0A; --red: #FF453A; --gray: #8E8E93;
    --bg: #000000; --bg2: #1C1C1E; --bg3: #2C2C2E;
    --label: #FFFFFF; --label2: rgba(235,235,245,.62); --label3: rgba(235,235,245,.32);
    --separator: rgba(84,84,88,.62);
    --fill: rgba(120,120,128,.36); --fill2: rgba(120,120,128,.32); --fill3: rgba(118,118,128,.24);
    --seg-thumb: #636366;
    --glass: rgba(30,30,32,.62); --glass-edge: rgba(255,255,255,.10);
    --glass-shadow: 0 10px 36px rgba(0,0,0,.5), 0 1px 2px rgba(0,0,0,.4);
    --card-shadow: none;
    --board-shadow: 0 22px 60px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.05);
    --q-best: #30D158; --q-exc: #40C8E0; --q-inacc: #FFD60A; --q-mist: #FF9F0A; --q-blun: #FF453A;
}
:root[data-appearance="light"] {
  color-scheme: light;
    --tint: #5856D6; --tint-pressed: #4644b8;
    --green: #34C759; --teal: #30B0C7; --yellow: #FFCC00; --orange: #FF9500; --red: #FF3B30; --gray: #8E8E93;
    --bg: #F2F2F7; --bg2: #FFFFFF; --bg3: #F2F2F7;
    --label: #000000; --label2: rgba(60,60,67,.62); --label3: rgba(60,60,67,.32);
    --separator: rgba(60,60,67,.18);
    --fill: rgba(120,120,128,.2); --fill2: rgba(120,120,128,.16); --fill3: rgba(118,118,128,.12);
    --seg-thumb: #FFFFFF;
    --glass: rgba(255,255,255,.62); --glass-edge: rgba(255,255,255,.75);
    --glass-shadow: 0 8px 32px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
    --card-shadow: 0 1px 2px rgba(0,0,0,.04);
    --board-shadow: 0 20px 50px rgba(0,0,0,.18), 0 2px 6px rgba(0,0,0,.08);
    --q-best: #34C759; --q-exc: #30B0C7; --q-inacc: #FFCC00; --q-mist: #FF9500; --q-blun: #FF3B30;
}
@media (prefers-contrast: more) {
  :root { --label2: rgba(60,60,67,.85); --separator: rgba(60,60,67,.45); --tint: #3634A3; --glass: rgba(255,255,255,.92); }
}
@media (prefers-contrast: more) and (prefers-color-scheme: dark) {
  :root:not([data-appearance="light"]) { --label2: rgba(235,235,245,.85); --separator: rgba(160,160,170,.7); --tint: #7D7AFF; --glass: rgba(20,20,22,.94); }
}
body[data-board="walnut"]    { --sq-light: #f0d9b5; --sq-dark: #b58863; }
body[data-board="maple"]     { --sq-light: #f7e7c6; --sq-dark: #d3a86b; }
body[data-board="rosewood"]  { --sq-light: #e8c9a8; --sq-dark: #8b4a36; }
body[data-board="emerald"]   { --sq-light: #ebecd0; --sq-dark: #779556; }
body[data-board="midnight"]  { --sq-light: #dee3ea; --sq-dark: #7d8fab; }
body[data-board="ice"]       { --sq-light: #eef4f8; --sq-dark: #9fbfd4; }
body[data-board="slate"]     { --sq-light: #d9dde1; --sq-dark: #5f6b77; }
body[data-board="marble"]    { --sq-light: #e9e4dc; --sq-dark: #a39a8f; }
body[data-board="coral"]     { --sq-light: #f3e1d6; --sq-dark: #d58a6c; }
body[data-board="lavender"]  { --sq-light: #ece6f5; --sq-dark: #9b88c2; }
body[data-board="olive"]     { --sq-light: #e6e4c4; --sq-dark: #8d8b54; }
body[data-board="newsprint"] { --sq-light: #f4f4f0; --sq-dark: #9b9b94; }

/* ───────────── Base & typography (Dynamic Type) ───────────── */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 17px; font: -apple-system-body; }          /* Safari: follows the user's Text Size setting */
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--label); font-family: var(--font); font-size: 1rem; line-height: 1.29;
  -webkit-font-smoothing: antialiased; overflow: hidden; display: flex; flex-direction: column;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; letter-spacing: -.01em;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; letter-spacing: inherit; }
svg { display: block; }
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--tint); outline-offset: 2px; border-radius: 10px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--label2); }
.small { font-size: .765rem; }                                 /* footnote 13 */
.center { text-align: center; }
p { margin: 4px 0; line-height: 1.35; }
/* text styles */
h2, .t-title2 { font-size: 1.294rem; font-weight: 700; margin: 0 0 4px; letter-spacing: -.02em; line-height: 1.2; }   /* title2 22 */
h3, .t-headline { font-size: 1rem; font-weight: 600; margin: 0 0 6px; display: flex; align-items: center; gap: 8px; }
.section-head { font-size: .765rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--label2); margin: 6px 16px -4px; }

/* ───────────── Functional layer: header + tab bar (Liquid Glass) ───────────── */
header {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) calc(env(safe-area-inset-right) + 16px) 10px calc(env(safe-area-inset-left) + 20px);
  position: relative; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { width: 34px; height: 34px; border-radius: 9px; background-color: #1c1c1e; background-size: 80%; background-position: center; box-shadow: 0 1px 3px rgba(0,0,0,.2); flex: none; }
.wordmark { font-family: var(--rounded); font-weight: 700; font-size: 1.294rem; letter-spacing: -.02em; white-space: nowrap; }
.wordmark b { font-weight: 700; color: var(--tint); }
#engine-status { width: 8px; height: 8px; border-radius: 50%; background: var(--gray); flex: none; transition: background .3s; }
#engine-status.ok { background: var(--green); }
#engine-status.bad { background: var(--red); }
.glass {
  background: var(--glass); -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--glass-edge); box-shadow: var(--glass-shadow);
}
nav { display: flex; gap: 2px; padding: 4px; border-radius: 999px; }
nav button {
  min-width: 88px; height: 40px; padding: 0 18px; border-radius: 999px; color: var(--label); font-weight: 500; font-size: .882rem;
  transition: background .25s var(--ease), color .25s var(--ease);
}
nav button.on { background: var(--fill3); color: var(--tint); font-weight: 600; }
@media (prefers-color-scheme: dark) { :root:not([data-appearance="light"]) nav button.on { background: rgba(255,255,255,.14); color: #fff; } }
:root[data-appearance="dark"] nav button.on { background: rgba(255,255,255,.14); color: #fff; }
.hdr-right { display: flex; justify-content: flex-end; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: var(--label); }
.icon-btn.glass { color: var(--label); }

/* ───────────── Layout ───────────── */
main { display: flex; flex: 1; min-height: 0; padding-bottom: env(safe-area-inset-bottom); }
.stage { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 6px 16px 12px; gap: 6px; }
body.landscape main { flex-direction: row; justify-content: center; gap: 20px; padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
body.landscape .stage { flex: 0 0 auto; }
body.landscape aside { width: var(--panel-w); flex: 0 0 var(--panel-w); padding: 10px 20px 20px 0; }
/* Folding phone, unfolded: two equal halves with the hinge in the gutter between board and panel */
body.landscape.split main { gap: 0; justify-content: flex-start; padding-left: 0; padding-right: 0; }
body.landscape.split .stage { flex: 0 0 var(--stage-w, 50%); width: var(--stage-w, 50%); padding-left: calc(env(safe-area-inset-left) + 8px); padding-right: 8px; }
body.landscape.split aside { padding: 10px calc(env(safe-area-inset-right) + 16px) 20px 16px; }
body.portrait main { flex-direction: column; }
body.portrait aside { flex: 1; padding: 4px 20px 20px; }
aside { overflow-y: auto; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; gap: 14px; }

.board-row { display: flex; gap: 8px; align-items: stretch; }
.board-wrap { position: relative; width: var(--board); height: var(--board); border-radius: 10px; box-shadow: var(--board-shadow); }
#board { width: 100%; height: 100%; border-radius: 10px; overflow: hidden; }

/* player strips */
.player { width: min(calc(var(--board) + 32px), 100vw - 24px); display: flex; align-items: center; gap: 10px; height: 40px; padding-left: 34px; min-width: 0; }
.pdot { width: 12px; height: 12px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px rgba(127,127,127,.5); transition: box-shadow .3s; }
.pdot.w { background: #fff; } .pdot.b { background: #1c1c1e; }
.pname { font-weight: 600; font-size: 1rem; display: flex; align-items: baseline; gap: 8px; white-space: nowrap; min-width: 0; flex: 0 1 auto; overflow: hidden; }
.pname small { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pname small { font-weight: 400; color: var(--label2); font-size: .882rem; }
.player.to-move .pdot { box-shadow: inset 0 0 0 1px rgba(127,127,127,.5), 0 0 0 3px var(--green); }
.player.thinking .pname::after { content: ''; width: 22px; height: 6px; align-self: center; background: radial-gradient(circle, var(--label2) 2.2px, transparent 2.8px) 0 0/7px 6px repeat-x; animation: dots 1.1s steps(4) infinite; }
@keyframes dots { from { width: 0; } to { width: 28px; } }
.caps { margin-left: auto; display: flex; align-items: center; flex: 0 1 auto; min-width: 0; overflow: hidden; }
.clock { flex: none; }
.caps .pc { width: 20px; height: 20px; display: inline-block; background-size: cover; margin-right: -6px; }
.caps b { margin-left: 12px; font-size: .765rem; color: var(--label2); font-weight: 600; font-variant-numeric: tabular-nums; }

/* evaluation bar */
.evalbar { width: 26px; border-radius: 8px; background: var(--eval-dark); position: relative; overflow: hidden; box-shadow: inset 0 0 0 1px var(--separator); }
.evalbar.hidden { visibility: hidden; }
.evalbar .fill { position: absolute; left: 0; right: 0; bottom: 0; height: 50%; background: var(--eval-light); transition: height .6s var(--ease); }
.evalbar.black-bottom { background: var(--eval-light); }
.evalbar.black-bottom .fill { background: var(--eval-dark); }
.evalbar span { position: absolute; left: -3px; right: -3px; font-size: 11px; font-weight: 700; text-align: center; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.evalbar span.bottom { bottom: 5px; } .evalbar span.top { top: 5px; }
.evalbar span[data-side="w"] { color: #1c1c1e; } .evalbar span[data-side="b"] { color: #fff; }

/* board skin (chessground) */
cg-board { background: repeating-conic-gradient(var(--sq-dark) 0 25%, var(--sq-light) 0 50%) 0 0 / 25% 25%; }
body.grain cg-board::before { content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .22; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.012 .18' numOctaves='3' seed='7'/><feColorMatrix values='0 0 0 0 .35  0 0 0 0 .22  0 0 0 0 .12  0 0 0 .9 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"); background-size: 240px 240px; }
body.grain[data-board="marble"] cg-board::before { opacity: .16; mix-blend-mode: soft-light; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='300' height='300'><filter id='n'><feTurbulence type='turbulence' baseFrequency='.008 .02' numOctaves='4' seed='3'/><feColorMatrix values='0 0 0 0 .3  0 0 0 0 .3  0 0 0 0 .3  0 0 0 1.2 -.2'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"); background-size: 300px 300px; }
cg-board square.move-dest { background: radial-gradient(rgba(0,0,0,.22) 19%, rgba(0,0,0,0) 21%); }
cg-board square.oc.move-dest { background: radial-gradient(transparent 0%, transparent 79%, rgba(0,0,0,.22) 80%); }
@media (hover: hover) { cg-board square.move-dest:hover { background: rgba(255,255,255,.22); } }
cg-board square.last-move { background-color: rgba(255, 204, 0, .36); }
cg-board square.selected { background-color: rgba(88, 86, 214, .38); }
cg-board square.check { background: radial-gradient(ellipse at center, rgba(255,59,48,.95) 0%, rgba(255,59,48,.65) 32%, rgba(255,59,48,0) 85%); }
.cg-wrap coords { font-family: var(--font); font-size: max(11px, calc(var(--board) / 48)); font-weight: 600; opacity: 1; text-transform: none; }
.cg-wrap coords.ranks { left: 4px; top: 3px; height: 100%; width: 16px; }
.cg-wrap coords.ranks coord { flex: 1 1 0; transform: none; }
.cg-wrap coords.files { left: 0; bottom: 1px; width: 100%; height: auto; text-transform: none; }
.cg-wrap coords.files coord { flex: 1 1 0; text-align: right; padding-right: 4px; line-height: 1.3; }
.orientation-white .ranks :nth-child(odd), .orientation-white .files :nth-child(odd),
.orientation-black .ranks :nth-child(even), .orientation-black .files :nth-child(even) { color: var(--sq-light); }
.orientation-white .ranks :nth-child(even), .orientation-white .files :nth-child(even),
.orientation-black .ranks :nth-child(odd), .orientation-black .files :nth-child(odd) { color: var(--sq-dark); }
.cg-wrap .cg-shapes { opacity: .8; }
piece.dragging { filter: drop-shadow(0 10px 12px rgba(0,0,0,.35)); }

/* promotion picker */
#promo { position: absolute; inset: 0; background: rgba(0,0,0,.35); z-index: 20; border-radius: 10px; }
.promo-col { position: absolute; width: 12.5%; display: flex; flex-direction: column; border-radius: 14px; overflow: hidden; background: var(--bg2); box-shadow: 0 12px 36px rgba(0,0,0,.35); }
.promo-col button { width: 100%; aspect-ratio: 1; background-size: 84%; background-position: center; background-repeat: no-repeat; }
.promo-col button:active { background-color: var(--fill); }
.pc { background-size: cover; background-repeat: no-repeat; }

/* ───────────── Content layer: grouped cards ───────────── */
.card { background: var(--bg2); border-radius: var(--r-card); padding: 16px 18px; box-shadow: var(--card-shadow); }
.card.hero { padding: 20px; }

/* buttons (iOS styles: prominent, gray, plain, destructive) */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: 999px; background: var(--fill3); color: var(--tint); font-weight: 600; font-size: 1rem;
  transition: transform .15s var(--ease), background .2s, opacity .2s;
}
.btn:active { transform: scale(.97); opacity: .8; }
.btn.primary { background: var(--tint); color: var(--on-tint); }
.btn.danger { background: var(--red); color: #fff; }
.btn.ghost { background: transparent; color: var(--tint); }
.btn.big { width: 100%; min-height: 52px; font-size: 1.059rem; margin-top: 16px; }
.row.gap .btn.big { flex: 1 1 180px; width: auto; margin-top: 4px; }
.btn.small { min-height: 36px; padding: 0 14px; font-size: .882rem; }
.btn.small svg { width: 17px; height: 17px; }
@media (hover: hover) { .btn:hover { filter: brightness(1.06); } .tool:hover, .mv[data-go]:hover, .game-row:hover, .drill:hover { background-color: var(--fill3); } }
.link { color: var(--tint); font-weight: 500; min-height: 44px; display: inline-flex; align-items: center; }
.row { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.stack { flex-direction: column; align-items: stretch; }
.tip { font-size: .882rem; color: var(--label2); margin-top: 12px; line-height: 1.35; }
.tip b { color: var(--label); font-weight: 600; }
.pill { font-style: normal; font-size: .765rem; font-weight: 600; color: var(--label2); background: var(--fill3); padding: 2px 9px; border-radius: 99px; }

/* new game */
.field { margin-top: 18px; }
.field > span { display: block; font-size: .765rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--label2); margin-bottom: 8px; }
.strength { display: flex; align-items: baseline; gap: 10px; }
.strength b { font-family: var(--rounded); font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.strength em { font-style: normal; color: var(--tint); font-weight: 600; }
/* iOS slider */
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 44px; background: transparent; margin: 0; --pct: 50%; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(to right, var(--tint) var(--pct), var(--fill) var(--pct)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 28px; border-radius: 50%; background: #fff; margin-top: -12px; box-shadow: 0 0.5px 4px rgba(0,0,0,.12), 0 6px 13px rgba(0,0,0,.12), 0 0 0 .5px rgba(0,0,0,.04); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 4px; background: var(--fill); }
input[type=range]::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--tint); }
input[type=range]::-moz-range-thumb { width: 28px; height: 28px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
/* iOS segmented control */
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--fill3); border-radius: 10px; padding: 2px; gap: 0; position: relative; }
.segmented button { min-height: 36px; border-radius: 8px; font-size: .824rem; font-weight: 500; color: var(--label); display: flex; align-items: center; justify-content: center; gap: 6px; transition: background .2s var(--ease), box-shadow .2s; }
.segmented button.on { background: var(--seg-thumb); font-weight: 600; box-shadow: 0 3px 8px rgba(0,0,0,.12), 0 3px 1px rgba(0,0,0,.04); }
.segmented .pc { width: 22px; height: 22px; }
.segmented svg { width: 18px; height: 18px; }
.presets { margin-top: 6px; }

/* coach */
.coach { display: flex; gap: 14px; align-items: flex-start; animation: rise .35s var(--ease); }
@keyframes rise { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }
.coach-ico { width: 40px; height: 40px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--fill3); color: var(--tint); }
.coach-badge { width: 40px; height: 40px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--cls); color: var(--q-on); font-weight: 800; font-size: .941rem; letter-spacing: -.06em; font-family: var(--rounded); }
.coach.inaccuracy .coach-badge { color: var(--q-on-inacc); }
.coach-body { min-width: 0; flex: 1; }
.coach-body > b { font-size: 1rem; font-weight: 600; display: block; }
.coach-body .cls-label { color: var(--label2); font-weight: 500; }
.coach-body p { color: var(--label); font-size: .941rem; opacity: .86; }
.drill-tag { display: inline-flex; gap: 8px; align-items: center; font-weight: 600; color: var(--tint); font-size: .941rem; padding: 0 4px; }
.drill-tag svg { width: 18px; height: 18px; }
.drill-tip { margin: -8px 4px 0; }
.status.done { font-size: 1rem; }

/* moves */
.moves-card { padding: 10px 12px; flex: 1 1 auto; min-height: 96px; display: flex; flex-direction: column; }
.moves { display: grid; grid-template-columns: 36px 1fr 1fr; gap: 2px 6px; overflow-y: auto; max-height: 100%; font-variant-numeric: tabular-nums; position: relative; }
body.landscape .moves { max-height: 32vh; }
body.portrait .moves { max-height: 20vh; }
.moves .num { color: var(--label3); font-size: .824rem; padding: 9px 0 0 6px; font-weight: 500; }
.mv { min-height: 36px; padding: 0 10px; border-radius: 10px; font-weight: 500; font-size: .941rem; display: flex; align-items: center; gap: 6px; }
.mv i { font-style: normal; font-weight: 800; font-size: 11px; letter-spacing: -.04em; min-width: 20px; height: 18px; padding: 0 4px; border-radius: 9px; display: inline-grid; place-items: center; background: var(--q); color: var(--q-on); font-family: var(--rounded); }
.mv i.inaccuracy { color: var(--q-on-inacc); }
.mv i.best { background: none; color: var(--q-best); min-width: 0; padding: 0; font-size: 12px; }
.mv[data-go] { cursor: pointer; }
.mv.cur { background: var(--tint); color: #fff; }
.mv.cur i.best { color: #fff; }
.mv.empty { color: var(--label3); }

/* toolbar (glass, bottom of panel) */
.toolbar { display: flex; gap: 4px; padding: 6px; border-radius: 26px; }
.tool { flex: 1; min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border-radius: 20px; color: var(--tint); font-size: .706rem; font-weight: 500; transition: transform .15s var(--ease), background .2s; }
.tool svg { width: 22px; height: 22px; }
.tool span { color: var(--label); }
.tool:active { transform: scale(.94); background: var(--fill3); }
.tool[disabled] { opacity: .3; pointer-events: none; }
.tool.wide { flex: 3; flex-direction: row; gap: 8px; font-size: 1rem; font-weight: 600; }
.tool.primary { background: var(--tint); color: #fff; }
.tool.primary span { color: #fff; }
.toolbar.nav .tool:nth-child(5) { flex: 2.8; flex-direction: row; gap: 6px; font-size: .824rem; white-space: nowrap; }

/* review */
.progress .bar { height: 4px; background: var(--fill); border-radius: 4px; margin-top: 10px; overflow: hidden; }
.progress .bar i { display: block; height: 100%; background: var(--tint); transition: width .3s var(--ease); }
.summary .acc { display: flex; align-items: center; gap: 16px; }
.ring { --p: 0; width: 72px; height: 72px; border-radius: 50%; flex: none; display: grid; place-items: center; background: conic-gradient(var(--green) calc(var(--p) * 1%), var(--fill3) 0); position: relative; }
.ring::before { content: ''; position: absolute; inset: 7px; background: var(--bg2); border-radius: 50%; }
.ring b { position: relative; font-family: var(--rounded); font-size: 1.118rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.counts { display: grid; grid-template-columns: repeat(6, 1fr); margin-top: 16px; }
.cnt { display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 600; font-size: .941rem; font-variant-numeric: tabular-nums; }
.cnt i { font-style: normal; width: 28px; height: 28px; border-radius: 50%; background: var(--cls); color: var(--q-on); display: grid; place-items: center; font-size: 11px; font-weight: 800; letter-spacing: -.06em; font-family: var(--rounded); }
.cnt.inaccuracy i { color: var(--q-on-inacc); }
.cnt small { font-size: 11px; color: var(--label2); font-weight: 500; }
.graph { width: 100%; height: 76px; border-radius: 16px; overflow: hidden; cursor: pointer; flex: none; }
.g-bg { fill: var(--eval-dark); } .g-area { fill: var(--eval-light); } .g-mid { stroke: var(--gray); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.g-line { fill: none; stroke: var(--tint); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.g-cur { stroke: var(--tint); stroke-width: 2; vector-effect: non-scaling-stroke; }

/* train */
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; margin: 16px 0 0; }
.card.stats3 { margin: 0; }
.stats3 b { display: block; font-family: var(--rounded); font-size: 1.765rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stats3 span { font-size: .765rem; color: var(--label2); }
.list { margin: 0 -18px -16px; }
.list > * { width: 100%; display: flex; align-items: center; gap: 14px; text-align: left; min-height: 60px; padding: 10px 18px; position: relative; }
.list > * + *::before { content: ''; position: absolute; top: 0; right: 0; left: 66px; border-top: .5px solid var(--separator); }
.list > *:last-child { border-radius: 0 0 var(--r-card) var(--r-card); }
.drill-ico { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--tint); color: #fff; flex: none; }
.drill-ico svg { width: 20px; height: 20px; }
.drill b, .g-main b { display: block; font-size: 1rem; font-weight: 400; color: var(--label); }
.drill small, .g-main small { color: var(--label2); font-size: .824rem; }
.drill .ok { margin-left: auto; color: var(--green); }
.chev { margin-left: auto; color: var(--label3); flex: none; }
.chev svg { width: 14px; height: 14px; stroke-width: 2.6; }
.drill .ok + .chev { margin-left: 4px; }
.train-head { display: flex; justify-content: space-between; align-items: center; color: var(--label2); font-size: .824rem; font-weight: 500; padding: 0 6px; }
.bad-move { color: var(--q-mist); font-weight: 600; }
.verdict { font-size: 1rem; animation: rise .3s var(--ease); display: flex; gap: 12px; align-items: flex-start; }
.verdict .v-ico { width: 28px; height: 28px; border-radius: 50%; flex: none; display: grid; place-items: center; color: #fff; }
.verdict.ok .v-ico { background: var(--green); } .verdict.bad .v-ico { background: var(--red); } .verdict.wait .v-ico { background: var(--gray); }
.verdict .v-ico svg { width: 16px; height: 16px; stroke-width: 2.6; }

/* progress */
.big-rating { display: flex; flex-direction: column; }
.big-rating span { font-size: .765rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--label2); }
.big-rating b { font-family: var(--rounded); font-size: 3rem; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.1; color: var(--label); }
.big-rating small { color: var(--label2); font-size: .882rem; }
.spark { width: 100%; height: 64px; margin-top: 12px; overflow: visible; }
.spark polyline { fill: none; stroke-width: 2.4; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.spark.rating polyline { stroke: var(--tint); } .spark.acc polyline { stroke: var(--green); }
.res { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-weight: 700; font-size: .824rem; flex: none; color: #fff; font-family: var(--rounded); }
.res.W { background: var(--green); } .res.D { background: var(--gray); } .res.L { background: var(--red); }
.g-main { flex: 1; min-width: 0; }
.g-acc { font-weight: 500; color: var(--label2); font-variant-numeric: tabular-nums; } .g-acc em { font-style: normal; color: var(--tint); font-size: .882rem; }

/* ───────────── Modals: sheets & alerts ───────────── */
#modal { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,0); display: flex; align-items: center; justify-content: center; padding: 24px; transition: background .25s var(--ease); }
#modal.open { background: rgba(0,0,0,.3); }
@media (prefers-color-scheme: dark) { :root:not([data-appearance="light"]) #modal.open { background: rgba(0,0,0,.5); } }
:root[data-appearance="dark"] #modal.open { background: rgba(0,0,0,.5); }
.sheet { width: min(540px, 100%); max-height: 88vh; overflow-y: auto; background: var(--bg); border-radius: 34px; box-shadow: 0 30px 90px rgba(0,0,0,.35); transform: translateY(40px); opacity: 0; transition: transform .38s var(--ease), opacity .25s; }
#modal.open .sheet { transform: none; opacity: 1; }
/* Unfolded phone: sheets live on the right half so the hinge never runs through a form */
body.split #modal { justify-content: flex-end; padding-right: calc(env(safe-area-inset-right) + 16px); }
body.split #modal .sheet { width: calc(var(--panel-w, 50vw) - 32px); max-width: 540px; max-height: 92vh; }
.sheet.center { text-align: center; padding: 28px 24px 22px; width: min(420px, 100%); background: var(--bg2); }
.sheet-nav { position: sticky; top: 0; z-index: 2; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 14px 16px 8px; background: var(--bg); }
.sheet-nav h2 { font-size: 1rem; font-weight: 600; margin: 0; letter-spacing: -.01em; }
.sheet-nav .done { justify-self: end; font-weight: 600; color: var(--tint); min-height: 44px; padding: 0 8px; }
.sheet-body { padding: 4px 20px 24px; display: flex; flex-direction: column; gap: 8px; }
.group { background: var(--bg2); border-radius: 22px; overflow: hidden; }
.group-foot { font-size: .765rem; color: var(--label2); margin: -2px 16px 12px; line-height: 1.35; }
.group .cell { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 52px; padding: 8px 16px; position: relative; }
.group .cell + .cell::before { content: ''; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--separator); }
.cell b { display: block; font-size: 1rem; font-weight: 400; }
.cell small { display: block; color: var(--label2); font-size: .765rem; margin-top: 1px; }
.cell .value { color: var(--label2); text-align: right; }
.cell input[type=text] { flex: 1; min-width: 0; text-align: right; border: 0; background: none; color: var(--label2); font: inherit; font-size: 1rem; padding: 10px 0; -webkit-user-select: text; user-select: text; }
.cell input[type=text]:focus { color: var(--label); }
.toggle { cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle i { width: 51px; height: 31px; flex: none; border-radius: 99px; background: var(--fill2); position: relative; transition: background .25s var(--ease); }
.toggle i::after { content: ''; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; transition: transform .3s var(--ease); box-shadow: 0 3px 8px rgba(0,0,0,.15), 0 3px 1px rgba(0,0,0,.06); }
.toggle input:checked + i { background: var(--green); }
.toggle input:checked + i::after { transform: translateX(20px); }
.toggle input:focus-visible + i { outline: 3px solid var(--tint); outline-offset: 2px; }
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; padding: 12px; }
.theme { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 6px 2px; border-radius: 14px; font-size: .765rem; color: var(--label2); font-weight: 500; min-height: 44px; }
.theme.on { color: var(--tint); font-weight: 600; }
.theme.on .sw { box-shadow: 0 0 0 2.5px var(--bg2), 0 0 0 5px var(--tint); }
.sw { width: 48px; height: 48px; border-radius: 12px; display: block; transition: box-shadow .2s; }
.sw { background: repeating-conic-gradient(var(--d) 0 25%, var(--l) 0 50%) 0 0/50% 50%; }
.sw.pcs { background-color: var(--sq-dark); background-position: center; background-size: 82%; background-repeat: no-repeat; }
.cell .link { min-height: 0; }
.credits { font-size: .706rem; color: var(--label2); text-align: center; margin: 8px 16px 0; line-height: 1.4; }

.result-icon { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 14px; color: #fff; }
.result-icon.win { background: var(--green); } .result-icon.draw { background: var(--gray); } .result-icon.loss { background: var(--tint); }
.rating-change { display: flex; align-items: baseline; justify-content: center; gap: 10px; margin: 16px 0 6px; }
.rating-change span { color: var(--label2); font-size: .882rem; }
.rating-change b { font-family: var(--rounded); font-size: 1.647rem; font-weight: 700; }
.rating-change em { font-style: normal; font-weight: 600; }
.rating-change em.up { color: var(--green); } .rating-change em.down { color: var(--red); }

/* iOS alert */
.alert { width: 300px; background: var(--glass); -webkit-backdrop-filter: blur(30px) saturate(180%); backdrop-filter: blur(30px) saturate(180%); border-radius: 28px; text-align: center; overflow: hidden; transform: scale(1.08); opacity: 0; transition: transform .3s var(--ease), opacity .2s; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
#modal.open .alert { transform: none; opacity: 1; }
.alert .a-body { padding: 22px 20px 18px; }
.alert h2 { font-size: 1rem; font-weight: 600; margin: 0 0 4px; }
.alert p { font-size: .765rem; color: var(--label); margin: 0; }
.alert .a-btns { display: flex; gap: 10px; padding: 0 16px 16px; }
.alert .a-btns button { flex: 1; min-height: 48px; border-radius: 999px; font-size: 1rem; font-weight: 500; background: var(--fill3); color: var(--label); }
.alert .a-btns button.destructive { background: var(--red); color: #fff; font-weight: 600; }

/* ───────────── Size classes ───────────── */
body.portrait .stage { padding-top: 2px; }
@media (max-width: 700px) {
  .wordmark { display: none; }
  nav button { min-width: 0; padding: 0 12px; }
  header { padding-left: 14px; padding-right: 10px; gap: 6px; }
}

/* ───────────── Reduce Motion ───────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .sheet, .alert { transform: none !important; }
}

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--orange); margin-right: 7px; vertical-align: middle; }
.dot.ok { background: var(--green); }

/* ───────────── v1.4: new components ───────────── */
/* banners (engine loading/failed, update ready, pairing) */
.banner { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 16px; background: var(--bg2); color: var(--label); font-size: .882rem; box-shadow: var(--card-shadow); }
.banner svg { color: var(--tint); flex: none; }
.banner.bad { background: color-mix(in srgb, var(--red) 14%, var(--bg2)); }
.banner.bad svg { color: var(--red); }
.banner span { flex: 1; }
.banner .link { min-height: 36px; font-weight: 600; }
.banner .link.muted { color: var(--label2); }
.spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--fill); border-top-color: var(--tint); animation: spin .8s linear infinite; flex: none !important; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn[disabled] { opacity: .45; pointer-events: none; }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px); transform: translate(-50%, 20px); opacity: 0; z-index: 60; padding: 12px 18px; border-radius: 999px; font-weight: 500; font-size: .941rem; display: flex; gap: 8px; align-items: center; max-width: min(560px, 92vw); transition: transform .3s var(--ease), opacity .25s; color: var(--label); }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast svg { color: var(--tint); flex: none; }

/* clocks */
.clock { font-family: var(--rounded); font-variant-numeric: tabular-nums; font-weight: 600; font-size: 1rem; padding: 4px 10px; border-radius: 9px; background: var(--fill3); color: var(--label2); margin-left: 10px; min-width: 64px; text-align: center; }
.clock.run { background: var(--label); color: var(--bg2); }
.clock.low.run { background: var(--red); color: #fff; }
.chip-pc { width: 22px; height: 22px; border-radius: 6px; background-color: rgba(127,127,127,.18); }

/* blunder check */
.card.bc { border: 2px solid var(--tint); animation: rise .3s var(--ease); }
.bc-head { display: flex; align-items: center; gap: 8px; color: var(--tint); font-size: 1rem; }
.bc-head b { color: var(--label); }
.bc ol { margin: 10px 0 2px; padding-left: 22px; color: var(--label); font-size: .941rem; line-height: 1.45; }
.bc em { font-style: normal; font-weight: 600; }
.verdict.info .v-ico { background: var(--tint); }
.verdict p { margin-top: 2px; font-size: .882rem; color: var(--label2); }
.verdict .note { color: var(--label); opacity: .86; font-size: .941rem; margin-top: 6px; }
.coach.retry .coach-badge { background: var(--cls); }

/* Claude */
.claude { display: flex; gap: 10px; margin-top: 12px; padding: 12px; border-radius: 14px; background: color-mix(in srgb, var(--tint) 9%, var(--bg2)); }
.claude .c-ico { color: var(--tint); flex: none; margin-top: 1px; }
.claude p { font-size: .941rem; margin: 0; color: var(--label); line-height: 1.42; opacity: 1; }
.claude p.q { color: var(--label2); font-style: italic; margin-bottom: 4px; }
.claude.loading p { color: var(--label2); }
.claude.loading .c-ico { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.claude.err { background: var(--fill3); }
.claude.err .c-ico { color: var(--orange); }
.ask { display: flex; gap: 6px; margin-top: 10px; }
.ask input { flex: 1; min-width: 0; min-height: 40px; border-radius: 999px; border: 0; background: var(--fill3); padding: 0 14px; font: inherit; font-size: .941rem; color: var(--label); -webkit-user-select: text; user-select: text; }
.ask button { width: 40px; height: 40px; border-radius: 50%; background: var(--tint); color: #fff; display: grid; place-items: center; flex: none; }
.ask button svg { width: 18px; height: 18px; }

/* train tab */
.train-seg { flex: none; }
.train-seg button { font-size: .765rem; padding: 0 2px; }
.today-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.streak { display: flex; flex-direction: column; align-items: center; color: var(--label3); min-width: 56px; }
.streak.on { color: var(--orange); }
.streak svg { width: 26px; height: 26px; }
.streak b { font-family: var(--rounded); font-size: 1.412rem; line-height: 1; color: var(--label); }
.streak small { font-size: .706rem; color: var(--label2); }
.tasks { margin-top: 14px; }
.task-ico { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--fill3); color: var(--tint); flex: none; }
.task.done .task-ico { background: var(--green); color: #fff; }
.task.done b { color: var(--label2); text-decoration: line-through; text-decoration-color: var(--label3); }
.task-main { flex: 1; min-width: 0; }
.task-main b { display: block; font-weight: 500; }
.task-main small { color: var(--label2); font-size: .824rem; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip { min-height: 36px; padding: 0 14px; border-radius: 999px; background: var(--fill3); color: var(--label); font-size: .882rem; font-weight: 500; display: inline-flex; gap: 8px; align-items: center; }
.chip b { color: var(--tint); }
.op-row .drill-ico.off { background: var(--fill); color: var(--label2); }
.op-row .ok { color: var(--green); margin-left: auto; }
.op-row .ok + .chev { margin-left: 4px; }
.line-row { gap: 8px !important; }
.line-row .g-main b { font-size: .941rem; }
.ideas { margin: 10px 0 0; padding-left: 20px; color: var(--label); font-size: .941rem; line-height: 1.45; }
.ideas li + li { margin-top: 4px; }
.cell.toggle.plain { padding: 12px 0 0; min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.cell.toggle.plain b { display: flex; align-items: center; gap: 6px; font-weight: 500; }
.cell.toggle.plain b svg { color: var(--tint); width: 18px; height: 18px; }
.cell.toggle.plain small { display: block; color: var(--label2); font-size: .765rem; margin-top: 1px; }
.bar.thin { height: 4px; background: var(--fill); border-radius: 4px; overflow: hidden; margin-top: 10px; }
.bar.thin i { display: block; height: 100%; background: var(--tint); transition: width .3s var(--ease); }
.ring.big { width: 104px; height: 104px; margin: 16px auto 8px; }
.ring.big b { font-size: 1.5rem; }

/* progress: weakness report */
.sync-line { display: flex; align-items: center; gap: 4px; font-size: .824rem; color: var(--label2); padding: 0 6px; }
.sync-line span { flex: 1; }
.sync-line .link { min-height: 32px; font-size: .824rem; }
.dot.pair { background: var(--tint); }
.section-sub { font-size: .706rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--label2); margin: 16px 0 8px; }
.pbars { display: flex; flex-direction: column; gap: 8px; }
.pbar { display: grid; grid-template-columns: 96px 1fr 44px; align-items: center; gap: 10px; font-size: .882rem; }
.pbar b { text-align: right; font-variant-numeric: tabular-nums; }
.track { height: 8px; border-radius: 8px; background: var(--fill3); overflow: hidden; }
.track i { display: block; height: 100%; border-radius: 8px; background: var(--tint); }
.track i.low { background: var(--red); } .track i.mid { background: var(--orange); } .track i.high { background: var(--green); }
.motifs { display: flex; flex-direction: column; gap: 12px; }
.m-top { display: flex; justify-content: space-between; font-size: .882rem; margin-bottom: 5px; }
.m-top b { font-weight: 500; }
.m-top span { color: var(--label2); font-variant-numeric: tabular-nums; }
.motif .track i { background: var(--q-mist); }
.motif .link { min-height: 32px; font-size: .824rem; gap: 2px; }
.motif .link svg { width: 14px; height: 14px; }
.insight { display: flex; gap: 12px; padding: 12px; border-radius: 14px; background: color-mix(in srgb, var(--orange) 12%, var(--bg2)); margin-top: 8px; }
.insight .i-ico { color: var(--orange); flex: none; }
.insight b { display: block; font-size: .941rem; }
.insight p { font-size: .882rem; color: var(--label); margin-top: 4px; }

/* review: sticky toolbar so navigation never scrolls away */
.toolbar.sticky { position: sticky; bottom: 0; z-index: 3; }

/* settings */
.segmented.small button { min-height: 30px; padding: 0 12px; font-size: .765rem; }
.keyform input { flex: 1; min-width: 0; border: 0; background: var(--fill3); border-radius: 10px; padding: 0 12px; min-height: 38px; font: inherit; font-size: .882rem; color: var(--label); -webkit-user-select: text; user-select: text; }
.pair input { width: 100%; text-align: center; font-family: var(--rounded); font-size: 2rem; letter-spacing: .3em; font-weight: 600; min-height: 64px; border: 0; border-radius: 16px; background: var(--bg2); color: var(--label); margin-top: 8px; -webkit-user-select: text; user-select: text; }
.err-text { color: var(--red); font-size: .882rem; text-align: center; }
.cell b svg { display: inline; vertical-align: -3px; width: 16px; height: 16px; color: var(--tint); }
.group-foot .link { min-height: 0; font-size: inherit; }

/* small phones */
@media (max-width: 400px) { .brand .logo { display: none; } }
@media (max-height: 500px) and (orientation: landscape) {
  header { padding-top: 4px; padding-bottom: 4px; }
  nav button { height: 34px; }
  .player { height: 32px; }
}

/* ───────────── v1.5: friends & 3D ───────────── */
.mode-seg { flex: none; }
.mode-seg button { gap: 6px; }
.mode-seg button svg { width: 16px; height: 16px; color: var(--tint); }
.prow { gap: 10px !important; }
.pres { width: 12px; height: 12px; border-radius: 50%; background: var(--label3); flex: none; margin: 0 6px; }
.pres.on { background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 25%, transparent); }
.icon-btn.small { width: 36px; height: 36px; color: var(--label2); flex: none; }
.icon-btn.small svg { width: 18px; height: 18px; }
.game-row.static { cursor: default; }
.tcs { grid-template-columns: repeat(4, 1fr); }
.sw.tc { display: grid; place-items: center; background: var(--fill3); color: var(--tint); }
.sw.tc svg { width: 24px; height: 24px; }
.invite-url { font-family: ui-monospace, Menlo, monospace; font-size: .882rem; word-break: break-all; background: var(--bg2); padding: 12px; border-radius: 12px; }
.pair.join input { font-size: 1.3rem; letter-spacing: 0; }

/* 3D board: the board tilts away from you with real perspective, and every piece is
   counter-rotated so it stands up. The app maps touches back onto the flat board
   (window.cgUnproject), so a tap on a square lands on that square. */
:root { --tilt: 30deg; --board-proj: var(--board); }
.board-wrap.three { height: var(--board-proj); perspective: calc(var(--board) * 2.4); perspective-origin: 50% 100%; }
.board-wrap.three #board { height: var(--board); transform: translateY(calc(var(--board-proj) - var(--board))) rotateX(var(--tilt)); transform-origin: 50% 100%; transform-style: preserve-3d; border-radius: 4px; box-shadow: none; }
.board-wrap.three cg-container { width: var(--board) !important; height: var(--board) !important; transform-style: preserve-3d; }
.board-wrap.three cg-board { transform-style: preserve-3d; }
.board-wrap.three cg-board::after { content: ''; position: absolute; left: 0; right: 0; top: 100%; height: 14px; background: linear-gradient(color-mix(in srgb, var(--sq-dark) 60%, black), color-mix(in srgb, var(--sq-dark) 35%, black)); transform: rotateX(-90deg); transform-origin: 50% 0; border-radius: 0 0 4px 4px; }
.board-wrap.three piece { background-image: none !important; transform-style: preserve-3d; overflow: visible; }
.board-wrap.three piece::before { content: ''; position: absolute; left: 0; top: 0; width: 100%; height: 100%; background: var(--img) center bottom / 88% no-repeat; transform: rotateX(calc(var(--tilt) * -1)) scale(1.15); transform-origin: 50% 94%; filter: drop-shadow(0 7px 4px rgba(0,0,0,.35)); pointer-events: none; }
.board-wrap.three piece.dragging::before { filter: drop-shadow(0 18px 10px rgba(0,0,0,.4)); }
.board-wrap.three piece.ghost::before { opacity: .35; }
.board-wrap.three coords.ranks coord, .board-wrap.three coords.files coord { transform: none; }
.board-wrap.three #promo { height: var(--board-proj); }
body.three-d .board-wrap.three { box-shadow: none; }
body.three-d .stage { padding-top: 10px; }

[hidden] { display: none !important; }
