/* Sudoku Coach. Phone first. One look, chosen by Si (17 Oct 2026): washi paper, sumi ink,
   a vermilion seal for the accent, indigo for the player's own entries. Restraint over decoration. */
@font-face{font-family:'Figtree';font-style:normal;font-weight:400 700;font-display:swap;src:url(fonts/Figtree-400-700.woff2) format('woff2')}
@font-face{font-family:'Marcellus';font-style:normal;font-weight:400;font-display:swap;src:url(fonts/Marcellus-400.woff2) format('woff2')}

:root {
  --bg: #F4EFE6;          /* washi */
  --surface: #FBF8F2;
  --board: #FDFBF6;
  --ink: #2A2522;         /* sumi */
  --muted: #5E554D;
  --line: #D6CCBE;
  --line-strong: #2A2522;
  --accent: #C8412B;      /* shu, vermilion */
  --accent-soft: #F3DCD4;
  --entry: #2E4A62;       /* ai, indigo */
  --given: #2A2522;
  --elim: #B3362F;
  --elim-soft: #F3D9D4;
  --win: #3E6F4A;
  --win-soft: #DCE9DA;
  --band: #EDE6DA;
  --select: #F2E3B4;
  --same: #EDE4D4;
  --radius: 6px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: 'Figtree', -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px; line-height: 1.5;
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
  overscroll-behavior: none; user-select: none; -webkit-user-select: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#app { max-width: 520px; margin: 0 auto; padding: 14px 18px 36px; }
h1 { font-family: 'Marcellus', Georgia, serif; font-weight: 400; font-size: 32px; letter-spacing: 0.01em; margin: 18px 0 0; line-height: 1.15; }
.seal { display: inline-block; vertical-align: middle; margin-left: 10px; font-size: 13px; color: var(--accent); border: 1.5px solid var(--accent); border-radius: 3px; padding: 1px 5px; letter-spacing: 0.1em; font-family: -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif; }
h2 { font-family: 'Marcellus', Georgia, serif; font-weight: 400; font-size: 22px; margin: 0 0 6px; }
.lede { color: var(--muted); margin: 10px 0 22px; max-width: 34em; }
.k, .tag, .steptag { font-size: 11.5px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); }

/* ---- home ---- */
.continue {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--ink); color: var(--bg); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 18px; width: 100%; text-align: left; min-height: 44px;
}
.continue b { display: block; font-size: 15px; font-weight: 600; }
.continue span { font-size: 13px; opacity: 0.8; }
.levels { display: flex; flex-direction: column; gap: 0; border-top: 1px solid var(--line); }
.level {
  display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 12px;
  background: transparent; border-bottom: 1px solid var(--line); padding: 14px 4px; width: 100%; text-align: left; min-height: 44px;
}
.level .num { font-family: 'Marcellus', Georgia, serif; font-size: 22px; color: var(--accent); font-variant-numeric: tabular-nums; text-align: center; }
.level .body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.level .name { font-family: 'Marcellus', Georgia, serif; font-size: 18px; color: var(--ink); }
.level .meta { font-size: 13px; color: var(--muted); }
.pill { font-size: 11.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; padding: 4px 9px; border-radius: 3px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill.next { background: var(--accent); color: #FFF8F2; border-color: var(--accent); }
.pill.passed { background: var(--win-soft); color: var(--win); border-color: transparent; }
.install-note { margin-top: 22px; font-size: 13.5px; color: var(--muted); border-left: 2px solid var(--accent); padding: 4px 12px; }
.footnote { margin-top: 18px; font-size: 12px; color: var(--muted); }

/* ---- play ---- */
.topbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.topbar .back { font-size: 15px; font-weight: 600; color: var(--accent); padding: 0 4px; min-height: 44px; display: flex; align-items: center; }
.topbar .title { flex: 1; font-family: 'Marcellus', Georgia, serif; font-size: 17px; text-align: center; }
.topbar .timer { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; min-width: 44px; text-align: right; }
.topbar .menu { font-size: 22px; line-height: 1; color: var(--muted); min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; }

.board {
  display: grid; grid-template-columns: repeat(9, 1fr);
  width: 100%; max-width: 440px; aspect-ratio: 1; margin: 0 auto;
  border: 2px solid var(--line-strong); background: var(--board);
}
.cell {
  position: relative; display: flex; align-items: center; justify-content: center;
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  font-size: clamp(17px, 5.2vw, 24px); font-variant-numeric: tabular-nums; color: var(--entry); font-weight: 500;
}
.cell.c2, .cell.c5 { border-right: 2px solid var(--line-strong); }
.cell.r2, .cell.r5 { border-bottom: 2px solid var(--line-strong); }
.cell.c8 { border-right: 0; } .cell.r8 { border-bottom: 0; }
.cell.given { color: var(--given); font-weight: 600; }
.cell.same { background: var(--same); }
.cell.unit { background: var(--band); }
.cell.selected { background: var(--select); }
.cell.conflict { color: var(--elim); }
.cell.wrong { background: var(--elim-soft); color: var(--elim); }
.cell.hl { background: var(--accent-soft); }
.cell.hl::after { content: ""; position: absolute; inset: 2px; border: 2px solid var(--accent); border-radius: 2px; pointer-events: none; }
.cell.elim { background: var(--elim-soft); }
.cell.place { background: var(--win-soft); }
.cell.place::after { content: ""; position: absolute; inset: 2px; border: 2px solid var(--win); border-radius: 2px; pointer-events: none; }
.marks { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); padding: 1px; }
.marks i { font-style: normal; font-size: clamp(8px, 2.4vw, 11px); line-height: 1; display: flex; align-items: center; justify-content: center; color: var(--muted); font-weight: 600; }
.marks i.on { color: var(--entry); }
.marks i.cut { color: var(--elim); text-decoration: line-through; }
.marks i.hit { color: var(--ink); background: var(--select); border-radius: 2px; }

.tools { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; max-width: 440px; margin: 14px auto 0; }
.tools button { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-height: 44px; padding: 6px 2px; font-size: 12.5px; font-weight: 600; color: var(--ink); }
.tools button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tools button:disabled { opacity: 0.4; }
.pad { display: grid; grid-template-columns: repeat(9, 1fr); gap: 5px; max-width: 440px; margin: 8px auto 0; }
.pad button { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 0 6px; min-height: 56px; font-size: 22px; font-weight: 500; color: var(--entry); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.pad button small { font-size: 10px; color: var(--muted); font-weight: 600; }
.pad button.done { opacity: 0.35; }
.pad button.pencil { font-size: 15px; padding-top: 12px; }

.panel { max-width: 440px; margin: 14px auto 0; background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--radius); padding: 12px 14px; }
.panel h3 { margin: 4px 0 6px; font-size: 18px; font-family: 'Marcellus', Georgia, serif; font-weight: 400; }
.panel p { margin: 0 0 8px; font-size: 15px; }
.panel .row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.btn { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 14px; min-height: 44px; font-weight: 600; font-size: 14px; color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #FFF8F2; }
.btn.quiet { color: var(--muted); }
.panel.warn { border-left-color: var(--elim); }
.panel.warn .tag { color: var(--elim); }
.banner { max-width: 440px; margin: 12px auto 0; font-size: 13.5px; color: var(--muted); text-align: center; }

/* ---- sheet (lesson, menu, done) ---- */
#sheet { position: fixed; inset: 0; background: rgba(42, 37, 34, 0.5); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
#sheet[hidden] { display: none; }
.sheet {
  background: var(--surface); width: 100%; max-width: 520px; max-height: 88vh; max-height: 88dvh; overflow: auto;
  border-radius: 12px 12px 0 0; padding: 20px 22px calc(26px + env(safe-area-inset-bottom, 0));
}
.sheet h2 { margin-bottom: 6px; }
.sheet p { margin: 0 0 10px; font-size: 15px; }
.sheet .row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.stats div { background: var(--band); border-radius: var(--radius); padding: 10px; text-align: center; }
.stats b { display: block; font-family: 'Marcellus', Georgia, serif; font-weight: 400; font-size: 22px; font-variant-numeric: tabular-nums; }
.stats span { font-size: 12px; color: var(--muted); }
.menu-list { display: flex; flex-direction: column; gap: 8px; }
.menu-list button { text-align: left; background: var(--band); border-radius: var(--radius); padding: 12px 14px; font-weight: 600; width: 100%; min-height: 44px; }
.menu-list button small { display: block; font-weight: 400; color: var(--muted); font-size: 13px; }
@media (prefers-reduced-motion: no-preference) { .cell { transition: background 0.15s; } }
