/* SAT Math fluency trainer — touch-first (Android tablet, portrait). */
:root {
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f7f8fa;
  --card: #ffffff;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --flag: #f59e0b;
  --flag-soft: #fef3c7;
  --ok: #16a34a;
  --danger: #dc2626;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
}
#app { max-width: 860px; margin: 0 auto; padding: 12px 16px calc(24px + env(safe-area-inset-bottom)); min-height: 100vh; }
.boot { padding: 48px 0; text-align: center; color: var(--muted); }
.hidden { display: none !important; }

button { font: inherit; color: inherit; cursor: pointer; }
.bigbtn {
  display: block; width: 100%; min-height: 56px; border: 0; border-radius: 12px;
  background: var(--accent); color: #fff; font-size: 1.1rem; font-weight: 600;
}
.bigbtn:active { filter: brightness(0.92); }
.bigbtn.secondary { background: #fff; color: var(--accent); border: 2px solid var(--accent); }
.bigbtn.gray { background: #fff; color: var(--muted); border: 2px solid var(--line); }

/* ---------- start screen ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 20px; margin-top: 16px; }
.start-title { font-size: 1.35rem; font-weight: 700; margin: 24px 0 4px; text-align: center; }
.start-sub { color: var(--muted); text-align: center; margin-bottom: 8px; }
.rules { margin: 0; padding-left: 1.2em; color: var(--ink); }
.rules li { margin: 6px 0; }
.ref-note { background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; color: #1e40af; font-size: 0.92rem; margin-top: 12px; }

/* ---------- quiz ---------- */
.qheader { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.qnum { font-weight: 700; font-size: 1.02rem; }
.qnum small { color: var(--muted); font-weight: 500; }
.iconbtn {
  min-height: 44px; padding: 0 14px; border-radius: 10px; border: 2px solid var(--line);
  background: #fff; font-size: 0.95rem;
}
.iconbtn.on { border-color: var(--flag); background: var(--flag-soft); color: #92400e; }

.sessionbar { margin: 10px 0 2px; }
.sessionbar .row { display: flex; justify-content: space-between; align-items: baseline; font-size: 0.85rem; color: var(--muted); }
.sessionbar .total { font-family: var(--mono); font-size: 0.95rem; color: var(--ink); }
.track { position: relative; height: 8px; background: var(--line); border-radius: 4px; margin-top: 5px; margin-bottom: 16px; overflow: visible; }
.track .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 4px; width: 0; }
.track .tick { position: absolute; top: -4px; bottom: -4px; width: 2px; background: #9ca3af; }
.track .ticklabel { position: absolute; top: 11px; transform: translateX(-50%); font-size: 0.68rem; color: #9ca3af; font-family: var(--mono); white-space: nowrap; }

.stem { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px 16px; margin-top: 10px; font-size: 1.12rem; line-height: 1.65; white-space: pre-wrap; }

.answers { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.opt {
  display: flex; align-items: flex-start; gap: 12px; text-align: left;
  background: var(--card); border: 2px solid var(--line); border-radius: 12px;
  padding: 14px; min-height: 56px; font-size: 1.05rem; line-height: 1.5;
}
.opt .badge {
  flex: 0 0 32px; height: 32px; border-radius: 50%; background: var(--bg); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.95rem;
}
.opt.sel { border-color: var(--accent); background: var(--accent-soft); }
.opt.sel .badge { background: var(--accent); color: #fff; border-color: var(--accent); }
.opt .katex-wrap { flex: 1 1 auto; min-width: 0; }

.sprrow { display: flex; gap: 10px; align-items: stretch; }
.sprinput {
  flex: 1 1 auto; min-height: 60px; border: 2px solid var(--accent); border-radius: 12px;
  padding: 10px 14px; font-size: 1.35rem; font-family: var(--mono); background: #fff;
}
.auxkeys { display: flex; flex-direction: column; gap: 6px; }
.auxkeys button {
  width: 56px; min-height: 44px; flex: 1; border-radius: 10px; border: 2px solid var(--line);
  background: #fff; font-size: 1.2rem; font-family: var(--mono);
}
.sprhint { color: var(--muted); font-size: 0.85rem; margin-top: 6px; }

.qfooter { position: sticky; bottom: 0; background: linear-gradient(to top, var(--bg) 70%, transparent); padding: 10px 0 6px; margin-top: 14px; }
.qtimer { text-align: center; font-family: var(--mono); font-size: 1.7rem; font-weight: 600; letter-spacing: 1px; }
.qtimer small { font-size: 0.8rem; color: var(--muted); font-family: system-ui; letter-spacing: 0; display: block; font-weight: 500; }
.navrow { display: flex; gap: 10px; margin-top: 8px; }
.navrow button { flex: 1; min-height: 52px; border-radius: 12px; border: 2px solid var(--line); background: #fff; font-size: 1rem; font-weight: 600; }
.navrow button.primary { background: var(--accent); border-color: var(--accent); color: #fff; flex: 1.4; }
.navrow button:disabled { opacity: 0.4; }

/* navigator grid overlay */
.overlay { position: fixed; inset: 0; background: rgba(17,24,39,0.55); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.overlay .panel { background: #fff; border-radius: 16px; padding: 18px; width: 100%; max-width: 480px; }
.overlay h3 { margin: 0 0 12px; font-size: 1.05rem; }
.dotgrid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.dot {
  min-height: 52px; border-radius: 10px; border: 2px solid var(--line); background: #fff;
  font-weight: 700; font-size: 1rem; color: var(--muted);
}
.dot.opened { color: var(--ink); border-color: #9ca3af; }
.dot.answered { background: var(--accent-soft); border-color: var(--accent); color: #1e40af; }
.dot.flagged { background: var(--flag-soft); border-color: var(--flag); color: #92400e; }
.dot.current { outline: 3px solid var(--ink); outline-offset: 1px; }
.overlay .actions { display: flex; gap: 10px; margin-top: 14px; }

.confirm-body { color: var(--ink); font-size: 1rem; line-height: 1.6; }

/* done screen */
.done { text-align: center; padding: 90px 12px; }
.done .mark { font-size: 3.4rem; }
.done h2 { margin: 10px 0 6px; font-size: 1.5rem; }
.done p { color: var(--muted); }
.done .warn { color: var(--danger); font-weight: 600; }
.done .bigbtn { max-width: 380px; margin: 10px auto; }

.fatal { padding: 40px 12px; text-align: center; color: var(--danger); }
.pause-note { font-size: 0.8rem; color: var(--muted); text-align: center; margin-top: 2px; }
