:root { --bench:#f6ecd6; --bench2:#efe0bf; --wood:#c79a63; --wood-d:#9a7040; --brass:#d2a336; --brass-d:#8a6a1f; --ink:#3a2a1c; --card:#e3c593; --card-line:#8a6a3b; --seed:#7a4a24; --seed-hl:#a9692f; --ok:#2f6b3a; --focus:#1f5fbf; --shadow:rgba(58,42,28,.22); --line:#4a3320; color-scheme: light; }
:root[data-theme='dark'] { --bench:#2a2118; --bench2:#35291d; --wood:#6b4c2c; --wood-d:#4a331d; --brass:#e0b348; --brass-d:#c9962f; --ink:#f3e6cc; --card:#4a3922; --card-line:#d9b98a; --seed:#e9a762; --seed-hl:#ffd08a; --ok:#8fd49b; --focus:#8fb8ff; --shadow:rgba(0,0,0,.5); --line:#120c06; color-scheme: dark; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bench); color: var(--ink); font: 17px/1.45 Georgia, 'Iowan Old Style', 'Times New Roman', serif; display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
header { display: flex; align-items: center; justify-content: space-between; padding: 6px 14px; min-height: 48px; }
.brand { font-weight: 700; font-size: 18px; letter-spacing: .02em; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.icon { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--card-line); background: var(--bench2); font-size: 20px; line-height: 1; display: inline-grid; place-items: center; }
#bench { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden; gap: 6px; padding: 0 14px 12px; max-width: 980px; width: 100%; margin: 0 auto; min-height: 0; }
#stage { overflow: hidden; border-radius: 16px; flex: 1 1 0; min-height: 0; background: none; border: 0; padding: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
#machine { width: 100%; flex: 1 1 0; min-height: 0; display: block; }
#cap { margin: 0 6px 4px; position: relative; z-index: 1; color: var(--bench); font-weight: 700; text-shadow: 0 1px 0 rgba(0,0,0,.25); min-height: 2.9em; font-size: 15px; text-align: center; }
#panel { flex: none; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.trail { list-style: none; display: flex; gap: 8px; padding: 0; margin: 0; align-items: center; }
.trail li { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--card-line); flex: none; font-size: 0; overflow: hidden; opacity: .7; }
.trail li.done { background: var(--card-line); opacity: 1; }
.trail li.here { width: auto; height: auto; min-width: 16px; border-radius: 999px; background: var(--brass); color: #2a1c0e; opacity: 1; font-size: 14px; font-weight: 700; padding: 1px 10px; border-color: var(--brass-d); }
#q { font-size: 21px; line-height: 1.3; margin: 0; font-weight: 700; }
#coach { margin: 0; font-size: 17px; }
#chips { display: flex; flex-direction: column; gap: 10px; }
.chip { min-height: 48px; text-align: left; padding: 10px 14px; border-radius: 14px; border: 3px dashed var(--card-line); background: var(--card); font-size: 17px; line-height: 1.3; }
.chip:active { transform: translateY(2px); }
#bar { display: flex; gap: 10px; align-items: center; margin-top: auto; }
#act, #next { min-height: 52px; padding: 10px 12px; white-space: nowrap; border-radius: 14px; border: 3px dashed var(--card-line); background: var(--card); font-weight: 700; font-size: 17px; flex: 1; box-shadow: 0 4px 0 var(--shadow); }
#next { background: var(--brass); color: #2a1c0e; }
#act.secondary { background: transparent; flex: 0 1 auto; }
#act:active, #next:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--shadow); }
[hidden] { display: none !important; }
/* machine */
.m-wall { fill: var(--bench2); } .m-peg { fill: var(--card-line); opacity: .4; } .m-tool { fill: none; stroke: var(--card-line); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; opacity: .75; }
.m-ledge { fill: var(--wood); } .m-ledge-top { fill: var(--wood-d); opacity: .5; }
.m-cubby { fill: var(--bench2); stroke: var(--card-line); stroke-width: 2.5; stroke-dasharray: 7 5; transition: filter .3s, opacity .3s, stroke .3s; }
.m-cubby.hl { stroke: var(--brass-d); stroke-width: 5; stroke-dasharray: none; fill: var(--card); }
.m-hop, .m-rim, .m-body, .m-win, .m-plate, .m-dial, .m-chute { stroke: var(--line); stroke-width: 3; stroke-linejoin: round; }
.m-hop { fill: var(--brass); } .m-rim { fill: var(--brass-d); } .m-body { fill: var(--wood); } .m-win { fill: #2a1c0e; } .m-plate { fill: var(--brass); } .m-dial { fill: var(--card); } .m-chute { fill: var(--wood-d); }
.m-read { fill: var(--brass); font: 700 22px Georgia, serif; }
.m-plate.go { animation: press .8s ease-in-out; }
@keyframes press { 0% { transform: translateY(0); } 40% { transform: translateY(-34px); } 70% { transform: translateY(8px); } 100% { transform: translateY(0); } }
.m-label { fill: var(--bench); font: 700 16px Georgia, serif; transition: opacity .3s; }
.m-num { fill: var(--ink); font: 700 26px Georgia, serif; transition: opacity .3s; }
.m-band { transition: opacity .5s; } .m-cap { fill: var(--brass); fill-opacity: .38; stroke: var(--brass-d); stroke-width: 3; } .m-tie { fill: var(--brass); stroke: var(--brass-d); stroke-width: 2; }
.m-seed { fill: var(--seed); stroke: var(--line); stroke-width: 1.6; transition: transform .45s cubic-bezier(.3,.9,.3,1), opacity .3s; }
.m-seed:nth-child(odd) { fill: var(--seed-hl); }
#machine.instant * { transition: none !important; }
@media (prefers-reduced-motion: reduce) { .m-seed, .m-cubby, .m-band { transition: none !important; } .m-plate.go { animation: none; } }
@media (orientation: landscape) and (max-height: 520px) {
  header { min-height: 36px; padding: 0 12px; } .icon { width: 44px; height: 44px; } #cap { min-height: 2.6em; font-size: 14px; }
  #bench { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.25fr); grid-template-rows: minmax(0, 1fr); gap: 12px; padding-bottom: 8px; }
  header .icon { width: 44px; height: 44px; } header .brand { margin-right: auto; margin-left: 8px; } #q { font-size: 17px; line-height: 1.25; } #coach, .chip, #act, #next { font-size: 16px; }
  .chip { min-height: 44px; padding: 7px 12px; } #act, #next { min-height: 46px; padding: 6px 14px; }
  #panel { gap: 6px; overflow-y: auto; max-height: calc(100dvh - 50px); } #bar { position: sticky; bottom: 0; background: var(--bench); padding: 4px 0; } body { height: 100dvh; overflow: hidden; }
}
@media (min-width: 900px) and (min-height: 521px) {
  body { font-size: clamp(18px, .75vw + 12px, 28px); }
  #bench { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); gap: 3vw; max-width: none; padding: 0 4vw 4vh; align-items: center; }
  #stage { align-self: stretch; } #machine { flex: 1 1 0; min-height: 0; }
  #panel { justify-content: center; gap: 2.2vh; } #bar { margin-top: 2vh; }
  #q { font-size: clamp(28px, 3.1vw, 56px); line-height: 1.12; letter-spacing: -.01em; }
  #coach { font-size: clamp(18px, 1.35vw, 28px); } .chip { font-size: clamp(18px, 1.3vw, 26px); min-height: 56px; padding: 14px 18px; }
  #act, #next { font-size: clamp(20px, 1.6vw, 30px); min-height: clamp(60px, 7vh, 84px); }
  .trail li { width: 20px; height: 20px; } .trail li.here { width: auto; height: auto; font-size: 16px; }
  .brand { font-size: clamp(18px, 1.2vw, 26px); } header { padding: 10px 4vw; } .icon { width: 52px; height: 52px; }
  #cap { font-size: clamp(16px, 1.3vw, 24px); }
}
header .trail { gap: 6px; }
@media (orientation: landscape) and (max-width: 640px) { header .brand { display: none; } header .trail { margin-left: auto; margin-right: 8px; } header { gap: 4px; } }
@media (orientation: landscape) and (max-height: 340px) { #coach { font-size: 15px; line-height: 1.3; } .chip { padding: 4px 12px; font-size: 15px; } #chips { gap: 6px; } #panel { gap: 4px; } }

#cap { color: var(--ink) !important; text-shadow: none !important; }
@media (orientation: landscape) and (max-height: 520px) { body[data-screen='watch'] #bench { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); } }
/* Clock Reader */
.m-tray { fill: var(--bench2); stroke: var(--card-line); stroke-width: 3; stroke-dasharray: 8 5; }
.m-body { fill: var(--wood); stroke: var(--line); stroke-width: 3; } .m-slot { fill: #2a1c0e; stroke: var(--line); stroke-width: 2; }
.m-win { fill: #2a1c0e; stroke: var(--line); stroke-width: 3; }
.m-read { fill: var(--brass); font: 700 22px Georgia, serif; }
.m-paper { fill: #f3e6cc; stroke: var(--line); stroke-width: 3; stroke-linejoin: round; } .m-bill { fill: #cfe3c0; } .m-note.short .m-bill { fill: #e9b8a8; } .m-hole { fill: var(--line); }
.m-tag, .m-note, .m-pay { transition: opacity .3s; } .m-pay { fill: #2a1c0e; font: 700 20px Georgia, serif; pointer-events: none; }
.m-coin { fill: #c98a4b; stroke: var(--line); stroke-width: 3; transition: transform .5s cubic-bezier(.3,.9,.3,1), opacity .3s; }
.m-coin.c1 { fill: #c98a4b; } .m-coin.c2 { fill: #cfd3d6; } .m-coin.c5 { fill: #e0b348; } .m-coin.hl { stroke: var(--focus); stroke-width: 5; }
.m-ct { fill: #2a1c0e; font: 700 20px Georgia, serif; pointer-events: none; transition: transform .5s cubic-bezier(.3,.9,.3,1), opacity .3s; }
.m-till.go { animation: drawer .6s ease-in-out; }
@keyframes drawer { 0% { transform: translateY(0); } 40% { transform: translateY(5px); } 100% { transform: translateY(0); } }
#machine.instant .m-coin, #machine.instant .m-ct { transition: none !important; }
@media (prefers-reduced-motion: reduce) { .m-coin, .m-ct { transition: none !important; } .m-till.go { animation: none; } }

.m-rim { fill: var(--brass); stroke: var(--line); stroke-width: 3; } .m-face { fill: var(--card); stroke: var(--line); stroke-width: 2; }
.m-tick { stroke: var(--card-line); stroke-width: 1.5; } .m-tick.big { stroke: var(--ink); stroke-width: 3; }
.m-num { fill: var(--ink); font: 700 20px Georgia, serif; pointer-events: none; }
.m-hand { transition: transform 1.1s cubic-bezier(.4,.1,.2,1); } #machine.instant .m-hand { transition: none !important; }
.m-hl { stroke: var(--ink); stroke-linecap: round; fill: none; transition: stroke .3s; } .m-hl.h { stroke-width: 9; } .m-hl.m { stroke-width: 5; }
.m-hand.hl .m-hl { stroke: var(--focus, #c2410c); } .m-pin { fill: var(--brass-d); stroke: var(--line); stroke-width: 2; }
@media (prefers-reduced-motion: reduce) { .m-hand { transition: none !important; } }

/* r6 shell */
#stage{background:var(--bench2);border:2px solid var(--card-line);border-radius:20px}
#machine{width:100%;flex:1 1 0;min-height:0;display:block}
#cap{margin:0 10px 8px;font-size:15px;min-height:2.6em}
#trail{position:relative}
#topic{min-height:44px;padding:6px 14px;border-radius:999px;border:2px solid var(--brass-d);background:var(--brass);color:#2a1c0e;font-weight:700;font-size:15px;display:inline-flex;gap:8px;align-items:center}
#topics{position:absolute;z-index:5;left:0;top:48px;margin:0;padding:6px;list-style:none;background:var(--card);border:2px solid var(--card-line);border-radius:14px;box-shadow:0 8px 0 var(--shadow);min-width:230px}
#topics button{display:flex;width:100%;min-height:44px;align-items:center;gap:10px;padding:6px 12px;border:0;border-radius:10px;background:transparent;font-size:15px;text-align:left}
#topics button[aria-current=step]{background:var(--brass);color:#2a1c0e;font-weight:700}
#topics button:disabled{opacity:.55;cursor:default}
#next{background:var(--brass);color:#2a1c0e;border:3px solid var(--brass-d)}
#act{border:3px solid var(--card-line)}
#act.secondary{background:transparent;border:0;box-shadow:none;text-decoration:underline;text-underline-offset:4px;flex:0 1 auto;min-height:44px;padding:6px 12px}
#bar #next[hidden]+*{}
.spark{color:var(--brass-d)}
@media (orientation: landscape) and (max-height: 520px){#topics{top:48px}#cap{min-height:2.4em;font-size:14px}}

/* number line */
.nl-ruler{fill:var(--card);stroke:var(--line);stroke-width:3}
.nl-tick{stroke:var(--card-line);stroke-width:1.5}.nl-tick.big{stroke:var(--ink);stroke-width:3}
.nl-num{fill:var(--ink);font:700 18px Georgia,serif}
.nl-mark{fill:none;stroke:var(--brass-d);stroke-width:3}
.nl-arc{fill:none;stroke:var(--brass-d);stroke-width:4;stroke-linecap:round}
.nl-hop{fill:var(--ink);font:700 16px Georgia,serif}
.nl-pin{fill:var(--brass-d)}
.nl-marker{transition:transform .8s cubic-bezier(.4,.1,.2,1)}
#machine.instant .nl-marker{transition:none!important}
@media (prefers-reduced-motion:reduce){.nl-marker{transition:none!important}}
#back,#theme-toggle{min-width:44px;min-height:44px;flex:0 0 auto}
#cap{margin:0!important;padding:8px 12px;width:100%;box-sizing:border-box;background:var(--wood);border-top:0}
#q:focus:not(:focus-visible),#coach:focus:not(:focus-visible){outline:none}
@media (max-width: 899px) and (orientation: portrait) {
  #bench { justify-content: space-evenly; }
  #stage { flex: 0 1 auto; min-height: 0; }
  #machine { flex: 0 1 auto; width: 100%; height: auto; aspect-ratio: 320 / 290; min-height: 0; }
}
@media (max-width: 899px) and (orientation: portrait) and (max-height: 720px) {
  #stage { flex: 1 1 0; } #machine { flex: 1 1 0; aspect-ratio: auto; height: auto; }
  #q { font-size: 18px; line-height: 1.25; } #cap { min-height: 2.4em; padding: 4px 10px; font-size: 14px; }
}
.m-ledge,.m-ledge-top{display:none}
#cap{background:transparent!important}
#next{min-width:0}#bar #act.secondary{padding:0 8px}
@media (max-width: 899px) and (orientation: portrait) and (min-height: 721px) {
  body[data-screen=watch] #machine { aspect-ratio: 320 / 365; }
  body[data-screen=watch] #words { min-height: 150px; }
}
@media (max-width: 899px) and (orientation: portrait) and (min-height: 721px) {
  body[data-screen=watch] #words { min-height: 0; }
  #panel { flex: 0 0 auto; } #bar { margin-top: 10px; }
}

/* r7: card takes the free height in portrait (up to 4:3.2 tall) so no gap between blocks exceeds 60px */
@media (max-width: 899px) and (orientation: portrait) and (min-height: 721px) {
  #stage { flex: 1 1 0; } #machine { flex: 1 1 0; aspect-ratio: auto; height: auto; max-height: 128vw; }
  body[data-screen=watch] #machine { aspect-ratio: auto; }
  #bench { justify-content: center; } #panel { flex: 0 0 auto; }
}
/* r7: short landscape, group the panel in the middle of its column */
@media (orientation: landscape) and (max-height: 520px) {
  #panel { justify-content: center; overflow-y: auto; } #bar { position: static; margin-top: 8px; }
  #panel #cap { min-height: 2.6em; font-size: 15px; text-align: left; padding: 2px 0; width: auto; }
}
@media (orientation: landscape) and (max-height: 520px) {
  #q { font-size: clamp(19px, 5.2vh, 26px); line-height: 1.25; } #coach { font-size: clamp(16px, 4.4vh, 20px); line-height: 1.35; }
  .chip { min-height: 50px; font-size: 17px; } #chips { gap: 8px; } #panel { gap: 12px; }
  #act, #next { min-height: 54px; font-size: 18px; } #bar { gap: 12px; }
  #panel #cap { font-size: 17px; line-height: 1.35; font-weight: 700; }
  #trail { margin-bottom: 4px; }
}
@media (orientation: landscape) and (min-height: 360px) and (max-height: 520px) {
  #q { font-size: 26px; } #coach { font-size: 21px; } .chip { min-height: 60px; font-size: 20px; } #chips { gap: 12px; } #panel { gap: 20px; }
  #act, #next { min-height: 64px; font-size: 21px; } #panel #cap { font-size: 20px; } #topic { min-height: 48px; }
}
@media (orientation: landscape) and (min-height: 360px) and (max-height: 520px) {
  body[data-screen=watch] #q, body[data-screen=cover] #q { font-size: 30px; } body[data-screen=watch] #panel #cap { font-size: 24px; min-height: 3.4em; }
  body[data-screen=cover] #act { min-height: 72px; }
}
@media (orientation: landscape) and (min-height: 400px) and (max-height: 520px) {
  #panel { gap: 26px; } .chip { min-height: 64px; } body[data-screen=ask] #q { font-size: 28px; }
}
@media (orientation: landscape) and (min-height: 400px) and (max-height: 520px) { #coach { font-size: 23px; } }
@media (orientation: landscape) and (max-height: 520px) {
  body[data-screen=ask] #q, body[data-screen=retry] #q { font-size: 18px; line-height: 1.22; }
  body[data-screen=ask] #coach, body[data-screen=retry] #coach { font-size: 16px; line-height: 1.3; }
  body[data-screen=ask] .chip, body[data-screen=retry] .chip { min-height: 44px; font-size: 16px; padding: 2px 12px; }
  body[data-screen=ask] #chips, body[data-screen=retry] #chips { gap: 6px; }
  body[data-screen=ask] #panel, body[data-screen=retry] #panel { gap: 8px; }
  body[data-screen=ask] #act, body[data-screen=retry] #act, body[data-screen=ask] #next, body[data-screen=retry] #next { min-height: 46px; font-size: 17px; }
  body[data-screen=ask] #bar, body[data-screen=retry] #bar { margin-top: 4px; }
}
@media (orientation: landscape) and (max-height: 359px) {
  body[data-screen=ask] #q, body[data-screen=retry] #q { font-size: 16px; line-height: 1.18; }
  body[data-screen=ask] #coach, body[data-screen=retry] #coach { font-size: 15px; line-height: 1.2; }
  body[data-screen=ask] #chips, body[data-screen=retry] #chips, body[data-screen=ask] #panel, body[data-screen=retry] #panel { gap: 3px; }
  body[data-screen=ask] #bar, body[data-screen=retry] #bar { margin-top: 0; }
  body[data-screen=ask] #act, body[data-screen=retry] #act, body[data-screen=ask] #next, body[data-screen=retry] #next { min-height: 44px; }
  body[data-screen=ask] #panel, body[data-screen=retry] #panel { padding-top: 0; }
}
@media (orientation: landscape) and (min-height: 360px) and (max-height: 520px) { body[data-screen=ask] #act { min-height: 72px; } }
@media (orientation: landscape) and (max-height: 520px) {
  body[data-screen=ask] #panel:has(#chips[hidden]) #q { font-size: 23px; line-height: 1.22; }
  body[data-screen=ask] #panel:has(#chips[hidden]) #act { min-height: 72px; font-size: 20px; }
}
@media (orientation: landscape) and (max-height: 359px) {
  body[data-screen=retry] #coach { font-size: 14px; line-height: 1.15; }
  body[data-screen=retry] #q { line-height: 1.1; }
}
@media (orientation: landscape) and (min-height: 360px) and (max-height: 399px) {
  body[data-screen=cover] #q { font-size: 25px; } body[data-screen=retry] #q, body[data-screen=result] #q { font-size: 22px; }
  body[data-screen=retry] #coach, body[data-screen=result] #coach { font-size: 18px; line-height: 1.25; }
  body[data-screen=retry] .chip { min-height: 52px; font-size: 18px; }
}
@media (orientation: landscape) and (min-height: 380px) and (max-height: 520px) {
  body[data-screen=ask] #panel:has(#chips[hidden]) #q { font-size: 28px; } body[data-screen=ask] #panel:has(#chips[hidden]) #act { min-height: 88px; font-size: 22px; }
}
@media (orientation: landscape) and (min-height: 360px) and (max-height: 399px) {
  body[data-screen=retry] .chip { min-height: 46px; font-size: 17px; } body[data-screen=retry] #coach { font-size: 16px; line-height: 1.2; } body[data-screen=retry] #chips { gap: 5px; } body[data-screen=retry] #panel { gap: 6px; }
}
@media (orientation: landscape) and (min-height: 380px) and (max-height: 399px) { body[data-screen=result] #coach { font-size: 23px; } }
@media (orientation: landscape) and (min-height: 400px) and (max-height: 520px) { body[data-screen=ask] #panel:has(#chips[hidden]) #act { min-height: 100px; } }
