/* SPDX-License-Identifier: AGPL-3.0-or-later
   Copyright (C) 2026 The Delvin authors */
/* Slate and shell: a calm, cool page so the wooden board and the stones are the colourful things. */
@font-face{font-family:Fredoka;font-weight:300 700;font-display:swap;src:url(fonts/fredoka-latin.woff2) format('woff2');
  unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215}
@font-face{font-family:Vazirmatn;font-weight:100 900;font-display:swap;src:url(fonts/vazirmatn-arabic.woff2) format('woff2');
  unicode-range:U+0600-06FF,U+200C-200F,U+0750-077F,U+FB50-FDFF,U+FE70-FEFF}

:root{
  --mist:#EDF2F1; --paper:#FFFFFF; --ink:#1F2D36; --ink-2:#4A5C66; --line:#D3DEDC; --wash:#E2EBEA;
  --primary:#0B7A78; --primary-press:#09615F; --primary-edge:#064645; --accent:#12A3A0; --tint:#D5F0EE;
  --saffron:#F4B23E; --saffron-deep:#A66A00; --berry:#B3243D; --berry-tint:#FBE3E7; --coral:#D04A2B;
  --kaya:#E5B05C; --stone-b:#1F2D36; --shell:#F7F3EA;
  --shadow:0 1px 2px rgba(20,40,50,.08),0 6px 18px rgba(20,40,50,.08);
  --ease:cubic-bezier(.2,.8,.2,1);
  --safe-b:env(safe-area-inset-bottom,0px); --safe-t:env(safe-area-inset-top,0px);
}
@media (prefers-color-scheme:dark){:root{
  --mist:#0E181E; --paper:#172830; --ink:#E9F1F0; --ink-2:#9DB0B8; --line:#2A3E48; --wash:#1F323B;
  --primary:#17A9A5; --primary-press:#128E8B; --primary-edge:#0A5C5A; --tint:#143B3C; --berry:#FF8C9E; --berry-tint:#3A1D26; --saffron-deep:#F4B23E; --coral:#FF8A6B;
  --shadow:0 1px 2px rgba(0,0,0,.4),0 6px 18px rgba(0,0,0,.35);
}}

*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{height:100%}
body{margin:0;background:var(--mist);color:var(--ink);font:400 17px/1.5 Fredoka,Vazirmatn,system-ui,sans-serif;
  -webkit-text-size-adjust:100%;touch-action:manipulation;overscroll-behavior:none}
html[lang=fa] body{line-height:1.75}
button{font:inherit;color:inherit;border:0;background:none;padding:0;cursor:pointer}
h1,h2,h3,p{margin:0}
:focus-visible{outline:3px solid var(--accent);outline-offset:2px;border-radius:10px}
.keys{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.25fr);gap:10px 14px;align-items:center;margin:0}   /* the shortcuts sheet: keys, then what they do */
.keys dt{display:flex;flex-wrap:wrap;gap:4px}[dir=rtl] .keys dt{justify-content:flex-end}.keys dd{margin:0;color:var(--ink-2);font-size:15px}
kbd{display:inline-block;min-width:1.7em;padding:2px 7px;border-radius:7px;background:var(--wash);box-shadow:inset 0 -2px 0 var(--line);font-family:inherit;font-weight:600;font-size:13px;line-height:1.5;text-align:center;white-space:nowrap}
#notice:empty{display:none}
#notice{position:fixed;z-index:60;top:calc(var(--safe-t) + 10px);inset-inline:12px;margin-inline:auto;max-width:520px;display:flex;flex-wrap:wrap;align-items:center;gap:6px 12px;
  padding:12px 14px;border-radius:18px;background:var(--paper);color:var(--ink);box-shadow:var(--shadow),0 0 0 1px var(--line);font-size:16px;line-height:1.4}   /* install and update notices (browser version) */
#notice span{flex:1 1 220px}
#notice .btn.small{min-height:40px;padding:0 16px}
.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}   /* read by screen readers only */
svg.board:focus{outline:none}svg.board:focus-visible{outline:3px solid var(--accent);outline-offset:3px;border-radius:18px}
.iconbtn.nudge{animation:nudge 1.4s ease-in-out 3;box-shadow:0 0 0 3px var(--accent)}
@keyframes nudge{50%{transform:scale(1.12)}}
.ic{width:24px;height:24px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;flex:none}
[dir=rtl] .flip{transform:scaleX(-1)}

#app{height:100dvh;display:flex;flex-direction:column;max-width:560px;margin:0 auto;position:relative;overflow:hidden;padding-left:env(safe-area-inset-left,0px);padding-right:env(safe-area-inset-right,0px);box-sizing:border-box}   /* landscape notch, installed as an app */
.screen{flex:1;overflow-y:auto;overflow-x:hidden;padding:0 16px 24px;-webkit-overflow-scrolling:touch}

/* ---------- top bar ---------- */
.topbar{display:flex;align-items:center;gap:8px;min-height:64px;padding:calc(var(--safe-t) + 8px) 12px 8px 16px}
[dir=rtl] .topbar{padding:calc(var(--safe-t) + 8px) 16px 8px 12px}
.topbar .grow{flex:1;min-width:0}
.topbar h1{font-size:22px;font-weight:600;line-height:1.2;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.iconbtn{flex:none;width:48px;height:48px;border-radius:24px;display:grid;place-items:center;color:var(--ink);transition:background .15s}
.iconbtn:active{background:var(--wash)}
.chip{display:inline-flex;align-items:center;gap:6px;min-height:40px;padding:0 14px;border-radius:20px;background:var(--paper);box-shadow:var(--shadow);font-weight:500;font-size:15px}

/* ---------- tab bar ---------- */
.tabbar{display:flex;background:var(--paper);box-shadow:0 -1px 0 var(--line);padding:6px 8px calc(var(--safe-b) + 6px)}
.tab{flex:1;min-height:56px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;font-size:13px;font-weight:500;color:var(--ink-2);border-radius:14px}
.tab[aria-current=page]{color:var(--primary)}
.tab[aria-current=page] .ic{stroke-width:2.4}
.tab .pip{width:28px;height:3px;border-radius:2px;background:transparent;margin-top:1px}
.tab[aria-current=page] .pip{background:var(--primary)}

/* ---------- buttons ---------- */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:52px;padding:0 24px;border-radius:26px;font-weight:600;font-size:18px;
  background:var(--paper);color:var(--ink);box-shadow:inset 0 0 0 2px var(--line);transition:transform .08s var(--ease),box-shadow .08s}
.btn:active{transform:translateY(2px)}
.btn.primary{background:var(--primary);color:#fff;box-shadow:0 4px 0 var(--primary-edge)}
.btn.primary:active{transform:translateY(3px);box-shadow:0 1px 0 var(--primary-edge)}
.btn.good{background:#0B7A78;animation:pop .35s var(--ease)}
.btn.danger{color:var(--berry);box-shadow:inset 0 0 0 2px var(--berry)}
.btn.big{min-height:60px;font-size:19px;width:100%}
.btn[disabled]{opacity:.4;pointer-events:none;box-shadow:none}
.btn.primary[disabled]{opacity:1;background:var(--wash);color:var(--ink-2);box-shadow:0 4px 0 var(--line)}
.btn.small{min-height:44px;font-size:16px;padding:0 18px}

/* ---------- learn: path of stones ---------- */
.hero{padding:4px 4px 16px}
.hero h2{font-size:30px;font-weight:600;line-height:1.15}
.hero p{color:var(--ink-2);margin-top:4px}
.hero .btn{margin-top:16px}
.path{position:relative;margin:8px 0 8px}
.path svg.route{position:absolute;inset:0;width:100%;height:100%;overflow:visible}
.path .seg{fill:none;stroke:var(--line);stroke-width:5;stroke-linecap:round;stroke-dasharray:1 12;vector-effect:non-scaling-stroke}
.path .seg.done{stroke:var(--accent);stroke-dasharray:none;stroke-width:6}
.node{position:absolute;transform:translateX(-50%);width:44%;display:flex;flex-direction:column;align-items:center;gap:8px;text-align:center}
.node .stone{width:76px;height:76px;border-radius:50%;display:grid;place-items:center;position:relative;transition:transform .12s var(--ease)}
.node:active .stone{transform:scale(.94)}
.node .stone .ic{width:34px;height:34px;stroke-width:1.9}
.node.todo .stone{background:radial-gradient(circle at 35% 30%,#fff,#f1ece0 60%,#cbc2ae);color:#1F2D36;box-shadow:0 5px 0 #b9af9a,0 10px 14px rgba(20,40,50,.15)}
.node.current .stone{background:radial-gradient(circle at 35% 30%,#5d6f7a,#26343c 45%,#0d151a);color:#fff;box-shadow:0 5px 0 #05090c,0 10px 14px rgba(20,40,50,.3)}
.node.current .stone::after{content:"";position:absolute;inset:-9px;border-radius:50%;border:3px solid var(--accent);animation:ring 1.8s ease-out infinite}
.node.done .stone{background:radial-gradient(circle at 35% 30%,#4fd0cb,#12A3A0 55%,#0B7A78);color:#fff;box-shadow:0 5px 0 var(--primary-edge),0 10px 14px rgba(20,40,50,.2)}
.node .badge{position:absolute;inset-inline-end:-6px;top:-6px;width:28px;height:28px;border-radius:50%;background:var(--saffron);color:#5a3a00;display:grid;place-items:center;box-shadow:0 2px 0 #b97d0c}
.node .badge .ic{width:16px;height:16px;stroke-width:3}
.node .name{font-weight:600;font-size:16px;line-height:1.25}
.node.todo .name{color:var(--ink-2)}
.node .go{font-size:13px;font-weight:600;color:#fff;background:var(--primary);border-radius:12px;padding:1px 10px}

/* ---------- tiles (puzzles, play) ---------- */
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.cat{display:flex;flex-direction:column;align-items:flex-start;gap:12px;min-height:150px;padding:16px;border-radius:22px;background:var(--paper);box-shadow:var(--shadow);text-align:start;position:relative}
.cat:active{transform:scale(.98)}
.cat .badge-ic{width:52px;height:52px;border-radius:16px;display:grid;place-items:center;background:var(--tint);color:var(--primary)}
.cat h3{font-size:18px;font-weight:600;line-height:1.25}
.cat .meter{height:8px;border-radius:4px;background:var(--wash);width:100%;overflow:hidden;margin-top:auto}
.cat .meter i{display:block;height:100%;background:var(--accent);border-radius:4px}
.cat small{color:var(--ink-2);font-size:14px}
.cat.wide{grid-column:1/-1;min-height:128px}
.cat.t1 .badge-ic{background:#DDF3F1;color:#0B7A78}.cat.t2 .badge-ic{background:#FCEBC8;color:#8A5600}
.cat.t3 .badge-ic{background:#E5E9FA;color:#3A4DA8}.cat.t4 .badge-ic{background:#FBE3E7;color:#B3243D}.cat.t5 .badge-ic{background:#E3F2D9;color:#2F6B1F}
@media (prefers-color-scheme:dark){.cat.t1 .badge-ic,.cat.t2 .badge-ic,.cat.t3 .badge-ic,.cat.t4 .badge-ic,.cat.t5 .badge-ic{background:var(--wash);color:var(--accent)}}
.play-tile{display:flex;align-items:center;gap:16px;width:100%;min-height:112px;padding:20px;border-radius:26px;text-align:start;margin-bottom:12px;position:relative;overflow:hidden;box-shadow:var(--shadow)}
.play-tile:active{transform:scale(.985)}
.play-tile h3{font-size:22px;font-weight:600;line-height:1.2}
.play-tile p{font-size:15px;opacity:.85;margin-top:2px}
.play-tile .art{flex:none;width:64px;height:64px}
.play-tile.cpu{background:linear-gradient(135deg,#27414d,#1F2D36);color:#fff}
.play-tile.friend{background:linear-gradient(135deg,#12A3A0,#0B7A78);color:#fff}
.play-tile.ai{min-height:84px;background:var(--paper);color:var(--ink);box-shadow:inset 0 0 0 2px var(--line)}
.status-chip{margin-inline-start:auto;font-size:14px;font-weight:600;padding:4px 12px;border-radius:14px;background:var(--wash);color:var(--ink-2);white-space:nowrap}
.status-chip.ok{background:var(--tint);color:var(--primary)}.status-chip.bad{background:var(--berry-tint);color:var(--berry)}

/* ---------- focus screens (lesson, game) ---------- */
.focus{display:flex;flex-direction:column;flex:1;min-height:0}
.focus .body{flex:1;min-height:0;overflow-y:auto;padding:0 16px 8px;display:flex;flex-direction:column;gap:12px}
.progress{flex:1;display:flex;gap:4px;align-items:center;padding:0 4px}
.progress i{flex:1;height:10px;border-radius:5px;background:var(--wash);position:relative;overflow:hidden}
.progress i.on{background:var(--accent)}
.progress i.cur{background:var(--wash);box-shadow:inset 0 0 0 2px var(--accent)}
.coach{display:flex;align-items:flex-start;gap:10px}
.coach .avatar{width:48px;height:48px;flex:none;margin-top:2px}
.bubble{position:relative;background:var(--paper);border-radius:20px;border-start-start-radius:6px;padding:12px 16px;box-shadow:var(--shadow);font-size:18px;line-height:1.45;flex:1;animation:pop .3s var(--ease)}
html[lang=fa] .bubble{font-size:17px;line-height:1.8}
.stage{display:flex;justify-content:center;align-items:center;flex:1 1 0;min-height:170px}   /* if the screen is too short the page scrolls; the board never overlaps */
.focus .body.game{justify-content:center;justify-content:safe center;padding-top:6px}   /* safe: when the content is taller than the screen it starts at the top instead of spilling under the header */
.focus .body.game .stage{flex:0 0 auto}
.focus .body.game svg.board{height:auto;width:min(100%,calc(100dvh - 330px),520px)}
.focus .body.game.counting svg.board{width:min(100%,max(240px,calc(100dvh - 445px)),520px)}   /* counting: room for the score panel under the board */
svg.board{height:100%;width:auto;max-width:min(100%,520px);aspect-ratio:1/1;display:block;touch-action:manipulation;filter:drop-shadow(0 8px 14px rgba(70,45,10,.28))}
svg.board.shake{animation:shake .32s}
.feedback{min-height:48px;display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:8px;text-align:center;font-weight:500;font-size:17px;padding:4px 8px;border-radius:16px}
.feedback[data-kind=ok]{color:var(--primary);background:var(--tint)}
.feedback[data-kind=bad]{color:var(--berry);background:var(--berry-tint)}
.feedback[data-kind=info]{color:var(--ink-2)}
.feedback>span{min-width:0;max-width:calc(100% - 40px)}   /* the icon stays beside the text; only a button wraps to its own line */
.feedback.roomy{min-height:calc(2 * 1.4em + 8px)}
.feedback.roomy.demo{min-height:calc(3 * 1.4em + 8px)}   /* demo notes are often three lines: keep room so the board stays put */
/* a demo note that waits for the learner is one big tap target; the arrow appears after a moment, in room kept for it */
.feedback.demo{position:relative;padding-inline-end:36px}   /* the arrow's room is kept on every demo note, so text never re-wraps */
.fbslot{display:grid;align-items:center;justify-items:center;font-size:17px;font-weight:500;flex-shrink:0}   /* a demo's note: the slot keeps the longest note's room, the pill fits its text */
.fbslot.roomy{min-height:calc(2 * 1.4em + 8px)}
.fbslot.roomy.demo{min-height:calc(3 * 1.4em + 8px)}
.fbslot>*{grid-area:1/1}
.fbghost{visibility:hidden;width:100%;min-height:48px;display:flex;align-items:center;gap:8px;text-align:center;padding:4px 36px;padding-inline-start:12px}
.fbslot>.feedback.demo{width:auto;max-width:100%;flex-wrap:nowrap;padding-inline-start:12px}
.fbslot>.feedback.demo>span{max-width:none;flex:0 1 auto}
.fbghost .szbox{flex:1;min-width:0;display:grid;overflow:hidden;max-height:max(calc(2 * 1.45em),min(calc(4 * 1.6em),18vh));max-height:max(2lh,min(4lh,18vh))}
.fbghost .szbox>span{grid-area:1/1}
@media (max-height:640px){.fbghost .szbox{max-height:calc(3 * 1.45em);max-height:3lh}}   /* very short screens: at most three lines kept for the note (a longer one would push the coach's bubble off the top) */
.fbghost .ic-ph{width:24px;height:24px;flex:none}
.feedback.tapnext{width:100%;border:0;font:inherit;font-weight:500;font-size:17px;cursor:pointer;-webkit-tap-highlight-color:transparent}
.feedback.tapnext:active{filter:brightness(.97)}
.feedback.tapnext:focus-visible{outline:2px solid var(--primary);outline-offset:2px}
.feedback.tapnext[data-kind=info]{background:var(--tint)}
.feedback .next-hint{position:absolute;inset-inline-end:10px;top:50%;transform:translateY(-50%);display:flex;width:22px;height:22px;align-items:center;justify-content:center;border-radius:50%;background:var(--primary);color:#fff;animation:hintIn .4s ease 1.2s both,hintNudge 1.8s ease-in-out 1.6s 2}
.feedback .next-hint svg{width:16px;height:16px}
@keyframes hintIn{from{opacity:0}}
@keyframes hintNudge{50%{margin-inline-end:-3px}}   /* puzzles and demos keep room for a two-line message; the board keeps its size anyway (see renderLesson) */
.opts{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.opt{min-height:56px;border-radius:18px;background:var(--paper);box-shadow:inset 0 0 0 2px var(--line),0 3px 0 var(--line);font-weight:600;font-size:19px;padding:6px 12px;line-height:1.3}
.opt:active{transform:translateY(2px)}
.opt.wrong{background:var(--berry-tint);box-shadow:inset 0 0 0 2px var(--berry);color:var(--berry);pointer-events:none}
.opt.right{background:var(--tint);box-shadow:inset 0 0 0 2px var(--primary);color:var(--primary);pointer-events:none}
.dock{display:flex;align-items:center;gap:8px;padding:10px 12px calc(var(--safe-b) + 10px);background:var(--paper);box-shadow:0 -1px 0 var(--line)}
.dock .btn.primary{flex:1;min-width:0;padding:0 16px}
.dock .iconbtn{background:var(--wash)}
.dock .spacer{flex:1}

/* ---------- game: player cards, status ---------- */
.player{display:flex;align-items:center;gap:12px;padding:8px 14px 8px 8px;border-radius:20px;background:var(--paper);box-shadow:var(--shadow);position:relative;transition:box-shadow .2s}
[dir=rtl] .player{padding:8px 8px 8px 14px}
.player .avatar{width:44px;height:44px;flex:none}
.player .who{flex:1;min-width:0}
.player .name{font-weight:600;font-size:17px;line-height:1.2;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.player .sub{font-size:14px;color:var(--ink-2)}
.player .caps{display:flex;align-items:center;gap:6px;font-weight:600;font-size:16px}
.player .caps svg{width:20px;height:20px}
.player.active{box-shadow:0 0 0 3px var(--accent),var(--shadow)}
.player.active{animation:glow 1.8s ease-in-out infinite}
.status{min-height:40px;display:flex;align-items:center;justify-content:center;gap:8px;font-weight:600;font-size:17px;text-align:center}
.status[data-state=bad]{color:var(--berry)}
.status[data-state=over]{color:var(--primary)}
.status .ic{width:20px;height:20px}
.hint-small{font-size:14px;color:var(--ink-2);text-align:center}

/* ---------- lobby ---------- */
.lobby{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;gap:16px;padding:16px}
.lobby h2{font-size:26px;font-weight:600;line-height:1.2}
.lobby p{color:var(--ink-2);max-width:32ch}
.duo{display:flex;margin-bottom:8px}
.duo svg{width:92px;height:92px}
.duo svg+svg{margin-inline-start:-14px}
.waiting-dots{display:inline-flex;gap:6px}.waiting-dots i{width:9px;height:9px;border-radius:50%;background:var(--accent);animation:bob 1.2s infinite}
.waiting-dots i:nth-child(2){animation-delay:.15s}.waiting-dots i:nth-child(3){animation-delay:.3s}

/* ---------- strong ai ---------- */
.steps{display:grid;gap:10px;margin:16px 0}
.step{display:flex;gap:14px;align-items:flex-start;background:var(--paper);border-radius:18px;padding:14px;box-shadow:var(--shadow)}
.step .n{flex:none;width:34px;height:34px;border-radius:50%;background:var(--tint);color:var(--primary);font-weight:700;display:grid;place-items:center}
.addr{display:block;direction:ltr;text-align:left;word-break:break-all;font:13px/1.4 ui-monospace,Menlo,monospace;background:var(--wash);padding:10px 12px;border-radius:12px;margin-top:8px;color:var(--ink-2)}
.stack{display:grid;gap:10px}

/* ---------- sheets ---------- */
.scrim{position:absolute;inset:0;background:rgba(10,20,26,.5);display:flex;align-items:flex-end;z-index:20;animation:fade .2s}
.sheet{width:100%;background:var(--paper);border-radius:28px 28px 0 0;padding:12px 20px calc(var(--safe-b) + 20px);max-height:88%;overflow-y:auto;animation:rise .28s var(--ease);box-shadow:0 -8px 30px rgba(0,0,0,.2)}
.scrim.still,.scrim.still .sheet{animation:none}   /* the same sheet drawn again (a setting changed) does not slide in again */
.sheet .grab{width:44px;height:5px;border-radius:3px;background:var(--line);margin:0 auto 14px}
.sheet h2{font-size:24px;font-weight:600;line-height:1.2;margin-bottom:12px}
.sheet .row{display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:56px}
.sheet .row+.row{border-top:1px solid var(--line)}
.sheet .label{font-weight:500}
.sheet .sub{font-size:14px;color:var(--ink-2)}
.seg{display:inline-flex;background:var(--wash);border-radius:22px;padding:4px;gap:4px}
.seg button{min-height:40px;padding:0 16px;border-radius:18px;font-weight:600;font-size:16px;color:var(--ink-2)}
.seg button[aria-pressed=true]{background:var(--paper);color:var(--ink);box-shadow:var(--shadow)}
.switch{width:60px;height:44px;position:relative;flex:none;background:none}   /* 44px tall hit area; the visible track is smaller */
.switch::before{content:"";position:absolute;inset-inline:2px;top:6px;height:32px;border-radius:16px;background:var(--line);transition:background .15s}
.switch::after{content:"";position:absolute;top:9px;inset-inline-start:5px;width:26px;height:26px;border-radius:50%;background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.3);transition:inset-inline-start .15s var(--ease)}
.switch[aria-checked=true]::before{background:var(--primary)}
.switch[aria-checked=true]::after{inset-inline-start:31px}
.choices{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-bottom:14px}
.choice{min-height:60px;border-radius:18px;background:var(--paper);box-shadow:inset 0 0 0 2px var(--line);font-weight:600;font-size:17px;display:flex;align-items:center;justify-content:center;gap:10px;padding:8px 10px;text-align:center;line-height:1.25}
.choice svg{width:38px;height:38px;flex:none}
.choice[aria-pressed=true]{background:var(--tint);box-shadow:inset 0 0 0 3px var(--primary);color:var(--primary)}
.sheet h3{font-size:16px;font-weight:600;margin:6px 0 8px;color:var(--ink-2)}
.menu-row{display:flex;align-items:center;gap:16px;width:100%;min-height:60px;padding:0 4px;font-weight:600;font-size:18px;text-align:start;border-top:1px solid var(--line)}
.menu-row:first-of-type{border-top:0}
.menu-row.danger{color:var(--berry)}
.menu-row:active{background:var(--wash)}
.result{text-align:center}
.result .art{width:104px;height:104px;margin:4px auto 6px;display:block}
.result .score{display:flex;justify-content:center;align-items:center;gap:14px;font-size:20px;font-weight:600;margin:8px 0 4px}
.result .score svg{width:26px;height:26px;vertical-align:middle;margin-inline-end:6px}
.result .cap{font-size:13px;color:var(--ink-2);margin-bottom:14px}
.stars{display:flex;justify-content:center;gap:6px;margin:6px 0 10px}
.stars svg{width:48px;height:48px;fill:var(--saffron);stroke:#b97d0c;stroke-width:1.5;animation:starin .5s var(--ease) both}
.stars svg:nth-child(2){animation-delay:.12s}.stars svg:nth-child(3){animation-delay:.24s}

/* ---------- board effects ---------- */
.board .drop{animation:drop .22s var(--ease);transform-box:fill-box;transform-origin:center}
.board .puff{transform-box:fill-box;transform-origin:center;animation:puff .36s ease-out forwards}
.board .burst{transform-box:fill-box;transform-origin:center;animation:burst .7s ease-out forwards}
.board .last{animation:blink 1.6s ease-in-out infinite}
.board .deny{transform-box:fill-box;transform-origin:center;animation:deny 1.2s ease-out forwards}
.board .ghost{opacity:.55}

@keyframes pop{0%{transform:scale(.9);opacity:0}100%{transform:scale(1);opacity:1}}
@keyframes glow{0%,100%{box-shadow:0 0 0 3px var(--accent),var(--shadow)}50%{box-shadow:0 0 0 7px rgba(18,163,160,.28),var(--shadow)}}
@keyframes ring{0%{transform:scale(.92);opacity:.9}100%{transform:scale(1.25);opacity:0}}
@keyframes shake{0%,100%{transform:translateX(0)}20%{transform:translateX(-7px)}40%{transform:translateX(6px)}60%{transform:translateX(-4px)}80%{transform:translateX(3px)}}
@keyframes drop{0%{transform:scale(1.35);opacity:.2}100%{transform:scale(1);opacity:1}}
@keyframes puff{0%{transform:scale(1);opacity:.9}100%{transform:scale(1.7);opacity:0}}
@keyframes burst{0%{transform:scale(.2) rotate(0);opacity:1}100%{transform:scale(1.6) rotate(40deg);opacity:0}}
@keyframes blink{0%,100%{opacity:1}50%{opacity:.35}}
@keyframes deny{0%{transform:scale(.3);opacity:0}18%{transform:scale(1.2);opacity:1}30%{transform:scale(1);opacity:1}78%{transform:scale(1);opacity:1}100%{transform:scale(1);opacity:0}}
@keyframes fade{from{opacity:0}to{opacity:1}}
@keyframes rise{from{transform:translateY(100%)}to{transform:translateY(0)}}
@keyframes bob{0%,60%,100%{transform:translateY(0);opacity:.5}30%{transform:translateY(-6px);opacity:1}}
@keyframes starin{from{transform:scale(0) rotate(-40deg);opacity:0}to{transform:scale(1) rotate(0);opacity:1}}
@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:.001s!important;animation-iteration-count:1!important;transition-duration:.001s!important}}

/* ---------- settings extras ---------- */
.swatches{display:grid;grid-template-columns:repeat(4,1fr);gap:8px;width:100%}
.swatch{display:flex;flex-direction:column;align-items:center;gap:6px;padding:8px 4px;border-radius:14px;font-size:14px;font-weight:500;box-shadow:inset 0 0 0 2px var(--line)}
.swatch i{display:block;width:100%;height:30px;border-radius:9px;box-shadow:inset 0 0 0 1px rgba(0,0,0,.12)}
.swatch[aria-pressed=true]{box-shadow:inset 0 0 0 3px var(--primary);color:var(--primary);font-weight:600}
html[data-size=large] body{font-size:20px}
html[data-size=large] .bubble{font-size:21px}
html[data-size=large] .btn{font-size:20px}
html[data-size=large] .node .name{font-size:18px}
html[data-motion=off] *,html[data-motion=off] *::before,html[data-motion=off] *::after{animation:none!important;transition:none!important}

/* ---------- puzzle explanations ---------- */
.explain{background:var(--paper);border-radius:18px;padding:12px 16px;box-shadow:var(--shadow);font-size:16px;line-height:1.5}
.explain h3{font-size:15px;font-weight:600;color:var(--primary);margin:0 0 4px}
.explain p{margin:6px 0}
.explain .sol{font-size:15px;color:var(--ink-2)}
.explain .credit{font-size:12px;color:var(--ink-2);opacity:.85}
.explain .btn{margin-top:4px}

.progress .fill{background:linear-gradient(90deg,var(--accent) var(--p),var(--wash) var(--p))}
[dir=rtl] .progress .fill{background:linear-gradient(270deg,var(--accent) var(--p),var(--wash) var(--p))}   /* fills from the right in Persian */
.progress .count{flex:none;font-size:14px;font-weight:600;color:var(--ink-2);margin-inline-start:8px;min-width:3.2em;text-align:end}

.choices.three{grid-template-columns:repeat(3,1fr)}
.choices.three .choice,.choices.stacked .choice{flex-direction:column;gap:2px;min-height:64px}
.choice small{display:block;font-size:12px;font-weight:500;color:var(--ink-2)}
.choice[aria-pressed=true] small{color:inherit}

.model-card{background:var(--paper);border-radius:18px;padding:14px 16px;margin-bottom:14px;box-shadow:inset 0 0 0 1.5px var(--line)}
.model-card h3{margin:0 0 8px;font-size:17px}
.kv{display:flex;justify-content:space-between;gap:12px;padding:6px 0;border-top:1px solid var(--line);font-size:15px;align-items:baseline}
.kv:first-of-type{border-top:0}
.kv span{color:var(--ink-2);flex:none}
.kv b{font-weight:600;text-align:end;overflow-wrap:anywhere;font-size:14px}

.seg.track{display:flex;margin:4px 0 12px}
.seg.track button{flex:1;min-height:44px}
.grp{margin:18px 4px 8px;font-size:16px;color:var(--ink-2)}
.lgroup{display:flex;flex-direction:column;gap:8px}
.lrow{display:flex;align-items:center;gap:12px;min-height:64px;padding:10px 14px;border-radius:18px;background:var(--paper);box-shadow:inset 0 0 0 1.5px var(--line);text-align:start;width:100%}
.lrow .lic{flex:none;width:44px;height:44px;border-radius:22px;background:var(--tint);color:var(--primary);display:grid;place-items:center;font-size:22px}
.lrow .lic svg{width:26px;height:26px}
.lrow.done .lic{background:var(--primary);color:#fff}
.lrow .ltx{flex:1;min-width:0;display:flex;flex-direction:column}
.lrow .ltx b{font-size:17px;line-height:1.25}
.lrow .ltx small{font-size:13px;color:var(--ink-2)}
.lrow>svg{flex:none;width:20px;height:20px;color:var(--ink-2)}
.bubble{white-space:pre-line}
.bubble.still{animation:none}
.lrow.sub{min-height:52px;margin-inline-start:22px;width:calc(100% - 22px);background:transparent}
.lrow.sub .lic{width:34px;height:34px;font-size:17px}
.lrow.sub .ltx b{font-size:15px;font-weight:600}

.reading{flex:1 1 auto;overflow:auto;white-space:pre-line;font-size:18px;line-height:1.65;padding:10px 6px 16px;-webkit-overflow-scrolling:touch}
.rankchart{white-space:normal;margin:16px 0 0;font-size:15px;line-height:1.35;display:grid;gap:6px}   /* the kyu/dan ladder: stronger at the top */
.rk-top{display:flex;align-items:center;gap:4px;font-weight:600;color:var(--primary)}
.rk-top .ic{width:18px;height:18px;transform:rotate(-90deg)}
.rk-band{border-radius:14px;padding:8px 12px;display:grid;gap:2px}
.rk-band.dan{background:var(--primary);color:#fff}
.rk-band.kyu{background:var(--tint);color:var(--ink)}
.rk-dir{font-size:13px;opacity:.85;margin-bottom:2px}
.rk-row{display:flex;align-items:baseline;gap:10px;padding:3px 0}
.rk-row b{min-width:4.6em;font-weight:700}
.rk-row span{font-size:14px}
.rk-row.goal{margin:2px -6px;padding:3px 6px;border-radius:8px;background:var(--saffron);color:#3A2600}
.caption{flex:0 1 auto;max-height:34vh;overflow:auto;white-space:pre-line;font-size:16px;line-height:1.55;padding:6px 6px 2px}

.progress.tappable{cursor:pointer;min-height:44px;align-items:center}
.chips{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:8px;max-height:46vh;overflow:auto;padding:2px}
.chip{min-height:46px;border-radius:14px;background:var(--paper);box-shadow:inset 0 0 0 2px var(--line);font-weight:600;font-size:16px;display:grid;place-items:center}
.chips .chip{padding:0}
.chip.ok{background:var(--tint);color:var(--primary);box-shadow:inset 0 0 0 2px var(--primary)}
.chip.ok svg{width:20px;height:20px}
.chip.cur{box-shadow:inset 0 0 0 3px var(--ink)}
.iconbtn:disabled{opacity:.35}
.stage{position:relative}
.pmeta{display:flex;align-items:center;justify-content:space-between;gap:10px;min-height:26px;margin-top:6px}
.diff{display:inline-flex;align-items:center;gap:7px;font-size:13px;color:var(--ink-2)}
.diff b{font-weight:600}
.diff .dots{display:inline-flex;gap:3px}
.diff .dots i{width:9px;height:9px;border-radius:50%;background:transparent;box-shadow:inset 0 0 0 1.5px var(--ink-2);opacity:.55}
.diff .dots i.on{background:var(--primary);box-shadow:none;opacity:1}
.solved-badge{flex:none;display:inline-flex;align-items:center;gap:4px;padding:3px 10px 3px 8px;border-radius:14px;background:var(--tint);color:var(--primary);font-size:13px;font-weight:600;box-shadow:inset 0 0 0 1.5px var(--primary)}
.solved-badge svg{width:14px;height:14px}
.learn-first{flex:0 1 auto;min-width:0;min-height:34px;display:inline-flex;align-items:center;gap:5px;padding:3px 12px 3px 10px;border:0;border-radius:17px;text-align:start;background:var(--tint);color:var(--primary);font:inherit;font-size:13px;font-weight:600;cursor:pointer}
.learn-first svg{flex:none;width:14px;height:14px}
.learn-first span{line-height:1.25;text-align:start}   /* the lesson name may take two lines rather than be cut */

.score small.komi{font-size:.62em;opacity:.8;font-weight:600}
.count-panel{background:var(--paper);border-radius:18px;padding:10px 14px;box-shadow:inset 0 0 0 1.5px var(--line);display:flex;flex-direction:column;gap:6px}
.crow{display:grid;grid-template-columns:auto 1fr;gap:2px 10px;align-items:center}
.crow .who{display:flex;align-items:center;gap:6px}
.crow .who svg{width:24px;height:24px}
.crow .eq{text-align:end;font-size:16px;font-variant-numeric:tabular-nums}
.crow .extra{grid-column:1/-1;font-size:13px;color:var(--ink-2);display:flex;align-items:center;gap:6px;flex-wrap:wrap}
.pile{display:inline-flex;align-items:center}
.pile svg{width:16px;height:16px;margin-inline-end:-6px}
.pile b{margin-inline-start:10px;font-weight:600}
.count-panel .verdict{margin:2px 0 0;font-weight:700;font-size:16px;color:var(--primary)}
.count-panel .sub{margin:0;font-size:13px;color:var(--ink-2)}
.count-panel .legend{margin:0;font-size:12px;color:var(--ink-2)}
.hchips{grid-template-columns:repeat(5,1fr);margin-bottom:6px}
.hchips .chip{min-height:44px}

/* Landscape phones: the board takes the whole height on the left. The top bar and the buttons move into the right-hand column,
   so nothing eats the height of the board. */
.sideA,.sideB{display:contents}
@media (orientation:landscape) and (max-height:560px){
  #app{max-width:none}
  .focus:has(.body.staged){display:grid;grid-template-columns:auto minmax(0,1fr);grid-template-rows:auto auto minmax(0,1fr) auto;column-gap:14px;padding-inline:max(10px,var(--safe-l,0px)) 10px}
  .focus:has(.body.staged) .body{display:contents}
  .focus:has(.body.staged) .topbar{grid-column:2;grid-row:1;min-height:44px;padding:calc(var(--safe-t) + 4px) 0 2px 0}
  .focus:has(.body.staged) .topbar h1{font-size:18px}
  .focus:has(.body.staged) .stage{grid-column:1;grid-row:1 / -1;align-self:center;height:calc(100dvh - var(--safe-t) - var(--safe-b) - 16px);width:calc(100dvh - var(--safe-t) - var(--safe-b) - 16px);max-width:min(60vw,calc(100vw - 290px));max-height:min(60vw,calc(100vw - 290px));min-height:0;flex:none}
  .focus:has(.body.staged) svg.board{width:100%;height:100%;max-width:none}
  .focus:has(.body.staged) .sideA{display:block;grid-column:2;grid-row:2}
  .focus:has(.body.staged) .sideB{display:flex;flex-direction:column;gap:8px;grid-column:2;grid-row:3;min-height:0;overflow-y:auto;padding-bottom:6px}
  .focus:has(.body.staged) .dock{grid-column:2;grid-row:4;padding:6px 0 calc(var(--safe-b) + 6px);background:transparent;box-shadow:none}
  .dock .iconbtn,.dock .btn{min-height:44px;height:44px}
  .focus:not(:has(.body.staged)) .topbar{min-height:44px;padding:calc(var(--safe-t) + 2px) 10px 2px 12px}
  .focus:not(:has(.body.staged)) .dock{padding:6px 12px calc(var(--safe-b) + 6px)}
  .coach .avatar{width:36px;height:36px}
  .player{padding:4px 12px 4px 6px}
  .player .avatar{width:34px;height:34px}
  .status{min-height:28px;font-size:15px}
  .count-panel{padding:8px 12px}
}

.explain h4{font-size:14px;font-weight:600;color:var(--primary);margin:2px 0 0}
.explain .res{font-size:15px}
.explain.walk h3{font-size:16px}

/* short screens: the score panel must leave room for the board, so drop the line that repeats the numbers of the equation */
@media (max-height:760px){.crow .extra{display:none}}
@media (max-height:700px){.count-panel .legend{display:none}}

/* text boxes in the scrolling column keep their full height: the page scrolls instead of the text spilling out of a squeezed box */
.focus .body>.feedback,.focus .body>.explain,.focus .body>.coach,.focus .body>.caption,.focus .body>.reading,.focus .body>.opts,.focus .body>.pmeta,.focus .sideA>*,.focus .sideB>*{flex-shrink:0}
.feedback{flex-shrink:0}
.cbtns{display:flex;flex-wrap:wrap;gap:8px;margin-top:8px}
.dock .btn{white-space:nowrap}
.feedback>.fbbtns{display:flex;flex-wrap:wrap;justify-content:center;gap:8px;max-width:100%}   /* try again + keep playing; pass + back in free play */
/* a point named in a text ("F1"): a dotted underline; tapping it shows the point on the board */
.pt{display:inline;font:inherit;color:inherit;padding:0 1px;margin:0;border-radius:4px;text-decoration:underline dotted;text-underline-offset:3px;
  text-decoration-thickness:1.5px;white-space:nowrap;unicode-bidi:isolate;direction:ltr}
button.pt:focus-visible{outline:2px solid var(--coral);outline-offset:1px}
button.pt:active{background:color-mix(in srgb,var(--coral) 18%,transparent)}
.board .ping .pulse{fill:none;stroke:#F0603E;stroke-width:3;opacity:0;transform-box:fill-box;transform-origin:center;animation:ring .9s ease-out 2}
.board text.lit{fill:#C23E20;fill-opacity:1;font-weight:700}
