/* ============================================================
   Steady — one committed dark theme: ink ground, warm paper text, one accent.
   ============================================================ */
:root {
  --bg: #0a0c13;
  --bg-2: #10131c;
  --bg-3: #171b27;
  --surface: rgba(236, 231, 219, 0.04);
  --surface-2: rgba(236, 231, 219, 0.08);
  --line: rgba(236, 231, 219, 0.10);
  --line-2: rgba(236, 231, 219, 0.20);
  --ink: #ece7db;
  --ink-2: #b1aca1;
  --ink-3: #7c8193;
  --accent: #86b6df;
  --accent-ink: #0a1a2a;
  --chart-grid: rgba(236, 231, 219, 0.08);
  --font-display: 'Fraunces', 'Iowan Old Style', 'Palatino', Georgia, serif;
  --font-body: 'Zen Kaku Gothic New', 'Hiragino Sans', 'Noto Sans JP', system-ui, -apple-system, sans-serif;
  --font-mono: 'DM Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --r-sm: 6px;
  --r-md: 12px;
  --r-lg: 18px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100%;
  background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 15px; line-height: 1.6;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
svg { display: block; }
h1, h2, h3, p { margin: 0; }
body.task-open { overflow: hidden; }

/* ---------- page ---------- */
.page { width: min(720px, 100%); margin: 0 auto; padding: 0 20px 56px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 0; padding-top: max(18px, env(safe-area-inset-top)); }
.wordmark { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.wordmark svg { width: 26px; height: 26px; color: var(--accent); }
.wordmark .name { font-family: var(--font-display); font-weight: 300; font-size: 26px; letter-spacing: .12em; }
.main { display: flex; flex-direction: column; gap: 36px; }

.text-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; align-self: flex-start;
  min-height: 38px; padding: 0 16px; border: 1px solid var(--line-2); border-radius: 999px; background: transparent; color: var(--ink-2); font-size: 13px;
}
.text-btn:hover { background: var(--surface-2); color: var(--ink); }
.text-btn:disabled { opacity: .5; cursor: default; }
.text-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 500; min-height: 44px; padding: 0 24px; font-size: 14px; }
.text-btn.primary:hover { background: var(--accent); filter: brightness(1.08); }
.note { font-size: 12px; color: var(--ink-3); line-height: 1.5; }
.empty { color: var(--ink-3); font-size: 14px; }

/* ---------- intro ---------- */
.intro { display: flex; flex-direction: column; gap: 18px; }
.intro h1 { font-family: var(--font-display); font-weight: 300; font-size: 34px; line-height: 1.25; }
.lead { color: var(--ink-2); max-width: 62ch; }
.how { margin: 0; padding: 0; list-style: none; display: grid; gap: 12px; }
.how li { display: grid; grid-template-columns: 96px 1fr; gap: 14px; font-size: 14px; color: var(--ink-2); line-height: 1.55; }
.how li b { font-family: var(--font-mono); font-weight: 500; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink); padding-top: 4px; }

/* ---------- start ---------- */
.start-card { display: flex; flex-direction: column; gap: 16px; padding: 22px; border: 1px solid var(--line-2); border-radius: var(--r-lg); background: var(--bg-2); }
.note-row { display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: var(--ink-2); }
.note-row input { width: 100%; padding: 11px 14px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); }
.note-row input::placeholder { color: var(--ink-3); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 32px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 999px; background: transparent; color: var(--ink-2); font-size: 13px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip:hover { background: var(--surface-2); color: var(--ink); }
.chip[aria-pressed="true"] { border-color: var(--accent); color: var(--ink); background: var(--surface-2); }
.actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.actions .text-btn { align-self: auto; }

/* ---------- results ---------- */
.results { display: flex; flex-direction: column; gap: 30px; }
.block { display: flex; flex-direction: column; gap: 12px; }
.block h3 { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.block h3 .when { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); margin-left: 6px; }
.cond { margin-top: -6px; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.tile { background: var(--bg-2); padding: 18px 20px 16px; display: flex; flex-direction: column; gap: 6px; }
.tile .num { font-family: var(--font-display); font-weight: 300; font-size: 40px; line-height: 1; font-variant-numeric: tabular-nums; }
.tile .lbl { font-family: var(--font-mono); font-size: 11px; letter-spacing: .14em; color: var(--ink-3); }
.tile .lbl.plain { letter-spacing: .04em; }

.chart { width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart .base { stroke: var(--line-2); stroke-width: 1; }
.chart .lbl, .chart .val { font-family: var(--font-mono); font-size: 11px; fill: var(--ink-3); letter-spacing: .06em; }
.chart .whisker { stroke: var(--ink-3); stroke-width: 1.5; }
.chart .dot { fill: var(--accent); stroke: var(--bg); stroke-width: 2; }
.chart .pt:hover .dot { r: 7; }
.tooltip {
  position: fixed; z-index: 30; pointer-events: none; background: var(--bg-3); border: 1px solid var(--line-2); border-radius: var(--r-sm);
  padding: 6px 10px; font-family: var(--font-mono); font-size: 12px; color: var(--ink); white-space: nowrap;
  transform: translate(-50%, calc(-100% - 12px)); box-shadow: 0 8px 30px rgba(0,0,0,.4);
}

.scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.table th { font-family: var(--font-mono); font-weight: 400; font-size: 11px; letter-spacing: .06em; color: var(--ink-3); text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--line-2); }
.table td { padding: 7px 8px; text-align: right; border-bottom: 1px solid var(--line); color: var(--ink-2); }
.table th:first-child, .table td:first-child, .table .left { text-align: left; }
.table tr.off td { color: var(--ink-3); }
.table .left { min-width: 9em; }
details summary { cursor: pointer; font-size: 13px; color: var(--ink-2); padding: 4px 0; }
details[open] summary { margin-bottom: 8px; }

.foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ---------- the task ---------- */
.task {
  position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; background: var(--bg);
  user-select: none; -webkit-user-select: none; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.task-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; font-family: var(--font-mono); font-size: 12px; letter-spacing: .06em; color: var(--ink-3); }
.progress { height: 2px; background: var(--line); flex: none; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); }
.ready { margin: auto; width: min(520px, 100%); padding: 24px 28px 48px; display: flex; flex-direction: column; align-items: flex-start; gap: 18px; }
.ready h2 { font-family: var(--font-display); font-weight: 300; font-size: 34px; letter-spacing: .12em; }
.ready p { color: var(--ink-2); }
.ready .cond-line { font-family: var(--font-mono); font-size: 13px; color: var(--ink); overflow-wrap: anywhere; }
.ready .rule { font-family: var(--font-mono); font-size: 13px; color: var(--ink); letter-spacing: .02em; padding: 10px 14px; border: 1px solid var(--line-2); border-radius: var(--r-sm); }
.play { position: relative; flex: 1; display: grid; place-items: center; }
.play > .digit, .play > .mask { grid-area: 1 / 1; visibility: hidden; }
.digit { font-family: var(--font-mono); font-weight: 500; line-height: 1; color: var(--ink); }
.digit.count { color: var(--ink-3); font-size: 64px !important; }
.mask { width: clamp(96px, 20vmin, 150px); height: clamp(96px, 20vmin, 150px); color: var(--ink-2); }
.play.show-digit > .digit, .play.show-mask > .mask { visibility: visible; }
.hint { position: absolute; left: 0; right: 0; bottom: 28px; text-align: center; font-family: var(--font-mono); font-size: 12px; letter-spacing: .04em; color: var(--ink-3); }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 60;
  background: var(--bg-3); border: 1px solid var(--line-2); border-radius: 999px; padding: 10px 18px;
  font-size: 13px; color: var(--ink); box-shadow: 0 10px 40px rgba(0,0,0,.5);
  opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none; max-width: min(92vw, 560px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

@media (max-width: 520px) {
  .page { padding: 0 16px 48px; }
  .intro h1 { font-size: 28px; }
  .how li { grid-template-columns: 1fr; gap: 4px; }
  .start-card { padding: 18px 16px; }
  .tile { padding: 14px 12px 12px; }
  .tile .num { font-size: 30px; }
  .tile .lbl { font-size: 10px; letter-spacing: .08em; }
  .chart .val, .chart .lbl { font-size: 15px; }
  .ready { padding: 20px 20px 40px; }
  .ready h2 { font-size: 28px; }
  .table th, .table td { padding: 6px 4px; }
  .table { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
