/* ずかんラン */
:root {
  --bg: #f4f1ea;
  --bg-2: #ebe6db;
  --surface: #ffffff;
  --surface-2: #f8f6f1;
  --line: #e2dcd0;
  --line-2: #cfc7b8;
  --text: #17191e;
  --text-2: #3d424b;
  --muted: #6c707a;
  --accent: #e5352b;
  --accent-2: #ff5a3c;
  --accent-ink: #ffffff;
  --accent-soft: rgba(229, 53, 43, 0.09);
  --gold: #b57a00;
  --gold-soft: rgba(214, 150, 0, 0.14);
  --ahead: #0f8a54;
  --behind: #cc3329;
  --ok: #0f8a54;
  --ok-soft: rgba(15, 138, 84, 0.12);
  --shadow: 0 1px 0 rgba(23, 25, 30, 0.04), 0 8px 24px -12px rgba(23, 25, 30, 0.18);
  --radius: 18px;
  --font: "Zen Kaku Gothic New", system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --display: "Dela Gothic One", "Zen Kaku Gothic New", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1015;
    --bg-2: #12161d;
    --surface: #161b23;
    --surface-2: #1c222c;
    --line: #262e3a;
    --line-2: #354050;
    --text: #edf0f5;
    --text-2: #c3c9d3;
    --muted: #8a94a3;
    --accent: #ff4a3d;
    --accent-2: #ff7a4d;
    --accent-ink: #ffffff;
    --accent-soft: rgba(255, 74, 61, 0.12);
    --gold: #ffc53d;
    --gold-soft: rgba(255, 197, 61, 0.14);
    --ahead: #35d58a;
    --behind: #ff6b61;
    --ok: #35d58a;
    --ok-soft: rgba(53, 213, 138, 0.14);
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 12px 32px -16px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  font-feature-settings: "palt" 1;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
body::before {
  /* うっすらトラックの線 */
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(1200px 500px at 85% -10%, var(--accent-soft), transparent 60%),
    repeating-linear-gradient(90deg, transparent 0 119px, color-mix(in srgb, var(--line) 45%, transparent) 119px 120px);
  mask-image: linear-gradient(to bottom, #000, transparent 70%);
  -webkit-mask-image: linear-gradient(to bottom, #000, transparent 70%);
  z-index: 0;
}
a { color: inherit; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
kbd {
  font-family: var(--mono);
  font-size: 0.72em;
  font-weight: 700;
  padding: 0.1em 0.45em;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-2);
  white-space: nowrap;
}
.muted { color: var(--muted); }

.app {
  position: relative;
  z-index: 1;
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 24px calc(32px + env(safe-area-inset-bottom));
}
.screen { animation: screen-in 0.28s cubic-bezier(.2,.8,.2,1); }
@keyframes screen-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 68px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-family: var(--display);
  font-size: 19px;
  letter-spacing: 0.02em;
}
.brand img { display: block; border-radius: 8px; }
.icon-btn {
  width: 40px; height: 40px;
  display: inline-grid; place-items: center;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn svg { width: 20px; height: 20px; fill: currentColor; }
.icon-btn .ico-off { display: none; }
.icon-btn[aria-pressed="false"] .ico-on { display: none; }
.icon-btn[aria-pressed="false"] .ico-off { display: block; }
.icon-btn[aria-pressed="false"] { color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
  touch-action: manipulation;
  transition: transform 0.08s, background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn small { font-family: var(--mono); font-size: 12px; font-weight: 700; color: var(--muted); }
.btn kbd { margin-left: 2px; }
.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 10px 24px -12px color-mix(in srgb, var(--accent) 80%, transparent);
}
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn-primary kbd { background: rgba(255,255,255,0.16); border-color: rgba(255,255,255,0.3); color: #fff; }
.btn-ghost {
  background: var(--surface);
  border-color: var(--line-2);
  color: var(--text);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--text-2); }
.btn-text { background: none; color: var(--muted); padding: 0 8px; font-weight: 500; font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
.btn-sm { min-height: 38px; font-size: 14px; padding: 0 14px; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.label {
  display: block;
  padding: 0;
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.kicker {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--accent);
}

/* ---------- hero ---------- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 40px;
  align-items: center;
  padding: 28px 0 36px;
}
.logo {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(64px, 9.4vw, 128px);
  line-height: 1.02;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.logo-a { color: var(--text); }
.logo-b {
  display: inline-block;
  color: var(--accent);
  transform: skewX(-9deg);
  position: relative;
  margin-left: 0.02em;
}
.logo-b::after {
  content: "";
  position: absolute;
  right: -0.42em;
  top: 0.32em;
  width: 0.34em;
  height: 0.36em;
  background:
    linear-gradient(var(--accent), var(--accent)) 0 0 / 100% 0.06em no-repeat,
    linear-gradient(var(--accent), var(--accent)) 30% 50% / 70% 0.06em no-repeat,
    linear-gradient(var(--accent), var(--accent)) 60% 100% / 40% 0.06em no-repeat;
  opacity: 0.85;
}
.hero-range {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 18px 0 18px;
  font-family: var(--mono);
  font-weight: 800;
  font-size: clamp(18px, 2.2vw, 24px);
  color: var(--text-2);
}
.hero-range i {
  flex: 0 1 120px;
  height: 2px;
  background: linear-gradient(90deg, var(--line-2), var(--accent));
  position: relative;
}
.hero-range i::after {
  content: "";
  position: absolute;
  right: -1px; top: -4px;
  border: 5px solid transparent;
  border-left: 8px solid var(--accent);
  border-right: 0;
}
.lead {
  margin: 0;
  max-width: 34em;
  color: var(--text-2);
  font-size: 16px;
  line-height: 1.9;
}

.hero-demo { display: flex; justify-content: flex-end; }
.demo-card {
  width: min(100%, 400px);
  padding: 20px 22px 18px;
  border-radius: 22px;
  background: #11151c;
  color: #edf0f5;
  border: 1px solid #262e3a;
  box-shadow: 0 30px 60px -30px rgba(0,0,0,0.55), 0 0 0 6px color-mix(in srgb, var(--surface) 70%, transparent);
  transform: rotate(1.2deg);
}
.demo-top { display: flex; justify-content: space-between; align-items: baseline; font-family: var(--mono); }
.demo-timer { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; }
.demo-prog { font-size: 14px; color: #8a94a3; font-weight: 700; }
.demo-no { margin-top: 6px; font-family: var(--mono); font-weight: 800; font-size: 46px; letter-spacing: -0.03em; color: #ff4a3d; line-height: 1.1; }
.demo-input {
  margin-top: 12px;
  height: 52px;
  display: flex; align-items: center;
  padding: 0 16px;
  border-radius: 14px;
  background: #0b0e13;
  border: 1.5px solid #354050;
  font-size: 24px; font-weight: 700;
  letter-spacing: 0.04em;
}
.demo-input.ok { border-color: #35d58a; background: rgba(53,213,138,0.08); }
.demo-ticker { display: flex; gap: 6px; margin-top: 12px; height: 28px; overflow: hidden; mask-image: linear-gradient(90deg, #000 70%, transparent); -webkit-mask-image: linear-gradient(90deg, #000 70%, transparent); }
.demo-ticker span { flex: none; font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 999px; background: #1c222c; color: #c3c9d3; white-space: nowrap; }
.demo-ticker span b { font-family: var(--mono); color: #8a94a3; margin-right: 5px; font-weight: 700; }

.caret {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-left: 2px;
  background: var(--accent);
  border-radius: 2px;
  animation: blink 1.05s steps(1) infinite;
  vertical-align: -0.12em;
}
.demo-input .caret { background: #ff4a3d; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- setup ---------- */
.setup { padding: 24px 24px 22px; margin-bottom: 28px; }
.setup-block { border: 0; margin: 0 0 22px; padding: 0; min-width: 0; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mode-opt { position: relative; display: block; cursor: pointer; }
.mode-opt input { position: absolute; opacity: 0; pointer-events: none; }
.mode-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  height: 100%;
  padding: 16px 14px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: var(--surface-2);
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.mode-opt:hover .mode-body { border-color: var(--line-2); }
.mode-opt input:checked + .mode-body {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}
.mode-opt input:focus-visible + .mode-body { outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px; }
.mode-name { display: flex; align-items: center; gap: 10px; font-size: 19px; font-weight: 900; }
.mode-ico {
  display: inline-grid; place-items: center;
  min-width: 40px; height: 26px; padding: 0 6px;
  border-radius: 8px;
  font-family: var(--mono); font-size: 12px; font-weight: 800;
  background: var(--text); color: var(--surface);
}
.mode-opt input:checked + .mode-body .mode-ico { background: var(--accent); color: var(--accent-ink); }
.mode-desc { font-size: 14px; color: var(--text-2); line-height: 1.6; }

.regions {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}
.region {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  min-height: 56px;
  padding: 8px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--surface-2);
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
  touch-action: manipulation;
}
.region:hover { border-color: var(--line-2); }
.region b { font-size: 15px; font-weight: 900; line-height: 1.35; }
.region span { font-family: var(--mono); font-size: 12px; color: var(--muted); font-weight: 700; }
.region[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.region[aria-pressed="true"] span { color: var(--accent); }
.region.all b::after { content: "全1025匹"; margin-left: 6px; font-size: 11px; font-weight: 700; color: var(--accent); }

.range-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.range-field {
  display: inline-flex; align-items: center;
  height: 46px;
  padding: 0 4px 0 14px;
  border-radius: 12px;
  border: 1.5px solid var(--line-2);
  background: var(--surface);
  font-family: var(--mono); font-weight: 800; font-size: 17px;
}
.range-field span { color: var(--muted); }
.range-field input {
  width: 4.6ch;
  border: 0; outline: 0;
  background: transparent;
  font-family: var(--mono); font-weight: 800; font-size: 17px;
  padding: 0 6px 0 2px;
  -moz-appearance: textfield;
}
.range-field input::-webkit-outer-spin-button, .range-field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.range-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.range-sep { color: var(--muted); font-weight: 700; }
.range-count { margin-left: 4px; font-weight: 900; font-size: 15px; color: var(--text-2); }

.start-row { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.btn-start {
  min-height: 64px;
  padding: 0 34px;
  border-radius: 16px;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.06em;
  flex-direction: column;
  gap: 0;
}
.btn-sub { font-size: 12px; font-weight: 700; letter-spacing: 0.04em; opacity: 0.85; }
.start-note { margin: 0; color: var(--muted); font-size: 14px; display: flex; align-items: center; gap: 8px; }
.start-note::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); flex: none; }

.tips { margin-top: 18px; border-top: 1px dashed var(--line-2); padding-top: 12px; color: var(--text-2); font-size: 14px; }
.tips summary { cursor: pointer; font-weight: 700; color: var(--text-2); width: fit-content; }
.tips ul { margin: 10px 0 0; padding-left: 1.2em; line-height: 1.9; }
.tips li::marker { color: var(--accent); }

/* ---------- records ---------- */
.records { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.rec-card { padding: 22px 24px; }
.rec-card h2 { margin: 0; font-size: 19px; font-weight: 900; }
.rec-head { display: flex; align-items: center; gap: 10px; }
.rec-badge { font-family: var(--mono); font-weight: 800; font-size: 13px; padding: 1px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--text-2); }
.rec-note { margin: 6px 0 14px; font-size: 14px; color: var(--muted); line-height: 1.7; }
.table-wrap { margin-top: 12px; overflow-x: auto; }
.pb-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.pb-table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 700; padding: 0 10px 8px; border-bottom: 1px solid var(--line); letter-spacing: 0.04em; }
.pb-table th:first-child, .pb-table td:first-child { padding-left: 0; }
.pb-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.pb-table tr:last-child td { border-bottom: 0; }
.pb-table tbody tr { cursor: pointer; transition: background 0.12s; }
.pb-table tbody tr:hover td { background: var(--surface-2); }
.pb-range b { font-weight: 900; line-height: 1.3; margin-right: 8px; }
.pb-range span { font-family: var(--mono); font-size: 12px; color: var(--muted); font-weight: 700; }
.pb-val { font-family: var(--mono); font-weight: 800; font-size: 15px; white-space: nowrap; }
.pb-val small { display: block; font-family: var(--font); font-size: 11px; font-weight: 500; color: var(--muted); }
.pb-none { color: var(--line-2); font-family: var(--mono); font-weight: 700; }

.weak-list { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; max-height: 260px; overflow: auto; }
.weak-list li {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px 5px 6px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 14px; font-weight: 700;
}
.weak-list li .no { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.weak-list li .cnt { font-family: var(--mono); font-size: 11px; color: var(--behind); }
.weak-empty { color: var(--muted); font-size: 14px; padding: 18px 0; width: 100%; text-align: center; border: 1.5px dashed var(--line); border-radius: 12px; font-weight: 500 !important; background: none !important; }
.weak-actions { display: flex; align-items: center; gap: 8px; }
.tdot { width: 10px; height: 10px; border-radius: 3px; flex: none; }

.footer { margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; line-height: 1.8; }
.footer p { margin: 0 0 4px; }

/* ---------- game ---------- */
.game-bar { position: relative; }
.btn-quit {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-weight: 700; font-size: 14px;
  color: var(--text-2);
}
.btn-quit span { font-size: 18px; line-height: 1; }
.btn-quit:hover { color: var(--text); background: var(--surface-2); }
.game-title { position: absolute; left: 50%; transform: translateX(-50%); text-align: center; line-height: 1.3; white-space: nowrap; }
.game-title b { display: block; font-weight: 900; font-size: 15px; }
.game-title span { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); font-weight: 700; }

.game-layout { display: grid; gap: 22px; align-items: start; padding-top: 4px; }
.game-layout.mode-run { grid-template-columns: minmax(0, 1fr) 340px; }
.game-layout.mode-fill { grid-template-columns: 400px minmax(0, 1fr); }
.game-layout.mode-fill .play-col { position: sticky; top: 12px; }
.mode-run .js-fill-only, .mode-fill .js-run-only { display: none !important; }

.clock { display: flex; align-items: flex-end; gap: 14px; }
.timer {
  font-family: var(--mono);
  font-weight: 800;
  font-size: clamp(52px, 7.4vw, 96px);
  line-height: 0.95;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
.timer.idle { color: var(--muted); }
.timer.done { color: var(--accent); }
.mode-fill .timer { font-size: 60px; }
.clock-side { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding-bottom: 6px; min-height: 52px; justify-content: flex-end; }
.delta { font-family: var(--mono); font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums; }
.delta.ahead { color: var(--ahead); }
.delta.behind { color: var(--behind); }
.penalty-pop { font-family: var(--mono); font-weight: 800; font-size: 16px; color: var(--behind); opacity: 0; }
.penalty-pop.show { animation: pop-up 1.1s ease-out; }
@keyframes pop-up { 0% { opacity: 0; transform: translateY(8px); } 15% { opacity: 1; transform: none; } 70% { opacity: 1; } 100% { opacity: 0; transform: translateY(-10px); } }

.progress { display: flex; align-items: center; gap: 12px; margin: 14px 0 16px; }
.progress-bar { flex: 1; height: 8px; border-radius: 99px; background: var(--bg-2); border: 1px solid var(--line); overflow: hidden; }
.progress-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-2), var(--accent)); border-radius: inherit; transition: width 0.18s ease-out; }
.progress-num { font-family: var(--mono); font-weight: 800; font-size: 16px; font-variant-numeric: tabular-nums; min-width: 6.5ch; text-align: right; }

.play-card { padding: 22px 24px 20px; position: relative; overflow: hidden; }
.run-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; min-height: 96px; }
.dexno {
  font-family: var(--mono);
  font-weight: 800;
  font-size: clamp(48px, 6.6vw, 84px);
  line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
.dexno .pre { font-size: 0.46em; letter-spacing: 0; color: var(--muted); margin-right: 0.08em; }
.dexno.tick { animation: no-tick 0.16s ease-out; }
@keyframes no-tick { from { transform: translateY(10px); opacity: 0.2; } to { transform: none; opacity: 1; } }
.hint-row { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; min-height: 30px; padding-bottom: 4px; }
.hint-types { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.hint-genus { font-size: 14px; font-weight: 700; color: var(--text-2); }
.tbadge { display: inline-flex; align-items: center; height: 26px; padding: 0 11px; border-radius: 8px; font-size: 13px; font-weight: 900; letter-spacing: 0.04em; }
.boxes { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.boxes i {
  width: 30px; height: 34px;
  display: inline-grid; place-items: center;
  border-radius: 7px;
  border: 1.5px solid var(--line-2);
  background: var(--surface-2);
  font-style: normal; font-weight: 900; font-size: 17px;
}
.boxes i.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.hint-new { animation: hint-in 0.25s ease-out; }
@keyframes hint-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.fill-head { min-height: 64px; display: flex; align-items: center; }
.fill-hint { font-size: 14px; line-height: 1.6; width: 100%; }
.fill-hint .fh-no { font-family: var(--mono); font-weight: 800; font-size: 20px; margin-right: 8px; }
.fill-hint .fh-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; }
.fill-hint .boxes { justify-content: flex-start; margin-top: 8px; }

.answer {
  position: relative;
  margin-top: 18px;
  height: 76px;
  border-radius: 16px;
  border: 2px solid var(--line-2);
  background: var(--bg);
  transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
  cursor: text;
}
.answer.focus { border-color: var(--text-2); box-shadow: 0 0 0 4px color-mix(in srgb, var(--text) 7%, transparent); }
.answer.ok { border-color: var(--ok); background: var(--ok-soft); }
.answer.bad { border-color: var(--behind); animation: shake 0.32s; }
@keyframes shake { 20% { transform: translateX(-6px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
.answer-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  outline: 0;
  padding: 0 20px;
  background: transparent;
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: transparent;
  font-size: 30px;
  z-index: 2;
}
.answer-input::selection { background: transparent; }
.answer-view {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  padding: 0 20px;
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  pointer-events: none;
}
.answer-view .caret { opacity: 0; height: 36px; width: 3px; }
.answer.focus .answer-view .caret { opacity: 1; }
.answer-view .pending { color: var(--muted); font-weight: 700; font-family: var(--mono); letter-spacing: 0; font-size: 28px; }
.answer-view .carry { color: var(--ok); transition: opacity 1.2s linear; }
.answer-view .carry.fade { opacity: 0.25; }
.answer.dead .typed, .answer.dead .pending { color: var(--behind); }
.answer.dead { border-color: color-mix(in srgb, var(--behind) 55%, var(--line-2)); }
.answer-view .placeholder { color: var(--muted); font-weight: 500; font-size: 20px; letter-spacing: 0.02em; opacity: 0.7; }
.answer.has-text .placeholder, .answer.focus .placeholder.when-blur { display: none; }

.status-line { min-height: 26px; margin-top: 8px; font-size: 14px; font-weight: 700; color: var(--muted); }
.status-line .warn { color: var(--behind); }
.status-line .good { color: var(--ok); }
.status-line .tip { color: var(--gold); }

.ready {
  display: flex; align-items: center; gap: 10px;
  margin-top: 2px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700; font-size: 14px;
}
.ready-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s ease-in-out infinite; flex: none; }
@keyframes pulse { 50% { transform: scale(0.6); opacity: 0.5; } }

.actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.actions .btn { flex: 1 1 0; min-width: 140px; min-height: 48px; }

.ticker { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; min-height: 34px; }
.tk {
  display: inline-flex; align-items: center; gap: 7px;
  height: 32px; padding: 0 12px 0 8px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 14px; font-weight: 700;
  animation: tk-in 0.2s ease-out;
}
.tk:nth-child(n+2) { opacity: 0.85; }
.tk:nth-child(n+5) { opacity: 0.6; }
.tk .no { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.tk.hint .no::after { content: "H"; margin-left: 4px; color: var(--gold); }
.tk.pass { border-color: color-mix(in srgb, var(--behind) 40%, var(--line)); }
.tk.pass .nm { color: var(--behind); text-decoration: line-through; text-decoration-thickness: 1px; }
@keyframes tk-in { from { transform: translateX(-8px); opacity: 0; } }

/* splits */
.splits-card { padding: 18px 0 8px; position: sticky; top: 12px; max-height: calc(100dvh - 24px); display: flex; flex-direction: column; }
.splits-head { display: flex; align-items: baseline; justify-content: space-between; padding: 0 18px 10px; border-bottom: 1px solid var(--line); }
.splits-head h2 { margin: 0; font-size: 16px; font-weight: 900; }
.splits-cmp { font-size: 12px; color: var(--muted); font-weight: 700; }
.splits { list-style: none; margin: 0; padding: 4px 0; overflow-y: auto; flex: 1; }
.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px 76px;
  align-items: center;
  gap: 6px;
  padding: 7px 18px;
  font-size: 14px;
  border-left: 3px solid transparent;
}
.split .sl b { display: block; font-weight: 900; font-size: 14px; line-height: 1.3; }
.split .sl span { font-family: var(--mono); font-size: 11px; color: var(--muted); font-weight: 700; }
.split .sd, .split .st { font-family: var(--mono); font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }
.split .sd { font-size: 13px; }
.split .st { font-size: 14px; }
.split.future .st { color: var(--muted); font-weight: 700; }
.split.current { background: var(--accent-soft); border-left-color: var(--accent); }
.split.current .st { color: var(--accent); }
.split .sd.ahead { color: var(--ahead); }
.split .sd.behind { color: var(--behind); }
.split .sd.gold { color: var(--gold); }
.split.flash { animation: split-flash 0.9s ease-out; }
@keyframes split-flash { 0% { background: var(--gold-soft); } 100% { background: transparent; } }
.splits-foot { display: flex; justify-content: space-between; padding: 10px 18px 6px; border-top: 1px solid var(--line); font-weight: 900; font-size: 14px; }
.splits-foot span:last-child { font-family: var(--mono); font-weight: 800; }

/* fill grid */
.grid-wrap { min-width: 0; }
.gen-block { margin-bottom: 22px; }
.gen-block h3 { display: flex; align-items: baseline; gap: 10px; margin: 0 0 8px; font-size: 15px; font-weight: 900; }
.gen-block h3 span { font-family: var(--mono); font-size: 12px; color: var(--muted); font-weight: 700; }
.gen-block h3 em { margin-left: auto; font-style: normal; font-family: var(--mono); font-size: 13px; font-weight: 800; color: var(--text-2); }
.gen-block h3 em.full { color: var(--ok); }
.cells { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 5px; }
.cell {
  position: relative;
  height: 46px;
  padding: 4px 6px 4px 8px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface);
  display: flex; flex-direction: column; justify-content: center;
  overflow: hidden;
  text-align: left;
  font-size: 13px;
  line-height: 1.25;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.cell .no { font-family: var(--mono); font-size: 11px; color: var(--muted); font-weight: 700; }
.cell .nm { font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell:hover { border-color: var(--line-2); }
.cell.filled { background: var(--surface-2); cursor: default; }
.cell.filled::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--tcolor, var(--ok)); }
.cell.just { animation: cell-in 0.6s ease-out; }
@keyframes cell-in { 0% { background: var(--ok-soft); border-color: var(--ok); transform: scale(1.06); } 100% { transform: none; } }
.cell.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.cell.missed { background: color-mix(in srgb, var(--behind) 7%, var(--surface)); border-color: color-mix(in srgb, var(--behind) 30%, var(--line)); }
.cell.missed .nm { color: var(--behind); font-weight: 700; }

/* ---------- result ---------- */
.result-inner { max-width: 760px; margin: 0 auto; text-align: center; padding: 16px 0 40px; }
.result-title { margin: 0; font-family: var(--display); font-weight: 400; font-size: clamp(30px, 5vw, 44px); line-height: 1.2; }
.result-title .pb-flag { color: var(--accent); }
.result-time { margin-top: 16px; font-family: var(--mono); font-weight: 800; font-size: clamp(64px, 12vw, 120px); letter-spacing: -0.045em; line-height: 1; font-variant-numeric: tabular-nums; }
.result-pb { margin-top: 12px; min-height: 28px; font-family: var(--mono); font-weight: 800; font-size: 18px; }
.result-pb .ahead { color: var(--ahead); }
.result-pb .behind { color: var(--behind); }
.result-pb .lbl { font-family: var(--font); font-size: 14px; color: var(--muted); font-weight: 700; margin-right: 8px; }
.result-stats { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin: 22px 0 0; }
.result-stats div { min-width: 110px; padding: 10px 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.result-stats dt { font-size: 12px; color: var(--muted); font-weight: 700; }
.result-stats dd { margin: 0; font-family: var(--mono); font-weight: 800; font-size: 20px; }
.result-actions { display: flex; justify-content: center; gap: 10px; margin-top: 26px; flex-wrap: wrap; }
.result-actions .btn { min-height: 54px; min-width: 170px; font-size: 17px; }
.share-row { display: flex; justify-content: center; gap: 8px; margin-top: 12px; }
.result-detail { margin-top: 30px; text-align: left; }
.result-detail h2 { font-size: 16px; font-weight: 900; margin: 22px 0 10px; }
.r-splits { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.r-splits th, .r-splits td { padding: 9px 14px; border-bottom: 1px solid var(--line); text-align: right; }
.r-splits th { font-size: 12px; color: var(--muted); font-weight: 700; background: var(--surface-2); }
.r-splits th:first-child, .r-splits td:first-child { text-align: left; }
.r-splits td { font-family: var(--mono); font-weight: 700; font-variant-numeric: tabular-nums; }
.r-splits td:first-child { font-family: var(--font); font-weight: 900; }
.r-splits td:first-child span { font-family: var(--mono); font-size: 11px; color: var(--muted); font-weight: 700; margin-left: 6px; }
.r-splits tr:last-child td { border-bottom: 0; }
.r-splits .ahead { color: var(--ahead); }
.r-splits .behind { color: var(--behind); }
.r-splits .gold { color: var(--gold); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips span { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); font-size: 14px; font-weight: 700; }
.chips span b { font-family: var(--mono); font-size: 11px; color: var(--muted); font-weight: 700; }

/* ---------- modal / toast ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(8, 10, 14, 0.55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: fade 0.15s; }
@keyframes fade { from { opacity: 0; } }
.modal-box { width: min(100%, 420px); padding: 24px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 30px 80px -30px rgba(0,0,0,0.6); }
.modal-box h2 { margin: 0 0 6px; font-size: 20px; font-weight: 900; }
.modal-box p { margin: 0 0 18px; color: var(--text-2); font-size: 14px; }
.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.modal-actions .btn { flex: 1 1 0; }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 60;
  transform: translate(-50%, 20px);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--text); color: var(--surface);
  font-weight: 700; font-size: 14px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 40; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .hero { grid-template-columns: minmax(0, 1fr); gap: 26px; }
  .hero-demo { justify-content: flex-start; }
  .game-layout.mode-run { grid-template-columns: minmax(0, 1fr); }
  .game-layout.mode-fill { grid-template-columns: minmax(0, 1fr); }
  .splits-card { position: static; max-height: none; }
  .regions { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .app { padding: 0 16px calc(28px + env(safe-area-inset-bottom)); }
  .topbar { height: 58px; }
  .hero { grid-template-columns: minmax(0, 1fr); gap: 22px; padding: 10px 0 24px; }
  .hero-demo { display: none; }
  .logo { font-size: clamp(56px, 18vw, 84px); }
  .hero-range { margin: 12px 0 14px; }
  .lead { font-size: 15px; }
  .setup { padding: 20px 16px 18px; }
  .modes { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .mode-body { padding: 13px 14px; }
  .mode-name { font-size: 17px; }
  .regions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .start-row { gap: 12px; }
  .btn-start { width: 100%; }
  .records { grid-template-columns: minmax(0, 1fr); }
  .pb-range span { display: block; }
  .rec-card { padding: 18px 16px; }

  .game-title { position: static; transform: none; flex: 1; min-width: 0; }
  .game-title b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
  .btn-quit kbd { display: none; }
  .actions .btn kbd { display: none; }
  .clock { gap: 10px; }
  .timer { font-size: 50px; }
  .clock-side { min-height: 40px; padding-bottom: 2px; }
  .delta { font-size: 16px; }
  .progress { margin: 10px 0 12px; }
  .play-card { padding: 14px 14px 14px; }
  .run-head { min-height: 0; gap: 10px; align-items: center; }
  .dexno { font-size: 48px; }
  .hint-row { align-items: flex-start; width: 100%; }
  .hint-row:empty { display: none; }
  .hint-types, .boxes { justify-content: flex-start; }
  .boxes i { width: 27px; height: 31px; font-size: 15px; }
  .answer { margin-top: 10px; height: 60px; }
  .status-line { min-height: 22px; margin-top: 6px; font-size: 13px; }
  .actions .btn { min-height: 44px; }
  .answer-view { font-size: 26px; padding: 0 16px; }
  .answer-input { font-size: 26px; padding: 0 16px; }
  .answer-view .pending { font-size: 22px; }
  .answer-view .placeholder { font-size: 17px; }
  .actions { margin-top: 10px; gap: 8px; }
  .actions .btn { min-width: 0; }
  /* 順不同うめ：キーボードを出してもマスが見えるよう上部を詰める */
  .game-layout.mode-fill .play-col {
    position: sticky; top: 0; z-index: 5;
    display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 14px; align-items: center;
    margin: 0 -16px; padding: 6px 16px 10px;
    background: color-mix(in srgb, var(--bg) 94%, transparent);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
  }
  .mode-fill .clock { gap: 6px; align-items: center; }
  .mode-fill .timer { font-size: 34px; }
  .mode-fill .clock-side { min-height: 0; padding: 0; }
  .mode-fill .penalty-pop { font-size: 13px; }
  .mode-fill .progress { margin: 0; }
  .mode-fill .play-card { grid-column: 1 / -1; margin-top: 8px; padding: 10px 12px; border-radius: 14px; }
  .mode-fill .fill-head { min-height: 0; margin-bottom: 8px; }
  .mode-fill .fill-head.idle { display: none; }
  .mode-fill .fill-hint .boxes { margin-top: 6px; }
  .mode-fill .answer { margin-top: 0; height: 54px; }
  .mode-fill .answer-view { font-size: 24px; }
  .mode-fill .status-line { min-height: 20px; margin-top: 4px; }
  .mode-fill .ready { padding: 6px 10px; font-size: 13px; }
  .mode-fill .actions { margin-top: 6px; }
  .mode-fill .actions .btn { min-height: 40px; font-size: 14px; }
  .mode-fill .ticker { display: none; }
  .grid-wrap { padding-top: 12px; }
  .cells { grid-template-columns: repeat(auto-fill, minmax(82px, 1fr)); gap: 4px; }
  .cell { height: 42px; font-size: 12px; }
  .result-stats { gap: 8px; }
  .result-stats div { min-width: 0; flex: 1 1 28%; padding: 8px 10px; }
  .result-stats dd { font-size: 17px; }
  .r-splits { font-size: 13px; }
  .r-splits td:first-child span { display: block; margin-left: 0; }
  .result-actions .btn { flex: 1 1 100%; }
  .r-splits th, .r-splits td { padding: 8px 8px; }
}
@media (hover: none) and (pointer: coarse) {
  .kbd-tip { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
