:root {
  color-scheme: light;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --ink: #173052;
  --muted: #53657d;
  --sky: #37b8ed;
  --blue: #2376dd;
  --blue-dark: #1250a8;
  --green: #45bd38;
  --green-dark: #20812b;
  --orange: #f79c24;
  --orange-dark: #b95d0b;
  --purple: #7d4fd0;
  --red: #e84949;
  --gold: #ffd54f;
  --cream: #fffbee;
  --panel: rgba(255, 255, 255, 0.96);
  --line: rgba(23, 48, 82, 0.16);
  --shadow-soft: 0 8px 20px rgba(21, 58, 73, 0.18);
  --shadow-button: 0 6px 0 rgba(20, 56, 83, 0.24);
  --focus-ring: #ffe052;
  --motion-fast: 140ms;
  --motion-normal: 260ms;
  --motion-drive: 440ms;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 100%;
  min-height: 100%;
}

body {
  margin: 0;
  display: grid;
  place-items: center;
  overflow: auto;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 18%, #e6f9ff 0 18%, transparent 48%),
    linear-gradient(150deg, #80d8f2, #badf86);
  font-family:
    Inter, "Noto Sans Khmer", "Khmer OS Battambang", system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  min-width: 48px;
  min-height: 48px;
  border: 0;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible {
  outline: 4px solid var(--focus-ring);
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.game-shell {
  position: relative;
  width: min(100vw, 430px, calc(100dvh * 9 / 16));
  max-height: 100dvh;
  aspect-ratio: 9 / 16;
  display: grid;
  grid-template-rows: 76px 1fr;
  overflow: hidden;
  isolation: isolate;
  background: #e7f8ff;
  box-shadow: 0 24px 70px rgba(15, 63, 82, 0.34);
}

.utility-bar {
  grid-column: 1 / -1;
  grid-row: 1;
  z-index: 20;
  min-height: 76px;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  background: rgba(241, 250, 255, 0.92);
  border-bottom: 3px solid rgba(27, 93, 132, 0.17);
  backdrop-filter: blur(10px);
}

.utility-bar.home-utility {
  grid-row: 1;
  background: transparent;
  border: 0;
  backdrop-filter: none;
  pointer-events: none;
}

.home-utility .back-action,
.home-utility .utility-title {
  visibility: hidden;
}

.home-utility .language-switch {
  pointer-events: auto;
}

.icon-action,
.language-option {
  color: #fff;
  background: linear-gradient(#3988ef, var(--blue));
  box-shadow: 0 5px 0 var(--blue-dark);
  font-weight: 900;
}

.back-action {
  position: relative;
  border: 3px solid #fff2b2;
  border-radius: 10px 10px 16px 16px;
  color: #fff;
  background: linear-gradient(#50b85a, #2f8d3d);
  box-shadow:
    0 5px 0 #176528,
    0 8px 16px rgba(12, 51, 29, 0.22);
  font-size: 1.45rem;
  line-height: 1;
}

.back-action::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -10px;
  width: 5px;
  height: 10px;
  transform: translateX(-50%);
  background: #765032;
}

.language-switch {
  display: grid;
  grid-template-columns: repeat(2, 40px);
  gap: 3px;
  padding: 4px;
  border: 3px solid #70492f;
  border-radius: 10px;
  background: #f6d566;
  box-shadow:
    0 4px 0 #70492f,
    0 7px 12px rgba(41, 44, 22, 0.18);
}

.language-option {
  min-width: 40px;
  min-height: 36px;
  padding: 0;
  border-radius: 7px;
  font-size: 0.75rem;
  box-shadow: none;
}

.language-option[aria-pressed="false"] {
  color: #62401e;
  background: transparent;
}

.language-option[aria-pressed="true"] {
  color: #fff;
  background: var(--blue);
  box-shadow: inset 0 -3px 0 var(--blue-dark);
}

.utility-title {
  min-width: 0;
  padding-inline: 2px;
  line-height: 1.2;
}

.utility-title .label {
  margin-bottom: 2px;
  font-size: 0.82rem;
  line-height: 1.18;
}

.utility-title strong {
  display: block;
  overflow: visible;
  color: var(--ink);
  font-size: 1.15rem;
  font-weight: 850;
  line-height: 1.25;
  text-overflow: clip;
  white-space: normal;
  word-break: keep-all;
  overflow-wrap: normal;
}

.screen {
  grid-column: 1 / -1;
  grid-row: 2;
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-3);
  padding-bottom: max(var(--space-3), env(safe-area-inset-bottom));
  overflow-y: auto;
  animation: screen-in var(--motion-normal) ease-out both;
}

.screen-home {
  grid-row: 1 / -1;
  justify-content: space-between;
  align-items: center;
  overflow: hidden;
  padding: 78px 20px max(28px, env(safe-area-inset-bottom));
  background:
    linear-gradient(180deg, transparent 55%, rgba(19, 82, 25, 0.1) 75%, rgba(12, 54, 19, 0.55)),
    url("assets/road/bg-road-portrait.webp") center / cover no-repeat;
}

.home-brand {
  width: min(92%, 370px);
  filter: drop-shadow(0 7px 5px rgba(28, 69, 73, 0.2));
  animation: logo-arrive 560ms cubic-bezier(0.2, 0.8, 0.3, 1) both;
}

.home-logo {
  width: 100%;
  height: auto;
  display: block;
}

.home-spacer {
  flex: 1;
}

.home-callout {
  width: 100%;
  display: grid;
  justify-items: center;
  gap: var(--space-3);
  margin-bottom: 24px;
  color: #fff;
  text-align: center;
  text-shadow: 0 2px 5px rgba(8, 42, 15, 0.72);
}

.home-callout > p {
  margin: 0;
  font-size: 1.04rem;
  font-weight: 800;
}

.start-action {
  position: relative;
  width: min(72vw, 236px);
  min-width: 0;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 9px 18px;
  overflow: hidden;
  border: 3px solid #fff;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(#69d74f, #2dac36);
  box-shadow:
    0 6px 0 #19772b,
    0 10px 20px rgba(15, 59, 20, 0.3);
  font-size: 1rem;
  font-weight: 950;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.16);
  animation: start-float 1.8s ease-in-out infinite;
}

.start-action::after {
  content: "";
  position: absolute;
  top: -55%;
  left: -35%;
  width: 24%;
  height: 210%;
  transform: rotate(23deg);
  background: rgba(255, 255, 255, 0.42);
  animation: start-shine 2.8s ease-in-out infinite;
}

.start-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding-left: 2px;
  border-radius: 50%;
  color: #2a8f31;
  background: #fff;
  font-size: 0.92rem;
}

.start-action:active,
.mode-card:active,
.primary-action:active,
.secondary-action:active,
.hint-action:active {
  transform: translateY(5px);
  box-shadow: 0 2px 0 rgba(20, 56, 83, 0.25);
}

.mission-button:active {
  transform: translate(-50%, 5px);
  box-shadow: 0 2px 0 rgba(20, 56, 83, 0.25);
}

.eyebrow,
.label {
  margin: 0;
  color: var(--muted);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.045em;
}

.eyebrow {
  font-size: 0.72rem;
}

.label {
  display: block;
  margin-bottom: 2px;
  font-size: 0.61rem;
}

h1,
h2,
p {
  text-wrap: pretty;
}

h1,
h2 {
  margin: 0;
  line-height: 1.05;
  letter-spacing: -0.025em;
}

h2 {
  font-size: clamp(1.48rem, 6vw, 2rem);
}

.section-heading {
  z-index: 3;
  align-self: center;
  width: min(94%, 370px);
  display: grid;
  gap: 3px;
  padding: 10px 14px;
  border: 3px solid #fff1ad;
  border-radius: 14px;
  color: var(--ink);
  background: rgba(255, 247, 203, 0.96);
  box-shadow:
    0 5px 0 #8e6735,
    var(--shadow-soft);
  text-align: center;
}

.section-heading p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.28;
}

#missionScreen {
  overflow: hidden;
  background:
    linear-gradient(rgba(255, 255, 255, 0.04), rgba(27, 83, 21, 0.08)),
    url("assets/road/mission-map.webp") center / cover no-repeat;
}

#missionScreen .section-heading {
  display: none;
}

.mission-list {
  position: absolute;
  inset: 0;
}

.mission-button {
  --mastery: 0deg;
  position: absolute;
  z-index: 2;
  width: clamp(84px, 25vw, 106px);
  min-width: 84px;
  height: clamp(70px, 20vw, 88px);
  min-height: 70px;
  display: grid;
  grid-template-columns: 30px 1fr;
  align-items: center;
  gap: 5px;
  padding: 7px;
  border: 4px solid transparent;
  border-radius: 50%;
  color: var(--ink);
  background:
    linear-gradient(#fff, #f5fbff) padding-box,
    conic-gradient(var(--green) var(--mastery), rgba(255, 255, 255, 0.96) 0) border-box;
  box-shadow:
    0 5px 0 rgba(31, 83, 33, 0.58),
    0 8px 18px rgba(21, 63, 47, 0.22);
  text-align: left;
  transition: transform var(--motion-fast) ease;
}

.mission-button:nth-child(1) {
  left: 25%;
  top: 84%;
  transform: translateX(-50%);
}

.mission-button:nth-child(2) {
  left: 81.1%;
  top: 61.5%;
  transform: translateX(-50%);
}

.mission-button:nth-child(3) {
  left: 18.4%;
  top: 38.5%;
  transform: translateX(-50%);
}

.mission-button:nth-child(4) {
  left: 76.1%;
  top: 18%;
  transform: translateX(-50%);
}

.mission-button:nth-child(5) {
  left: 24.9%;
  top: 3%;
  transform: translateX(-50%);
}

.mission-button:nth-child(n + 6) {
  left: 50%;
  top: 42%;
  transform: translateX(-50%);
}

.mission-button.current {
  border-color: var(--gold);
  animation: checkpoint-pulse 1.8s ease-in-out infinite;
}

.mission-gate {
  position: absolute;
  z-index: 3;
  left: 46.3%;
  top: 70.5%;
  width: clamp(68px, 22vw, 94px);
  height: clamp(34px, 10vw, 44px);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.mission-gate::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 4px 11% -2px;
  clip-path: polygon(14% 0, 86% 0, 100% 100%, 0 100%);
  background: linear-gradient(90deg, #bcb8ad, #e2ded3 50%, #bcb8ad);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.72);
}

.gate-panel {
  position: absolute;
  z-index: 2;
  top: 5px;
  width: 44%;
  height: 72%;
  border: 2px solid #26333e;
  background:
    repeating-linear-gradient(90deg, #26333e 0 3px, transparent 3px 7px),
    rgba(214, 224, 229, 0.94);
  box-shadow: 0 2px 3px rgba(23, 48, 60, 0.28);
  transition: transform 300ms ease-in-out;
}

.gate-left {
  left: 6%;
  transform-origin: left center;
}

.gate-right {
  right: 6%;
  transform-origin: right center;
}

.mission-gate.open .gate-left {
  transform: rotate(-78deg);
}

.mission-gate.open .gate-right {
  transform: rotate(78deg);
}

.mission-map-car {
  position: absolute;
  z-index: 4;
  width: clamp(36px, 10vw, 44px);
  height: auto;
  display: block;
  transform: translate(-50%, -50%) rotate(var(--car-angle, 0deg));
  transform-origin: center;
  filter: drop-shadow(0 4px 3px rgba(20, 62, 28, 0.35));
  pointer-events: none;
  transition:
    left var(--drive-duration, 180ms) linear,
    top var(--drive-duration, 180ms) linear,
    transform 150ms ease-out,
    opacity 120ms ease;
}

.mission-map-car.steer-immediate {
  transition: none;
}

.mission-map-car.driving {
  filter:
    drop-shadow(0 4px 3px rgba(20, 62, 28, 0.38))
    brightness(1.05);
}

.mission-map-car.occluded {
  opacity: 0;
}

.mission-map-car.arrived {
  animation: map-car-arrive 220ms ease-out;
}

.mission-number {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--blue);
  box-shadow: inset 0 -3px 0 var(--blue-dark);
  font-size: 0.82rem;
  font-weight: 950;
}

.mission-copy {
  min-width: 0;
}

.mission-copy strong {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  font-size: clamp(0.62rem, 2.7vw, 0.77rem);
  line-height: 1.05;
}

.mission-copy small {
  display: none;
}

.mission-progress {
  position: absolute;
  right: 10px;
  bottom: 5px;
  color: var(--green-dark);
  font-size: 0.58rem;
  font-weight: 950;
}

#modeScreen {
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02) 40%, rgba(21, 74, 28, 0.11)),
    url("assets/road/garage.webp") center / cover no-repeat;
}

.mode-list {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
  gap: 7px;
  padding: 44% 0 10px;
}

.mode-card {
  position: relative;
  min-width: 0;
  min-height: 215px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 5px;
  padding: 7px 5px 9px;
  border: 3px solid #fff;
  border-radius: 18px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-button);
  text-align: center;
  transition:
    transform var(--motion-fast) ease,
    filter var(--motion-fast) ease;
}

#learnModeButton {
  border-color: #a5e68e;
  background: rgba(245, 255, 238, 0.96);
}

.mode-vehicle {
  width: 100%;
  max-width: 114px;
  height: auto;
  aspect-ratio: 1;
  object-fit: contain;
  filter: drop-shadow(0 4px 2px rgba(23, 48, 82, 0.19));
}

.mode-badge {
  position: absolute;
  top: 7px;
  left: 7px;
  padding: 4px 6px;
  border: 2px solid #fff;
  border-radius: 999px;
  color: #fff;
  background: var(--green);
  box-shadow: 0 3px 0 var(--green-dark);
  font-size: 0.55rem;
  font-weight: 950;
}

.mode-card-hunt .mode-badge {
  background: var(--purple);
  box-shadow: 0 3px 0 #5630a5;
}

#speedModeButton .mode-badge {
  background: var(--orange);
  box-shadow: 0 3px 0 var(--orange-dark);
}

.mode-card strong {
  font-size: clamp(0.7rem, 3vw, 0.84rem);
  line-height: 1.12;
}

.mode-card small {
  display: block;
  color: var(--muted);
  font-size: clamp(0.57rem, 2.4vw, 0.67rem);
  font-weight: 700;
  line-height: 1.2;
}

.mode-card:disabled {
  border-color: #7c8792;
  color: #354356;
  background:
    repeating-linear-gradient(-45deg, #e6ebef 0 8px, #d9e0e5 8px 16px);
  box-shadow: 0 6px 0 #68737c;
}

.mode-card:disabled .mode-vehicle {
  filter: grayscale(0.8) contrast(0.85);
}

.mode-card:disabled::after {
  content: "🔒";
  position: absolute;
  top: 49px;
  left: 50%;
  width: 43px;
  height: 43px;
  display: grid;
  place-items: center;
  transform: translateX(-50%);
  border: 3px solid #fff;
  border-radius: 50%;
  background: #33455c;
  font-size: 1.15rem;
}

.screen-game {
  gap: 9px;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, rgba(224, 249, 255, 0.12), rgba(235, 255, 232, 0.46)),
    url("assets/road/bg-road-portrait.webp") center / cover no-repeat;
}

.game-hud {
  flex: 0 0 auto;
  min-height: 62px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  overflow: hidden;
  border: 3px solid #fff;
  border-radius: 16px;
  background: rgba(239, 249, 255, 0.94);
  box-shadow: 0 5px 0 rgba(31, 80, 104, 0.22);
}

.game-hud > div {
  min-height: 60px;
  display: grid;
  align-content: center;
  padding: 8px 9px;
  border-right: 1px solid rgba(23, 48, 82, 0.12);
  text-align: center;
}

.game-hud > div:last-child {
  border-right: 0;
}

.game-hud strong {
  font-size: 1.34rem;
  line-height: 1.05;
}

.game-hud .label {
  font-size: 0.78rem;
  line-height: 1.12;
}

.progress-row {
  position: absolute;
  z-index: 4;
  top: 73px;
  right: 20px;
  min-width: 55px;
  min-height: 28px;
  display: grid;
  place-items: center;
  padding: 4px 8px;
  border: 2px solid #fff;
  border-radius: 999px;
  color: #fff;
  background: var(--blue);
  box-shadow: 0 3px 0 var(--blue-dark);
  font-size: 0.68rem;
  font-weight: 950;
}

.progress-row .meter {
  display: none;
}

.meter {
  height: 12px;
  overflow: hidden;
  border: 2px solid #fff;
  border-radius: 999px;
  background: rgba(23, 48, 82, 0.15);
}

.meter span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--gold));
  transition: width var(--motion-normal) ease;
}

.rescue-scene {
  --rescue-progress: 0;
  position: relative;
  flex: 0 0 112px;
  overflow: hidden;
  border: 3px solid #fff;
  border-radius: 18px;
  background: url("assets/road/progress-road.webp") center / cover no-repeat;
  box-shadow: 0 5px 0 rgba(31, 80, 104, 0.2);
}

.rescue-scene::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 24px;
  background: linear-gradient(transparent, rgba(32, 108, 29, 0.2));
  pointer-events: none;
}

.rescue-checkpoints {
  position: absolute;
  z-index: 2;
  inset: 10px 7% auto;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 2px;
}

.rescue-checkpoints span {
  width: 9px;
  height: 9px;
  justify-self: center;
  border: 2px solid #fff;
  border-radius: 50%;
  background: rgba(23, 48, 82, 0.4);
  transition:
    transform var(--motion-fast) ease,
    background var(--motion-fast) ease;
}

.rescue-checkpoints span.complete {
  transform: scale(1.3);
  background: var(--gold);
}

.rescue-car {
  position: absolute;
  z-index: 3;
  left: 4%;
  bottom: 7px;
  width: 76px;
  height: auto;
  transform: translateX(-10%) scaleX(-1);
  filter: drop-shadow(0 4px 2px rgba(23, 48, 82, 0.28));
  transition: left var(--motion-drive) cubic-bezier(0.2, 0.8, 0.3, 1);
}

.rescue-effect {
  position: absolute;
  z-index: 4;
  left: 4%;
  bottom: 15px;
  width: 62px;
  height: 62px;
  object-fit: contain;
  pointer-events: none;
}

.rescue-car.car-correct {
  animation: car-hop var(--motion-drive) ease-out;
}

.rescue-car.car-wrong {
  animation: car-shake 360ms ease-in-out;
}

.rescue-effect.effect-correct,
.rescue-effect.effect-wrong {
  animation: rescue-effect 560ms ease-out both;
}

.sentence-card {
  position: relative;
  flex: 0 0 auto;
  min-height: 112px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 14px 16px;
  border: 4px solid #6e4c28;
  border-radius: 15px;
  color: #2c2d29;
  background: linear-gradient(#fff3a1, #ffdf5d);
  box-shadow:
    inset 0 0 0 3px rgba(255, 255, 255, 0.65),
    0 6px 0 #6e4c28;
}

.sentence-card::before {
  content: "";
  position: absolute;
  top: 50%;
  left: -12px;
  width: 12px;
  height: 8px;
  background: #6e4c28;
}

.sentence-card p {
  margin: 4px 0 0;
  font-size: clamp(1.25rem, 5.8vw, 1.8rem);
  font-weight: 950;
  line-height: 1.12;
}

#sentenceText,
.answer-button,
.hunt-token {
  font-family: Inter, system-ui, sans-serif;
}

.hunt-instruction {
  display: block;
  margin-top: 3px;
  color: #5f2fae;
  font-size: 0.72rem;
  font-weight: 900;
}

.hunt-sentence {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.hunt-token {
  min-width: 44px;
  min-height: 48px;
  padding: 7px 9px;
  border: 2px solid #816533;
  border-radius: 9px;
  color: var(--ink);
  background: #fffdf2;
  box-shadow: 0 3px 0 rgba(74, 53, 23, 0.27);
  font-size: clamp(0.95rem, 4.5vw, 1.23rem);
  font-weight: 900;
}

.hunt-token.wrong {
  color: #6b1c1c;
  border-color: #d96b6b;
  background: #ffe4e4;
}

.hunt-token.found {
  color: #fff;
  border-color: #9c78e2;
  background: var(--purple);
}

.answer-list {
  display: grid;
  gap: 8px;
}

.answer-button {
  position: relative;
  width: calc(100% - 10px);
  min-height: 60px;
  margin-left: 10px;
  padding: 10px 12px 10px 56px;
  border: 3px solid #fff;
  border-radius: 11px;
  color: #fff;
  background: linear-gradient(#3d8aec, var(--blue));
  box-shadow:
    0 5px 0 var(--blue-dark),
    var(--shadow-soft);
  font-size: 1.05rem;
  font-weight: 900;
  line-height: 1.2;
  text-align: left;
}

.answer-button::before {
  content: attr(data-letter);
  position: absolute;
  top: 50%;
  left: -12px;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  transform: translateY(-50%);
  border: 3px solid #fff;
  border-radius: 50%;
  color: var(--ink);
  background: var(--gold);
  box-shadow: 0 3px 0 #b67c15;
  font-size: 0.9rem;
  font-weight: 1000;
}

.answer-button.correct {
  color: #fff;
  border-color: #e6ffdb;
  background: linear-gradient(#5fce53, var(--green));
  box-shadow: 0 5px 0 var(--green-dark);
}

.answer-button.correct::before {
  color: #fff;
  background: var(--green-dark);
  box-shadow: 0 3px 0 #12551d;
}

.answer-button.wrong {
  color: #fff;
  border-color: #ffe6e6;
  background: linear-gradient(#f06969, var(--red));
  box-shadow: 0 5px 0 #a52828;
}

.answer-button.wrong::before {
  color: #fff;
  background: #a52828;
  box-shadow: 0 3px 0 #721818;
}

.game-actions {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.hint-action {
  flex: 0 0 auto;
  min-height: 48px;
  padding: 8px 13px;
  border: 3px solid #fff5c7;
  border-radius: 12px;
  color: #604100;
  background: #ffe378;
  box-shadow: 0 4px 0 #b98517;
  font-weight: 950;
}

.hint-action::before {
  content: "🧰 ";
}

.hint-action span {
  font-size: 0.64rem;
}

.hint-text {
  margin: 0;
  padding: 5px 8px;
  border-radius: 9px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.88);
  font-size: 0.75rem;
  font-weight: 800;
  line-height: 1.28;
}

.feedback-box {
  position: absolute;
  z-index: 12;
  right: 10px;
  bottom: 10px;
  left: 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px 10px;
  padding: 14px;
  border: 4px solid #fff;
  border-radius: 22px 22px 14px 14px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 -6px 30px rgba(23, 48, 82, 0.3);
  animation: feedback-up var(--motion-normal) ease-out both;
}

.feedback-box > div {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.feedback-box strong {
  font-size: 1.32rem;
  line-height: 1.12;
}

.feedback-box p {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
  font-weight: 800;
  line-height: 1.38;
}

.feedback-rule {
  padding: 6px 9px;
  border-radius: 999px;
  color: #244f90;
  background: #e2efff;
  font-size: 0.82rem;
  font-weight: 950;
  line-height: 1.15;
}

.feedback-box .compact {
  grid-column: 2;
  min-width: 104px;
}

.primary-action,
.secondary-action {
  width: 100%;
  min-height: 54px;
  border: 3px solid #fff;
  border-radius: 15px;
  font-weight: 950;
}

.primary-action {
  color: #fff;
  background: linear-gradient(#61d452, var(--green));
  box-shadow: 0 6px 0 var(--green-dark);
}

.secondary-action {
  color: var(--ink);
  background: linear-gradient(#fff, #eaf4ff);
  box-shadow: 0 6px 0 #9aaabd;
}

.primary-action.compact {
  min-height: 48px;
}

.screen-result {
  justify-content: flex-start;
  gap: 8px;
  padding: 6% 14px 12px;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(19, 119, 181, 0.42) 0 30%, rgba(19, 119, 181, 0.12) 46%, rgba(31, 91, 25, 0.08)),
    url("assets/road/finish-line.webp") center / cover no-repeat;
}

.result-seal {
  z-index: 2;
  width: 82px;
  height: 82px;
  display: grid;
  place-items: center;
  align-self: center;
  margin-bottom: -14px;
  border: 5px solid #fff;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(145deg, #ffd85d, #f39c27);
  box-shadow:
    0 5px 0 #ad6515,
    0 8px 18px rgba(23, 48, 82, 0.22);
  font-size: 2.65rem;
  font-weight: 1000;
  animation: seal-pop 480ms cubic-bezier(0.2, 1.25, 0.3, 1) both;
}

.result-copy,
.result-mastery,
.run-highlights,
.mistake-summary {
  width: 100%;
  border: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.result-copy {
  display: grid;
  gap: 5px;
  padding: 18px 8px 4px;
  color: #fff;
  text-shadow:
    0 2px 0 rgba(20, 70, 104, 0.3),
    0 4px 16px rgba(16, 56, 86, 0.42);
  animation: result-slide-up 520ms ease-out both;
}

.result-copy h2 {
  font-size: clamp(1.9rem, 8.2vw, 2.6rem);
  line-height: 1.18;
}

.result-copy p {
  margin: 0;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.82rem;
  font-weight: 850;
  line-height: 1.42;
}

.result-copy #resultMessage,
.run-highlights,
.mistake-summary {
  display: none;
}

.result-mastery {
  display: grid;
  gap: 8px;
  margin-top: 2px;
  padding: 10px 12px;
  color: #fff;
  text-shadow: 0 2px 10px rgba(16, 56, 86, 0.35);
  animation: result-slide-up 520ms ease-out 100ms both;
}

.result-mastery > div:first-child {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.result-mastery .label {
  margin: 0;
}

.result-mastery strong {
  color: #ffffff;
  font-size: 1.2rem;
}

.result-mastery .meter {
  height: 16px;
  border: 3px solid rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.34);
  box-shadow:
    inset 0 2px 7px rgba(23, 48, 82, 0.2),
    0 5px 14px rgba(16, 56, 86, 0.24);
}

.run-highlights {
  margin: 0;
  padding: 8px 12px;
  border-top: 1px solid rgba(23, 48, 82, 0.09);
  border-radius: 0;
  color: var(--green-dark);
  font-size: 0.72rem;
  font-weight: 800;
}

.mistake-summary {
  min-height: 0;
  max-height: 54px;
  overflow: auto;
  padding: 8px 12px 10px;
  border-top: 1px solid rgba(23, 48, 82, 0.09);
  border-radius: 0 0 20px 20px;
  color: var(--muted);
  box-shadow: 0 7px 18px rgba(23, 48, 82, 0.14);
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.4;
  text-align: left;
}

.mistake-summary strong {
  color: var(--ink);
}

.result-actions {
  width: 100%;
  margin-top: 2px;
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 8px;
  padding: 0 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.result-actions .primary-action,
.result-actions .secondary-action {
  min-height: 50px;
  border-width: 2px;
  border-radius: 14px;
  box-shadow: 0 4px 0 var(--green-dark);
}

.result-actions .secondary-action {
  box-shadow: 0 4px 0 #9aaabd;
}

.result-actions .text-action {
  grid-column: 1 / -1;
}

#retryMistakesButton.hidden + #continueButton {
  grid-column: 1 / -1;
}

.social-share {
  grid-column: 1 / -1;
  display: grid;
  margin-top: 0;
  padding-top: 2px;
  border-top: 0;
}

.social-share-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.social-action {
  width: 48px;
  min-width: 48px;
  height: 48px;
  min-height: 48px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
}

.facebook-action {
  background: transparent;
}

.tiktok-action {
  background: transparent;
  box-shadow: none;
}

.social-action img {
  width: 45px;
  height: 45px;
  display: block;
  object-fit: contain;
}

.text-action {
  min-height: 42px;
  color: #234d71;
  background: transparent;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 850;
  text-decoration: underline;
  text-underline-offset: 3px;
}

html[lang="km"] body {
  font-family:
    "Noto Sans Khmer", "Khmer OS Battambang", system-ui, "Segoe UI", sans-serif;
}

html[lang="km"] .eyebrow,
html[lang="km"] .label,
html[lang="km"] button,
html[lang="km"] h2,
html[lang="km"] p {
  letter-spacing: 0;
  text-transform: none;
}

html[lang="km"] h2 {
  font-size: clamp(1.28rem, 5.6vw, 1.75rem);
  line-height: 1.22;
  font-weight: 700;
}

html[lang="km"] .home-callout > p {
  line-height: 1.65;
}

html[lang="km"] .start-action {
  font-size: 0.98rem;
  font-weight: 700;
}

html[lang="km"] .utility-title .label {
  font-size: 0.76rem;
  line-height: 1.35;
}

html[lang="km"] .utility-title strong {
  font-size: 1.12rem;
  font-weight: 750;
  line-height: 1.45;
  word-break: keep-all;
  overflow-wrap: normal;
}

html[lang="km"] .mission-copy strong,
html[lang="km"] .mode-card strong {
  font-size: clamp(0.64rem, 2.7vw, 0.77rem);
  line-height: 1.38;
  font-weight: 700;
}

html[lang="km"] .mode-card small,
html[lang="km"] .feedback-box p,
html[lang="km"] .mistake-summary {
  line-height: 1.5;
  font-weight: 600;
}

html[lang="km"] .feedback-box strong {
  font-size: 1.24rem;
  line-height: 1.22;
}

html[lang="km"] .feedback-box p {
  font-size: 0.96rem;
  font-weight: 700;
}

html[lang="km"] .feedback-rule {
  font-size: 0.78rem;
}

@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateX(10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes logo-arrive {
  from {
    opacity: 0;
    transform: translateY(-16px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes start-float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

@keyframes start-shine {
  0%,
  50% {
    left: -35%;
  }
  72%,
  100% {
    left: 125%;
  }
}

@keyframes checkpoint-pulse {
  0%,
  100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.08) drop-shadow(0 0 8px rgba(255, 223, 72, 0.85));
  }
}

@keyframes map-car-arrive {
  0%,
  100% {
    filter: drop-shadow(0 3px 2px rgba(20, 62, 28, 0.3)) brightness(1);
  }
  50% {
    filter:
      drop-shadow(0 3px 2px rgba(20, 62, 28, 0.3))
      brightness(1.25);
  }
}

@keyframes feedback-up {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes result-slide-up {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes car-hop {
  0%,
  100% {
    transform: translateX(-10%) translateY(0) scaleX(-1);
  }
  45% {
    transform: translateX(-2%) translateY(-9px) rotate(-2deg) scaleX(-1);
  }
}

@keyframes car-shake {
  0%,
  100% {
    transform: translateX(-10%) scaleX(-1);
  }
  25% {
    transform: translateX(-16%) scaleX(-1);
  }
  75% {
    transform: translateX(-4%) scaleX(-1);
  }
}

@keyframes rescue-effect {
  from {
    opacity: 0;
    transform: scale(0.45);
  }
  45% {
    opacity: 1;
  }
  to {
    opacity: 0;
    transform: scale(1.2);
  }
}

@keyframes seal-pop {
  from {
    opacity: 0;
    transform: scale(0.6) rotate(-8deg);
  }
  to {
    opacity: 1;
    transform: scale(1) rotate(0);
  }
}

@media (max-width: 350px), (max-height: 650px) {
  .game-shell {
    grid-template-rows: 68px 1fr;
  }

  .utility-bar {
    min-height: 68px;
    padding-top: max(8px, env(safe-area-inset-top));
  }

  .screen {
    gap: 7px;
    padding: 9px;
  }

  .screen-home {
    padding-top: 68px;
    padding-bottom: 20px;
  }

  .home-brand {
    width: 78%;
  }

  .home-callout {
    gap: 8px;
  }

  .start-action {
    min-height: 56px;
  }

  .section-heading {
    padding: 7px 10px;
  }

  .mode-list {
    gap: 5px;
    padding-top: 40%;
  }

  .mode-card {
    min-height: 184px;
    padding-inline: 3px;
  }

  .mode-card small {
    font-size: 0.55rem;
  }

  .rescue-scene {
    flex-basis: 86px;
  }

  .rescue-car {
    width: 63px;
  }

  .sentence-card {
    min-height: 91px;
    padding: 10px 13px;
  }

  .sentence-card p {
    font-size: clamp(1.06rem, 5.3vw, 1.35rem);
  }

  .answer-button {
    min-height: 54px;
    padding-block: 8px;
    font-size: 0.94rem;
  }

  .feedback-box {
    padding: 11px;
  }

  .feedback-box strong {
    font-size: 1.16rem;
  }

  .feedback-box p {
    font-size: 0.88rem;
  }

  .feedback-rule {
    font-size: 0.72rem;
  }

  .screen-result {
    gap: 7px;
    padding-top: 12px;
  }

  .result-seal {
    width: 68px;
    height: 68px;
    margin-bottom: -12px;
    font-size: 2.2rem;
  }

  .result-copy {
    padding-top: 21px;
  }
}

@media (max-width: 280px) {
  .utility-bar {
    grid-template-columns: 48px 1fr auto;
    padding-inline: 6px;
  }

  .utility-title .label {
    display: none;
  }

  .utility-title strong,
  html[lang="km"] .utility-title strong {
    font-size: 0.9rem;
    line-height: 1.3;
  }

  .language-switch {
    grid-template-columns: repeat(2, 34px);
  }

  .language-option {
    min-width: 34px;
  }

  #missionScreen,
  #modeScreen {
    overflow-y: auto;
  }

  .mission-list {
    position: relative;
    inset: auto;
    display: grid;
    gap: 9px;
    padding: 10px 2px 24px;
  }

  .mission-button,
  .mission-button:nth-child(n) {
    position: relative;
    inset: auto;
    width: 100%;
    height: 72px;
    transform: none;
    border-radius: 18px;
  }

  .mission-button:active {
    transform: translateY(5px);
  }

  .mission-map-car,
  .mission-gate {
    display: none;
  }

  .mode-list {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 160px 2px 20px;
  }

  .mode-card {
    min-height: 104px;
    flex-direction: row;
    justify-content: flex-start;
    padding: 8px;
    text-align: left;
  }

  .mode-vehicle {
    flex: 0 0 78px;
    width: 78px;
  }

  .mode-card strong,
  .mode-card small {
    text-align: left;
  }

  .mode-card:disabled::after {
    top: 28px;
    left: 48px;
  }

  .game-hud > div {
    padding-inline: 3px;
  }

  .game-hud strong {
    font-size: 1.12rem;
  }

  .game-hud .label {
    font-size: 0.68rem;
  }

  .answer-button {
    padding-left: 43px;
    font-size: 0.86rem;
  }

  .feedback-box {
    grid-template-columns: 1fr;
  }

  .feedback-box .compact {
    grid-column: 1;
  }

  .result-actions {
    grid-template-columns: 1fr;
  }

  .result-actions .text-action {
    grid-column: 1;
  }

  .social-share-buttons {
    grid-template-columns: 1fr;
  }

  #retryMistakesButton.hidden + #continueButton {
    grid-column: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
