/* Fluxion: engineer's graph paper, navy ink, one orange pencil */
@font-face { font-family: "Young Serif"; font-display: swap; src: url(../fonts/young-serif-latin-400-normal.woff2) format("woff2"); }

:root {
  --bg: #EEF2EA;
  --grid: rgba(31, 58, 95, .07);
  --card: #FFFFFF;
  --ink: #1F3A5F;
  --muted: #5B6B7D;
  --line: #CBD5CC;
  --pencil: #E85D04;
  --good: #2B8A3E;
  --display: "Young Serif", Georgia, serif;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #131A22; --grid: rgba(180, 200, 230, .05); --card: #1C2530; --ink: #DCE6F2; --muted: #93A3B5; --line: #2C3846; --pencil: #FF8A3D; --good: #5BC07A; color-scheme: dark; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); font-family: var(--ui); line-height: 1.45; min-height: 100vh;
  background-color: var(--bg);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 22px 22px; }
a { color: inherit; }
button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--pencil); outline-offset: 2px; }

.wrap { max-width: 520px; margin: 0 auto; padding: 0 14px; }
.top { display: flex; justify-content: space-between; align-items: center; padding: 10px 0 0; }
.back { text-decoration: none; color: var(--muted); font-size: 0.95rem; }
.top-actions { display: flex; gap: 4px; }
.icon-btn { width: 40px; height: 40px; border-radius: 10px; border: 0; background: transparent; cursor: pointer; display: grid; place-items: center; font-weight: 700; font-size: 1.1rem; }
.icon-btn:hover { background: var(--card); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.title-row { display: flex; align-items: baseline; justify-content: space-between; padding: 4px 0 10px; }
h1 { font-family: var(--display); font-weight: 400; font-size: 2.2rem; margin: 0; line-height: 1; }
.sub { margin: 0; color: var(--muted); font-size: 0.95rem; }

.goal { display: flex; align-items: baseline; gap: 12px; margin: 4px 0 14px; }
.goal-lead { margin: 0; color: var(--muted); }
.goal-q { margin: 0; font-family: var(--display); font-size: 2rem; line-height: 1.1; }
.goal-q .ans { color: var(--pencil); }

.row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; padding: 14px 8px; background: var(--card); border-radius: 16px; box-shadow: 0 1px 0 var(--line); }
.tok { min-width: 44px; height: 52px; display: grid; place-items: center; font-family: var(--display); font-size: 1.7rem; padding: 0 6px; }
.tok.x { font-style: italic; }
.gap { width: 44px; height: 44px; border-radius: 12px; border: 2px dashed var(--muted); background: transparent; cursor: pointer; font-size: 1.45rem; font-weight: 800; color: var(--muted); }
.gap.set { border: 2px solid var(--ink); background: var(--ink); color: var(--card); }
.gap.locked { cursor: default; }
.hint { color: var(--muted); font-size: 0.85rem; text-align: center; margin: 8px 0 0; }

.fx { margin-top: 14px; background: var(--card); border-radius: 16px; padding: 12px 12px 8px; box-shadow: 0 1px 0 var(--line); }
.fx-line { margin: 0 0 6px; font-size: 1.15rem; font-variant-numeric: tabular-nums; min-height: 1.6em; }
.fx-name { color: var(--muted); }
.fx-line .err { color: var(--pencil); font-size: 0.95rem; }
.plot { width: 100%; display: block; }
.plot .ax { stroke: var(--muted); stroke-width: 1; opacity: .6; }
.plot .tick { fill: var(--muted); font: 10px var(--ui); }
.plot .curve { fill: none; stroke: var(--ink); stroke-width: 2.4; }
.plot .tan { stroke: var(--pencil); stroke-width: 2; stroke-dasharray: 5 4; }
.plot .pt { fill: var(--pencil); }
.plot .area { fill: var(--pencil); opacity: .18; }

.checkbar { display: flex; gap: 12px; align-items: center; margin-top: 14px; }
.tries { display: flex; gap: 6px; margin: 0; }
.tries i { width: 12px; height: 12px; border-radius: 3px; background: var(--ink); display: inline-block; }
.tries i.used { background: transparent; box-shadow: inset 0 0 0 2px var(--muted); }
.go { flex: 1; border: 0; border-radius: 16px; padding: 14px; background: var(--ink); color: var(--card); font-weight: 800; font-size: 1.1rem; cursor: pointer; }
.go:disabled { opacity: .45; cursor: default; }
.log { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.log li { display: flex; justify-content: space-between; gap: 10px; font-size: 0.9rem; color: var(--muted); background: var(--card); border-radius: 10px; padding: 6px 10px; font-variant-numeric: tabular-nums; }
.log li b { color: var(--ink); font-weight: 600; }
.log li.hit { color: var(--good); }

.card { background: var(--card); border-radius: 20px; padding: 20px 18px; box-shadow: 0 1px 0 var(--line); }
.done { margin-top: 14px; }
.done .go { width: 100%; }
.kicker { margin: 0; color: var(--muted); font-weight: 600; }
.big { font-family: var(--display); font-size: 2.3rem; line-height: 1.1; margin: 6px 0 6px; }
.res-line { margin: 0 0 14px; }
.fine { color: var(--muted); font-size: 0.85rem; text-align: center; margin: 10px 0 0; }

/* ads */
.ad-inline { margin-top: 26px; }
.ad-slot { display: block; margin: 0 auto; overflow: hidden; }
.ad-banner { width: 100%; max-width: 728px; min-height: 100px; }
.ad-slot.placeholder { border: 1.5px dashed var(--line); border-radius: 12px; display: grid; place-items: center; color: var(--muted); font-size: 0.85rem; background: var(--bg); }
.ad-slot.placeholder::before { content: "Ad space " attr(data-size); }
.ad-slot.collapsed { min-height: 0; }
.ad-slot ins[data-ad-status="unfilled"] { display: none !important; }
.ad-label { font-size: 11px; color: var(--muted); text-align: center; margin: 0 0 4px; }

.foot { display: flex; justify-content: center; gap: 22px; padding: 26px 0 40px; color: var(--muted); font-size: 0.9rem; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; z-index: 50; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.dlg { border: 0; border-radius: 16px; padding: 22px; width: min(420px, calc(100vw - 32px)); background: var(--card); color: var(--ink); }
.dlg::backdrop { background: rgba(10, 16, 24, .5); }
.dlg h2 { font-family: var(--display); font-weight: 400; margin: 0 0 10px; font-size: 1.6rem; }
.dlg p { color: var(--muted); }
.dlg .x { position: absolute; right: 10px; top: 8px; border: 0; background: transparent; font-size: 26px; cursor: pointer; color: var(--muted); width: 40px; height: 40px; }
.dlg .go { width: 100%; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 0; }
.stats div { display: flex; flex-direction: column-reverse; background: var(--bg); border-radius: 10px; padding: 10px; }
.stats dt { color: var(--muted); font-size: 0.85rem; }
.stats dd { margin: 0; font-size: 1.4rem; font-weight: 800; font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
@media (max-width: 380px) { .tok { min-width: 34px; font-size: 1.45rem; } .gap { width: 38px; height: 40px; } }
