/* QRambled. Label stock, black ink, a scanner's red. */
:root {
  --stock: #FFD60A;   /* page: signal-yellow label stock */
  --ink: #000;
  --paper: #FFF;
  --frame-dark: #4A5263;
  --frame-light: #D5D9E0;
  --laser: #FF2D55;   /* wrong squares, the scan line */
  --sans: system-ui, -apple-system, "Segoe UI Variable Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--stock); color: var(--ink); font-family: var(--sans); }
body { min-height: 100vh; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
#app { max-width: 520px; margin: 0 auto; padding: 20px 16px calc(28px + env(safe-area-inset-bottom)); }

/* ---- home ---- */
.wordmark { margin: 8px 0 14px; line-height: 0; }
#wordmark { width: 100%; display: block; image-rendering: pixelated; }
.lede { font-size: 17px; line-height: 1.4; margin: 0 0 22px; max-width: 34ch; }

.mode { border-top: 4px solid var(--ink); padding-top: 14px; margin-top: 26px; }
.mode h2 { margin: 0; font-size: 28px; font-weight: 850; letter-spacing: -0.03em; line-height: 1.1; }
.mode-sub { margin: 4px 0 14px; font-size: 15px; line-height: 1.4; }

.daily {
  display: grid; width: 100%; text-align: left; gap: 4px;
  padding: 16px 18px 18px; background: var(--paper); border: 3px solid var(--ink); border-radius: 4px;
  box-shadow: 0 6px 0 var(--ink); transition: transform .08s, box-shadow .08s;
}
.daily:active, .go-wide:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.daily-date { font-size: 30px; font-weight: 850; letter-spacing: -0.03em; line-height: 1.05; }
.daily-status { font-size: 15px; }
.go { justify-self: start; margin-top: 10px; padding: 10px 18px; background: var(--ink); color: var(--stock); font-weight: 750; border-radius: 3px; }
.go-wide {
  width: 100%; height: 54px; margin-bottom: 12px; background: var(--ink); color: var(--stock);
  border: 3px solid var(--ink); border-radius: 4px; font-size: 17px; font-weight: 750;
  box-shadow: 0 6px 0 #4d4000; transition: transform .08s, box-shadow .08s;
}
.level-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.level {
  aspect-ratio: 1; padding: 4px; border: 2px solid var(--ink); border-radius: 4px; background: var(--paper);
  display: grid; place-items: center; align-content: center; gap: 2px;
}
.level b { font-size: 24px; font-weight: 850; line-height: 1; }
.level small { font-size: 12px; }
.level.done { background: var(--ink); color: var(--stock); }
.level:disabled { background: transparent; border-style: dashed; opacity: .45; cursor: default; }

/* ---- play ---- */
.play-head { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; }
.back { width: 44px; height: 44px; border: 2px solid var(--ink); border-radius: 4px; background: var(--paper); display: grid; place-items: center; padding: 0; }
.back svg { width: 22px; height: 22px; }
.titles { min-width: 0; }
.lvl-name { margin: 0; font-size: 26px; font-weight: 850; letter-spacing: -0.03em; line-height: 1.05; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lvl-num { margin: 2px 0 0; font-size: 14px; }
.count { text-align: right; line-height: 1; }
.count-n { display: block; font-size: 38px; font-weight: 850; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.count-par { font-size: 14px; }
.count.over .count-n { color: var(--laser); -webkit-text-stroke: 1px var(--ink); }
.lesson { margin: 12px 0 14px; font-size: 15px; line-height: 1.4; min-height: 1.4em; max-width: 46ch; }

/* the board sits in a scanner viewfinder: four black corner brackets */
.finder {
  --b: 22px; --t: 4px;
  position: relative; padding: 12px;
  background:
    linear-gradient(var(--ink), var(--ink)) top left / var(--b) var(--t),
    linear-gradient(var(--ink), var(--ink)) top left / var(--t) var(--b),
    linear-gradient(var(--ink), var(--ink)) top right / var(--b) var(--t),
    linear-gradient(var(--ink), var(--ink)) top right / var(--t) var(--b),
    linear-gradient(var(--ink), var(--ink)) bottom left / var(--b) var(--t),
    linear-gradient(var(--ink), var(--ink)) bottom left / var(--t) var(--b),
    linear-gradient(var(--ink), var(--ink)) bottom right / var(--b) var(--t),
    linear-gradient(var(--ink), var(--ink)) bottom right / var(--t) var(--b);
  background-repeat: no-repeat;
}
#board { display: block; margin: 0 auto; touch-action: none; background: var(--paper); }
.toast {
  position: absolute; left: 50%; bottom: 24px; transform: translate(-50%, 6px); pointer-events: none;
  background: var(--ink); color: var(--stock); font-size: 15px; font-weight: 600; padding: 8px 14px; border-radius: 3px;
  opacity: 0; transition: opacity .15s, transform .15s; max-width: calc(100% - 40px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.wrong { margin: 10px 0 14px; font-size: 15px; font-weight: 600; min-height: 1.3em; }
.wrong i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--laser); box-shadow: 0 0 0 2px var(--paper); margin-right: 8px; vertical-align: 0; }

.controls { display: flex; flex-wrap: wrap; gap: 8px; }
.pair { flex: 1 1 calc(25% - 8px); min-width: 0; display: grid; grid-template-columns: 1fr 1fr; border: 2px solid var(--ink); border-radius: 4px; background: var(--paper); overflow: hidden; }
.pair[hidden] { display: none; }
.pair button { border: 0; background: none; height: 52px; font-size: 22px; }
.pair button + button { border-left: 2px solid var(--ink); }
.pair button:active:not(:disabled) { background: var(--stock); }
.pair button:disabled { color: #b8b8b8; cursor: default; }
.tools { display: flex; gap: 8px; margin-top: 8px; }
.tools button { flex: 1; height: 46px; border: 2px solid var(--ink); border-radius: 4px; background: transparent; font-weight: 700; }
.tools button:disabled { opacity: .35; cursor: default; }
.tools .hint-btn { background: var(--ink); color: var(--stock); }

/* ---- result sheet ---- */
.sheet-wrap { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheet {
  width: 100%; max-width: 520px; background: var(--paper); border-top: 4px solid var(--ink);
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom)); animation: rise .28s cubic-bezier(.2,.8,.2,1);
}
.sheet-top { display: grid; grid-template-columns: 112px 1fr; gap: 16px; align-items: center; }
#win-qr { width: 112px; height: 112px; image-rendering: pixelated; display: block; }
.reads { margin: 0 0 4px; font-size: 14px; }
.win-text { margin: 0; font-size: 24px; font-weight: 850; letter-spacing: -0.02em; line-height: 1.1; word-break: break-all; }
.win-score { margin: 18px 0 4px; font-size: 17px; font-weight: 600; }
.win-note { margin: 0; font-size: 15px; line-height: 1.4; }
.sheet-actions { display: flex; gap: 10px; margin-top: 20px; }
.sheet-actions button { flex: 1; height: 52px; border-radius: 4px; font-weight: 750; border: 2px solid var(--ink); }
.sheet-actions .solid { background: var(--ink); color: var(--stock); flex: 2; }
.sheet-actions .ghost { background: transparent; }
@keyframes rise { from { transform: translateY(100%); } to { transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .sheet { animation: none; }
  .daily, .toast { transition: none; }
}
@media (max-width: 360px) {
  .pair button { height: 46px; font-size: 19px; }
  .level b { font-size: 20px; }
  .daily-date { font-size: 28px; }
}
