:root {
  --bg: #0a0c11; --ink: #e9ecf2; --muted: #8b93a7; --faint: #5d6476;
  --glass: rgba(22, 26, 36, .72); --glass2: rgba(255, 255, 255, .04); --line: rgba(255, 255, 255, .08);
  --gold: #e8b64c; --green: #81b64c; --green2: #95c95f;
  --size: min(calc(100vh - 230px), calc(100vw - 560px), 760px);
  /* move classification colors */
  --k-brilliant: #1baca6; --k-great: #5c8bb0; --k-best: #81b64c; --k-excellent: #81b64c; --k-good: #77915f;
  --k-inaccuracy: #f7c045; --k-mistake: #ffa459; --k-miss: #ff7769; --k-blunder: #fa412d; --k-forced: #8b93a7;
}
body[data-theme="walnut"]  { --l: #edd3a8; --d: #b2804f; --frame: linear-gradient(145deg, #6b4428, #2e1c0f); --tex: repeating-linear-gradient(93deg, rgba(60,30,0,.07) 0 2px, transparent 2px 9px), repeating-linear-gradient(87deg, rgba(255,240,210,.06) 0 1px, transparent 1px 14px); }
body[data-theme="emerald"] { --l: #ebecd0; --d: #739552; --frame: linear-gradient(145deg, #34412c, #141a10); --tex: none; }
body[data-theme="ocean"]   { --l: #dee3e6; --d: #7e97a6; --frame: linear-gradient(145deg, #2c3d4a, #111a21); --tex: none; }
body[data-theme="royal"]   { --l: #ebe3f6; --d: #8a6fc0; --frame: linear-gradient(145deg, #3d2c5c, #170f26); --tex: none; }
body[data-theme="slate"]   { --l: #c8d0db; --d: #5b6a80; --frame: linear-gradient(145deg, #2a3140, #0f1218); --tex: none; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh; color: var(--ink); font: 15px/1.45 "Outfit", "Segoe UI", system-ui, sans-serif;
  background:
    radial-gradient(1100px 700px at 12% -10%, rgba(64, 98, 160, .28), transparent 60%),
    radial-gradient(900px 700px at 105% 110%, rgba(129, 70, 170, .22), transparent 55%),
    radial-gradient(600px 400px at 60% 40%, rgba(232, 182, 76, .05), transparent 70%),
    var(--bg);
  background-attachment: fixed;
}
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- Header ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 28px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 26px;
        background: linear-gradient(145deg, #f3cf7a, #b9852a); color: #2a1a05; box-shadow: 0 6px 18px rgba(232,182,76,.35), inset 0 1px 0 rgba(255,255,255,.5); }
.brand b { display: block; font-size: 19px; letter-spacing: .3px; }
.brand small { color: var(--muted); font-size: 12px; letter-spacing: .5px; }
.tabs { display: flex; background: var(--glass); border: 1px solid var(--line); border-radius: 999px; padding: 4px; backdrop-filter: blur(14px); }
.tabs button { border: 0; background: none; padding: 8px 16px; border-radius: 999px; cursor: pointer; color: var(--muted); font-weight: 600; transition: .2s; }
.tabs button.on { background: linear-gradient(145deg, #95c95f, #5f9a36); color: #fff; box-shadow: 0 4px 14px rgba(129,182,76,.35); }
.tools { display: flex; align-items: center; gap: 10px; }
.swatches { display: flex; gap: 6px; }
.sw { width: 24px; height: 24px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; transition: transform .15s; }
.sw:hover { transform: scale(1.12); } .sw.on { border-color: #fff; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--glass); cursor: pointer; display: grid; place-items: center; font-size: 16px; }
.icon-btn:hover { background: rgba(255,255,255,.08); }

/* ---------- Layout ---------- */
.app { display: flex; gap: 26px; justify-content: center; align-items: flex-start; padding: 4px 24px 30px; }
.stage { display: flex; flex-direction: column; gap: 10px; }
.board-row { display: flex; gap: 12px; }

/* ---------- Player cards ---------- */
.pcard { display: flex; align-items: center; gap: 10px; height: 44px; padding-left: 34px; }
.avatar { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-size: 19px; font-weight: 700; flex: none; }
.avatar.w { background: linear-gradient(145deg, #fff, #c9ced6); color: #222; }
.avatar.b { background: linear-gradient(145deg, #3c414b, #12151a); color: #eee; border: 1px solid #444a55; }
.pname { font-weight: 600; } .pname small { color: var(--muted); font-weight: 400; margin-left: 4px; }
.caps { display: flex; align-items: center; height: 18px; }
.caps svg { width: 19px; height: 19px; margin-right: -6px; filter: none; }
.caps .adv { margin-left: 10px; font-size: 12px; color: var(--muted); font-weight: 600; }
.pcard .accchip { margin-left: auto; padding: 4px 10px; border-radius: 8px; font-weight: 700; font-size: 14px; background: var(--glass); border: 1px solid var(--line); }
.turn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green2); box-shadow: 0 0 10px var(--green2); margin-left: 4px; }

/* ---------- Eval bar ---------- */
.evalbar { width: 22px; border-radius: 6px; overflow: hidden; background: #2b2e35; position: relative; display: flex; flex-direction: column;
           box-shadow: 0 10px 30px rgba(0,0,0,.45), inset 0 0 0 1px rgba(255,255,255,.06); margin: 14px 0; }
.evalbar .fill { background: linear-gradient(90deg, #ffffff, #dfe3e8); transition: height .5s cubic-bezier(.2,.8,.2,1); margin-top: auto; height: 50%; }
.evalbar.flipped { flex-direction: column-reverse; }
.evalbar.flipped .fill { margin-top: 0; margin-bottom: auto; }
.evaltext { position: absolute; left: 0; right: 0; text-align: center; font-size: 10px; font-weight: 800; font-family: "JetBrains Mono", monospace; }
.evaltext.bot { bottom: 5px; color: #333; } .evaltext.top { top: 5px; color: #ddd; }

/* ---------- Board ---------- */
.frame { position: relative; padding: 14px; border-radius: 16px; background: var(--frame);
         box-shadow: 0 30px 60px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.06), inset 0 1px 0 rgba(255,255,255,.12); }
.board { width: var(--size); height: var(--size); min-width: 300px; min-height: 300px; display: grid; position: relative;
         grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr);
         border-radius: 6px; overflow: hidden; user-select: none; touch-action: none; box-shadow: 0 0 0 2px rgba(0,0,0,.35); }
.board::after { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 4;
                background: var(--tex), linear-gradient(135deg, rgba(255,255,255,.10), transparent 35%, transparent 65%, rgba(0,0,0,.10)); }
.sq { position: relative; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.sq.l { background: var(--l); } .sq.d { background: var(--d); }
.sq.last::before, .sq.sel::before { content: ""; position: absolute; inset: 0; }
.sq.last::before { background: rgba(255, 214, 70, .42); }
.sq.sel::before { background: rgba(255, 214, 70, .62); }
.sq.check { background-image: radial-gradient(circle, #ff5a4a 0%, rgba(240,40,30,.75) 35%, rgba(200,0,0,0) 72%); }
.sq.hint::after { content: ""; position: absolute; width: 30%; height: 30%; border-radius: 50%; background: rgba(20, 20, 20, .2); z-index: 2; }
.sq.hint.cap::after { width: 100%; height: 100%; border-radius: 0; background: radial-gradient(transparent 0 58%, rgba(20,20,20,.22) 60%); }
.sq:hover.hint::after { background: rgba(20,20,20,.32); }
.coord { position: absolute; font-size: calc(var(--size) / 50); font-weight: 700; pointer-events: none; z-index: 1; opacity: .9; }
.coord.r { top: 3px; left: 4px; } .coord.f { bottom: 1px; right: 5px; }
.sq.l .coord { color: var(--d); } .sq.d .coord { color: var(--l); }
.pc { width: 90%; height: 90%; position: relative; z-index: 2; pointer-events: none; filter: drop-shadow(0 3px 2px rgba(0,0,0,.32)); will-change: transform; }
.pc .detb { display: none; } .pc.pb .detb, .pc.pb .det { stroke: #e9e9e9; } .pc.pb .detb { display: inline; } .pc.pb .eye { fill: #e9e9e9; stroke: #e9e9e9; }
.dragging { position: fixed; pointer-events: none; z-index: 100; transform: translate(-50%, -50%) scale(1.08); }
.dragging .pc { width: 100%; height: 100%; filter: drop-shadow(0 10px 8px rgba(0,0,0,.4)); }
.arrows { position: absolute; left: 14px; top: 14px; width: var(--size); height: var(--size); min-width: 300px; min-height: 300px; pointer-events: none; z-index: 5; }
.badge { position: absolute; top: -2%; right: -2%; width: 38%; height: 38%; border-radius: 50%; z-index: 6; display: grid; place-items: center;
         color: #fff; font-weight: 800; font-size: calc(var(--size) / 44); box-shadow: 0 2px 6px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.35);
         border: 2px solid rgba(255,255,255,.9); animation: pop .32s cubic-bezier(.2,1.6,.4,1); letter-spacing: -1px; }
@keyframes pop { from { transform: scale(0); } to { transform: scale(1); } }
.sq.edge-r .badge { right: 1%; } .sq.edge-t .badge { top: 1%; }

/* ---------- Panel ---------- */
.panel { width: 400px; max-height: calc(var(--size) + 116px); display: flex; flex-direction: column; gap: 12px; overflow-y: auto; padding-right: 4px; }
.panel::-webkit-scrollbar, .moves::-webkit-scrollbar, .games::-webkit-scrollbar { width: 8px; }
.panel::-webkit-scrollbar-thumb, .moves::-webkit-scrollbar-thumb, .games::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 8px; }
.view { display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--glass); border: 1px solid var(--line); border-radius: 16px; padding: 16px; backdrop-filter: blur(16px);
        box-shadow: 0 12px 30px rgba(0,0,0,.25); display: flex; flex-direction: column; gap: 12px; }
.card-h { font-size: 12px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); font-weight: 700; }
.status { font-size: 18px; font-weight: 700; color: var(--gold); min-height: 26px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 600; letter-spacing: .4px; }
.seg { display: flex; background: rgba(0,0,0,.25); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: none; padding: 8px 10px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 600; transition: .15s; }
.seg button.on { background: rgba(255,255,255,.1); color: var(--ink); box-shadow: 0 2px 8px rgba(0,0,0,.3); }
select, input, textarea { width: 100%; background: rgba(0,0,0,.28); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none; }
select option { background: #1b1f29; }
input:focus, textarea:focus, select:focus { border-color: rgba(129,182,76,.6); box-shadow: 0 0 0 3px rgba(129,182,76,.15); }
textarea { min-height: 120px; resize: vertical; font-family: "JetBrains Mono", monospace; font-size: 12px; }
.btn { border: 1px solid var(--line); background: rgba(255,255,255,.06); padding: 10px 14px; border-radius: 10px; cursor: pointer; font-weight: 600; transition: .15s; }
.btn:hover { background: rgba(255,255,255,.12); transform: translateY(-1px); }
.btn:disabled { opacity: .4; cursor: default; transform: none; }
.btn.primary { background: linear-gradient(145deg, #95c95f, #5f9a36); border-color: transparent; color: #fff; box-shadow: 0 6px 16px rgba(129,182,76,.3); }
.btn.accent { background: linear-gradient(145deg, #f3cf7a, #c38e2c); border-color: transparent; color: #2a1a05; box-shadow: 0 6px 16px rgba(232,182,76,.25); }
.btn.wide { width: 100%; }
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.inrow { display: flex; gap: 8px; } .inrow input { flex: 1; }
.row { display: flex; gap: 8px; } .row .btn { flex: 1; }
.msg { font-size: 13px; color: var(--muted); min-height: 0; } .msg.err { color: #ff8a7a; }
.info { font-size: 11px; color: var(--faint); font-family: "JetBrains Mono", monospace; min-height: 14px; }

/* ---------- Move lists ---------- */
.moves { max-height: 260px; min-height: 120px; overflow-y: auto; font-family: "JetBrains Mono", monospace; font-size: 13.5px;
         display: grid; grid-template-columns: 38px 1fr 1fr; align-content: start; row-gap: 1px; }
.moves .n { color: var(--faint); padding: 4px 0; }
.moves .m { padding: 4px 8px; border-radius: 6px; cursor: default; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.moves.review .m { cursor: pointer; } .moves.review .m:hover { background: rgba(255,255,255,.06); }
.moves .m.cur { background: rgba(255,255,255,.12); font-weight: 700; }
.moves .row-alt { background: rgba(255,255,255,.02); }

/* classification icons */
.kb { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; color: #fff; font-style: normal; font-weight: 800;
      font-size: 10px; flex: none; letter-spacing: -.5px; font-family: "Outfit", sans-serif; box-shadow: inset 0 1px 0 rgba(255,255,255,.3); }
.kb.big { width: 40px; height: 40px; font-size: 18px; box-shadow: 0 4px 14px rgba(0,0,0,.3), inset 0 1px 0 rgba(255,255,255,.35); }
.k-brilliant { background: var(--k-brilliant); } .k-great { background: var(--k-great); } .k-best { background: var(--k-best); }
.k-excellent { background: var(--k-excellent); } .k-good { background: var(--k-good); } .k-inaccuracy { background: var(--k-inaccuracy); }
.k-mistake { background: var(--k-mistake); } .k-miss { background: var(--k-miss); } .k-blunder { background: var(--k-blunder); } .k-forced { background: var(--k-forced); }
.t-brilliant { color: var(--k-brilliant); } .t-great { color: var(--k-great); } .t-best, .t-excellent { color: var(--k-best); } .t-good { color: #9bb784; }
.t-inaccuracy { color: var(--k-inaccuracy); } .t-mistake { color: var(--k-mistake); } .t-miss { color: var(--k-miss); } .t-blunder { color: var(--k-blunder); } .t-forced { color: var(--muted); }

/* ---------- Game list ---------- */
.games { display: flex; flex-direction: column; gap: 6px; max-height: 430px; overflow-y: auto; }
.gitem { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px;
         background: var(--glass); border: 1px solid var(--line); cursor: pointer; transition: .15s; text-align: left; width: 100%; }
.gitem:hover { border-color: rgba(129,182,76,.5); transform: translateX(3px); background: rgba(30,36,48,.85); }
.res { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-weight: 800; font-size: 14px; }
.res.W { background: rgba(129,182,76,.18); color: var(--green2); } .res.L { background: rgba(250,65,45,.15); color: #ff7a6a; } .res.D { background: rgba(255,255,255,.08); color: var(--muted); }
.gmain { min-width: 0; } .gmain b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gmain small { color: var(--muted); font-size: 12px; }
.gside { text-align: right; font-size: 12px; color: var(--muted); }
.gside .tc { font-size: 15px; display: block; }

/* ---------- Review ---------- */
.game-h { display: flex; align-items: center; gap: 10px; }
.game-title { font-weight: 700; line-height: 1.25; min-width: 0; } .game-title small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress { position: relative; height: 22px; background: rgba(0,0,0,.3); border-radius: 999px; overflow: hidden; }
.progress .bar { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, #5f9a36, #95c95f); transition: width .3s; border-radius: 999px; }
.progress span { position: relative; display: block; text-align: center; font-size: 11.5px; line-height: 22px; font-weight: 700; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.graph { position: relative; height: 92px; border-radius: 10px; overflow: hidden; cursor: pointer; background: #2b2f37; box-shadow: inset 0 0 0 1px var(--line); }
.graph svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.gdot { position: absolute; width: 9px; height: 9px; border-radius: 50%; transform: translate(-50%, -50%); border: 1.5px solid #fff; pointer-events: none; }
.gcur { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--gold); transform: translateX(-1px); pointer-events: none; box-shadow: 0 0 8px var(--gold); }
.acc-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; }
.acc { text-align: center; padding: 12px 6px; border-radius: 14px; background: rgba(0,0,0,.22); }
.acc .avatar { margin: 0 auto 6px; }
.acc .nm { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc .num { font-size: 30px; font-weight: 800; letter-spacing: -.5px; line-height: 1.1; margin-top: 4px; }
.acc .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.acc.w .num { color: #fff; } .acc.b .num { color: #c9ced6; }
.vs { color: var(--faint); font-weight: 700; font-size: 12px; }
.ktable { display: flex; flex-direction: column; gap: 2px; }
.krow { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 5px 4px; border-radius: 8px; font-weight: 700; }
.krow:hover { background: rgba(255,255,255,.04); }
.krow .wc { text-align: center; } .krow .bc { text-align: center; }
.krow .kname { display: flex; align-items: center; gap: 8px; width: 140px; font-weight: 600; }
.krow .zero { color: var(--faint); font-weight: 500; }
.coach { gap: 10px; border-width: 1px; position: relative; overflow: hidden; }
.coach::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--kc, var(--line)); }
.coach-h { display: flex; gap: 12px; align-items: center; }
.coach-t { font-size: 17px; font-weight: 600; line-height: 1.3; } .coach-t b { font-family: "JetBrains Mono", monospace; }
.coach-sub { font-size: 12px; color: var(--muted); }
.evchip { margin-left: auto; font-family: "JetBrains Mono", monospace; font-weight: 700; font-size: 13px; padding: 5px 9px; border-radius: 8px; flex: none; }
.evchip.w { background: #f1f3f5; color: #222; } .evchip.b { background: #15181d; color: #eee; border: 1px solid #3a3f49; }
.coach-b p { margin: 0 0 8px; color: #cfd5e0; } .coach-b p:last-child { margin: 0; }
.coach-b b { color: #fff; font-family: "JetBrains Mono", monospace; font-size: 13.5px; }
.bestline { background: rgba(129,182,76,.1); border: 1px solid rgba(129,182,76,.25); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.bestline .bh { display: flex; align-items: center; gap: 8px; font-weight: 600; } .bestline .bh b { font-family: "JetBrains Mono", monospace; }
.bestline .ln { font-family: "JetBrains Mono", monospace; font-size: 12px; color: #a9b8a0; }
.nav { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.nav .btn { padding: 12px 0; font-size: 16px; }
.nav.nav4 { grid-template-columns: repeat(4, 1fr); margin-top: 10px; }
.nav.nav4 .btn:disabled { opacity: .35; cursor: default; }
.nav.nav4.browsing [data-nav="last"] { background: var(--green); color: #fff; animation: navPulse 1.4s ease-in-out infinite; }
@keyframes navPulse { 50% { filter: brightness(1.25); } }
#moves .m[data-i] { cursor: pointer; } #moves .m[data-i]:hover { background: rgba(255,255,255,.06); }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.2); border-top-color: var(--green2); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; color: var(--muted); padding: 20px 10px; font-size: 14px; }
.empty .big { font-size: 42px; display: block; margin-bottom: 6px; }

/* ---------- Promotion ---------- */
.promo { position: fixed; inset: 0; background: rgba(5,7,10,.65); backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center; z-index: 200; }
.promo.show { display: flex; }
.promo > div { background: var(--glass); border: 1px solid var(--line); padding: 16px; border-radius: 16px; display: flex; gap: 10px; }
.promo button { width: 82px; height: 82px; padding: 8px; background: var(--l); border: 0; border-radius: 12px; cursor: pointer; transition: transform .15s; }
.promo button:hover { transform: scale(1.08); }
.promo button svg { width: 100%; height: 100%; }

@media (max-width: 1000px) {
  :root { --size: min(calc(100vw - 92px), 640px); }
  .app { flex-direction: column; align-items: center; padding: 4px 12px 30px; }
  .panel { width: min(100%, calc(var(--size) + 64px)); max-height: none; overflow: visible; }
  .top { padding: 12px 16px; justify-content: center; }
  .frame { padding: 8px; } .arrows { left: 8px; top: 8px; }
}

/* ---------- Puzzles ---------- */
.pz-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.pz-stats > div { background: rgba(0,0,0,.22); border-radius: 12px; padding: 10px 4px; }
.pz-num { display: block; font-size: 26px; font-weight: 800; line-height: 1.1; }
.pz-stats > div:first-child .pz-num { color: var(--gold); }
.pz-lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; }
.levels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.lvl-chip { border: 1px solid var(--line); background: rgba(0,0,0,.22); border-radius: 10px; padding: 7px 4px; cursor: pointer; transition: .15s; display: flex; flex-direction: column; align-items: center; }
.lvl-chip b { font-size: 13px; } .lvl-chip small { font-size: 10.5px; color: var(--muted); }
.lvl-chip:hover { border-color: rgba(255,255,255,.25); }
.lvl-chip.on { background: linear-gradient(145deg, rgba(149,201,95,.25), rgba(95,154,54,.2)); border-color: rgba(149,201,95,.7); }
.pz-status { gap: 10px; position: relative; overflow: hidden; }
.pz-status::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--line); }
.pz-status.good::before { background: var(--k-best); } .pz-status.bad::before { background: var(--k-blunder); }
.pz-status.hint::before { background: var(--k-inaccuracy); } .pz-status.play::before { background: var(--gold); }
.pz-h { display: flex; gap: 12px; align-items: center; }
.pz-ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; font-weight: 800; flex: none; background: rgba(255,255,255,.08); }
.pz-status.good .pz-ic { background: var(--k-best); color: #fff; } .pz-status.bad .pz-ic { background: var(--k-blunder); color: #fff; }
.pz-status.hint .pz-ic { background: var(--k-inaccuracy); } .pz-status.play .pz-ic { background: linear-gradient(145deg, #f3cf7a, #c38e2c); color: #2a1a05; }
.pz-t { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.pz-s { font-size: 13px; color: var(--muted); }
.delta { font-size: 13px; padding: 2px 8px; border-radius: 6px; font-weight: 700; }
.delta.up { background: rgba(129,182,76,.2); color: var(--green2); } .delta.down { background: rgba(250,65,45,.18); color: #ff7a6a; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: rgba(255,255,255,.07); border: 1px solid var(--line); color: #cfd5e0; text-decoration: none; }
.tag.lvl { color: var(--gold); } .tag.link:hover { border-color: rgba(255,255,255,.3); }
.ana-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
#anaBtn.on { border-color: rgba(92,139,176,.7); background: rgba(92,139,176,.18); }
.alines { display: flex; flex-direction: column; gap: 4px; }
.aline { display: flex; gap: 10px; align-items: center; text-align: left; border: 1px solid transparent; background: rgba(0,0,0,.2); border-radius: 10px; padding: 7px 8px; cursor: pointer; }
.aline:hover { border-color: rgba(92,139,176,.6); }
.aline .evchip { margin: 0; min-width: 56px; text-align: center; }
.aln { font-family: "JetBrains Mono", monospace; font-size: 12px; color: #cfd5e0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pz-hist { display: flex; flex-wrap: wrap; gap: 5px; }
.hchip { width: 42px; height: 40px; border-radius: 9px; border: 0; cursor: pointer; font-weight: 800; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05; }
.hchip small { font-size: 10px; font-weight: 600; opacity: .85; }
.hchip.ok { background: rgba(129,182,76,.2); color: var(--green2); } .hchip.no { background: rgba(250,65,45,.16); color: #ff7a6a; }
.hchip:hover { filter: brightness(1.3); }
.linkbtn { background: none; border: 0; color: var(--faint); font-size: 12px; cursor: pointer; text-decoration: underline; }
.linkbtn:hover { color: #ff8a7a; }

.caps svg.pb { filter: drop-shadow(0 0 1px rgba(255,255,255,.75)); }

/* ---------- Phone / home-screen app ---------- */
body { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); -webkit-tap-highlight-color: transparent; }
button, .sq { touch-action: manipulation; }
.board, .pcard, .evalbar { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
@media (max-width: 600px) {
  .top { gap: 10px; padding: 10px 12px 6px; }
  .brand small { display: none; }
  .tabs { order: 3; width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); border-radius: 16px; }
  .tabs button { padding: 8px 4px; font-size: 13px; border-radius: 12px; }
  :root { --size: min(calc(100vw - 64px), 640px); }
  .board-row { gap: 6px; }
  .evalbar { width: 16px; }
  .pcard { padding-left: 22px; }
  .panel { width: 100%; }
  .card { padding: 14px; border-radius: 14px; }
  .levels { grid-template-columns: repeat(4, 1fr); }
  input, textarea, select { font-size: 16px; } /* stops iOS zooming into inputs */
}

/* ---------- Openings ---------- */
.op-feed { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; }
.op-note.coach { border-left-color: var(--k-great); background: rgba(92,139,176,.12); }
.op-note.surprise { border-left-color: var(--k-brilliant); background: rgba(27,172,166,.12); }
.op-note.bad { border-left-color: var(--k-mistake); }
.op-body { font-size: 14px; line-height: 1.5; }
.op-body p { margin: 0 0 8px; } .op-body p:last-child { margin-bottom: 0; }
.op-ok { color: var(--green2); font-weight: 600; } .op-task { color: var(--gold); font-weight: 600; }
.op-opts { display: flex; flex-direction: column; gap: 6px; }
.op-opt { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.op-opt select { width: auto; padding: 4px 8px; }
.sq.mark { box-shadow: inset 0 0 0 4px rgba(232,182,76,.9); }
#opModeSeg button { padding: 8px 4px; font-size: 13px; }
.op-note { font-size: 13.5px; line-height: 1.45; padding: 8px 10px; border-radius: 10px; background: rgba(0,0,0,.22); border-left: 3px solid var(--line); }
.op-note.me { border-left-color: var(--k-best); } .op-note.them { border-left-color: var(--gold); }
.op-note b { font-family: "JetBrains Mono", monospace; }
.op-lines { display: flex; flex-direction: column; gap: 4px; max-height: 340px; overflow-y: auto; }
.op-group { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--faint); font-weight: 700; margin: 8px 2px 2px; }
.op-group:first-child { margin-top: 0; }
.op-line { display: flex; align-items: center; gap: 8px; border: 1px solid transparent; background: rgba(0,0,0,.18); color: var(--ink); border-radius: 9px; padding: 7px 10px; cursor: pointer; text-align: left; font: inherit; font-size: 13.5px; }
.op-line:hover { border-color: rgba(255,255,255,.18); }
.op-line.on { border-color: rgba(149,201,95,.7); background: rgba(129,182,76,.14); }
.op-line .st { width: 20px; text-align: center; flex: none; }
.op-line .nm { flex: 1; }
.op-line .stars { color: var(--gold); font-size: 12px; letter-spacing: 1px; flex: none; }
.op-line .stars i { color: var(--faint); font-style: normal; }
#opSeg button { font-size: 13px; }
.op-opt input[type=checkbox] { width: auto; margin: 0; }

/* ---------- Vision ---------- */
.v-drills { grid-template-columns: repeat(3, 1fr); }
.v-drills .lvl-chip b { font-size: 12.5px; text-align: center; }
.v-prompt { font: 800 64px/1.1 "JetBrains Mono", monospace; text-align: center; color: var(--gold); letter-spacing: 2px; }
.v-prompt.small { font-size: 26px; }
.v-opts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.v-opts .btn { font: 700 22px "JetBrains Mono", monospace; padding: 14px; }
.v-opts .btn small { font-size: 11px; color: var(--faint); margin-left: 6px; }
.v-bar { display: flex; justify-content: space-between; font: 700 18px "JetBrains Mono", monospace; }
.v-time { color: var(--gold); } .v-score { color: var(--green2); } .v-miss { color: #ff7a6a; }
.v-start { padding: 14px; font-size: 17px; }
.sq.tint-good::before, .sq.tint-bad::before, .sq.tint-pick::before, .sq.tint-trail::before { content: ""; position: absolute; inset: 0; }
.sq.tint-good::before { background: rgba(129,182,76,.7); } .sq.tint-bad::before { background: rgba(250,65,45,.6); }
.sq.tint-pick::before { background: rgba(92,139,176,.6); } .sq.tint-trail::before { background: rgba(232,182,76,.3); }
.board.blind .sq { background: #39404b !important; } .board.blind .sq.mark { box-shadow: none; }
/* ---------- Endgames ---------- */
#egTb { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 5px; }
#egTb .card-h { grid-column: 1 / -1; }
.eg-mv { display: flex; align-items: center; gap: 6px; border: 1px solid transparent; background: rgba(0,0,0,.2); border-radius: 8px; padding: 6px 8px; cursor: pointer; color: var(--ink); font: inherit; font-size: 13px; }
.eg-mv:hover { border-color: rgba(255,255,255,.2); }
.eg-mv b { font-family: "JetBrains Mono", monospace; min-width: 44px; text-align: left; }
.eg-r { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 5px; }
.eg-r.w { background: rgba(129,182,76,.25); color: var(--green2); } .eg-r.d { background: rgba(255,255,255,.1); color: var(--muted); } .eg-r.l { background: rgba(250,65,45,.2); color: #ff7a6a; }
.eg-mv small { color: var(--faint); margin-left: auto; }

/* ---------- Online ---------- */
.acct-btn { height: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--glass); cursor: pointer; font-weight: 600; font-size: 13px; color: var(--ink); white-space: nowrap; }
.acct-btn:hover { background: rgba(255,255,255,.08); }
.login { position: fixed; inset: 0; z-index: 50; background: rgba(5,7,10,.78); backdrop-filter: blur(6px); display: grid; place-items: center; padding: 16px; }
.login-box { width: min(380px, 100%); background: var(--glass); border: 1px solid var(--line); border-radius: 18px; padding: 22px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.5); background-color: #12151b; }
.lg-l { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--muted); }
.lg-l small { font-weight: 400; color: var(--faint); }
.lg-err { color: #ff7a6a; font-size: 13px; min-height: 18px; }
.login .linkbtn { align-self: center; }
.on-msg { margin-top: 8px; }
.on-push { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.on-friend { display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-bottom: 1px solid var(--line); }
.on-friend .nm { flex: 1; font-weight: 600; }
.on-friend .btn { padding: 6px 12px; }
.on-friend .nm small { display: block; font-weight: 400; font-size: 11.5px; color: var(--muted); }
.on-more { font-size: 20px; line-height: 1; padding: 2px 8px; text-decoration: none; }
.on-dot { width: 10px; height: 10px; border-radius: 50%; background: #4a505c; flex: none; }
.on-dot.on { background: var(--green2); box-shadow: 0 0 8px var(--green2); }
.on-inv { display: flex; flex-direction: column; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.on-inv .btn { padding: 7px 8px; font-size: 13px; }
.on-seats { display: flex; flex-direction: column; gap: 6px; }
.on-seats > div { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.on-empty { opacity: .5; border-style: dashed; }
.on-invbtn { cursor: pointer; } .on-invbtn:hover { border-color: var(--green2); }
.on-order { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; }
.on-order span { padding: 3px 9px; border-radius: 999px; background: rgba(255,255,255,.06); border: 1px solid var(--line); }
.on-order span.now { background: rgba(232,182,76,.22); border-color: var(--gold); color: var(--gold); font-weight: 700; }
.on-order i { color: var(--faint); font-style: normal; }
#onGames .op-line .tag { flex: none; }
.on-size { width: auto !important; white-space: nowrap; font-size: 12px; color: var(--muted); }

/* ---------- Live coach (Play) ---------- */
.coach-toggle { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--muted); cursor: pointer; user-select: none; }
.coach-toggle input { display: none; }
.coach-toggle .tg { width: 36px; height: 20px; border-radius: 999px; background: rgba(255,255,255,.12); position: relative; flex: none; transition: background .2s; }
.coach-toggle .tg::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .25s cubic-bezier(.3,1.5,.5,1); }
.coach-toggle input:checked + .tg { background: var(--green); }
.coach-toggle input:checked + .tg::after { transform: translateX(16px); }
.play-coach .coach-hd { min-width: 0; }
.coach-x { margin-left: 4px; border: 0; background: none; color: var(--faint); cursor: pointer; font-size: 14px; padding: 4px; border-radius: 6px; flex: none; }
.coach-x:hover { color: var(--ink); background: rgba(255,255,255,.08); }
.play-coach .evchip { margin-left: auto; }
.coach-act { display: flex; gap: 8px; } .coach-act .btn { flex: 1; }
.kb.k-hint { background: linear-gradient(145deg, #f3cf7a, #c38e2c); }
.kb.k-thinking { background: rgba(255,255,255,.08); }
.bestline .bwhy { font-size: 13.5px; color: #cfd8c6; }
.coach-b .why-line { font-size: 13px; color: var(--muted); } .coach-b .why-line b { font-size: 12.5px; color: #dfe6d8; }
.coach-b .why-eval { font-size: 13px; color: var(--muted); }
.coach-b .bestline { margin-top: 8px; }

/* ---------- Motion ---------- */
@keyframes riseIn { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes glowPulse { 0%, 100% { box-shadow: 0 0 6px var(--green2); } 50% { box-shadow: 0 0 16px 3px var(--green2); } }
@keyframes checkPulse { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.35); } }
@keyframes arrowIn { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }
@keyframes curPop { 0% { transform: scale(.9); } 60% { transform: scale(1.06); } 100% { transform: none; } }
@keyframes burst { 0% { transform: scale(.2); opacity: .9; } 100% { transform: scale(1.9); opacity: 0; } }
@keyframes spark { 0% { transform: translate(0, 0) scale(1); opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)) scale(.2); opacity: 0; } }
@keyframes confetti { 0% { transform: translate(0, -10vh) rotate(0); opacity: 1; } 100% { transform: translate(var(--dx), 105vh) rotate(var(--rot)); opacity: .9; } }
@keyframes shimmer { from { background-position: -200% 0; } to { background-position: 200% 0; } }

.panel > .view:not([hidden]), .view > .view:not([hidden]) { animation: riseIn .35s cubic-bezier(.2,.8,.2,1) both; }
.card { transition: border-color .25s, box-shadow .25s, transform .25s; }
.card:hover { border-color: rgba(255,255,255,.13); }
.anim-in { animation: riseIn .4s cubic-bezier(.2,.9,.25,1) both; }
.coach::before { transition: background .4s; }
.coach .kb.big { animation: pop .4s cubic-bezier(.2,1.6,.4,1); }
.coach-b p, .coach-b .bestline { animation: riseIn .45s cubic-bezier(.2,.8,.2,1) both; }
.coach-b > :nth-child(2) { animation-delay: .06s; } .coach-b > :nth-child(3) { animation-delay: .12s; }
.coach-b > :nth-child(4) { animation-delay: .18s; } .coach-b > :nth-child(5) { animation-delay: .24s; }
.turn-dot { animation: glowPulse 1.6s ease-in-out infinite; }
.sq.check { animation: checkPulse .9s ease-in-out 2; }
.sq.last::before { animation: fadeIn .3s ease-out; }
.arrows polygon { transform-box: fill-box; transform-origin: center; animation: arrowIn .35s cubic-bezier(.2,1.3,.4,1) both; }
.moves .m.cur { animation: curPop .3s ease-out; }
.btn:active:not(:disabled) { transform: translateY(1px) scale(.97); transition-duration: .05s; }
.btn.primary, .btn.accent { background-size: 200% 100%; position: relative; overflow: hidden; }
.btn.primary::after, .btn.accent::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .3s;
  background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.28) 50%, transparent 70%) 0 0 / 200% 100%; }
.btn.primary:hover::after, .btn.accent:hover::after { opacity: 1; animation: shimmer 1.1s linear infinite; }
.progress .bar { background-size: 200% 100%; background-image: linear-gradient(90deg, #5f9a36, #95c95f, #5f9a36); animation: shimmer 2.2s linear infinite; }
.fx-burst { position: absolute; inset: 8%; border-radius: 50%; border: 3px solid rgba(255,220,120,.9); pointer-events: none; z-index: 7; animation: burst .5s ease-out forwards; }
.fx-spark { position: absolute; left: 50%; top: 50%; width: 7px; height: 7px; margin: -3.5px; border-radius: 50%; pointer-events: none; z-index: 7;
            background: #ffd66e; box-shadow: 0 0 6px #ffb84a; animation: spark .55s cubic-bezier(.2,.7,.3,1) forwards; }
.fx-confetti { position: fixed; top: 0; width: 9px; height: 14px; border-radius: 2px; pointer-events: none; z-index: 300; animation: confetti linear forwards; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .fx-burst, .fx-spark, .fx-confetti { display: none; }
}

/* ---------- chat ---------- */
.on-chat { display: flex; flex-direction: column; gap: 8px; }
.on-chat .ch-title { display: flex; align-items: center; gap: 7px; text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--ink); }
.on-chat .ch-title small { color: var(--muted); font-weight: 400; font-size: 12px; }
.ch-list { display: flex; flex-direction: column; gap: 4px; max-height: 260px; min-height: 70px; overflow-y: auto; padding: 4px 2px; overscroll-behavior: contain; }
.ch-empty { margin: auto; }
.ch-m { align-self: flex-start; max-width: 82%; background: rgba(255,255,255,.07); border: 1px solid var(--line); border-radius: 14px 14px 14px 4px; padding: 6px 10px; font-size: 14px; line-height: 1.35; overflow-wrap: anywhere; animation: rise .18s ease-out both; }
.ch-m.me { align-self: flex-end; background: rgba(129,182,76,.2); border-color: rgba(149,201,95,.35); border-radius: 14px 14px 4px 14px; }
.ch-m b { display: block; font-size: 11.5px; color: var(--gold); }
.ch-m i { font-style: normal; font-size: 10.5px; color: var(--muted); margin-left: 8px; white-space: nowrap; }
.ch-quick { display: flex; gap: 5px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.ch-quick .tag { cursor: pointer; flex: none; font: inherit; font-size: 12px; } .ch-quick .tag:hover { border-color: var(--green2); }
.ch-form input { font-size: 16px; } /* 16px stops iPhone from zooming in */
.on-chatbtn { position: relative; padding: 6px 10px !important; }
.on-chatbtn.on { border-color: var(--green2); }
.ch-dot { position: absolute; top: -3px; right: -3px; width: 10px; height: 10px; border-radius: 50%; background: #fa412d; box-shadow: 0 0 6px #fa412d; }
.ch-new { color: var(--green2) !important; font-weight: 600 !important; }
#acctBtn.ch-has { border-color: var(--green2); }
.ch-toast { position: fixed; left: 50%; bottom: 18px; transform: translate(-50%, 140%); z-index: 60; display: flex; flex-direction: column; gap: 2px; text-align: left; max-width: min(420px, calc(100vw - 32px));
  background: rgba(22,26,36,.96); color: var(--ink); border: 1px solid rgba(149,201,95,.5); border-radius: 14px; padding: 10px 14px; font: inherit; font-size: 14px; cursor: pointer;
  box-shadow: 0 10px 30px rgba(0,0,0,.5); transition: transform .25s ease; }
.ch-toast.show { transform: translate(-50%, 0); }
.ch-toast span { color: #cfd5e0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
