:root {
  --bg-1: #f6efe7;
  --bg-2: #c8e6dc;
  --ink: #1d2830;
  --panel: #ffffffea;
  --line: #0a7a66;
  --line-2: #d5472f;
  --muted: #5e6d78;
  --accent: #ef6f39;
  --grid: #d7e1e7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink);
  min-height: 100vh;
  background: radial-gradient(circle at 20% 15%, #fff7d9 0%, transparent 30%),
    radial-gradient(circle at 80% 10%, #d8f7ff 0%, transparent 30%),
    linear-gradient(135deg, var(--bg-1), var(--bg-2));
}

.shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem 1rem 1.5rem;
  display: grid;
  gap: 0.7rem;
}

.panel {
  background: var(--panel);
  border: 1px solid #ffffff;
  border-radius: 18px;
  box-shadow: 0 18px 40px #24453f1a;
  padding: 0.75rem;
}

.hero {
  padding: 0.1rem 0.2rem 0.35rem;
}

.hero h1 {
  margin: 0.2rem 0 0.25rem;
  font-size: clamp(1.6rem, 5vw, 2.4rem);
}

.kicker {
  margin: 0;
  font-family: "IBM Plex Mono", monospace;
  color: var(--line-2);
  letter-spacing: 0.08em;
  font-size: 0.84rem;
  text-transform: uppercase;
}

h2 {
  margin: 0;
  font-size: 1.1rem;
}

p {
  margin: 0;
  color: var(--muted);
}

.graph-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.graph-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-right: 0.45rem;
  font-family: "IBM Plex Mono", monospace;
  color: #2d3d48;
}

.mode-toggle input {
  appearance: none;
  width: 2.2rem;
  height: 1.2rem;
  border-radius: 999px;
  background: #c9d9e3;
  border: 1px solid #b9cbd8;
  position: relative;
  margin: 0 0.1rem;
  cursor: pointer;
}

.mode-toggle input::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 1px;
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px #00000029;
  transition: transform 120ms ease;
}

.mode-toggle input:checked {
  background: #7cb5d7;
}

.mode-toggle input:checked::after {
  transform: translateX(1rem);
}

.graph-type-picker {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: "IBM Plex Mono", monospace;
  color: #2d3d48;
}

.graph-type-picker select {
  border: 1px solid #c5d5de;
  border-radius: 8px;
  background: #fff;
  font: inherit;
  color: #1f3340;
  padding: 0.2rem 0.35rem;
}

.quiz-count-picker {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: "IBM Plex Mono", monospace;
  color: #2d3d48;
}

.quiz-count-picker input {
  width: 4.4rem;
  border: 1px solid #c5d5de;
  border-radius: 8px;
  background: #fff;
  font: inherit;
  color: #1f3340;
  padding: 0.2rem 0.35rem;
}

.animation-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.animation-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.slow-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: "IBM Plex Mono", monospace;
  color: #2d3d48;
}

.car-picker {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: "IBM Plex Mono", monospace;
  color: #2d3d48;
}

.car-picker select {
  border: 1px solid #c5d5de;
  border-radius: 8px;
  background: #fff;
  font: inherit;
  color: #1f3340;
  padding: 0.2rem 0.35rem;
}

.journey-scene {
  position: relative;
  height: 86px;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid #dbe6ef;
  background: linear-gradient(180deg, #d9f3ff 0%, #edf9ff 70%, #f8fbfd 100%);
}

.track-line {
  position: absolute;
  left: 30px;
  right: 30px;
  bottom: 24px;
  height: 4px;
  border-radius: 999px;
  background: #4d5f67;
}

.distance-marks {
  position: absolute;
  left: 30px;
  right: 30px;
  bottom: 0;
  height: 18px;
}

.distance-marks span {
  position: absolute;
  transform: translateX(-50%);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  color: #3a4b55;
  white-space: nowrap;
}

.distance-marks .mark-start {
  transform: translateX(0);
}

.distance-marks .mark-end {
  transform: translateX(-100%);
}

.distance-marks span::before {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: -11px;
  width: 1px;
  height: 8px;
  background: #5a6f79;
}

.car-icon {
  position: absolute;
  width: auto;
  height: clamp(26px, 5.2vw, 38px);
  left: 18px;
  bottom: 29px;
  transform: translateX(-50%) scaleX(0.86);
  transform-origin: center center;
  user-select: none;
  pointer-events: none;
  display: block;
}

.car-icon.reverse {
  transform: translateX(-50%) scaleX(-0.86);
}

.animation-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-top: 0.5rem;
}

.animation-stats p {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.92rem;
}

.speed-meter {
  height: 10px;
  margin-top: 0.35rem;
  border-radius: 999px;
  background: #d5e2eb;
  overflow: hidden;
}

.speed-meter span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #56c086, #ef6f39);
  transition: width 120ms linear;
}

button {
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-weight: 700;
  padding: 0.58rem 0.9rem;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.97);
}

button.quiet {
  background: #1f3d49;
}

.graph-panel canvas {
  width: 100%;
  height: auto;
  border-radius: 12px;
  background: #f9fdff;
  border: 1px solid #dde8f0;
  cursor: grab;
  margin-top: 0.45rem;
  touch-action: none;
}

.graph-panel canvas.dragging {
  cursor: grabbing;
}

.analysis ol {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
}

.analysis li {
  margin-bottom: 0.5rem;
  color: #2d3d48;
}

.quiz-box p {
  margin-top: 0.45rem;
}

.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.quiz-answer-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.5rem;
  font-family: "IBM Plex Mono", monospace;
}

.quiz-answer-label input {
  width: 7rem;
  border: 1px solid #c5d5de;
  border-radius: 8px;
  padding: 0.3rem 0.45rem;
  font: inherit;
}

.quiz-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.65rem;
}

.warn {
  color: #b2442a;
}

.site-footer {
  text-align: center;
  font-family: "IBM Plex Mono", monospace;
  color: #4c606b;
  font-size: 0.82rem;
  padding: 0.2rem 0 0.4rem;
}

@media (max-width: 700px) {
  .shell {
    padding: 1rem 0.8rem 2rem;
  }

  button {
    font-size: 0.88rem;
  }
}
