:root {
  --bg: #efeae0;
  --ink: #1c2430;
  --muted: #5c6570;
  --header: #1a232b;
  --card: #fffdf8;
  --line: #e3d9c8;
  --good: #1f8a4c;
  --good-bg: #e5f4ec;
  --bad: #c0392b;
  --bad-bg: #fdeceb;
  --wait: #e0a106;
  --lane: #f5c518;
  --accent: #9a4e22;
  --chip: #e7eef5;
}
* { box-sizing: border-box; }
html { font-size: 18px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", "Segoe UI", sans-serif;
  line-height: 1.45;
}
a { color: var(--header); }
.top {
  background: linear-gradient(#2c3842, #1a232b);
  color: #f7f4ee;
  padding: 0.45rem 0.9rem;
  border-bottom: 4px solid var(--lane);
}
.top-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.6rem;
}
.brand { justify-self: start; }
.top a { color: inherit; text-decoration: none; }
.top h1 { font-size: 1rem; margin: 0; font-weight: 700; letter-spacing: 0.01em; }
.road-nav {
  justify-self: center;
  display: flex;
  gap: 0.35rem;
  margin: 0;
  flex-wrap: wrap;
  justify-content: center;
}
.road-nav a {
  color: #e8eef2;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  font-size: 0.8rem;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.icon { width: 1.05em; height: 1.05em; flex: none; display: block; }
.btn, button, .road-nav a { gap: 0.35rem; }
.btn, button { display: inline-flex; align-items: center; justify-content: center; }
.road-nav a.on { background: var(--lane); color: #1a232b; border-color: var(--lane); font-weight: 700; }
.coffee {
  justify-self: end;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  width: auto;
  height: auto;
  border-radius: 999px;
  background: #ffdd00;
  color: #0d0c22 !important;
  border: 0;
  padding: 0.22rem 0.7rem 0.22rem 0.35rem;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.1;
  overflow: visible;
}
.coffee-face {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}
.coffee-cup { width: 20px; height: 28px; object-fit: contain; display: block; }
.coffee-mark { padding: 0.35rem 0.9rem 0.35rem 0.45rem; font-size: 0.95rem; }
.coffee-mark .coffee-face { width: 40px; height: 40px; }
.coffee-mark .coffee-cup { width: 24px; height: 34px; }
.coffee:hover, .coffee-mark:hover { filter: brightness(1.05); }
.coffee:active, .coffee-mark:active { transform: translateY(1px) scale(0.98); }
@media (max-width: 720px) {
  .top { padding: 0.35rem 0.7rem 0.4rem; }
  .top-bar { grid-template-columns: 1fr auto; gap: 0.45rem; }
  .road-nav { grid-column: 1 / -1; }
  .top .coffee span {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  .top .coffee { padding-right: 0.28rem; }
}
dialog {
  border: 0;
  border-radius: 16px;
  padding: 0;
  width: min(36rem, calc(100% - 1.5rem));
  color: var(--ink);
}
dialog::backdrop { background: rgba(22, 50, 79, 0.55); }
.welcome { padding: 1.1rem 1.1rem 1.15rem; }
.welcome h2 { margin: 0 0 0.35rem; font-size: 1.2rem; }
.keep { white-space: nowrap; }
.welcome p { margin: 0.65rem 0; }
.welcome a:not(.btn) { color: var(--header); }
.welcome form { margin: 0.4rem 0 0; }
.welcome .ghost { width: 100%; }
.wrap { max-width: 42rem; margin: 0 auto; padding: 1rem 1rem 7rem; position: relative; z-index: 1; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  margin: 0 0 0.8rem;
}
.card h2 { font-size: 1.05rem; margin: 0 0 0.25rem; }
.muted { color: var(--muted); font-size: 0.86rem; }
.row { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.stats { display: flex; gap: 0.35rem; flex-wrap: wrap; margin: 0.45rem 0; }
.chip {
  background: var(--chip);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.78rem;
}
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.good { background: var(--good-bg); color: var(--good); }
.bar {
  height: 12px;
  background:
    linear-gradient(#f4f6f8, #f4f6f8) 0 2px / 100% 2px no-repeat,
    linear-gradient(#f4f6f8, #f4f6f8) 0 8px / 100% 2px no-repeat,
    #2e3942;
  border-radius: 99px;
  overflow: hidden;
  margin: 0.35rem 0;
}
.bar span { display: block; height: 100%; background: var(--lane); }
.dash-grid { display: grid; gap: 1rem; align-items: center; }
.road {
  position: relative;
  height: 3.4rem;
  border-radius: 10px;
  background:
    linear-gradient(#f4f6f8, #f4f6f8) 0 22% / 100% 3px no-repeat,
    linear-gradient(#f4f6f8, #f4f6f8) 0 74% / 100% 3px no-repeat,
    repeating-linear-gradient(90deg, var(--lane) 0 10px, transparent 10px 20px) center / 100% 3px no-repeat,
    #2e3942;
  border: 1px solid #1a232b;
}
.road-car {
  position: absolute;
  top: 50%;
  left: calc(var(--p) * 1%);
  width: 2.2rem;
  height: 1.15rem;
  transform: translate(calc(var(--p) * -1%), -50%);
  border-radius: 4px 7px 7px 4px;
  background:
    linear-gradient(#d7eef8, #d7eef8) 38% 18% / 28% 64% no-repeat,
    linear-gradient(#f7f8f4, #f7f8f4);
  box-shadow: 8px 2px 0 -2px var(--lane), 8px -2px 0 -2px var(--lane);
}
.road-caption { margin: 0.45rem 0 0; }
.donut-wrap { display: flex; gap: 0.8rem; align-items: center; }
.donut {
  width: 8.2rem;
  height: 8.2rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: conic-gradient(
    var(--good) 0 var(--a),
    var(--wait) var(--a) var(--b),
    var(--bad) var(--b) var(--c),
    #d7dde3 var(--c) 100%
  );
}
.donut span {
  width: 5rem;
  height: 5rem;
  border-radius: 50%;
  background: var(--card);
  display: grid;
  place-items: center;
  font-weight: 700;
}
.legend { list-style: none; margin: 0.7rem 0 0; padding: 0; font-size: 0.82rem; display: flex; flex-wrap: wrap; gap: 0.35rem 0.85rem; }
.legend li { display: flex; gap: 0.4rem; align-items: center; margin: 0; white-space: nowrap; }
.swatch { width: 0.7rem; height: 0.7rem; border-radius: 2px; display: inline-block; }
.swatch.go { background: var(--good); }
.swatch.wait { background: var(--wait); }
.swatch.stop { background: var(--bad); }
.swatch.idle { background: #d7dde3; }
.dash h3 { margin: 1rem 0 0.35rem; font-size: 0.95rem; }
.activity {
  list-style: none;
  display: flex;
  align-items: flex-end;
  gap: 0.2rem;
  height: 7.2rem;
  margin: 0.2rem 0 0;
  padding: 0 0 1.35rem;
  border-bottom: 4px solid #2e3942;
}
.activity li { flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; position: relative; }
.shaft {
  width: 68%;
  max-width: 1.1rem;
  height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  border-radius: 3px 3px 0 0;
  overflow: hidden;
}
.shaft .miss { background: var(--bad); }
.shaft .hit { background: var(--good); }
.activity small {
  position: absolute;
  bottom: -1.2rem;
  font-size: 0.62rem;
  color: var(--muted);
}
.btn, button {
  appearance: none;
  border: 0;
  background: var(--header);
  color: white;
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  font: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 48px;
  cursor: pointer;
  transition: transform 80ms ease, filter 80ms ease, background 80ms ease, box-shadow 80ms ease;
}
.btn:hover, button:hover { filter: brightness(1.14); }
.btn:active, button:active { transform: translateY(2px) scale(0.98); filter: brightness(0.92); }
.btn.ghost:hover, button.ghost:hover { background: #f3eee4; filter: none; }
.btn.ghost, button.ghost { background: transparent; color: var(--header); border: 1px solid var(--header); }
.choice label { transition: transform 80ms ease, background 80ms ease, border-color 80ms ease; cursor: pointer; }
.choice label:hover { border-color: var(--header); background: #f7f1e4; }
.choice label:active { transform: scale(0.985); }
.road-nav a { transition: background 80ms ease, transform 80ms ease; }
.road-nav a:hover { background: rgba(255, 255, 255, 0.14); }
.road-nav a:active { transform: translateY(1px); }
.road-nav a.on:hover { background: var(--lane); filter: brightness(1.06); }
.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: rgba(255, 253, 248, 0.97);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 18px rgba(26, 35, 43, 0.08);
  padding: 0.55rem 1rem calc(0.55rem + env(safe-area-inset-bottom));
}
.dock-inner { max-width: 42rem; margin: 0 auto; }
.dock .btn, .dock button { width: 100%; }
.dock .pair .btn, .dock .pair button { width: auto; }
.keys { margin: 0.35rem 0 0; text-align: center; color: var(--muted); font-size: 0.75rem; }
.btn.yes, button.yes { background: var(--good); }
.btn.no, button.no { background: var(--bad); }
.choice { display: block; margin: 0.35rem 0; }
.choice label {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  padding: 0.7rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.choice input { width: 1.2rem; height: 1.2rem; margin-top: 0.15rem; }
.figure {
  display: block;
  width: 100%;
  max-height: 280px;
  margin: 0.4rem auto 0.8rem;
  background: white;
  border-radius: 12px;
  border: 1px solid var(--line);
}
.result { border-radius: 12px; padding: 0.8rem; margin-bottom: 0.8rem; }
.result.good { background: var(--good-bg); }
.result.bad { background: var(--bad-bg); }
.result h3 { margin: 0 0 0.3rem; }
.cite { font-size: 0.84rem; }
.group-title { margin: 1.1rem 0 0.4rem; font-size: 0.95rem; }
.pair { display: flex; gap: 0.5rem; }
.pair .btn, .pair button { flex: 1; }
fieldset { border: 0; margin: 0.6rem 0; padding: 0; }
legend { font-weight: 700; margin-bottom: 0.2rem; }
@media (min-width: 700px) {
  .wrap { padding-top: 1.3rem; }
  .dash-grid { grid-template-columns: 1.35fr 0.9fr; }
}
