/* Halawi Shatranj by Halawi Media. Solid Halawi brand colors, light and dark themes, system fonts only. */
:root {
  --violet: #9b3df5; --magenta: #c84fb4; --coral: #ea6a5a;
  --felt: #4a2390; --felt-hi: #7a45d6; --felt-lo: #1f0f45; --cushion: #3d1d7a;
  --font-display: ui-rounded, "SF Pro Rounded", "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 16px; --ease: cubic-bezier(.16, 1, .3, 1);
  --safe-t: env(safe-area-inset-top, 0px); --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-l: env(safe-area-inset-left, 0px);
  --bs: 320px; --anim: .22s;
}
/* light (default) */
#app, :root {
  --bg: #f6f3fa; --surface: #ffffff; --surface-2: #efe9f8; --line: #ddd3ee; --line-strong: #c6b8e0;
  --text: #1d1430; --text-2: #3f3554; --muted: #645a78; --brand: #6d28d9; --brand-ink: #ffffff; --brand-text: #6d28d9;
  --chip: #ede5fb; --shadow: 0 10px 30px -14px rgba(40, 20, 80, .35); --scrim: rgba(24, 12, 48, .5);
  --warn: #b4232a; --ok: #1f7a46; --gold: #b7791f;
}
#app[data-theme="dark"] {
  --bg: #0f0a1a; --surface: #1a1328; --surface-2: #241a38; --line: #352a4d; --line-strong: #4a3d68;
  --text: #f6f3fa; --text-2: #d6d0e0; --muted: #aaa2b8; --brand: #9b3df5; --brand-ink: #ffffff; --brand-text: #c9a3ff;
  --chip: #2a1f40; --shadow: 0 10px 30px -14px rgba(0, 0, 0, .8); --scrim: rgba(4, 2, 10, .66);
  --warn: #ff7b7b; --ok: #5bd28f; --gold: #f3c74b;
}
/* boards */
#app { --sq-l: #ece3fa; --sq-d: #8f62d8; --frame: #4a2390; --frame-lo: #1f0f45; --co-l: #6d4bb0; --co-d: #f6f0ff; }
#app[data-board="clapper"] { --sq-l: #e6e2ec; --sq-d: #6f6880; --frame: #1d1430; --frame-lo: #0c0814; --co-l: #4d4560; --co-d: #f2eff7; }
#app[data-board="sepia"] { --sq-l: #f1e4c8; --sq-d: #b88a5a; --frame: #4a2390; --frame-lo: #1f0f45; --co-l: #8a5f33; --co-d: #fff6e4; }

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font-family: var(--font-sans); -webkit-font-smoothing: antialiased; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; }
input, textarea, select { font: inherit; }
[hidden] { display: none !important; }
#app { position: fixed; inset: 0; overflow: hidden; background: var(--bg); color: var(--text); }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
img { -webkit-user-drag: none; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 10px 20px; border-radius: 14px;
  border: 2px solid transparent; font-weight: 700; font-size: 16px; cursor: pointer; text-align: center; line-height: 1.2;
  transition: transform .15s var(--ease), background .2s, border-color .2s; }
.btn:active { transform: scale(.97); }
.btn--primary { background: var(--brand); color: var(--brand-ink); }
.btn--primary:hover { background: #5b21b6; }
#app[data-theme="dark"] .btn--primary:hover { background: #8b35ec; }
.btn--ghost { background: var(--surface); border-color: var(--line-strong); color: var(--text); }
.btn--ghost:hover { border-color: var(--brand); }
.btn--danger { background: var(--surface); border-color: var(--warn); color: var(--warn); }
.btn--sm { min-height: 40px; padding: 8px 14px; font-size: 15px; }
.btn--xs { min-height: 34px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.btn--big { min-height: 54px; font-size: 18px; padding: 12px 34px; min-width: 200px; }
.btn[disabled], .ctl[disabled] { opacity: .45; cursor: default; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 18px; }
.btn-row--start { margin-top: 22px; }
.btn-col { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.btn-wrap { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; }
.btn-wrap--left { justify-content: flex-start; margin-top: 8px; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; cursor: pointer; color: var(--text);
  background: var(--surface); border: 1px solid var(--line-strong); flex: 0 0 auto; position: relative; padding: 0; }
.icon-btn:hover { border-color: var(--brand); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn .ico-fill { fill: currentColor; }
.icon-btn .ico-on, .icon-btn .ico-off { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.icon-btn[aria-pressed="true"] .ico-off, .icon-btn[aria-pressed="false"] .ico-on { display: none; }
.icon-btn[aria-pressed="false"] { color: var(--muted); }

/* ---------- screens ---------- */
.screen { position: absolute; inset: 0; z-index: 20; display: none; overflow-y: auto; -webkit-overflow-scrolling: touch; background: var(--bg);
  padding: calc(16px + var(--safe-t)) calc(14px + var(--safe-r)) calc(24px + var(--safe-b)) calc(14px + var(--safe-l)); touch-action: pan-y; }
.screen.is-active { display: block; animation: scrIn .3s var(--ease); }
@keyframes scrIn { from { opacity: 0; transform: translateY(8px); } }
.panel { width: 100%; max-width: 680px; margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: 22px;
  padding: 18px clamp(14px, 4vw, 30px) 22px; box-shadow: var(--shadow); }
.panel--small { max-width: 520px; }
.panel--rules { max-width: 900px; }
.panel--menu { max-width: 560px; text-align: center; }
.eyebrow { margin: 4px 0 2px; font-size: 13px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--brand-text); }
.title { margin: 2px 0 6px; font-family: var(--font-display); font-weight: 800; font-size: clamp(34px, 9vw, 52px); line-height: 1.05; letter-spacing: -.01em; }
.title span { color: var(--brand-text); }
.title--sm { font-size: clamp(26px, 6vw, 36px); }
.lede { margin: 6px auto 12px; max-width: 440px; color: var(--text-2); font-size: 16px; line-height: 1.45; }
.setup-sub { margin: 2px 0 10px; color: var(--text-2); font-size: 15px; line-height: 1.45; }
.back-btn { display: inline-flex; align-items: center; min-height: 40px; padding: 6px 12px; margin: 0 0 6px; border: 0; background: none; color: var(--brand-text);
  font-weight: 700; font-size: 15px; cursor: pointer; border-radius: 10px; }
.back-btn:hover { background: var(--chip); }
.ver { margin: 6px 0 0; font-size: 12px; color: var(--muted); text-align: center; }
.panel-foot { margin-top: 18px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.link-back { color: var(--brand-text); font-weight: 700; font-size: 14px; text-decoration: none; padding: 6px 10px; border-radius: 8px; }
.link-back:hover { text-decoration: underline; }

/* menu */
.menu-brand { display: inline-block; line-height: 0; margin-top: 2px; }
.menu-brand img { height: 30px; width: auto; }
.menu-cast { display: flex; justify-content: center; align-items: flex-end; gap: 2px; margin: 12px auto 4px; height: 76px; }
.menu-cast i { display: block; width: 52px; height: 52px; background-size: contain; background-repeat: no-repeat; background-position: center bottom; }
.menu-cast i.big { width: 66px; height: 66px; }
.name-chip { display: flex; align-items: center; gap: 8px; max-width: 320px; margin: 4px auto 0; padding: 4px 6px 4px 14px; border-radius: 999px;
  background: var(--chip); border: 1px solid var(--line); cursor: text; }
.name-chip-k { font-size: 13px; font-weight: 700; color: var(--muted); white-space: nowrap; flex: 0 0 auto; }
.name-chip-in { flex: 1 1 auto; min-width: 0; border: 0; background: transparent; color: var(--text); padding: 8px 8px; font-size: 16px; font-weight: 700; outline: none; -webkit-user-select: text; user-select: text; }
.name-chip-in::placeholder { color: var(--muted); font-weight: 500; }
.modes { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; text-align: left; }
.mode, .resume { display: grid; grid-template-columns: 48px minmax(0, 1fr) 20px; align-items: center; gap: 12px; width: 100%; min-height: 70px; padding: 10px 14px;
  background: var(--surface-2); border: 2px solid var(--line); border-radius: 16px; cursor: pointer; text-align: left; transition: border-color .2s, transform .15s var(--ease); }
.resume { margin-top: 16px; border-color: var(--brand); background: var(--chip); }
.mode:hover, .resume:hover { border-color: var(--brand); }
.mode:active, .resume:active { transform: scale(.985); }
.mode-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mode-txt b { font-family: var(--font-display); font-size: 18px; font-weight: 800; }
.mode-txt span { font-size: 14px; color: var(--text-2); line-height: 1.35; }
.mode-go { font-size: 28px; color: var(--brand-text); line-height: 1; }
.mode-ico, .resume-ico { width: 48px; height: 48px; border-radius: 14px; background: var(--felt); background-size: 40px 40px; background-repeat: no-repeat; background-position: center; }
.resume-ico { background-color: var(--brand); }

/* setup */
.set-block { margin-top: 16px; }
.set-k { display: block; font-weight: 800; font-size: 14px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.set-hint { margin: 6px 0 0; font-size: 14px; color: var(--text-2); }
.seg { display: inline-flex; flex-wrap: wrap; gap: 6px; padding: 4px; border-radius: 14px; background: var(--chip); max-width: 100%; }
.seg button { min-height: 40px; min-width: 48px; padding: 6px 14px; border-radius: 10px; border: 0; background: transparent; font-weight: 700; font-size: 15px; cursor: pointer; color: var(--text-2); }
.seg button[aria-checked="true"] { background: var(--brand); color: var(--brand-ink); }
.opp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 8px; }
.opp-card { position: relative; display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 4px 10px; align-items: start; padding: 10px 12px; text-align: left;
  background: var(--surface-2); border: 2px solid var(--line); border-radius: 14px; cursor: pointer; min-height: 64px; }
.opp-card:hover { border-color: var(--line-strong); }
.opp-card[aria-checked="true"] { border-color: var(--brand); background: var(--chip); }
.opp-card .av { grid-row: span 2; }
.opp-card b { font-size: 16px; font-weight: 800; }
.opp-meta { font-size: 13px; color: var(--muted); font-weight: 700; }
.opp-desc { grid-column: 1 / -1; font-size: 13px; color: var(--text-2); line-height: 1.4; margin-top: 2px; }
.opp-rec { position: absolute; top: 8px; right: 10px; font-size: 12px; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.av { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 17px; font-family: var(--font-display); flex: 0 0 auto; background: var(--av, #6d28d9); }
.av--you { background: var(--brand); }
.level-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.level-row input { flex: 1 1 200px; min-width: 0; accent-color: var(--brand); height: 32px; }
.level-out { font-weight: 800; font-family: var(--font-display); font-size: 17px; min-width: 150px; }
.name-list { display: flex; flex-direction: column; gap: 8px; }
.name-row { display: flex; align-items: center; gap: 10px; }
.name-row span { flex: 0 0 64px; font-weight: 700; color: var(--muted); font-size: 14px; }
.txt { flex: 1 1 auto; min-width: 0; min-height: 44px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font-size: 16px; -webkit-user-select: text; user-select: text; }
textarea.txt { width: 100%; min-height: 120px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; resize: vertical; }

/* settings rows */
.settings { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.set-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.set-row:last-child { border-bottom: 0; }
.set-row > span:first-child { flex: 1 1 180px; min-width: 0; font-weight: 700; font-size: 16px; display: flex; flex-direction: column; gap: 2px; }
.set-row--block { margin-top: 12px; border-bottom: 0; }
.set-sub { font-size: 13px; font-weight: 500; color: var(--muted); line-height: 1.35; }
.toggle { -webkit-appearance: none; appearance: none; width: 52px; height: 30px; border-radius: 15px; background: var(--line-strong); position: relative; cursor: pointer; flex: 0 0 auto; transition: background .2s; margin: 0; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s var(--ease); box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.toggle:checked { background: var(--brand); }
.toggle:checked::after { transform: translateX(22px); }
.set-preview { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0; margin: 14px auto 0; max-width: 360px; border-radius: 10px; overflow: hidden; border: 4px solid var(--frame); }
.set-preview i { aspect-ratio: 1; background-size: 92%; background-repeat: no-repeat; background-position: center; }
.set-preview i:nth-child(odd) { background-color: var(--sq-l); } .set-preview i:nth-child(even) { background-color: var(--sq-d); }

/* how to play */
.legend { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 8px; margin: 10px 0 4px; }
.lg { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 4px 12px; align-items: center; padding: 10px 12px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.lg-ico { grid-row: span 2; width: 56px; height: 56px; border-radius: 10px; background-color: var(--sq-l); background-size: 90%; background-repeat: no-repeat; background-position: center; }
.lg b { font-size: 16px; }
.lg b small { font-weight: 700; color: var(--muted); font-size: 13px; }
.lg span { font-size: 13.5px; color: var(--text-2); line-height: 1.4; }
.rules-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 4px 28px; }
.rules-col h3 { font-family: var(--font-display); font-size: 18px; margin: 16px 0 6px; }
.rules-list, .howto { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 7px; font-size: 15px; line-height: 1.45; color: var(--text-2); }
.howto { padding-left: 0; list-style: none; }
.keys { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--chip); border: 1px solid var(--line); font-weight: 700; font-size: 13px; color: var(--text); white-space: nowrap; }

/* lists: puzzles, scenes, archive, stats */
.grp { margin-top: 18px; }
.grp-h { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.grp-h h3 { margin: 0; font-family: var(--font-display); font-size: 19px; }
.grp-h span { font-size: 13px; font-weight: 700; color: var(--muted); }
.grp-sub { margin: 2px 0 8px; font-size: 14px; color: var(--text-2); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 6px; }
.tile { position: relative; min-height: 50px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface-2); font-weight: 800; font-size: 15px; cursor: pointer; color: var(--text); font-variant-numeric: tabular-nums; }
.tile:hover { border-color: var(--brand); }
.tile.is-done { background: var(--chip); border-color: var(--brand); color: var(--brand-text); }
.tile.is-done::after { content: ""; position: absolute; top: 4px; right: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.tile.is-side-b::before { content: ""; position: absolute; left: 5px; top: 5px; width: 8px; height: 8px; border-radius: 2px; background: #2a2236; border: 1px solid #f3edfb; }
.daily { display: grid; grid-template-columns: 48px minmax(0, 1fr) 20px; gap: 12px; align-items: center; width: 100%; padding: 10px 14px; margin-top: 6px; min-height: 64px; border-radius: 16px; border: 2px solid var(--brand); background: var(--chip); text-align: left; cursor: pointer; }
.scene-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 8px; }
.scene { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 4px 12px; align-items: center; padding: 10px 12px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface-2); text-align: left; cursor: pointer; }
.scene:hover { border-color: var(--brand); }
.scene canvas, .scene .mini { grid-row: span 3; width: 64px; height: 64px; border-radius: 6px; }
.scene b { font-size: 16px; font-family: var(--font-display); }
.scene .sc-goal { font-size: 12.5px; font-weight: 800; color: var(--brand-text); text-transform: uppercase; letter-spacing: .04em; }
.scene .sc-brief { font-size: 13.5px; color: var(--text-2); line-height: 1.35; }
.stars { display: inline-flex; gap: 2px; vertical-align: middle; }
.stars i { width: 14px; height: 14px; display: block; background: var(--line-strong); clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
.stars i.on { background: var(--gold); }
.mini { display: grid; grid-template-columns: repeat(8, 1fr); overflow: hidden; }
.mini i { display: block; background-size: 100%; background-repeat: no-repeat; }
.archive { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.arc { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; align-items: center; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2); }
.arc b { font-size: 15px; } .arc span { font-size: 13px; color: var(--text-2); display: block; line-height: 1.35; }
.arc-btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.empty { padding: 18px; text-align: center; color: var(--muted); font-size: 15px; border: 1px dashed var(--line-strong); border-radius: 14px; }
.career { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 140px), 1fr)); gap: 8px; margin-top: 10px; }
.stat { padding: 12px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.stat b { display: block; font-family: var(--font-display); font-size: 24px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--muted); font-weight: 700; }
.opp-table { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.opp-row { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 14px; }
.opp-row .av { width: 30px; height: 30px; font-size: 13px; }
.opp-row em { font-style: normal; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 700; }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 8px; margin-top: 8px; }
.ach { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 10px; align-items: center; padding: 10px 12px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.ach-medal { width: 36px; height: 36px; border-radius: 50%; background: var(--line); }
.ach.is-on .ach-medal { background: var(--gold); box-shadow: inset 0 0 0 4px rgba(255, 255, 255, .35); }
.ach b { font-size: 15px; display: block; } .ach span { font-size: 13px; color: var(--text-2); line-height: 1.35; display: block; }
h3.sec { font-family: var(--font-display); font-size: 19px; margin: 20px 0 4px; }

/* ---------- play view ---------- */
.play { position: absolute; inset: 0; display: flex; flex-direction: column;
  padding: calc(4px + var(--safe-t)) calc(8px + var(--safe-r)) calc(6px + var(--safe-b)) calc(8px + var(--safe-l)); }
.is-menu .play { visibility: hidden; }
.bar { display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 48px; flex: 0 0 auto; }
.bar-brand { line-height: 0; flex: 0 0 auto; }
.bar-brand img { height: 20px; width: auto; }
.bar-title { flex: 1 1 auto; min-width: 0; font-weight: 800; font-size: 14px; color: var(--text-2); text-align: center; line-height: 1.2; overflow-wrap: anywhere; }
.bar-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.arena { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.strip { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 2px 10px; align-items: center; min-height: 46px; flex: 0 0 auto; padding: 0 2px; }
.strip .av { width: 38px; height: 38px; font-size: 15px; grid-row: span 2; }
.strip .av.is-turn { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--brand); }
.st-name { font-weight: 800; font-size: 15px; line-height: 1.2; min-width: 0; overflow-wrap: anywhere; }
.st-name small { font-weight: 700; color: var(--muted); font-size: 12px; margin-left: 6px; }
.st-caps { display: flex; align-items: center; flex-wrap: nowrap; gap: 0; overflow: hidden; min-height: 18px; min-width: 0; }
.st-caps i { flex: 0 1 14px; min-width: 7px; height: 18px; background-size: 18px 18px; background-position: center; background-repeat: no-repeat; }
.st-caps em { flex: 0 0 auto; font-style: normal; font-size: 12px; font-weight: 800; color: var(--muted); margin-left: 8px; }
.clock { grid-row: span 2; min-width: 78px; padding: 6px 10px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); font-variant-numeric: tabular-nums; font-weight: 800; font-size: 20px; text-align: center; font-family: var(--font-display); color: var(--text-2); }
.clock.is-run { background: var(--brand); color: #fff; border-color: var(--brand); }
.clock.is-low { background: var(--warn); border-color: var(--warn); color: #fff; }
.talk { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 8px; align-items: center; min-height: 40px; flex: 0 0 auto; padding: 4px 10px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.talk-av { width: 26px; height: 26px; border-radius: 50%; background: var(--av, var(--brand)); background-size: 80%; background-position: center; background-repeat: no-repeat; }
.talk-t { margin: 0; font-size: 14px; line-height: 1.3; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.talk-t b { color: var(--text); }
.talk.is-new { animation: talkIn .35s var(--ease); }
@keyframes talkIn { from { transform: translateY(-4px); opacity: .3; } }
.no-talk .talk { display: none; }
.goal { flex: 0 0 auto; padding: 6px 12px; border-radius: 12px; background: var(--chip); border: 1px solid var(--line); display: flex; flex-wrap: wrap; align-items: center; gap: 2px 12px; }
.goal b { font-family: var(--font-display); font-size: 15px; }
.goal span { font-size: 13.5px; color: var(--text-2); line-height: 1.35; }
.goal .goal-k { font-size: 12px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--brand-text); }
.goal .goal-c { margin-left: auto; font-weight: 800; font-size: 13px; color: var(--text); font-variant-numeric: tabular-nums; }

.board-zone { flex: 0 0 auto; display: flex; justify-content: center; align-items: stretch; gap: 6px; }
.evalbar { position: relative; width: 14px; border-radius: 6px; overflow: hidden; background: #2a2236; border: 1px solid var(--line-strong); flex: 0 0 auto; }
.evalbar i { position: absolute; left: 0; right: 0; bottom: 0; height: 50%; background: #fffaf1; transition: height .4s var(--ease); }
.evalbar span { position: absolute; left: 0; right: 0; bottom: 4px; writing-mode: vertical-rl; transform: rotate(180deg); display: flex; align-items: center; font-size: 9px; font-weight: 800; line-height: 12px; color: #8a7fa0; white-space: nowrap; }
.evalbar.is-flip span { bottom: auto; top: 4px; }
.evalbar.is-flip i { top: 0; bottom: auto; }
.frame { position: relative; padding: 14px 5px 5px; border-radius: 12px; background: var(--frame); box-shadow: 0 14px 30px -16px rgba(30, 10, 60, .6); }
.clap-band { position: absolute; left: 5px; right: 5px; top: 3px; height: 8px; border-radius: 3px;
  background: repeating-linear-gradient(-55deg, #f6f0ff 0 9px, var(--frame-lo) 9px 18px); opacity: .9; }
.board { position: relative; width: var(--bs); height: var(--bs); touch-action: none; border-radius: 3px; overflow: hidden; }
.squares { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); }
.sq { position: relative; background: var(--sq-l); }
.sq.d { background: var(--sq-d); }
.sq .co { position: absolute; font-size: max(9px, calc(var(--bs) / 36)); font-weight: 800; line-height: 1; pointer-events: none; color: var(--co-l); }
.sq.d .co { color: var(--co-d); }
.sq .co-r { left: 3px; top: 3px; } .sq .co-f { right: 3px; bottom: 2px; }
.no-coords .sq .co { display: none; }
.sq.last::before { content: ""; position: absolute; inset: 0; background: rgba(243, 199, 75, .42); }
.sq.sel::before { content: ""; position: absolute; inset: 0; background: rgba(155, 61, 245, .45); }
.sq.pre::before { content: ""; position: absolute; inset: 0; background: rgba(234, 106, 90, .45); }
.sq.hint::before { content: ""; position: absolute; inset: 0; background: rgba(31, 154, 87, .45); }
.sq.chk::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle, rgba(255, 70, 60, .95) 0, rgba(255, 70, 60, .55) 38%, rgba(255, 70, 60, 0) 72%); animation: spot .6s var(--ease); }
@keyframes spot { from { transform: scale(.4); opacity: 0; } }
.sq.dot::after { content: ""; position: absolute; left: 50%; top: 50%; width: 30%; height: 30%; transform: translate(-50%, -50%); border-radius: 50%; background: rgba(29, 20, 48, .32); }
.sq.ring::after { content: ""; position: absolute; inset: 4%; border-radius: 50%; border: calc(var(--bs) / 96) solid rgba(29, 20, 48, .34); }
.sq.over { box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .85); }
.no-legal .sq.dot::after, .no-legal .sq.ring::after { display: none; }
.pieces { position: absolute; inset: 0; pointer-events: none; }
.pc { position: absolute; left: 0; top: 0; width: 12.5%; height: 12.5%; background-size: 100%; background-repeat: no-repeat; background-position: center;
  transform: translate(calc(var(--x) * 100%), calc(var(--y) * 100%)); transition: transform var(--anim) var(--ease); will-change: transform; z-index: 1; }
.pc.is-drag { transition: none; z-index: 5; filter: drop-shadow(0 8px 10px rgba(20, 8, 40, .45)); }
.pc.is-moving { z-index: 4; }
.pc.is-gone { animation: gone .3s ease forwards; z-index: 0; }
@keyframes gone { to { opacity: 0; transform: translate(calc(var(--x) * 100%), calc(var(--y) * 100%)) scale(.6); } }
.pc.is-new { animation: popIn .35s var(--ease); }
@keyframes popIn { from { opacity: 0; } }
.arrows { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }
.fx { position: absolute; inset: 0; pointer-events: none; z-index: 6; }
.flash { position: absolute; width: 12.5%; height: 12.5%; border-radius: 50%; background: radial-gradient(circle, #fff 0, rgba(255, 255, 255, .7) 30%, rgba(255, 255, 255, 0) 70%); animation: flash .45s ease-out forwards; }
@keyframes flash { from { transform: scale(.3); opacity: 1; } to { transform: scale(1.8); opacity: 0; } }
.vignette { position: absolute; inset: 0; background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 45%, rgba(10, 4, 24, .55) 100%); animation: vig .8s ease forwards; }
@keyframes vig { from { opacity: 0; } }
.reduced .pc, .reduced .evalbar i { transition: none; }
.reduced .flash, .reduced .vignette { display: none; }
.card { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; z-index: 8; opacity: 0; }
.card.is-on { animation: cardShow 1.3s var(--ease) forwards; }
.card-in { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 26px 16px; border-radius: 16px; background: #1d1430; color: #fff; box-shadow: 0 18px 40px -12px rgba(0, 0, 0, .6); }
.card-in b { font-family: var(--font-display); font-size: clamp(26px, calc(var(--bs) / 9), 48px); line-height: 1; letter-spacing: .02em; }
.card-clap { width: 72px; height: 14px; border-radius: 3px; background: repeating-linear-gradient(-55deg, #fff 0 8px, #1d1430 8px 16px); border: 2px solid #fff; transform-origin: 0 100%; }
.card.is-on .card-clap { animation: clap .5s .1s ease-in both; }
@keyframes clap { from { transform: rotate(-28deg); } to { transform: rotate(0); } }
@keyframes cardShow { 0% { opacity: 0; transform: scale(.85); } 15% { opacity: 1; transform: scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: scale(1.04); } }
.card.is-stay { animation: cardStay .5s var(--ease) forwards; }
@keyframes cardStay { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: scale(1); } }
.promo { position: absolute; inset: 0; z-index: 9; display: grid; place-items: center; background: rgba(15, 8, 30, .45); }
.promo-in { background: var(--surface); border-radius: 16px; padding: 12px 14px 14px; box-shadow: var(--shadow); text-align: center; max-width: 94%; }
.promo-in p { margin: 0 0 8px; font-weight: 800; font-size: 15px; }
.promo-row { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.promo-btn { width: 72px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface-2); cursor: pointer; }
.promo-btn:hover, .promo-btn:focus-visible { border-color: var(--brand); }
.promo-btn i { width: 54px; height: 54px; background-size: contain; background-repeat: no-repeat; }
.promo-btn span { font-size: 12px; font-weight: 800; line-height: 1.2; }

.controls { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; flex: 0 0 auto; }
.ctl { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px; padding: 4px 2px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; color: var(--text); }
.ctl:hover { border-color: var(--brand); }
.ctl svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ctl span { font-size: 12px; font-weight: 800; line-height: 1.1; }
.movebox { flex: 1 1 auto; min-height: 44px; display: flex; flex-direction: column; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 6px 8px; overflow: hidden; }
.movebox-head { display: flex; align-items: center; gap: 8px; min-height: 30px; }
.opening { flex: 1 1 auto; min-width: 0; font-size: 13px; font-weight: 700; color: var(--brand-text); line-height: 1.25; }
.nav { display: flex; gap: 4px; flex: 0 0 auto; }
.nav-btn { width: 34px; height: 30px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface-2); font-size: 18px; line-height: 1; cursor: pointer; font-weight: 800; padding: 0; }
.moves { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 2px 4px; overflow-y: auto; flex: 1 1 auto; min-height: 0; font-size: 14px; font-variant-numeric: tabular-nums; }
.moves li { display: inline-flex; align-items: center; gap: 2px; }
.moves .num { color: var(--muted); font-weight: 700; font-size: 12.5px; padding-left: 4px; }
.mv { border: 0; background: none; padding: 3px 5px; border-radius: 6px; font-weight: 700; cursor: pointer; color: var(--text); font-size: 14px; }
.mv:hover { background: var(--chip); }
.mv.is-cur { background: var(--brand); color: #fff; }
.mv .tag { font-size: 11px; margin-left: 2px; font-weight: 800; }
.tag--blunder { color: #d63333; } .tag--mistake { color: #d97706; } .tag--inacc { color: #b59a00; } .tag--best { color: #1f9a57; }
.mv.is-cur .tag { color: #fff; }
.review { display: flex; flex-direction: column; gap: 4px; flex: 0 0 auto; }
.review-acc { display: flex; gap: 10px; flex-wrap: wrap; font-size: 13px; font-weight: 700; color: var(--text-2); }
.review-acc b { font-family: var(--font-display); font-size: 15px; color: var(--text); }
.graph { width: 100%; height: 56px; border-radius: 8px; background: #2a2236; cursor: pointer; display: block; }
.review-note { margin: 0; font-size: 13px; color: var(--text-2); line-height: 1.35; }
.analysis-tools { flex: 0 0 auto; }
.ana-line { font-size: 13px; color: var(--text-2); line-height: 1.35; min-height: 18px; overflow-wrap: anywhere; }
.banner { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(10px + var(--safe-b)); z-index: 12; display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line-strong); box-shadow: var(--shadow); font-size: 13px; font-weight: 700; max-width: calc(100% - 20px); }

/* sheets */
.sheet { position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; background: var(--scrim); padding: 16px; overflow-y: auto; }
.sheet-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: 20px; padding: 18px 18px 20px; box-shadow: var(--shadow); text-align: center; animation: scrIn .25s var(--ease); }
.sheet-t { margin: 0 0 4px; font-family: var(--font-display); font-size: 24px; font-weight: 800; line-height: 1.15; }
.sheet-s { margin: 0 0 6px; color: var(--text-2); font-size: 15px; line-height: 1.45; }
.sheet-k { margin: 6px 0 0; font-size: 13px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--brand-text); }
.res-big { font-family: var(--font-display); font-size: clamp(30px, 9vw, 40px); font-weight: 800; margin: 2px 0 2px; }
.res-facts { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 8px 0 2px; }
.res-facts span { padding: 4px 10px; border-radius: 999px; background: var(--chip); font-size: 13px; font-weight: 700; }
.chat-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.chat-list button { text-align: left; }
.sheet-card .txt { width: 100%; margin-top: 8px; }
.sheet-err { color: var(--warn); font-size: 14px; font-weight: 700; margin: 6px 0 0; min-height: 18px; }
.toast { position: absolute; left: 50%; top: calc(58px + var(--safe-t)); transform: translateX(-50%); z-index: 40; padding: 8px 16px; border-radius: 999px; background: #1d1430; color: #fff; font-weight: 700; font-size: 14px; box-shadow: var(--shadow); max-width: calc(100% - 24px); text-align: center; }

/* ---------- wide screens: board left, panel right ---------- */
@media (min-width: 860px) and (min-aspect-ratio: 5/4) {
  .bar-brand img { height: 24px; }
  .arena { display: grid; grid-template-columns: auto minmax(300px, 380px); grid-template-rows: auto auto auto minmax(0, 1fr) auto auto; column-gap: 18px; row-gap: 8px; justify-content: center; align-content: center; }
  .board-zone { grid-column: 1; grid-row: 1 / -1; align-self: center; }
  .strip--top { grid-column: 2; grid-row: 1; }
  .talk { grid-column: 2; grid-row: 2; }
  .goal { grid-column: 2; grid-row: 3; }
  .movebox { grid-column: 2; grid-row: 4; min-height: 120px; }
  .strip--bot { grid-column: 2; grid-row: 5; }
  .controls { grid-column: 2; grid-row: 6; }
}
@media (max-width: 380px) {
  .bar-brand img { height: 16px; }
  .icon-btn { width: 40px; height: 40px; }
  .clock { min-width: 70px; font-size: 18px; padding: 5px 8px; }
  .ctl span { font-size: 11px; }
}
