:root {
  color-scheme: light;
  --bg: #f4f7f9;
  --surface: #ffffff;
  --ink: #202124;
  --muted: #687480;
  --line: #d7e1ea;
  --blue: #1f5fbf;
  --blue-dark: #164a98;
  --green: #0d7a55;
  --red: #b3261e;
  --soft-blue: #edf4ff;
  --soft-green: #eaf8f1;
  --soft-red: #fff0ef;
  --shadow: 0 12px 30px rgba(20, 35, 50, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

.app-shell {
  width: min(100%, 760px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 16px 96px;
  background: var(--surface);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.topbar.compact {
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
}

h1 {
  margin: 0;
  font-size: 25px;
  letter-spacing: 0;
}

h2 {
  margin: 0 0 10px;
  font-size: 17px;
  letter-spacing: 0;
}

p {
  line-height: 1.6;
}

.hidden {
  display: none;
}

.icon-button,
.back-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
  min-height: 40px;
  padding: 8px 12px;
}

.icon-button {
  width: 42px;
  font-size: 22px;
  line-height: 1;
}

.counter {
  color: var(--muted);
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.stat,
.panel,
.question-card,
.history-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stat {
  padding: 14px;
}

.stat span {
  display: block;
  color: var(--muted);
  margin-bottom: 4px;
}

.stat strong {
  font-size: 26px;
}

.garage-panel {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 14px;
}

.garage-panel img {
  width: min(70vw, 260px);
  max-width: 100%;
  aspect-ratio: 5 / 3;
  object-fit: contain;
  object-position: center;
  justify-self: center;
  cursor: pointer;
}

.primary-actions {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}

.primary-button,
.secondary-button {
  width: 100%;
  min-height: 52px;
  border-radius: 8px;
  padding: 13px 14px;
  font-weight: 700;
}

.primary-button {
  border: 0;
  background: var(--blue);
  color: #ffffff;
}

.primary-button:active {
  background: var(--blue-dark);
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.danger-button {
  width: 100%;
  min-height: 48px;
  border-radius: 8px;
  padding: 12px 14px;
  font-weight: 700;
  border: 1px solid #f0b8b8;
  background: #fff5f5;
  color: #9f1d1d;
}

.panel {
  padding: 14px;
  margin-top: 14px;
}

.priority-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.priority-list span,
.category,
.trap-note {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 9px;
  background: var(--soft-blue);
  color: var(--blue);
}

.question-card {
  padding: 17px;
  min-height: 255px;
  display: flex;
  flex-direction: column;
}

.category {
  align-self: flex-start;
  margin: 0 0 12px;
}

.question-text {
  margin: 0;
  font-size: 22px;
  line-height: 1.62;
}

.sign-image-wrap {
  display: grid;
  place-items: center;
  margin: 0 0 14px;
}

.sign-image-wrap.hidden {
  display: none;
}

.sign-render {
  width: min(46vw, 190px);
  aspect-ratio: 1 / 1;
  max-height: 160px;
  display: grid;
  place-items: center;
}

.sign-render svg,
.sign-render img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.trap-note {
  align-self: flex-start;
  margin-top: auto;
  color: var(--muted);
  background: var(--bg);
}

.answer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
}

.answer-button {
  min-height: 92px;
  border-radius: 12px;
  font-size: 42px;
  font-weight: 700;
  background: var(--surface);
}

.answer-button.true {
  border: 2px solid var(--green);
  color: var(--green);
}

.answer-button.false {
  border: 2px solid var(--red);
  color: var(--red);
}

.result-box {
  border-radius: 8px;
  padding: 20px 16px;
  margin-bottom: 14px;
  text-align: center;
}

.result-box.correct {
  border: 1px solid var(--green);
  background: var(--soft-green);
}

.result-box.wrong {
  border: 1px solid var(--red);
  background: var(--soft-red);
}

.result-box p {
  margin: 0;
}

.result-box strong {
  display: block;
  font-size: 32px;
  margin-top: 2px;
}

.result-mark {
  display: block;
  font-size: 118px;
  font-weight: 700;
  line-height: 1;
}

.result-box.correct .result-mark {
  color: var(--green);
}

.result-box.wrong .result-mark {
  color: var(--red);
}

.answer-panel p {
  margin: 0;
}

#backToResultBtn {
  margin-top: 14px;
}

#lookBackBtn {
  margin-top: 14px;
}

.summary-hero {
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft-blue);
  padding: 20px 14px;
  margin-bottom: 14px;
}

.summary-hero p {
  margin: 0;
  color: var(--muted);
}

.summary-hero strong {
  display: block;
  font-size: 56px;
  margin: 2px 0;
}

.summary-hero span {
  color: var(--blue);
  font-weight: 700;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.segment {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 10px;
}

.segment.active {
  border-color: var(--blue);
  background: var(--soft-blue);
  color: var(--blue);
  font-weight: 700;
}

.history-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.history-item {
  padding: 12px;
}

.history-item p {
  margin: 7px 0;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 8px;
  margin-bottom: 6px;
}

.badge.ok {
  background: var(--soft-green);
  color: var(--green);
}

.badge.ng {
  background: var(--soft-red);
  color: var(--red);
}

.meta {
  color: var(--muted);
}

.version-note {
  color: var(--muted);
  text-align: center;
  margin: 18px 0 0;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(100%, 760px);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
}

.bottom-nav button {
  border: 0;
  background: transparent;
  color: var(--muted);
  min-height: 44px;
}

@media (min-width: 720px) {
  .garage-panel {
    grid-template-columns: minmax(0, 1fr) minmax(220px, 280px);
  }

  .garage-panel img {
    width: min(28vw, 260px);
  }
}

@media (max-width: 380px) {
  .question-text {
    font-size: 20px;
  }

  .answer-button {
    min-height: 82px;
  }

  .garage-panel img {
    justify-self: center;
    width: min(68vw, 230px);
  }
}


.car-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 8px;
  background: rgba(15, 23, 42, 0.62);
}

.car-modal.hidden {
  display: none;
}

.car-modal-card {
  position: relative;
  width: min(98vw, 900px);
  border-radius: 8px;
  background: #ffffff;
  padding: 10px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
}

.car-modal-card h2 {
  margin: 0 48px 4px 0;
  font-size: 18px;
}

.car-modal-card img {
  width: 100%;
  max-height: 82vh;
  object-fit: contain;
  display: block;
}

.modal-close-button {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
}
