
/* Theme 3: Pastel Blue–Yellow, from banding/_theme-preview.html.
   Presentation only: card artwork and all game rules are preserved. */
:root {
  --primary:#1670C0; --primary-hover:#0F5490; --bright:#1670C0;
  --candy:#1670C0; --candy-light:#a8d7f6; --accent:#5FB4EA; --accent-light:#DBEEFF;
  --primary-soft:rgba(22,112,192,.10); --yellow:#FFEEA7; --peach:#FFBF6F;
  --orange:#FFBF6F; --coral:#FFB4A8; --text:#123049; --gray-text:#526f85;
  --bg:#fff; --bg2:#F7FBFF; --slate:#F7FBFF; --sky:#edf7ff; --amber:#fff9e1;
  --border:#DCEEF7; --error:#c52f39; --success:#147b55;
  --shadow:0 4px 18px rgba(22,112,192,.09); --radius:20px;
}
body { background:var(--slate); }
button { font-family:var(--font-h); touch-action:manipulation; }
button,a,[tabindex] { -webkit-tap-highlight-color:transparent; }
button:focus-visible,a:focus-visible,[tabindex]:focus-visible { outline:3px solid var(--primary); outline-offset:4px; }
button:disabled { cursor:not-allowed; }
.primary { background:var(--primary); border-color:var(--primary); box-shadow:0 4px 0 var(--primary-hover); transition:transform .16s,box-shadow .16s; }
.primary:hover:not(:disabled) { background:var(--primary-hover); transform:translateY(-1px); }
.primary:active:not(:disabled) { transform:translateY(2px); box-shadow:0 1px 0 var(--primary-hover); }
.ghost, .back-home, .hist-btn { background:#fff; border-color:var(--border); color:var(--primary-hover); }
.ghost:hover:not(:disabled),.back-home:hover,.hist-btn:hover { background:var(--sky); border-color:var(--accent); }
.lang-toggle { border:1px solid var(--border); border-radius:999px; padding:3px; background:#fff; }
.lang-btn { border:0; min-height:32px; }
.lang-btn.active { background:var(--primary); }
.top,.play-top { border-bottom:1px solid var(--border); padding-bottom:10px; gap:10px; }
.top .brand { min-width:0; }
.t1,.play-title { color:var(--primary-hover); }
/* A cheerful lobby with a tabletop demo. */
.landing { background:radial-gradient(ellipse at 90% 12%,#DBEEFF80,transparent 45%),var(--slate); color:var(--text); }
.landing-header { border-color:var(--border); }
.landing-brand small, .landing-section-title>span { color:var(--gray-text); }
.landing-intro h1 span { color:var(--primary); }
.landing-intro p { color:var(--gray-text); }
.landing-demo { background:#DBEEFF; border:2px solid #fff; box-shadow:0 8px 0 #c8e2f5,0 16px 30px #1670c011; }
.demo-top,.demo-bottom { color:var(--primary-hover); }
.demo-mode-tabs { display:flex; gap:3px; padding:3px; border:1px solid #9cc8e4; border-radius:9px; background:#ffffff90; }
.demo-mode-tabs button { border:0; border-radius:6px; padding:6px 9px; background:transparent; color:var(--primary-hover); font-size:9px; font-weight:700; letter-spacing:.35px; cursor:pointer; }
.demo-mode-tabs button.on { background:var(--yellow); box-shadow:0 1px 3px #12304918; }
.demo-card { box-sizing:border-box; min-height:146px; padding:10px 4px; gap:8px; background:#fff; border-color:#d2e7f5; box-shadow:0 6px 0 #bdd7eb,0 12px 22px #12304912; }
.landing-demo .demo-card.demo-game-card { height:auto; min-height:0; padding:0; gap:0; border:0; border-radius:0; background:transparent; box-shadow:none; filter:drop-shadow(0 5px 2px #12304920); }
.demo-game-card > svg { width:100%; height:auto; overflow:visible; }
.demo-equation.has-extra .demo-card { width:74px; }
.demo-equation.has-extra .demo-card small { font-size:8px; }
.demo-plus,.demo-whole,.demo-bottom button { color:var(--primary-hover); }
.demo-whole.match { color:var(--success); }
.demo-bottom { border-color:#bddbee; }
.demo-controls { display:flex; align-items:center; justify-content:flex-end; gap:10px; flex-wrap:wrap; }
.demo-count { font:600 11px Inter,var(--font-b); white-space:nowrap; }
.demo-controls button { min-height:36px; white-space:nowrap; }
.demo-bottom { flex-wrap:wrap; gap:10px; }
.demo-animated { animation:demo-enter .5s ease-out both; }
@keyframes demo-enter { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }
@media(prefers-reduced-motion:reduce) { .demo-animated { animation:none; } }
.landing-mode { border:1.5px solid var(--border); border-bottom-width:5px; background:#fff; color:var(--text); }
.landing-mode.play { background:var(--primary); border-color:var(--primary-hover); }
.landing-mode.tutorial { background:#fff7d6; border-color:#efdfa0; }
.landing-mode.fraclab { background:#fff; border-color:#c7e5f7; }
.landing-mode:hover { transform:translateY(-5px) rotate(-.4deg); }
.mode-illustration { display:block; width:100%; height:112px; flex-shrink:0; margin:0 0 10px; border-radius:12px; background:#ffffff45; }
.play .mode-illustration { background:#DBEEFF; }
.landing-mode:focus-visible { outline:3px solid #123049; outline-offset:5px; }
.landing-mode-desc { color:var(--gray-text); }
.play .landing-mode-desc { color:#fff; }
.landing-mode-action { border-color:#12304920; }
.landing-resources button { color:var(--primary-hover); }
/* Responsive lobby: one demonstration beside three compact mode choices. */
.landing-header { max-width:1200px; padding:16px 28px; }
.landing-main { max-width:1200px; padding:24px 28px 16px; display:grid; grid-template-columns:minmax(0,1.2fr) minmax(0,1fr); gap:22px 32px; align-items:start; }
.landing-hero { display:contents; }
.landing-intro { grid-column:1 / -1; }
.landing-intro h1 { font-size:clamp(26px,3vw,38px); margin:0 0 4px; line-height:1.3; }
.landing-intro h1 br { display:none; }
.landing-intro h1 span { margin-left:.3em; }
.landing-intro p { max-width:none; font-size:13px; margin:0; }
.landing-demo { padding:22px; min-width:0; align-self:stretch; display:flex; flex-direction:column; justify-content:space-between; }
.demo-top { flex-wrap:wrap; letter-spacing:0; font-size:13px; }
.demo-mode-tabs button { min-height:36px; font-size:10px; }
.landing-demo .demo-equation { flex:1; min-height:260px; gap:14px; padding:26px 0; }
.landing-demo .demo-card { width:106px; }
.landing-demo .demo-equation.has-extra .demo-card { width:82px; }
.landing-demo .demo-whole { font-size:52px; }
.landing-demo .demo-bottom { font-size:11px; padding-top:10px; }
.landing-modes { min-width:0; }
.landing-section-title { margin:0 0 12px; }
.landing-section-title h2 { margin:0; font-size:18px; }
.landing-mode-grid { grid-template-columns:1fr; gap:12px; }
.landing-mode { display:grid; grid-template-columns:112px minmax(0,1fr); column-gap:16px; padding:14px; border-radius:18px; }
.landing-mode .mode-illustration { grid-column:1; grid-row:1 / 4; width:112px; height:100%; min-height:82px; margin:0; }
.landing-mode strong { grid-column:2; margin:0; font-size:19px; }
.landing-mode-desc { grid-column:2; font-size:12px; line-height:1.5; }
.landing-mode-action { grid-column:2; margin-top:8px; padding-top:7px; font-size:12px; }
.landing-mode:hover { transform:translateY(-2px); }
.landing-resources { grid-column:1 / -1; padding:0; gap:24px; }
@media(max-width:900px) and (min-width:641px) {
  .landing-main { gap:18px; padding:20px; grid-template-columns:minmax(0,1.1fr) minmax(0,1fr); }
  .landing-demo { padding:16px; }
  .landing-demo .demo-card { width:76px; }
  .landing-demo .demo-equation.has-extra .demo-card { width:60px; }
  .landing-demo .demo-equation { gap:8px; }
  .landing-demo .demo-whole { font-size:38px; }
  .landing-mode { grid-template-columns:80px minmax(0,1fr); gap:4px 10px; padding:12px; }
  .landing-mode .mode-illustration { width:80px; }
  .landing-mode strong { font-size:17px; }
}
@media(max-width:640px) {
  .landing-header { padding:12px 16px; }
  .landing-brand { font-size:18px; }
  .landing-brand img { width:34px; height:34px; }
  .landing-main { grid-template-columns:minmax(0,1fr); padding:16px; gap:18px; }
  .landing-intro h1 { font-size:27px; }
  .landing-intro p { font-size:12px; }
  .landing-demo { padding:14px; border-radius:20px; }
  .landing-demo .demo-equation { min-height:190px; padding:20px 0; }
  .landing-demo .demo-top { gap:8px; }
  .landing-demo .demo-bottom { gap:4px; }
  .demo-controls { gap:8px; }
  .landing-section-title { margin:0 0 10px; }
  .landing-mode { padding:10px 12px; grid-template-columns:90px minmax(0,1fr); gap:2px 12px; }
  .landing-mode .mode-illustration { width:90px; min-height:76px; }
  .landing-mode strong { font-size:18px; }
  .landing-mode-desc { font-size:11px; }
  .landing-mode-action { margin-top:5px; padding-top:5px; }
}
@media(min-width:1000px) and (min-height:650px) {
  .landing { height:100dvh; display:flex; flex-direction:column; }
  .landing-header { width:100%; max-width:none; padding:16px clamp(24px,3vw,64px); flex-shrink:0; }
  .landing-main { width:100%; max-width:none; margin:0; flex:1; min-height:0; padding:clamp(16px,2.5vh,32px) clamp(24px,3vw,64px) 14px; grid-template-rows:auto minmax(0,1fr) auto; gap:clamp(14px,2.5vh,28px) clamp(24px,3vw,56px); }
  .landing-intro h1 { font-size:clamp(32px,3vw,52px); }
  .landing-intro p { font-size:clamp(13px,1.1vw,18px); }
  .landing-demo { height:100%; min-height:0; padding:clamp(20px,2vw,38px); }
  .landing-demo .demo-equation { min-height:0; gap:clamp(12px,1.4vw,28px); }
  .landing-demo .demo-card { width:clamp(100px,min(12vw,25vh),240px); }
  .landing-demo .demo-equation.has-extra .demo-card { width:clamp(76px,min(9vw,23vh),180px); }
  .landing-demo .demo-whole { font-size:clamp(48px,5vw,88px); }
  .landing-demo .demo-plus { font-size:clamp(25px,2.4vw,42px); }
  .demo-top { font-size:clamp(13px,1.2vw,20px); }
  .demo-mode-tabs button { font-size:clamp(10px,.9vw,15px); padding:9px 12px; }
  .landing-demo .demo-bottom,.demo-bottom button,.demo-count { font-size:clamp(11px,1vw,16px); }
  .landing-modes { height:100%; min-height:0; display:flex; flex-direction:column; }
  .landing-section-title h2 { font-size:clamp(18px,1.6vw,26px); }
  .landing-mode-grid { flex:1; min-height:0; grid-template-rows:repeat(3,minmax(0,1fr)); gap:clamp(10px,1.6vh,20px); }
  .landing-mode { grid-template-columns:clamp(100px,11vw,200px) minmax(0,1fr); padding:clamp(12px,1.2vw,24px); align-content:center; }
  .landing-mode .mode-illustration { width:100%; min-height:0; height:100%; }
  .landing-mode strong { font-size:clamp(19px,1.8vw,30px); }
  .landing-mode-desc,.landing-mode-action,.landing-resources button { font-size:clamp(12px,1.1vw,18px); }
}
/* Setup: rules, card styles and AI difficulty on one screen. */
.setup-one { max-width:none; min-height:100dvh; display:flex; flex-direction:column; padding:16px clamp(16px,3vw,64px) 20px; }
.setup-one .top { margin-bottom:14px; }
.setup-board { display:grid; gap:14px; }
.setup-panel { min-width:0; padding:14px 18px; border:1.5px solid var(--border); border-radius:18px; background:#fff; box-shadow:0 4px 0 #dfedf6; }
.setup-panel h2 { display:flex; align-items:center; flex-wrap:wrap; gap:6px 10px; margin:0 0 12px; font:700 clamp(16px,1.3vw,22px) var(--font-h); color:var(--primary-hover); }
.setup-panel h2 small { font:500 clamp(12px,.95vw,16px) var(--font-b); color:var(--gray-text); }
.setup-panel h2 small b { color:var(--primary); }
.setup-no { width:1.6em; height:1.6em; display:grid; place-items:center; border-radius:50%; background:var(--yellow); color:var(--text); font:700 .85em Inter,var(--font-h); }
.preset-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; }
.preset-option { display:flex; align-items:center; gap:14px; min-width:0; padding:12px 14px; border:2px solid var(--border); border-radius:16px; background:#fff; color:var(--text); text-align:left; font-family:var(--font-b); cursor:pointer; transition:transform .16s,box-shadow .16s; }
.preset-option:hover { transform:translateY(-2px); }
.preset-option.on { border-color:var(--primary); background:var(--sky); box-shadow:0 4px 0 #a8d7f6; }
.preset-option strong { display:block; margin-bottom:4px; font:600 clamp(18px,1.5vw,26px) Inter,var(--font-h); }
.preset-option div > span { display:block; font-size:clamp(12px,.9vw,15px); line-height:1.55; color:var(--gray-text); }
/* each rule set: a small fan of its own cards that opens on hover / when chosen */
.preset-option { position:relative; }
.preset-option.on::after { content:'✓'; position:absolute; top:-9px; right:-9px; width:26px; height:26px; display:grid; place-items:center; border-radius:50%; background:var(--primary); color:#fff; font:700 15px var(--font-h); box-shadow:0 2px 0 var(--primary-hover); animation:setup-pop .35s cubic-bezier(.3,1.6,.5,1) backwards; }
.preset-fan { position:relative; flex-shrink:0; width:clamp(64px,5.4vw,96px); aspect-ratio:1/1; }
.fan-card { position:absolute; left:50%; bottom:2px; width:56%; transform-origin:50% 100%; transform:translateX(-50%) rotate(calc(var(--i) * 10deg)); transition:transform .35s cubic-bezier(.3,1.5,.5,1); }
.fan-card svg { display:block; width:100%; height:auto; overflow:visible; filter:drop-shadow(0 2px 2px #12304926); }
.preset-option:hover .fan-card, .preset-option.on .fan-card { transform:translateX(calc(-50% + var(--i) * 16%)) translateY(-3px) rotate(calc(var(--i) * 18deg)); }
@keyframes setup-pop { from { transform:scale(.3); opacity:0; } }
.setup-custom-options { display:flex; flex-wrap:wrap; gap:6px 28px; margin-top:12px; padding-top:10px; border-top:1px dashed var(--border); }
.setup-custom-options .set-group h3 { margin:0 0 6px; font:700 13px var(--font-h); color:var(--primary-hover); }
.setup-custom-options .level-row { justify-content:flex-start; flex-wrap:wrap; gap:8px; margin:0; }
.setup-custom-options .level-opt { padding:7px 16px; font-size:13px; }
.setup-custom-options .set-hint { margin:6px 0 0; font-size:12px; color:var(--gray-text); }
.count-row { display:flex; flex-wrap:wrap; gap:8px; }
.count-step { display:flex; align-items:center; gap:8px; padding:3px 4px 3px 12px; border:1.5px solid var(--border); border-radius:999px; background:#fff; }
.count-name { font:600 13px var(--font-h); color:var(--text); white-space:nowrap; }
.count-ctl { display:flex; align-items:center; gap:2px; }
.count-btn { width:30px; height:30px; padding:0; border:0; border-radius:50%; background:var(--primary-soft); color:var(--primary-hover); font:700 18px/1 Inter,var(--font-h); cursor:pointer; touch-action:manipulation; }
.count-btn:disabled { opacity:.35; cursor:default; }
.count-val { min-width:22px; text-align:center; font:700 16px Inter,var(--font-h); color:var(--primary-hover); }
.setup-style-grid { display:grid; grid-template-columns:repeat(var(--cols,5),minmax(0,1fr)); gap:12px; margin:0; }
.rep-opt.fixed { cursor:default; background:#fff; }
.rep-opt.fixed:hover { transform:none; }
.setup-style-grid .rep-opt { min-width:0; padding:10px; gap:6px; }
.setup-style-grid .rep-prev svg { width:auto; max-width:100%; height:clamp(110px,30vh,300px); margin:auto; overflow:visible; }
/* the card styles are dealt in one by one; switching to or from Custom deals them again */
@keyframes setup-deal { from { opacity:0; transform:translateY(22px) rotate(-7deg) scale(.9); } }
.setup-style-grid.deal .rep-opt { animation:setup-deal .45s cubic-bezier(.2,1.3,.4,1) backwards; animation-delay:calc(var(--i) * 70ms); }
.setup-style-grid .rep-prev svg { transition:transform .3s cubic-bezier(.3,1.5,.5,1), opacity .2s, filter .2s; }
.setup-style-grid .rep-opt:hover .rep-prev svg { transform:rotate(-3deg) scale(1.03); }
.setup-style-grid.picking .rep-opt:not(.on) .rep-prev svg { opacity:.55; filter:saturate(.5); }
.setup-style-grid.picking .rep-opt.on { transform:translateY(-4px); }
.setup-style-grid .rep-opt span { font-size:clamp(13px,1vw,17px); }
.setup-go { display:flex; flex-direction:column; }
/* AI difficulty: one robot per level; the chosen one bobs */
.difficulty-row { display:grid; grid-template-columns:repeat(3,1fr); gap:10px; margin:0 0 14px; }
.ai-opt { display:flex; flex-direction:column; align-items:center; gap:3px; min-width:0; padding:10px 6px 8px; border:2px solid var(--border); border-radius:16px; background:#fff; color:var(--text); font-family:var(--font-h); cursor:pointer; box-shadow:0 3px 0 var(--border); transition:transform .16s; touch-action:manipulation; }
.ai-opt:hover { transform:translateY(-2px); }
.ai-opt.on { border-color:var(--primary); background:var(--sky); box-shadow:0 3px 0 var(--primary); }
.robot { display:block; width:clamp(42px,3.4vw,62px); height:auto; overflow:visible; }
.ai-opt.on .robot { animation:setup-bob 1.8s ease-in-out infinite; }
.ai-opt.on .robot-bulb { animation:setup-glow 1.8s ease-in-out infinite; }
@keyframes setup-bob { 50% { transform:translateY(-3px) rotate(-4deg); } }
@keyframes setup-glow { 50% { opacity:.4; } }
.ai-name { font-weight:700; font-size:clamp(15px,1.15vw,20px); }
.ai-pips { display:flex; gap:4px; }
.ai-pips i { width:8px; height:8px; border-radius:50%; background:var(--border); }
.ai-pips i.on { background:var(--primary); }
/* summary: the hand each player starts with, drawn as real cards */
.setup-summary { margin:0 0 14px; padding:12px 14px; border:1px solid var(--border); border-radius:14px; background:var(--slate); font-size:clamp(13px,.95vw,16px); color:var(--gray-text); }
.setup-summary strong { display:flex; align-items:center; justify-content:space-between; gap:8px; flex-wrap:wrap; font:700 clamp(16px,1.25vw,22px) var(--font-h); color:var(--primary-hover); }
.sum-clock { display:inline-flex; align-items:center; gap:5px; padding:3px 10px; border:1px solid var(--border); border-radius:999px; background:#fff; font:600 clamp(13px,.95vw,16px) var(--font-h); color:var(--primary-hover); }
.sum-label { margin:10px 0 6px; font:600 clamp(12px,.85vw,15px) var(--font-h); color:var(--gray-text); }
.sum-label em { font-style:normal; color:#C2410C; }
.sum-hand { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:6px; }
.sum-card { display:flex; flex-direction:column; align-items:center; gap:4px; font:600 clamp(12px,.85vw,15px) var(--font-h); color:var(--text); transition:opacity .2s; }
.sum-art { position:relative; width:clamp(38px,3.6vw,66px); transform:rotate(calc((var(--i) - 1) * 4deg)); }
.sum-art svg, .sum-mini svg, .sum-gem-art svg, .count-card svg { display:block; width:100%; height:auto; overflow:visible; filter:drop-shadow(0 2px 2px #12304922); }
.sum-n { position:absolute; right:-12px; bottom:-4px; min-width:28px; padding:1px 6px; border-radius:999px; background:var(--primary); color:#fff; font:700 13px/1.4 Inter,var(--font-h); text-align:center; animation:setup-pop .35s cubic-bezier(.3,1.6,.5,1) backwards; }
.sum-card.none { opacity:.4; }
.sum-card.none .sum-n { background:var(--gray-text); }
.sum-gem { display:flex; align-items:center; gap:8px; margin-top:10px; padding:6px 10px; border-radius:10px; background:#fff; font:600 clamp(12px,.85vw,15px) var(--font-h); color:var(--text); transition:opacity .2s; }
.sum-gem-art { flex-shrink:0; width:24px; }
.sum-gem.none { opacity:.5; }
.sum-styles { display:flex; justify-content:center; padding:2px 0 4px; }
.sum-mini { width:clamp(34px,3.2vw,58px); margin:0 -3px; transform-origin:50% 140%; transform:rotate(calc(var(--i) * 8deg)); animation:setup-deal .4s cubic-bezier(.2,1.3,.4,1) backwards; }
.count-name { display:inline-flex; align-items:center; gap:6px; }
.count-card { width:20px; flex-shrink:0; }
.sr-only { position:absolute; width:1px; height:1px; margin:-1px; padding:0; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; border:0; }
.setup-go .setup-start { width:100%; min-height:60px; margin-top:auto; font-size:clamp(18px,1.4vw,24px); }
.go-arrow { display:inline-block; margin-left:.4em; transition:transform .2s; }
.setup-start:hover .go-arrow { transform:translateX(5px); }
.setup-start.ready { animation:setup-nudge 3s ease-in-out 1.5s infinite; }
@keyframes setup-nudge { 0%, 84%, 100% { transform:none; } 90% { transform:scale(1.03); } 95% { transform:scale(.99); } }
@media(min-width:1000px) {
  .setup-board { flex:1; min-height:0; grid-template-columns:minmax(0,1fr) clamp(300px,25vw,440px); grid-template-rows:auto minmax(0,1fr); }
  .setup-rules { grid-column:1; grid-row:1; }
  .setup-styles { grid-column:1; grid-row:2; display:flex; flex-direction:column; }
  /* the card previews take whatever height is left, so opening Custom shrinks them instead of scrolling */
  .setup-styles .setup-style-grid { flex:1; min-height:0; grid-template-rows:minmax(0,1fr); }
  .setup-style-grid .rep-opt { min-height:0; }
  .setup-style-grid .rep-prev { flex:1; min-height:0; display:flex; align-items:center; justify-content:center; }
  .setup-style-grid .rep-prev svg { height:100%; max-height:440px; }
  .setup-custom-options .set-group h3 { font-size:clamp(13px,.95vw,16px); }
  .setup-custom-options .level-opt { font-size:clamp(13px,.95vw,16px); }
  .setup-custom-options .set-hint { font-size:clamp(12px,.85vw,15px); }
  .setup-go { grid-column:2; grid-row:1 / 3; }
}
@media(max-width:999px) { .setup-go .setup-start { margin-top:0; } .sum-body { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:0 18px; align-items:start; } .sum-col + .sum-col .sum-gem { margin-top:10px; } .setup-style-grid .rep-prev svg { width:100%; height:auto; max-height:min(30vh,300px); } }
@media(max-width:760px) {
  .preset-grid { grid-template-columns:1fr; gap:8px; }
  .preset-option { padding:10px 12px; }
  .preset-fan { width:56px; }
  .preset-option strong { font-size:18px; margin-bottom:2px; }
  .setup-panel { padding:12px; }
  .setup-style-grid { grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; }
  .setup-style-grid.fixed { grid-template-columns:repeat(4,minmax(0,1fr)); }
  .setup-style-grid .rep-opt { padding:8px; }
  .setup-style-grid .rep-prev svg, .is-custom .setup-style-grid .rep-prev svg { width:auto; height:110px; }
}
.rep-opt { position:relative; border-color:var(--border); box-shadow:0 3px 0 var(--border); }
.rep-opt.on { background:var(--sky); border-color:var(--primary); box-shadow:0 3px 0 var(--primary); }
.rep-opt.on::after { content:'✓'; position:absolute; top:6px; right:6px; width:23px; height:23px; display:grid; place-items:center; background:var(--primary); color:#fff; border-radius:50%; font:700 14px var(--font-h); }
.rep-opt:hover { transform:translateY(-2px); }
.level-opt.on,.pl-mode-btn.on,.spd.on { background:var(--primary); color:white; }
/* Landing: way home, page link, device hint. */
.landing-top-actions { display:flex; align-items:center; gap:12px; }
.landing-home { display:inline-flex; align-items:center; gap:6px; min-height:36px; padding:6px 14px; border:1px solid var(--border); border-radius:999px; background:#fff; color:var(--primary-hover); font:600 13px var(--font-h); text-decoration:none; }
.landing-home:hover { background:var(--sky); border-color:var(--accent); }
.landing-resources { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:8px 24px; }
.landing-tools { display:flex; gap:10px; flex-wrap:wrap; }
.landing-tools button { min-height:38px; padding:7px 16px; border:1px solid var(--border); border-radius:999px; background:#fff; color:var(--primary-hover); font:600 13px var(--font-h); cursor:pointer; }
.landing-tools button:hover { background:var(--sky); border-color:var(--accent); text-decoration:none; }
.landing-device { margin:0; font-size:13px; color:var(--gray-text); }
.landing-fb { display:inline-flex; align-items:center; gap:8px; color:var(--primary-hover); font:600 13px var(--font-h); text-decoration:none; }
.landing-fb img { border-radius:50%; object-fit:cover; }
.landing-fb:hover span { text-decoration:underline; }
@media(min-width:1000px) and (min-height:650px) {
  .landing-home,.landing-tools button,.landing-device,.landing-fb { font-size:clamp(13px,1vw,17px); }
}
@media(max-width:640px) {
  .landing-home span { display:none; }
  .landing-resources { flex-direction:column; align-items:flex-start; }
}
/* Table: keep the board flexible and all original card identities intact. */
.play-root { max-width:1480px; gap:8px; padding:10px 18px; }
.play-top { min-height:42px; padding-bottom:7px; }
.pl-row { border-color:var(--border); gap:16px; box-shadow:0 3px 0 #dfedf6; }
.pl-row.active { background:var(--sky); border-color:var(--primary); box-shadow:0 0 0 2px #1670c015,0 3px 0 #bdddf3; }
.pl-score { background:var(--yellow); color:var(--text); }
.pl-clock { font-family:Inter,var(--font-b); font-variant-numeric:tabular-nums; padding:4px 7px; border-radius:8px; background:#fff; }
.pl-clock.over { background:#fff1f0; }
.pl-stage { border:2px dashed #a8d7f6; background:radial-gradient(circle at 1px 1px,#1670c00b 1px,transparent 0) 0 0/18px 18px,#edf7ff; padding:8px 14px; border-radius:18px; justify-content:flex-start; }
.pl-stage-label { color:var(--primary-hover); }
.pl-empty { border:1px dashed #c1dbec; background:#ffffff95; padding:16px 24px; border-radius:14px; font-style:normal; }
.pl-card { box-shadow:0 4px 0 #c5dbea,0 7px 12px #12304912; }
.pl-card.picked { outline:3px solid var(--primary); box-shadow:0 0 0 5px var(--yellow),0 8px 16px #1670c020; }
.pl-card:focus-visible { outline:3px solid var(--primary); outline-offset:4px; }
.pile-label { color:var(--primary-hover); }
.revive-grid { padding:7px; }
.grave-item { min-width:0; }
.grave-item .gi-card { width:100%; box-sizing:border-box; }
.grave-item .gi-card svg { display:block; width:100%; height:auto; }
@media(min-width:1001px) {
  .pl-stage-body { flex:1; min-height:0; display:grid; grid-template-columns:clamp(130px,12vw,190px) minmax(0,1fr) clamp(130px,12vw,190px); align-items:center; }
  .pl-stage-main { grid-column:2; }
  .pl-piles { grid-column:3; justify-content:center; }
  .pl-stage .pl-card.sm { height:clamp(120px,18vh,180px); }
}
.pile.clickable { border-radius:12px; }
.pl-actions { border:1px solid var(--border); background:#fff; border-radius:14px; padding:10px 12px; gap:9px; }
.pl-hint { font-style:normal; line-height:1.65; color:var(--primary-hover); }
.pl-note { border-radius:10px; }
.turn-guide { display:flex; align-items:center; gap:12px; flex-shrink:0; border:1px solid var(--border); border-radius:12px; background:#fff; padding:7px 12px; }
.turn-guide strong { color:var(--primary-hover); font:600 12px var(--font-h); white-space:nowrap; }
.turn-guide span { font-size:12px; color:var(--gray-text); line-height:1.5; }
.turn-guide.your-turn { background:#fff9e5; border-color:#efdfa0; }
.pl-turnbadge { background:var(--primary); color:#fff; }
.gem-tray { border-color:var(--border); background:#f2f9ff; }
/* Shared dialogs and learning tools. */
.overlay { background:rgba(18,48,73,.48); backdrop-filter:blur(5px); padding:18px; overflow-y:auto; grid-template-columns:minmax(0,1fr); }
.overlay > * { min-width:0; max-width:100%; }
.add-card,.revive-modal,.grave-menu,.result-modal,.tut-modal,.howto { border:1px solid var(--border); box-shadow:0 20px 70px #12304930; }
.add-head { color:var(--primary-hover); border-color:var(--border); gap:12px; }
.add-head > span { min-width:0; overflow-wrap:anywhere; }
.add-head .x,.result-x { min-width:36px; min-height:36px; }
.hist-row { background:var(--slate); padding:12px; }
.hist-row.me { border-left-color:var(--primary); }
.hist-row.ai { border-left-color:var(--orange); }
.hist-calc { background:white; border-style:solid; }
.hc-total { background:var(--amber); border-radius:8px; padding:8px; }
/* Unseen cards: all 26 fractions on one screen — one glyph per card style. */
.unseen-panel { width:min(1180px,100%); max-height:94dvh; overflow:hidden; padding:20px 24px; display:flex; flex-direction:column; box-sizing:border-box; }
.unseen-panel > * { flex-shrink:0; }
.unseen-panel .unseen-grid,.unseen-panel .unseen-special-grid { flex-shrink:1; min-height:0; }
.unseen-explanation[open] { max-height:18dvh; overflow:auto; }
.unseen-meta { display:flex; gap:6px 22px; flex-wrap:wrap; margin:10px 0 12px; color:var(--gray-text); font-size:13px; }
.unseen-meta b { color:var(--text); }
.unseen-tabs { display:flex; gap:10px; margin-bottom:10px; }
.unseen-tabs button { flex:1; display:flex; align-items:center; justify-content:space-between; gap:8px; padding:8px 14px; border:1px solid var(--border); border-radius:12px; background:var(--slate); color:var(--primary-hover); cursor:pointer; font-size:14px; }
.unseen-tabs button.on { background:var(--primary); color:white; border-color:var(--primary); }
.remaining-count { white-space:nowrap; font-family:Inter,var(--font-b); }
.remaining-count b { font-size:18px; }
.remaining-count small { font-size:12px; opacity:.8; }
.unseen-toolbar { display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:8px 16px; margin-bottom:10px; font-size:12px; color:var(--gray-text); }
.unseen-toolbar select { font:inherit; color:var(--text); border:1px solid #9cc8e4; border-radius:8px; padding:5px 10px; background:white; }
.unseen-legend { display:flex; flex-wrap:wrap; gap:4px 14px; align-items:center; }
.unseen-legend i { font-style:normal; font-size:1.25em; color:var(--primary-hover); }
.unseen-key { padding:2px 8px; border-radius:6px; background:#e9eef2; }
.unseen-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(122px,1fr)); gap:8px; overflow:auto; padding:2px; }
.unseen-fraction { padding:7px 9px; border:1px solid var(--border); border-radius:12px; background:var(--slate); }
.unseen-card-head { display:flex; align-items:center; gap:8px; margin-bottom:6px; }
.unseen-card-head .ktop,.unseen-card-head .kbot { font-size:18px; padding:0 5px 1px; border-bottom-width:2px; }
.unseen-card-head .kbot { padding:1px 5px 0; }
.unseen-card-head > .remaining-count { margin-left:auto; color:var(--primary-hover); }
.unseen-stars { font:600 12px Inter,var(--font-b); color:#a85a00; }
.unseen-styles { display:flex; gap:4px; }
.unseen-styles > span { flex:1; padding:2px 0; border-radius:6px; text-align:center; font-size:15px; line-height:1.3; }
.unseen-styles .available { color:var(--primary-hover); background:var(--accent-light); }
.unseen-styles .seen { color:#b4bec8; background:#eef1f4; }
.exhausted { background:#f0f2f4; border-style:dashed; }
.unseen-special-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); gap:12px; overflow:auto; }
.unseen-special { display:flex; flex-direction:column; align-items:center; gap:10px; padding:20px 12px; border:1px solid var(--border); border-radius:14px; background:var(--sky); }
.unseen-special strong { font:600 28px Inter,var(--font-h); }
.unseen-special small { color:var(--gray-text); }
.unseen-explanation { margin-top:10px; font-size:12px; color:var(--gray-text); }
.unseen-explanation summary { cursor:pointer; padding:4px 0; }
.unseen-explanation p { line-height:1.7; margin:6px 0; }
@media(min-width:1400px) and (min-height:840px) {
 .unseen-panel { width:min(1500px,94vw); padding:26px 32px; }
 .unseen-meta,.unseen-toolbar,.unseen-explanation { font-size:clamp(13px,.9vw,17px); }
 .unseen-tabs button { font-size:clamp(14px,1vw,19px); padding:10px 18px; }
 .remaining-count b { font-size:clamp(18px,1.3vw,26px); }
 .unseen-grid { grid-template-columns:repeat(auto-fill,minmax(clamp(122px,10vw,190px),1fr)); gap:10px; }
 .unseen-fraction { padding:10px 12px; }
 .unseen-card-head .ktop,.unseen-card-head .kbot { font-size:clamp(18px,1.4vw,28px); }
 .unseen-stars { font-size:clamp(12px,.9vw,17px); }
 .unseen-styles > span { font-size:clamp(15px,1.15vw,22px); }
}
@media(max-width:640px) {
 .unseen-panel { padding:16px; }
 .unseen-tabs { gap:6px; }
 .unseen-tabs button { flex-direction:column; padding:8px 6px; font-size:12px; }
 .unseen-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
 .unseen-special-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
 .unseen-meta { gap:4px 12px; }
}
.result-modal { border-top:7px solid var(--yellow); }
.pl-scoretab { width:100%; }
.pl-scoretab td,.pl-scoretab th { padding:9px 12px; }
.pl-scoretab tr.net { background:var(--amber); }
.result-btns { flex-wrap:wrap; justify-content:center; }
.howto { border-radius:22px; }
.ht-nav { border-color:var(--border); }
.ht-dot.on { background:var(--primary); }
.ht-progress { color:var(--primary-hover); font:600 12px var(--font-h); text-align:center; padding:6px; }
.tut-coach { border-color:#eacb6f; background:#fffbeb; box-shadow:0 8px 28px #1230491c; }
.tut-modal { border-top:6px solid var(--yellow); }
@media(min-width:1001px) { .pl-info { width:275px; gap:3px; } .pl-meta { gap:5px; } .pl-clock { padding:2px 4px; } .pl-row { padding:6px 10px; } .play-root .sp-cv { width:34px; } .gem-tray { margin-top:1px; }}
@media(min-width:1001px) and (min-height:720px) { .pl-card { height:clamp(108px,15vh,150px); } .pl-card.sm { height:clamp(108px,15vh,150px); } }
@media(max-width:1000px) { .play-root { height:auto; min-height:100dvh; overflow:visible; } .pl-stage { min-height:210px; flex:auto; } .pl-row { gap:12px; } .pl-info { width:205px; } .pl-hand { gap:7px; } .play-top { flex-wrap:wrap; } .tut-coach { position:relative; inset:auto; transform:none; width:100%; order:10; } }
@media(max-width:640px) {
  .landing-demo .demo-equation.has-extra .demo-card { width:56px; }
  .landing-demo .demo-equation.has-extra .demo-card strong { font-size:27px; }
  .landing-demo .demo-equation.has-extra .demo-card small { font-size:7px; }
  .landing-demo .demo-equation.has-extra .demo-whole small { white-space:normal; }
  .landing-demo .demo-top { align-items:flex-start; flex-direction:column; } .demo-mode-tabs { align-self:stretch; } .demo-mode-tabs button { flex:1; padding:7px 5px; } .landing-demo .demo-equation { gap:7px; } .landing-demo .demo-card { width:78px; height:120px; }.landing-demo .demo-whole { font-size:42px; }
  .wrap { padding:16px 12px 28px; } .top { flex-wrap:wrap; margin-bottom:14px; } .top .brand { gap:8px; } .t1 { font-size:17px; }
  .overlay { padding:10px; } .add-card,.revive-modal,.result-modal,.tut-modal { padding:18px; max-height:90dvh; overflow:auto; }
  .howto { padding:16px; } .howto .add-head { font-size:16px; }.ht-nav { display:grid; grid-template-columns:1fr 1fr; } .ht-nav > .ht-dots { order:3; grid-column:1 / -1; } .ht-nav > button { width:100%; }
  .hist-top { flex-direction:column; align-items:stretch; gap:10px; } .hist-meta { width:auto; } .hist-cards { overflow-x:auto; padding-bottom:7px; } .hist-card { flex:0 0 54px; } .hist-list { max-height:65dvh; }
  .howto { width:100%; max-width:100%; height:90dvh; }.ht-nav { gap:6px; flex-wrap:wrap; } .ht-dots { flex-wrap:wrap; justify-content:center; }
.landing-mode:hover { transform:translateY(-3px); }
}
@media(max-height:650px) and (min-width:1001px) { .play-root { height:auto; min-height:100dvh; overflow:visible; } .pl-stage { flex:auto; min-height:180px; } }
@media(prefers-reduced-motion:reduce) { *,*::before,*::after { animation-duration:.01ms!important; animation-iteration-count:1!important; transition-duration:.01ms!important; } }
/* Full-screen button beside every TH/EN toggle. */
.top-tools { display:flex; align-items:center; gap:10px; }
.fs-btn { display:grid; place-items:center; width:40px; height:40px; flex-shrink:0; padding:0; border:1px solid var(--border); border-radius:50%; background:#fff; color:var(--primary-hover); cursor:pointer; }
.fs-btn:hover { background:var(--sky); border-color:var(--accent); }
.fs-btn.on { background:var(--primary); border-color:var(--primary); color:#fff; }
.play-top-right .fs-btn { width:36px; height:36px; }
/* Tutorial: rules, then card styles — same look as the play setup. */
.tut-pick-body { flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:clamp(14px,2.4vh,28px); padding:12px 0; }
.tut-pick-lead { margin:0; font-size:clamp(14px,1.1vw,20px); color:var(--gray-text); text-align:center; }
.tut-rule-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:clamp(14px,2vw,36px); width:min(960px,100%); }
.tut-rule { display:flex; flex-direction:column; align-items:center; gap:8px; min-width:0; padding:clamp(16px,2vw,32px); border:1.5px solid var(--border); border-bottom-width:5px; border-radius:20px; background:#fff; color:var(--text); font-family:var(--font-b); cursor:pointer; transition:transform .18s; }
.tut-rule:hover { transform:translateY(-3px); }
.tut-rule.gem { background:var(--primary); border-color:var(--primary-hover); color:#fff; }
.tut-rule-art { width:clamp(86px,min(9vw,16vh),170px); margin-bottom:6px; transform:rotate(-5deg); }
.tut-rule.gem .tut-rule-art { transform:rotate(5deg); }
.tut-rule-art svg { display:block; width:100%; height:auto; overflow:visible; filter:drop-shadow(0 6px 3px #12304922); }
.tut-rule strong { font:600 clamp(24px,2.2vw,40px) Inter,var(--font-h); }
.tut-rule-desc { font-size:clamp(13px,1vw,18px); color:var(--gray-text); text-align:center; }
.tut-rule.gem .tut-rule-desc { color:#fff; }
.tut-rule .landing-mode-action { margin-top:8px; font-size:clamp(13px,1vw,18px); }
.tut-rule.gem .landing-mode-action { border-color:#ffffff40; }
.tut-pick .menu-note { margin:0; font-size:clamp(12px,.9vw,16px); }
.tut-styles { display:flex; flex-direction:column; }
.tut-go { display:flex; align-items:center; gap:14px; margin-top:14px; }
.tut-go .setup-start { flex:1; min-height:60px; margin:0; font-size:clamp(18px,1.4vw,24px); }
.tut-rule-chip { padding:8px 16px; border-radius:999px; background:var(--yellow); color:var(--text); font:700 clamp(14px,1vw,18px) Inter,var(--font-h); }
@media(min-width:1000px) { .tut-styles { flex:1; min-height:0; } }
@media(max-width:640px) { .tut-rule-grid { grid-template-columns:1fr; } .tut-rule { flex-direction:row; flex-wrap:wrap; text-align:left; } .tut-rule-art { width:60px; margin:0; } }
/* Big screens (the TV at the front of the room): the table spreads edge to edge and grows with the screen height. */
@media(min-width:1400px) and (min-height:840px) {
  .play-root { max-width:none; padding:12px clamp(20px,2.4vw,56px); gap:clamp(8px,1vh,14px); }
  .play-top { min-height:52px; }
  .play-title { font-size:clamp(20px,1.4vw,28px); }
  .play-root .back-home,.play-root .hist-btn { font-size:clamp(14px,.9vw,18px); padding:8px 16px; }
  .play-top-right .fs-btn { width:42px; height:42px; }
  .turn-guide { padding:10px 18px; gap:16px; }
  .turn-guide strong { font-size:clamp(15px,1.05vw,21px); }
  .turn-guide span { font-size:clamp(14px,.95vw,19px); }
  .pl-row { padding:10px 16px; gap:24px; }
  .pl-info { width:clamp(300px,19vw,380px); gap:6px; }
  .pl-name,.pl-clock { font-size:clamp(17px,1.15vw,23px); }
  .pl-score { font-size:clamp(14px,.95vw,19px); padding:3px 12px; }
  .play-root .sp-cv { width:clamp(42px,2.6vw,54px); }
  .gem-tray-label { font-size:clamp(12px,.8vw,15px); }
  .pl-info .pl-mode-btn { font-size:clamp(12px,.85vw,16px); padding:7px 10px; }
  .pl-card { height:clamp(160px,19vh,240px); }
  .pl-card.sm,.pl-stage .pl-card.sm { height:clamp(160px,20vh,250px); }
  .pl-staged { min-height:clamp(160px,20vh,250px); }
  .card-back-mini { height:clamp(100px,12vh,150px); }
  .pile-count,.pile-card { height:clamp(120px,16vh,200px); }
  .pile-label,.pl-stage-label { font-size:clamp(12px,.85vw,16px); }
  .pile-num { font-size:clamp(24px,2vw,38px); }
  .pl-empty { font-size:clamp(14px,1vw,19px); }
  .pl-stage-body { grid-template-columns:clamp(160px,12vw,260px) minmax(0,1fr) clamp(160px,12vw,260px); }
  .pl-actions { padding:12px 16px; }
  .pl-actions .primary,.pl-actions .ghost { font-size:clamp(15px,1vw,19px); padding:11px 26px; }
  .pl-hint { font-size:clamp(14px,.95vw,18px); }
  .sum-toggle { font-size:clamp(12px,.85vw,16px); padding:5px 14px; }
  .pl-result { font-size:clamp(15px,1.1vw,22px); }
  /* the tutorial coach is fixed on the left — keep the table clear of it */
  .tut-coach { width:clamp(236px,17vw,340px); }
  .play-root:has(.tut-coach) { padding-left:calc(clamp(236px,17vw,340px) + 28px); }
  .tut-step { font-size:clamp(15px,1.1vw,21px); }
  .tut-text { font-size:clamp(13.5px,1vw,19px); }
  .tut-prog,.tut-skip { font-size:clamp(12px,.85vw,16px); }
  .tut-modal,.result-modal { zoom:1.2; }
  .setup-one .t1 { font-size:clamp(22px,1.5vw,30px); }
  .setup-one .back-home { font-size:clamp(13px,.9vw,17px); padding:8px 16px; }
}
@media(min-width:1800px) and (min-height:1000px) { .tut-modal,.result-modal { zoom:1.4; } }
/* Tutorial lesson map: every lesson as a tile, in play order */
.tut-map-top { display:flex; align-items:center; gap:clamp(12px,2vw,32px); margin-bottom:14px; }
.tut-map-progress { flex:1; display:flex; align-items:center; gap:14px; min-width:0; font-size:clamp(14px,1.1vw,19px); color:var(--gray-text); }
.tut-map-progress b { color:var(--primary-hover); }
.tut-map-bar { flex:1; height:14px; border:1.5px solid var(--border); border-radius:999px; background:#fff; overflow:hidden; }
.tut-map-bar i { display:block; height:100%; border-radius:999px; background:linear-gradient(90deg,var(--accent),var(--primary)); transition:width .6s ease; }
.tut-map-top .setup-start { flex:0 0 auto; width:auto; min-height:54px; margin:0; padding:10px 28px; font-size:clamp(17px,1.3vw,24px); }
.tut-map-grid { flex:1; min-height:0; display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); grid-auto-rows:1fr; gap:clamp(8px,1.2vw,16px); margin:0; padding:0; list-style:none; }
.tut-lesson { position:relative; width:100%; height:100%; display:grid; grid-template-columns:auto 1fr; grid-template-rows:auto auto; align-content:center; align-items:center; column-gap:12px; padding:clamp(8px,1vw,16px) clamp(10px,1.2vw,18px); border:1.5px solid var(--border); border-bottom-width:4px; border-radius:16px; background:#fff; color:var(--text); text-align:left; font-family:var(--font-b); cursor:pointer; transition:transform .16s, box-shadow .16s, border-color .16s; }
.tut-lesson:hover { transform:translateY(-2px); border-color:var(--accent); }
.tut-lesson-n { grid-row:1 / 3; width:clamp(32px,2.6vw,46px); aspect-ratio:1; display:grid; place-items:center; border-radius:50%; background:var(--slate); border:1.5px solid var(--border); font:800 clamp(14px,1.1vw,20px) Inter,var(--font-h); color:var(--primary-hover); }
.tut-lesson-ic { position:absolute; top:8px; right:12px; font-size:clamp(16px,1.3vw,24px); opacity:.85; }
.tut-lesson strong { padding-right:28px; font:700 clamp(13px,1.05vw,18px) var(--font-h); line-height:1.35; color:var(--primary-hover); }
.tut-lesson small { font-size:clamp(11px,.85vw,15px); color:var(--gray-text); }
.tut-lesson.done { background:#f1fbf5; border-color:#bfe6cf; }
.tut-lesson.done .tut-lesson-n { background:var(--success); border-color:var(--success); color:#fff; }
.tut-lesson.done small { color:var(--success); font-weight:700; }
.tut-lesson.skipped small { color:#a85a00; }
.tut-lesson.next { border-color:var(--primary); background:var(--sky); box-shadow:0 4px 0 #a8d7f6; }
.tut-lesson.next .tut-lesson-n { background:var(--yellow); border-color:#ebcf70; color:var(--text); animation:ht2-pulse 1.6s ease-in-out infinite; }
.tut-map-foot { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:8px 16px; margin-top:12px; font-size:clamp(12px,.95vw,16px); color:var(--gray-text); }
@media(max-width:900px) { .tut-map-grid { grid-template-columns:repeat(2,minmax(0,1fr)); grid-auto-rows:auto; } }
@media(max-width:640px) {
  .tut-map-top { flex-direction:column; align-items:stretch; }
  .tut-map-top .setup-start { width:100%; }
  .tut-map-grid { grid-template-columns:1fr; }
}
/* Tutorial coach: spotlight + pointing hand + one instruction, example preview, cheer and notes */
.tut-dim { position:fixed; z-index:41; border-radius:14px; box-shadow:0 0 0 200vmax rgba(18,48,73,.42); pointer-events:none; transition:left .3s ease, top .3s ease, width .3s ease, height .3s ease; }
.tut-hand { position:fixed; z-index:60; font-size:40px; line-height:1; pointer-events:none; filter:drop-shadow(0 3px 2px rgba(0,0,0,.3)); transition:left .3s ease, top .3s ease; animation:tut-bob .9s ease-in-out infinite; }
.tut-hand.up { animation-name:tut-bob-down; }
.tut-bubble { position:fixed; z-index:60; max-width:300px; transform:translateX(-50%); padding:8px 16px; border-radius:14px; background:#123049; color:#fff; font:700 clamp(14px,1.1vw,20px) var(--font-h); text-align:center; white-space:nowrap; pointer-events:none; box-shadow:0 8px 20px rgba(0,0,0,.25); transition:left .3s ease, top .3s ease, bottom .3s ease; }
.tut-coach-btns { display:flex; flex-wrap:wrap; gap:6px; }
.tut-why { margin-top:8px; padding:6px 10px; border-radius:10px; background:#fff1e6; color:#9a4a00; font-size:13px; line-height:1.5; }
.tut-cheer { position:fixed; left:50%; top:16%; z-index:60; transform:translateX(-50%); display:flex; flex-direction:column; align-items:center; gap:6px; padding:14px 24px; border:2px solid #bfe6cf; border-radius:18px; background:#f1fbf5; box-shadow:0 14px 40px rgba(18,48,73,.25); pointer-events:none; animation:tut-pop .45s cubic-bezier(.3,1.6,.5,1) both; }
.tut-cheer strong { font:800 clamp(20px,1.7vw,30px) var(--font-h); color:var(--success); }
.tut-cheer small { font-size:clamp(13px,1vw,17px); color:var(--text); }
.tut-cheer-calc { display:flex; flex-wrap:wrap; justify-content:center; gap:6px; }
.tut-cheer-calc span { padding:3px 10px; border-radius:999px; background:#fff; border:1px solid #bfe6cf; font:600 clamp(12px,.95vw,16px) Inter,var(--font-b); color:var(--text); }
.tut-nudge { position:fixed; left:50%; bottom:26%; z-index:60; transform:translateX(-50%); padding:8px 16px; border-radius:12px; background:#fff1e6; border:1.5px solid #ffc999; color:#9a4a00; font:600 clamp(13px,1vw,17px) var(--font-h); pointer-events:none; animation:tut-pop .3s ease both; }
.tut-modal.tut-preview { width:min(940px,96vw); container-type:inline-size; }
.tut-preview .ht2-stage { --hc:min(clamp(90px,26vh,240px),20cqi); min-height:calc(var(--hc) * 1.7); padding:10px 0; }
.tut-never { margin-top:8px; border:0; background:none; color:var(--gray-text); font-size:12px; text-decoration:underline; cursor:pointer; }
@keyframes tut-bob { 0%,100% { transform:translateY(0); } 50% { transform:translateY(-10px); } }
@keyframes tut-bob-down { 0%,100% { transform:translateY(0); } 50% { transform:translateY(10px); } }
@keyframes tut-pop { from { opacity:0; transform:translate(-50%,10px) scale(.85); } to { opacity:1; transform:translate(-50%,0) scale(1); } }
@media(min-width:1400px) and (min-height:840px) { .tut-hand { font-size:52px; } .tut-bubble { max-width:420px; } .tut-why { font-size:clamp(13px,.95vw,17px); } }
/* a picker (Blank value, gems) is open during a lesson: keep the coach readable above its backdrop */
.play-root:has(.overlay .add-card, .overlay .gem-modal) .tut-coach { z-index:55; }
/* Add-card panel: the card preview on the left, the choices on the right; numbers come from the MIW keypad */
.add-card { width:min(760px,96vw); padding:20px 24px 22px; }
.add-tabs { margin:14px 0 4px; }
.add-tabs .seg-btn { padding:9px 14px; font-size:clamp(13px,1vw,16px); }
.add-split { display:grid; grid-template-columns:minmax(0,.9fr) minmax(0,1.1fr); gap:clamp(14px,2vw,28px); margin-top:14px; }
.add-preview { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:10px; padding:16px; border:1.5px solid var(--border); border-radius:18px; background:radial-gradient(circle at 50% 40%,#fff,var(--sky)); }
.add-preview-card { display:grid; place-items:center; min-height:clamp(150px,30vh,280px); }
.add-preview-card svg { width:auto; height:clamp(150px,30vh,280px); overflow:visible; filter:drop-shadow(0 8px 6px rgba(18,48,73,.18)); animation:ht2-flip .4s ease both; }
.add-status { margin:0; text-align:center; font:600 clamp(13px,1vw,16px) var(--font-h); color:var(--primary-hover); text-wrap:pretty; }
.add-status.warn { color:var(--error); font-weight:500; }
.add-controls { display:flex; flex-direction:column; gap:16px; min-width:0; }
.add-field label { display:block; margin-bottom:8px; font:700 13px var(--font-h); color:var(--gray-text); }
.add-styles { display:flex; flex-wrap:wrap; gap:8px; }
.add-style { display:inline-flex; align-items:center; gap:6px; padding:8px 12px; border:1.5px solid var(--border); border-radius:999px; background:#fff; color:var(--text); font:600 13px var(--font-h); cursor:pointer; }
.add-style i { font-style:normal; color:var(--primary-hover); }
.add-style.on { background:var(--primary); border-color:var(--primary); color:#fff; }
.add-style.on i { color:#fff; }
.add-style.num { min-width:46px; justify-content:center; font:700 16px Inter,var(--font-h); }
.add-frac { display:flex; flex-direction:column; align-items:center; gap:8px; width:max-content; margin:0 auto; }
.pad-num { min-width:92px; height:64px; padding:0 18px; border:2px solid var(--border); border-radius:16px; background:#fff; color:var(--text); font:800 36px Inter,var(--font-h); box-shadow:0 3px 0 var(--border); cursor:pointer; }
.pad-num:hover { border-color:var(--accent); }
.pad-num.empty { border-style:dashed; color:#9aa9b6; }
.pad-num.miw-pad-target { border-color:var(--primary); box-shadow:0 0 0 4px var(--accent-light); }
.add-bar { display:block; width:116px; height:4px; border-radius:2px; background:var(--text); }
.add-place { width:100%; min-height:54px; margin-top:auto; font-size:18px; }
.add-ops { margin-top:14px; }
.add-ops .op-grid { gap:12px; }
.add-ops .note { margin-top:12px; }
@media(max-width:640px) {
  .add-card { padding:16px; }
  .add-split { grid-template-columns:1fr; }
  .add-preview-card,.add-preview-card svg { min-height:0; height:130px; }
  .pad-num { height:54px; font-size:30px; }
}
/* Line breaks: never inside an equation, a fraction or a quoted button name; prefer to break at " · " */
.nw { white-space:nowrap; }
.nbs { display:inline-block; }
.ht2-cap p, .ht2-demo small, .tut-text, .tut-why, .tut-bubble, .preset-option div > span, .tut-rule-desc, .setup-summary li, .landing-mode-desc, .landing-intro p, .note, .tut-cheer small { text-wrap:pretty; }
.tut-bubble { white-space:normal; }
.tut-hand.side { animation-name:tut-bob-side; }
.tut-bubble.side { transform:none; max-width:240px; white-space:normal; text-align:left; }
@keyframes tut-bob-side { 0%,100% { transform:translateX(0); } 50% { transform:translateX(8px); } }
/* clause separator "—" with room on both sides, and a little more space between words, so phrases don't run together */
.dsep { display:inline-block; margin:0 .3em; color:var(--gray-text); font-weight:400; }
.ht2-cap p,.ht2-demo small,.ht2-sub,.tut-text,.tut-why,.tut-bubble,.tut-pick-lead,.preset-option div > span,.tut-rule-desc,.setup-summary li,.add-status,.landing-intro p,.pl-hint,.note { word-spacing:.14em; }
/* the play area keeps its cards on one row: they shrink to fit (down to 56px) before wrapping.
   --n = cards on the stage; 28px = gap + group divider + gap; 550/900 = card art ratio; 4px = border */
.pl-staged { container-type:inline-size; }
.pl-staged .pl-card.sm { max-height:max(56px, calc(((100cqi - 12px - (var(--n,1) - 1) * 28px) / var(--n,1) - 4px) * 900 / 550 + 4px)); }
.pl-staged .brk.sm { min-height:0; }
@media(min-width:1001px) {
  /* six or more cards also take the empty column on the left of the stage */
  .pl-stage-body:has(.pl-staged > div:nth-of-type(6), .lp-cards > div:nth-of-type(6)) .pl-stage-main { grid-column:1 / 3; }
}
/* rule cards on the tutorial picker: hover only lifts and tilts, the colours stay */
.tut-rule-art { transition:transform .25s cubic-bezier(.2,.8,.2,1); }
.tut-rule:hover .tut-rule-art { transform:rotate(-9deg) translateY(-6px) scale(1.04); }
.tut-rule.gem:hover .tut-rule-art { transform:rotate(9deg) translateY(-6px) scale(1.04); }
.tut-rule.gem .dsep { color:#ffffffa0; }
/* ==== phone, portrait: the whole table on one screen — no page scroll, no sideways scrolling.
   Cards size themselves: the hand fits its row (--n = cards in hand), the play area takes what is left. ==== */
@media (max-width:640px) {
  .play-root { height:100dvh; min-height:0; overflow:hidden; padding:6px 8px 8px; gap:6px; }
  .play-top { flex-wrap:nowrap; gap:6px; padding:0; }
  .play-top .back-home { flex-shrink:0; padding:6px 11px; font-size:14px; }
  .play-top .bh-label, .play-title .pt-game, .hist-btn .hb-label { display:none; }
  .play-title { flex:1; min-width:0; font-size:15px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  .play-top-right { width:auto; flex-wrap:nowrap; gap:4px; }
  .play-top-right .hist-btn { padding:6px 9px; font-size:14px; }
  .play-top-right .lang-btn { padding:5px 8px; font-size:12px; }
  .turn-guide { flex-direction:row; align-items:baseline; flex-wrap:wrap; gap:2px 8px; padding:6px 10px; }
  .turn-guide strong { font-size:14px; white-space:nowrap; }
  .turn-guide span { font-size:12.5px; }
  .pl-row { flex-direction:row; align-items:center; gap:8px; padding:6px 8px; }
  .pl-info { width:auto; gap:4px; }
  .pl-idrow { flex-wrap:nowrap; justify-content:space-between; gap:6px; }
  .pl-name, .pl-clock { font-size:14px; }
  .pl-score { padding:1px 8px; font-size:12px; }
  .pl-special { gap:4px; margin:0; }
  .play-root .sp-cv, .play-root .blank-stack .sp-cv { width:30px; }
  .gem-tray { display:flex; align-items:center; margin:0; }
  .gem-tray .gem-grid { display:none; }
  .gem-tray-label { margin:0; font-size:11.5px; }
  /* opponent: one short strip, its hand a fan of small backs */
  .pl-ai .pl-info { flex:1; min-width:0; }
  .pl-ai .pl-hand { flex:0 0 auto; flex-wrap:nowrap; gap:0; padding-left:14px; min-height:0; }
  .pl-ai .card-back-mini { flex-shrink:0; height:42px; margin-left:-15px; }
  /* play area: takes the height that is left */
  .pl-stage { flex:1 1 auto; min-height:0; overflow:hidden; padding:6px 8px; }
  .pl-stage-body { flex:1; min-height:0; display:flex; flex-direction:column; align-items:stretch; gap:6px; }
  .pl-stage-main { flex:1; min-height:0; }
  .pl-staged { flex:1; min-height:0; flex-wrap:wrap; padding:4px 0; }
  .pl-card.sm, .pl-stage .pl-card.sm { height:clamp(64px, 16dvh, 132px); }
  /* the play area keeps one row on a phone too: the group divider sits on the seam between cards instead of taking room (6px = the gap on each side of it) */
  .pl-staged { gap:3px; }
  .pl-staged .brk.sm { position:relative; z-index:2; flex:0 0 16px; margin:0 -8px; }
  .pl-staged .pl-card.sm { max-height:max(60px, calc(((100cqi - 8px - (var(--n, 1) - 1) * 6px) / var(--n, 1) - 4px) * 900 / 550 + 4px)); }
  .stg-x { top:2px; right:2px; width:18px; height:18px; font-size:10px; }
  .pl-result { padding:2px; font-size:15px; }
  .pl-piles { justify-content:center; gap:22px; padding:0; }
  .pl-piles .card-back-mini, .pile-count, .pile-card { height:clamp(46px, 7.5dvh, 72px); }
  .pile-num { font-size:20px; }
  .pile-label { font-size:11px; }
  /* me: name row, special cards + Make Whole / Make Match, then the hand on one row that always fits */
  .pl-row.pl-me { flex-direction:column; align-items:stretch; gap:4px; }
  .pl-me .pl-info { width:100%; display:grid; grid-template-columns:auto minmax(0,1fr); align-items:center; gap:4px 10px; }
  .pl-me .pl-idrow { grid-column:1 / -1; }
  .pl-me .pl-mode { margin:0; }
  .pl-me .pl-mode-btn { padding:7px 6px; font-size:13px; }
  .pl-me .gem-tray { grid-column:1 / -1; }
  /* --g = space between hand cards; from 6 cards on they overlap a little at the edges so each card stays bigger */
  .pl-hand.mine { --g:5px; container-type:inline-size; flex-wrap:nowrap; justify-content:center; gap:0; padding:10px 0 2px; overflow:visible; min-height:0; }
  .pl-hand.mine:has(> .pl-card:nth-child(6)) { --g:-12px; }
  .pl-hand.mine .pl-card { flex-shrink:0; height:min(124px, calc((100cqi - 10px - (var(--n, 6) - 1) * var(--g)) / var(--n, 6) * 900 / 550)); }
  .pl-hand.mine .pl-card + .pl-card { margin-left:var(--g); }
  .pl-hand.mine .pl-card:hover { transform:none; }
  .pl-hand.mine .pl-card.picked { transform:translateY(-6px); }
  .pl-actions { justify-content:center; gap:6px; margin:0; }
  .pl-actions button { min-height:40px; padding:7px 14px; font-size:14px; }
  .pl-actions .long { display:none; }
  .pl-hint, .pl-msg, .pl-note { font-size:12.5px; text-align:center; }
  .pl-speed { margin:0 auto; }
  /* tutorial: the coach sits under the turn line instead of floating over the hand */
  .play-root:has(.tut-coach) .play-top { order:-3; }
  .play-root:has(.tut-coach) .turn-guide { display:none; }
  .play-root .tut-coach { position:relative; inset:auto; transform:none; width:auto; order:-2; padding:8px 10px; }
  .play-root .tut-step { font-size:14px; }
  .play-root .tut-text { margin-top:3px; font-size:13px; line-height:1.5; }
}

/* ===== play board: avatars, dealt hands, a beckoning draw pile ===== */
.pl-ava { display:inline-block; width:1.6em; height:1.5em; margin-right:6px; vertical-align:-.42em; }
.pl-ava svg { display:block; width:100%; height:100%; overflow:visible; }
.pl-name.turn .pl-ava svg { animation:setup-bob 1.8s ease-in-out infinite; }
.pl-turnbadge { display:inline-block; animation:badge-pulse 1.6s ease-in-out infinite; }
@keyframes badge-pulse { 50% { transform:scale(1.08); } }
.pl-score { display:inline-block; animation:score-pop .45s cubic-bezier(.3,1.6,.5,1) backwards; }
@keyframes score-pop { from { transform:scale(1.4); } }
@keyframes hand-deal { from { opacity:0; transform:translateY(-34px) rotate(-8deg) scale(.85); } }
@keyframes hand-deal-up { from { opacity:0; transform:translateY(34px) rotate(8deg) scale(.85); } }
.pl-hand.dealt > .pl-card { animation:hand-deal .45s cubic-bezier(.2,1.2,.4,1) backwards; }
.pl-hand.dealt:not(.mine) > .card-back-mini { animation:hand-deal-up .45s cubic-bezier(.2,1.2,.4,1) backwards; }
.pl-hand.dealt > :nth-child(2) { animation-delay:70ms; } .pl-hand.dealt > :nth-child(3) { animation-delay:140ms; }
.pl-hand.dealt > :nth-child(4) { animation-delay:210ms; } .pl-hand.dealt > :nth-child(5) { animation-delay:280ms; }
.pl-hand.dealt > :nth-child(6) { animation-delay:350ms; } .pl-hand.dealt > :nth-child(n+7) { animation-delay:0ms; }
@keyframes stage-in { from { opacity:0; transform:translateY(18px) scale(.9); } }
.pl-staged .pl-card.sm { animation:stage-in .3s ease-out backwards; }
.pile.beckon .pileface::after { content:''; position:absolute; inset:-6px; border:3px solid var(--primary); border-radius:12px; pointer-events:none; animation:beckon 1.6s ease-out infinite; }
@keyframes beckon { from { opacity:.9; transform:scale(.96); } to { opacity:0; transform:scale(1.14); } }

/* ===== coin toss: pink heart side, green leaf side ===== */
.coin-picks { gap:14px; }
.coin-pick { display:inline-flex; align-items:center; gap:10px; padding:8px 24px 8px 8px; border:2px solid; border-radius:999px; font:700 19px var(--font-h); cursor:pointer; touch-action:manipulation; transition:transform .15s, box-shadow .15s; }
.coin-pick.head { background:#FFE1EC; border-color:#EC4F86; color:#9C2F58; box-shadow:0 4px 0 #EC4F86; }
.coin-pick.tail { background:#E2F6DA; border-color:#46A352; color:#25662F; box-shadow:0 4px 0 #46A352; }
.coin-pick:hover { transform:translateY(-2px); }
.coin-pick:active { transform:translateY(3px); box-shadow:0 1px 0 currentColor; }
.coin-pick:focus-visible { outline:3px solid var(--primary); outline-offset:3px; }
.coin-pick-face { display:block; width:42px; height:42px; flex-shrink:0; }
.coin-pick-face svg { display:block; width:100%; height:100%; }
.coin-pick:hover .coin-pick-face { animation:coin-wobble .55s ease-in-out; }
@keyframes coin-wobble { 25% { transform:rotate(-14deg); } 60% { transform:rotate(10deg); } }
.coin-outcome.head { color:#9C2F58; } .coin-outcome.tail { color:#25662F; }
.coin3d-edge { background:linear-gradient(90deg,#9a7a3a,#e2c27a 30%,#f6e2a8 50%,#d6b166 70%,#8a6a2a); }

/* ===== result popup ===== */
.result-modal { animation:result-in .45s cubic-bezier(.2,1.3,.4,1) backwards; }
@keyframes result-in { from { opacity:0; transform:translateY(24px) scale(.92); } }
.result-art { position:relative; display:flex; align-items:flex-end; justify-content:center; gap:8px; height:clamp(80px,12vh,110px); }
.result-art svg { display:block; width:auto; height:100%; overflow:visible; }
.result-art.draw svg { height:80%; }
.result-art.win .trophy { transform-origin:50% 90%; animation:trophy-rise .6s cubic-bezier(.3,1.5,.5,1) .15s backwards, trophy-sway 2.8s ease-in-out .9s infinite; }
.result-art.lose .robot, .result-art.draw svg { animation:setup-bob 1.8s ease-in-out infinite; }
.result-art.draw svg + svg { animation-delay:-.9s; }
@keyframes trophy-rise { from { opacity:0; transform:translateY(30px) scale(.6); } }
@keyframes trophy-sway { 50% { transform:rotate(-4deg); } }
.sparkle { position:absolute; width:16px; height:16px; background:#FFBF6F; clip-path:polygon(50% 0,62% 38%,100% 50%,62% 62%,50% 100%,38% 62%,0 50%,38% 38%); animation:twinkle 1.8s ease-in-out infinite; animation-delay:calc(var(--i) * .45s); }
.sparkle:nth-of-type(1) { left:calc(50% - 74px); top:8%; } .sparkle:nth-of-type(2) { left:calc(50% + 58px); top:2%; background:#F58BB0; }
.sparkle:nth-of-type(3) { left:calc(50% - 62px); top:62%; background:#7FC3EE; width:12px; height:12px; } .sparkle:nth-of-type(4) { left:calc(50% + 66px); top:56%; width:12px; height:12px; }
@keyframes twinkle { 0%, 100% { opacity:0; transform:scale(.4) rotate(0); } 50% { opacity:1; transform:scale(1) rotate(45deg); } }
.result-kicker { margin-top:4px; font:600 13px var(--font-h); letter-spacing:.06em; color:var(--gray-text); }
.result-title { font-size:clamp(24px,2vw,32px); line-height:1.25; animation:setup-pop .45s cubic-bezier(.3,1.6,.5,1) .25s backwards; }
.result-cheer { margin:0 0 4px; font-size:15px; color:var(--gray-text); }
.pl-scoretab th.win { color:var(--primary); }
.pl-scoretab tr.net td.win .count-up { display:inline-block; min-width:2.2em; padding:0 10px; border-radius:999px; background:var(--yellow); color:var(--text); text-align:center; }
.result-btns button { display:inline-flex; align-items:center; gap:7px; }
.result-btns .primary .lucide { transition:transform .3s; }
.result-btns .primary:hover .lucide { transform:rotate(-200deg); }

/* ===== landing: swoosh, drifting cards, dealt demo, a timer bar, live mode pictures ===== */
.landing-intro { position:relative; }
.title-hl { position:relative; display:inline-block; isolation:isolate; }
.title-swoosh { position:absolute; left:-2%; bottom:-.08em; z-index:-1; width:104%; height:.34em; overflow:visible; }
.title-swoosh path { stroke-dasharray:210; stroke-dashoffset:210; animation:swoosh-draw .8s ease-out .35s forwards; }
@keyframes swoosh-draw { to { stroke-dashoffset:0; } }
.float-cards { position:absolute; top:0; right:0; bottom:0; width:min(46%,520px); pointer-events:none; }
.float-card { position:absolute; width:clamp(32px,2.8vw,48px); rotate:calc((var(--i) - 2) * 9deg); animation:float-in .6s cubic-bezier(.2,1.3,.4,1) backwards, float-drift 4.2s ease-in-out infinite; animation-delay:calc(var(--i) * 90ms), calc(var(--i) * -.8s); }
.float-card svg { display:block; width:100%; height:auto; overflow:visible; filter:drop-shadow(0 3px 3px #12304920); }
.float-card:nth-child(1) { left:2%; top:10%; } .float-card:nth-child(2) { left:22%; top:-6%; } .float-card:nth-child(3) { left:43%; top:12%; }
.float-card:nth-child(4) { left:64%; top:-4%; } .float-card:nth-child(5) { left:84%; top:10%; }
@keyframes float-in { from { opacity:0; scale:.4; } }
@keyframes float-drift { 50% { translate:0 -8px; } }
@media(max-width:640px) { .float-cards { display:none; } }
.demo-animated .demo-game-card { animation:demo-deal .55s cubic-bezier(.2,1.2,.4,1) backwards, demo-float 3.4s ease-in-out .7s infinite; }
.demo-animated .demo-game-card.second { animation-delay:.14s, 1.4s; }
.demo-animated .demo-game-card ~ .demo-game-card:not(.second) { animation-delay:.28s, 2s; }
@keyframes demo-deal { from { opacity:0; translate:0 -36px; scale:.8; } }
@keyframes demo-float { 50% { translate:0 -6px; } }
.demo-animated .demo-whole { animation:demo-whole-pop .5s cubic-bezier(.3,1.6,.5,1) .5s backwards; }
@keyframes demo-whole-pop { from { opacity:0; scale:.3; } }
.demo-timer { height:4px; margin:4px 0 8px; border-radius:999px; background:#ffffffa0; overflow:hidden; }
.demo-timer i { display:block; width:100%; height:100%; background:var(--primary); opacity:.45; transform-origin:0 50%; transform:scaleX(0); }
.demo-timer i.run { animation:demo-timer 5s linear forwards; }
@keyframes demo-timer { to { transform:scaleX(1); } }
.landing-mode { animation:mode-in .5s cubic-bezier(.2,1.2,.4,1) backwards; }
.landing-mode:nth-child(2) { animation-delay:.1s; } .landing-mode:nth-child(3) { animation-delay:.2s; }
@keyframes mode-in { from { opacity:0; translate:28px 0; } }
.mi-bulb { animation:setup-glow 1.8s ease-in-out infinite; }
.mi-flow { animation:mi-flow 1.4s linear infinite; }
@keyframes mi-flow { to { stroke-dashoffset:-18; } }
.landing-mode:hover .mi-cards, .landing-mode:focus-visible .mi-cards { animation:mi-hop .45s ease-in-out infinite alternate; }
.landing-mode:hover .mi-hand, .landing-mode:focus-visible .mi-hand { animation:mi-hop .35s ease-in-out infinite alternate; }
.landing-mode:hover .mi-result, .landing-mode:focus-visible .mi-result { animation:mi-hop .5s ease-in-out infinite alternate; }
@keyframes mi-hop { to { transform:translateY(-5px); } }
.landing-tools button { display:inline-flex; align-items:center; gap:6px; }
.landing-device .lucide { vertical-align:-.2em; margin-right:6px; color:var(--primary); }
.landing-home .lucide { flex-shrink:0; }

/* ===== landing: the game manual link (opens the slide manual in a new tab) ===== */
.landing-tools .landing-manual { display:inline-flex; align-items:center; gap:6px; min-height:38px; padding:7px 16px; border:1px solid var(--border); border-radius:999px; background:#fff; color:var(--primary-hover); font:600 13px var(--font-h); text-decoration:none; }
.landing-tools .landing-manual:hover { background:var(--sky); border-color:var(--accent); }
.landing-tools .landing-manual:focus-visible { outline:3px solid var(--primary); outline-offset:3px; }
@media(min-width:1000px) and (min-height:650px) { .landing-tools .landing-manual { font-size:clamp(13px,1vw,17px); } }

/* ===== lesson map: the bar grows toward a trophy, lessons are dealt in, your face marks the next one ===== */
.tut-map-track { flex:1; display:flex; align-items:center; gap:10px; min-width:0; }
.tut-map-bar i { transform-origin:0 50%; animation:bar-grow .9s cubic-bezier(.2,.9,.3,1) .25s backwards; }
@keyframes bar-grow { from { transform:scaleX(0); } }
.tut-map-goal { flex-shrink:0; width:clamp(30px,2.4vw,42px); filter:grayscale(1); opacity:.45; transition:filter .3s, opacity .3s; }
.tut-map-goal svg { display:block; width:100%; height:auto; overflow:visible; }
.tut-map-goal.on { filter:none; opacity:1; }
.tut-map-goal.on svg { transform-origin:50% 90%; animation:trophy-sway 2.8s ease-in-out infinite; }
.tut-map-grid > li { animation:lesson-in .45s cubic-bezier(.2,1.2,.4,1) backwards; animation-delay:calc(var(--i) * 45ms); }
@keyframes lesson-in { from { opacity:0; transform:translateY(18px) scale(.94); } }
.tut-lesson.done .tut-lesson-n { animation:lesson-stamp .5s cubic-bezier(.3,1.6,.5,1) backwards; animation-delay:calc(var(--i) * 45ms + .35s); }
@keyframes lesson-stamp { from { transform:scale(2) rotate(-20deg); opacity:0; } }
.tut-lesson.done::after { content:''; position:absolute; right:12px; bottom:10px; width:15px; height:15px; background:#FFBF6F; clip-path:polygon(50% 0,61% 35%,98% 35%,68% 57%,79% 91%,50% 70%,21% 91%,32% 57%,2% 35%,39% 35%); }
.tut-here { position:absolute; top:-14px; left:-10px; z-index:1; width:clamp(30px,2.4vw,40px); pointer-events:none; animation:setup-bob 1.8s ease-in-out infinite; }
.tut-here svg { display:block; width:100%; height:auto; overflow:visible; filter:drop-shadow(0 2px 2px #12304930); }
.tut-lesson.next:hover .tut-lesson-ic, .tut-lesson:hover .tut-lesson-ic { animation:mi-hop .35s ease-in-out infinite alternate; }

/* ===== How to play: pages slide the way you go, chapter tabs fill up, a spinning replay ===== */
.ht2-page { animation:ht2-slide .42s cubic-bezier(.2,1,.3,1) both; }
.ht2-page.back { animation-name:ht2-slide-back; }
@keyframes ht2-slide { from { opacity:0; translate:48px 0; } }
@keyframes ht2-slide-back { from { opacity:0; translate:-48px 0; } }
.ht2-cap p { animation:ht2-line .4s ease-out backwards; }
.ht2-cap p:nth-of-type(1) { animation-delay:.12s; } .ht2-cap p:nth-of-type(2) { animation-delay:.22s; } .ht2-cap p:nth-of-type(3) { animation-delay:.32s; } .ht2-cap p:nth-of-type(4) { animation-delay:.42s; }
@keyframes ht2-line { from { opacity:0; translate:0 8px; } }
.ht2-ic { display:inline-block; animation:setup-pop .5s cubic-bezier(.3,1.6,.5,1) .05s backwards; }
.ht2-tabs button { position:relative; overflow:hidden; }
.ht2-tabs button.done b { background:#d9f2e3; color:var(--success); }
.ht2-tabfill { position:absolute; left:0; bottom:0; height:3px; width:0; background:var(--yellow); }
.ht2-tabs button.on .ht2-tabfill { width:calc(var(--p, 0) * 100%); transition:width .35s ease; }
.ht2-replay { display:grid; place-items:center; }
.ht2-spin { display:grid; place-items:center; animation:ht2-spin .5s ease-out; }
@keyframes ht2-spin { from { rotate:-360deg; } }
.ht2-finish { animation:setup-nudge 2.6s ease-in-out 1s infinite; }

/* ===== Fraction lab: Lucide flask and dice, ✓ on finished steps, a small cheer when the answer is reached ===== */
.lab-flask { display:inline-grid; place-items:center; margin-right:8px; color:var(--primary); vertical-align:-.12em; }
.lab-dice, .lab-dock .primary.lab-ready { display:inline-flex; align-items:center; gap:6px; }
.dice-roll { display:inline-grid; place-items:center; animation:dice-roll .6s cubic-bezier(.3,1.4,.5,1); }
@keyframes dice-roll { from { rotate:-540deg; scale:.6; } }
.lab-steps button.done b { animation:lesson-stamp .45s cubic-bezier(.3,1.6,.5,1) backwards; }
.lab-read { position:relative; }
.lab-read.lab-done { animation:lab-cheer .6s cubic-bezier(.3,1.6,.5,1); }
@keyframes lab-cheer { 40% { scale:1.06; } }
.lab-read .sparkle { top:auto; }
.lab-read .sparkle:nth-of-type(1) { left:calc(50% - 170px); top:6%; } .lab-read .sparkle:nth-of-type(2) { left:calc(50% + 150px); top:0; }
.lab-read .sparkle:nth-of-type(3) { left:calc(50% - 130px); top:62%; } .lab-read .sparkle:nth-of-type(4) { left:calc(50% + 120px); top:58%; }

/* ── MIW number pad — pairs with miw-pad.js ── */
.miw-pad { position: fixed; z-index: 9600; width: 256px; padding: 10px; background: #fff; border: 1px solid #e2e8f0; border-radius: 20px;
  box-shadow: 0 16px 40px rgba(15, 30, 74, .22); font-family: 'Kanit', sans-serif; user-select: none; -webkit-user-select: none;
  touch-action: manipulation; animation: miwPadIn .16s ease-out; }
.miw-pad-head { display: flex; align-items: center; gap: 6px; margin-bottom: 9px; }
.miw-pad-label { font: 600 13px 'Kanit', sans-serif; color: #64748b; white-space: nowrap; max-width: 40%; overflow: hidden; text-overflow: ellipsis; }
.miw-pad-show { flex: 1; min-width: 0; min-height: 48px; display: flex; align-items: center; justify-content: flex-end; gap: 1px; padding: 0 12px;
  border-radius: 12px; background: #f7fbff; border: 1.5px solid #93c5fd; font: 700 26px 'Inter', 'Kanit', sans-serif; color: #1e3a8a;
  white-space: nowrap; overflow: hidden; }
.miw-pad-show::after { content: ''; flex: none; width: 2px; height: 1.05em; margin-left: 2px; background: #1e3a8a; animation: miwPadCaret 1s steps(1) infinite; }
.miw-pad-show.empty::before { content: '?'; color: #cbd5e1; }
.miw-pad-show.fresh { background: #dbeafe; }
.miw-pad-show.fresh::after { opacity: 0; animation: none; }
.miw-pad-show i { font: italic 600 1.08em 'Cambria', 'Times New Roman', serif; padding: 0 1px; }
.miw-pad-frac { display: inline-flex; flex-direction: column; align-items: center; font-size: .62em; line-height: 1.05; }
.miw-pad-frac span:first-child { border-bottom: 2px solid currentColor; padding: 0 3px; }
/* a power: the exponent sits up and smaller; an empty one is an orange box (the same box as on the ^ key) */
.miw-pad-pow { position: relative; top: -.5em; font-size: .62em; line-height: 1; padding-left: 1px; }
.miw-pad-pow.empty { top: -.3em; min-width: .85em; height: 1.05em; margin-left: 2px; border: 2px dashed #f59e0b; border-radius: 4px; text-align: center; }
.miw-pad-show.up::after { height: .62em; transform: translateY(-.4em); }
/* a root: the sign stretches to the number's height and its bar runs over the number; ∛ has a small 3 on the hook */
.miw-pad-rad { position: relative; display: inline-flex; align-items: stretch; margin-left: 1px; }
.miw-pad-rad.cube { padding-left: .14em; }
.miw-pad-radidx { position: absolute; left: 0; top: .02em; font-size: .4em; line-height: 1; }
.miw-pad-radsign { flex: none; width: .48em; height: auto; overflow: visible; fill: none; stroke: currentColor; stroke-width: 2.2;
  stroke-linecap: round; stroke-linejoin: round; }
.miw-pad-radsign path { vector-effect: non-scaling-stroke; }
.miw-pad-radin { border-top: 2.2px solid currentColor; padding: .05em .1em 0 .06em; line-height: 1.05; }
.miw-pad-radin.empty::before { content: ''; display: block; width: .55em; height: .75em; margin: .04em 0 .02em; border: 2px dashed #f59e0b; border-radius: 4px; }
.miw-pad-radkey { width: 1.2em; height: 1.05em; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.miw-pad-key svg.miw-pad-radkey { width: 1.2em; height: 1.05em; }
.miw-pad-radkey rect { fill: #f59e0b; stroke: none; }
.miw-pad-radkey text { fill: currentColor; stroke: none; font: 700 9px 'Inter', sans-serif; }
.miw-pad-powkey { position: relative; display: block; width: 1.25em; height: 1.2em; }   /* in em: a page can show it in a smaller label too */
.miw-pad-powkey::before { content: ''; position: absolute; left: .05em; bottom: .05em; width: .75em; height: .75em; box-sizing: border-box;
  border: .1em solid currentColor; border-radius: .14em; }
.miw-pad-powkey::after { content: ''; position: absolute; right: .05em; top: .05em; width: .42em; height: .42em; border-radius: .11em; background: #f59e0b; }
.miw-pad-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.miw-pad-extra { display: grid; grid-template-columns: repeat(var(--n, 3), 1fr); gap: 7px; margin-top: 7px; }
.miw-pad-key { height: 52px; min-width: 0; padding: 0; display: grid; place-items: center; border: 1.5px solid #e2e8f0; border-radius: 14px;
  background: #f7f9fc; box-shadow: 0 3px 0 #dbe3ef; font: 700 24px 'Inter', sans-serif; color: #1e293b; cursor: pointer;
  transition: transform .06s, box-shadow .06s, background .1s; }
.miw-pad-key:hover { background: #eef4fb; }
.miw-pad-key:active, .miw-pad-key.hit { transform: translateY(2px); box-shadow: 0 1px 0 #dbe3ef; background: #e3edf9; }
.miw-pad-key:focus-visible, .miw-pad-ok:focus-visible { outline: 3px solid #93c5fd; outline-offset: 1px; }
.miw-pad-key.fn { font: 600 16px 'Kanit', sans-serif; color: #475569; }
.miw-pad-key svg, .miw-pad-ok svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.miw-pad-key.var { font: italic 600 26px 'Cambria', 'Times New Roman', serif; color: #1e3a8a; }
.miw-pad-key.op { color: #1e3a8a; }
.miw-pad-ok, .miw-pad-key.ok { display: flex; align-items: center; justify-content: center; gap: 8px; border: 0; background: #1e3a8a; color: #fff;
  font: 600 17px 'Kanit', sans-serif; cursor: pointer; box-shadow: 0 3px 0 #142a66; }
.miw-pad-ok { width: 100%; height: 50px; margin-top: 9px; border-radius: 14px; }
.miw-pad-okrow { display: flex; gap: 7px; margin-top: 9px; }
.miw-pad-okrow .miw-pad-ok { flex: 1; width: auto; margin-top: 0; }
.miw-pad-close { flex: none; width: 50px; height: 50px; display: grid; place-items: center; padding: 0; border: 1.5px solid #fed7aa; border-radius: 14px;
  background: #fff4e6; color: #c2410c; box-shadow: 0 3px 0 #fde0c2; cursor: pointer; }
.miw-pad-close:hover { background: #ffedd5; }
.miw-pad-close:active { transform: translateY(2px); box-shadow: 0 1px 0 #fde0c2; }
.miw-pad-close svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.miw-pad-ok:hover:not(:disabled), .miw-pad-key.ok:hover:not(:disabled) { background: #253f99; }
.miw-pad-ok:disabled, .miw-pad-key.ok:disabled { background: #9db3e0; box-shadow: 0 3px 0 #8aa1d2; cursor: default; }
.miw-pad.shake { animation: miwPadShake .36s; }
.miw-pad.shake .miw-pad-show { border-color: #ef4444; background: #fef2f2; color: #b91c1c; }
.miw-pad.nudge .miw-pad-show { animation: miwPadNudge .2s; }
.miw-pad-target { outline: 3px solid #ffbf6f !important; outline-offset: 2px; }
.miw-pad-input { cursor: pointer; caret-color: transparent; }

/* phone held upright / short screen: a sheet on the bottom edge, digits in two rows */
.miw-pad.sheet { left: 50%; right: auto; top: auto; bottom: 0; width: min(560px, 100vw); transform: translateX(-50%);
  border-radius: 18px 18px 0 0; border-bottom: 0; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); animation: miwPadUp .18s ease-out; }
.miw-pad.sheet .miw-pad-head { margin-bottom: 6px; }
.miw-pad.sheet .miw-pad-head .miw-pad-key { flex: none; width: 56px; height: 42px; box-shadow: none; }
.miw-pad.sheet .miw-pad-head .miw-pad-key[data-k="close"] { width: 42px; background: transparent; border-color: transparent; }
.miw-pad.sheet .miw-pad-show { min-height: 42px; font-size: 22px; }
.miw-pad.sheet .miw-pad-grid { grid-template-columns: repeat(var(--n, 6), 1fr); gap: 6px; }
.miw-pad.sheet .miw-pad-key { height: 46px; font-size: 21px; border-radius: 12px; }
.miw-pad.sheet .miw-pad-key.var { font-size: 23px; }
.miw-pad.sheet .miw-pad-key.ok { font-size: 15px; gap: 4px; }
.miw-pad.sheet .miw-pad-grid[style*="--n:8"] .miw-pad-key.ok span, .miw-pad.sheet .miw-pad-grid[style*="--n:9"] .miw-pad-key.ok span { display: none; }
.miw-pad.sheet .miw-pad-key.ok svg { width: 20px; height: 20px; }
.miw-pad.sheet.shake { animation: miwPadShakeSheet .36s; }

@keyframes miwPadIn { from { opacity: 0; transform: scale(.94); } }
@keyframes miwPadUp { from { transform: translate(-50%, 100%); } }
@keyframes miwPadCaret { 50% { opacity: 0; } }
@keyframes miwPadShake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
@keyframes miwPadShakeSheet { 20%, 60% { transform: translateX(calc(-50% - 7px)); } 40%, 80% { transform: translateX(calc(-50% + 7px)); } }
@keyframes miwPadNudge { 50% { transform: translateX(-4px); } }
@media (prefers-reduced-motion: reduce) { .miw-pad, .miw-pad.sheet, .miw-pad.shake, .miw-pad-show::after { animation: none; } }

