:root {
  --ink: #19324a;
  --cream: #fff9ec;
  --orange: #ff7044;
  --yellow: #ffc83d;
  --green: #51c985;
  --blue: #58b9e9;
  --purple: #8f71e8;
  --shadow: 0 12px 0 rgba(25, 50, 74, .10), 0 18px 35px rgba(25, 50, 74, .12);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  color: var(--ink);
  background: var(--cream);
  font-family: "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; }
button:focus-visible { outline: 5px solid #2f80ed; outline-offset: 4px; }

.topbar {
  position: relative;
  z-index: 20;
  height: 78px;
  padding: 12px clamp(16px, 4vw, 54px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 249, 236, .92);
  border-bottom: 3px solid rgba(25, 50, 74, .07);
}

.brand, .sound-button {
  border: 0;
  cursor: pointer;
  background: transparent;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px;
  font-size: clamp(20px, 3vw, 27px);
  font-weight: 900;
}

.brand-car { font-size: 34px; transform: scaleX(-1); }
.top-actions { display: flex; align-items: center; gap: 12px; }

.stars-total, .drive-score {
  min-width: 76px;
  padding: 9px 14px;
  background: #fff;
  border: 3px solid rgba(25, 50, 74, .10);
  border-radius: 999px;
  font-size: 20px;
  text-align: center;
  box-shadow: 0 4px 0 rgba(25, 50, 74, .08);
}

.sound-button, .speak-button {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  font-size: 23px;
  box-shadow: 0 4px 0 rgba(25, 50, 74, .10);
}

.screen { display: none; min-height: calc(100vh - 78px); }
.screen.active { display: block; animation: screen-in .35s ease both; }

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

.home-screen {
  position: relative;
  overflow: hidden;
  padding: clamp(38px, 7vh, 72px) 20px 42px;
  background:
    linear-gradient(180deg, #dff6ff 0 64%, #9fe080 64% 67%, #77c85e 67% 100%);
}

.home-screen::after {
  content: "";
  position: absolute;
  z-index: 0;
  left: -10%; right: -10%; bottom: -90px;
  height: 180px;
  background: #65b950;
  border-radius: 50% 50% 0 0;
}

.sun {
  position: absolute; top: 38px; right: 8%; width: 100px; height: 100px;
  border-radius: 50%; background: #ffd052; box-shadow: 0 0 0 18px rgba(255, 208, 82, .18);
}

.cloud { position: absolute; width: 115px; height: 38px; border-radius: 50px; background: rgba(255,255,255,.78); }
.cloud::before, .cloud::after { content: ""; position: absolute; border-radius: 50%; background: inherit; }
.cloud::before { width: 55px; height: 55px; left: 18px; bottom: 3px; }
.cloud::after { width: 43px; height: 43px; right: 16px; bottom: 3px; }
.cloud-one { top: 15%; left: 5%; }
.cloud-two { top: 32%; right: 3%; transform: scale(.75); }

.welcome { position: relative; z-index: 2; max-width: 700px; margin: 0 auto 30px; text-align: center; }
.eyebrow { margin: 0 0 5px; color: #e15232; font-size: 15px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(36px, 7vw, 66px); line-height: .98; letter-spacing: -.045em; }
.welcome-copy { margin-bottom: 0; font-size: clamp(20px, 3vw, 27px); }

.game-cards {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(2, minmax(250px, 390px));
  justify-content: center;
  gap: clamp(18px, 3vw, 34px);
}

.game-card {
  min-height: 285px;
  padding: 25px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: 1fr auto;
  gap: 14px;
  text-align: left;
  border: 5px solid #fff;
  border-radius: 36px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .18s, box-shadow .18s;
}

.game-card:hover { transform: translateY(-7px) rotate(-1deg); box-shadow: 0 17px 0 rgba(25,50,74,.10), 0 25px 45px rgba(25,50,74,.16); }
.game-card:active { transform: translateY(4px); box-shadow: 0 6px 0 rgba(25,50,74,.10); }
.clock-card { background: #ffe28a; }
.car-card { background: #8dddbc; }

.card-art { grid-column: 1 / 3; align-self: center; justify-self: center; }
.card-text { display: flex; flex-direction: column; gap: 5px; }
.card-text strong { font-size: clamp(27px, 4vw, 37px); }
.card-text small { font-family: system-ui, sans-serif; font-size: 16px; font-weight: 700; }
.play-dot { align-self: center; display: grid; place-items: center; width: 50px; height: 50px; border-radius: 50%; color: #fff; background: var(--orange); }

.mini-clock {
  position: relative; width: 132px; height: 132px; overflow: hidden; border: 10px solid var(--orange); border-radius: 50%; background: #fffdf7;
  box-shadow: inset 0 0 0 4px rgba(25,50,74,.08), 0 7px 0 rgba(25,50,74,.12);
}
.mini-clock::before, .mini-clock::after { content: ""; position: absolute; left: 50%; top: 12px; width: 6px; height: 14px; border-radius: 5px; background: var(--ink); transform: translateX(-50%); box-shadow: 0 86px var(--ink); }
.mini-clock::after { top: 50%; left: 12px; transform: translateY(-50%) rotate(90deg); box-shadow: 0 86px var(--ink); }
.mini-hand { position: absolute; left: 50%; bottom: 50%; width: 8px; height: 42px; border-radius: 8px; background: var(--ink); transform-origin: bottom; transform: translateX(-50%) rotate(45deg); }
.mini-hand::after { content: ""; position: absolute; left: 2px; bottom: -30px; width: 5px; height: 35px; border-radius: 5px; background: var(--orange); transform: rotate(80deg); transform-origin: 2px 2px; }

.mini-road { position: relative; width: 190px; height: 118px; overflow: hidden; border-radius: 18px; background: #586676; border: 7px solid #fff; box-shadow: 0 7px 0 rgba(25,50,74,.12); }
.mini-road::before { content: ""; position: absolute; left: 50%; top: -20px; width: 8px; height: 160px; background: repeating-linear-gradient(#fff 0 18px, transparent 18px 36px); transform: translateX(-50%); }
.mini-car { position: absolute; left: 50%; bottom: 8px; font-style: normal; font-size: 53px; transform: translateX(-50%) rotate(-90deg); filter: drop-shadow(3px 4px 0 rgba(0,0,0,.22)); }

.tip { position: relative; z-index: 3; width: fit-content; max-width: calc(100% - 20px); margin: 34px auto 0; padding: 12px 18px; border-radius: 18px; background: rgba(255,255,255,.88); font: 700 14px/1.4 system-ui, sans-serif; }

.game-screen { padding: 22px clamp(14px, 4vw, 52px) 32px; }
.clock-screen { background: radial-gradient(circle at 20% 20%, #fff 0 5%, transparent 5.5%), #fff3ce; background-size: 90px 90px; }
.car-screen { background: #dff5ff; }

.game-heading { max-width: 1050px; margin: 0 auto 24px; display: grid; grid-template-columns: 58px 1fr 58px; align-items: center; gap: 15px; }
.game-heading h2 { margin: 0; font-size: clamp(28px, 4vw, 42px); }
.back-button { width: 55px; height: 55px; border: 0; border-radius: 18px; background: #fff; cursor: pointer; font-size: 32px; box-shadow: 0 5px 0 rgba(25,50,74,.10); }

.clock-layout { max-width: 970px; margin: 0 auto; display: grid; grid-template-columns: minmax(300px, 1fr) minmax(280px, .85fr); align-items: center; gap: clamp(32px, 7vw, 90px); }
.clock-wrap { position: relative; justify-self: center; padding: 18px; }

.analog-clock {
  position: relative;
  width: min(72vw, 390px);
  aspect-ratio: 1;
  border: clamp(12px, 2vw, 20px) solid var(--orange);
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 6px #ffe8dc, 0 14px 0 rgba(25,50,74,.11), 0 26px 50px rgba(25,50,74,.12);
}

.tick { position: absolute; width: 48px; height: 48px; display: grid; place-items: center; font-size: clamp(18px, 3vw, 28px); font-weight: 900; transform: translate(-50%, -50%); }
.tick-12 { left:50%; top:8%; }.tick-1 { left:71%; top:14%; }.tick-2 { left:86%; top:29%; }.tick-3 { left:92%; top:50%; }
.tick-4 { left:86%; top:71%; }.tick-5 { left:71%; top:86%; }.tick-6 { left:50%; top:92%; }.tick-7 { left:29%; top:86%; }
.tick-8 { left:14%; top:71%; }.tick-9 { left:8%; top:50%; }.tick-10 { left:14%; top:29%; }.tick-11 { left:29%; top:14%; }
.hand { position: absolute; left: 50%; bottom: 50%; border-radius: 999px; transform-origin: 50% 100%; }
.hour-hand { z-index: 3; width: 13px; height: 28%; background: var(--ink); transform: translateX(-50%) rotate(0deg); transition: transform .5s cubic-bezier(.2,.9,.3,1.2); }
.minute-hand { z-index: 2; width: 8px; height: 37%; background: var(--orange); transform: translateX(-50%) rotate(0deg); }
.clock-pin { position: absolute; z-index: 4; left: 50%; top: 50%; width: 28px; height: 28px; border: 7px solid #fff; border-radius: 50%; background: var(--yellow); transform: translate(-50%,-50%); box-shadow: 0 2px 0 rgba(25,50,74,.15); }
.clock-mascot { position: absolute; right: -20px; bottom: -15px; font-size: clamp(60px, 11vw, 100px); transform: rotate(8deg); filter: drop-shadow(0 7px 0 rgba(25,50,74,.1)); }

.clock-question { text-align: center; }
.clock-question > p { font-size: 20px; font-weight: 900; }
.time-options { display: grid; gap: 14px; }
.time-button { min-height: 72px; border: 4px solid rgba(25,50,74,.10); border-radius: 23px; background: #fff; cursor: pointer; font-size: clamp(25px, 4vw, 34px); font-weight: 900; box-shadow: 0 7px 0 rgba(25,50,74,.11); transition: transform .15s; }
.time-button:hover { transform: translateY(-3px); }
.time-button:active { transform: translateY(5px); box-shadow: 0 2px 0 rgba(25,50,74,.11); }
.time-button.correct { color: #12653a; background: #c8f6d9; border-color: var(--green); }
.time-button.wrong { animation: wiggle .35s ease; background: #ffe1dc; border-color: #ff8a76; }
.time-button:disabled { cursor: default; }

@keyframes wiggle { 25% { transform: translateX(-8px); } 50% { transform: translateX(8px); } 75% { transform: translateX(-5px); } }
.feedback { min-height: 42px; padding: 15px 5px 5px; font-size: 20px; font-weight: 900; }
.next-button { width: 100%; margin-top: 8px; padding: 18px; border: 0; border-radius: 21px; color: #fff; background: var(--purple); cursor: pointer; font-size: 20px; box-shadow: 0 7px 0 #634caf; }
.hidden { visibility: hidden; pointer-events: none; }

.car-heading { max-width: 900px; grid-template-columns: 58px 1fr auto; margin-bottom: 14px; }
.road-shell { position: relative; width: min(100%, 900px); height: clamp(350px, 56vh, 590px); margin: 0 auto; overflow: hidden; border: 8px solid #fff; border-radius: 30px; background: #63c46a; box-shadow: var(--shadow); touch-action: none; }
#roadCanvas { display: block; width: 100%; height: 100%; }

.start-panel { position: absolute; inset: 0; z-index: 4; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 25px; text-align: center; background: rgba(222,247,255,.88); backdrop-filter: blur(5px); }
.start-panel.gone { display: none; }
.start-car { font-size: 83px; filter: drop-shadow(0 8px 0 rgba(25,50,74,.15)); animation: idle-car 1s ease-in-out infinite alternate; }
@keyframes idle-car { to { transform: translateY(-7px) rotate(2deg); } }
.start-panel h3 { margin: 10px 0 5px; font-size: clamp(28px, 5vw, 43px); }
.start-panel p { margin-bottom: 20px; font-size: 19px; }
.start-panel button { padding: 16px 36px; border: 4px solid #fff; border-radius: 20px; color: #fff; background: var(--orange); cursor: pointer; font-size: 25px; box-shadow: 0 8px 0 #bf482a; }
.drive-message { position: absolute; z-index: 3; left: 50%; top: 22%; transform: translateX(-50%); padding: 8px 18px; border-radius: 99px; background: rgba(255,255,255,.92); font-size: clamp(19px,4vw,28px); font-weight: 900; opacity: 0; pointer-events: none; white-space: nowrap; }
.drive-message.show { animation: message-pop 1.1s ease both; }
@keyframes message-pop { 0% { opacity:0; transform:translate(-50%,20px) scale(.8); } 20%,70% { opacity:1; transform:translate(-50%,0) scale(1); } 100% { opacity:0; transform:translate(-50%,-20px) scale(1); } }

.drive-controls { width: min(100%, 760px); margin: 22px auto 0; display: grid; grid-template-columns: 1fr 1.05fr 1.05fr 1fr; gap: clamp(8px, 2vw, 18px); touch-action: none; }
.control-button { height: clamp(70px, 10vw, 92px); border: 5px solid #fff; cursor: pointer; user-select: none; -webkit-user-select: none; box-shadow: 0 8px 0 rgba(25,50,74,.18); }
.control-button.pressed, .control-button:active { transform: translateY(6px); box-shadow: 0 2px 0 rgba(25,50,74,.18); }
.steer { border-radius: 25px; color: #fff; background: var(--blue); font-size: 46px; }
.pedal { border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.pedal span { font-size: clamp(19px, 3vw, 28px); font-weight: 900; }
.pedal small { font-family: system-ui,sans-serif; font-size: 13px; font-weight: 800; }
.brake { color: #fff; background: #ef665d; }
.gas { color: #fff; background: var(--green); }
.keyboard-tip { margin: 14px auto 0; text-align: center; font: 700 13px system-ui,sans-serif; opacity: .72; }

.celebration { position: fixed; z-index: 99; inset: 0; pointer-events: none; overflow: hidden; }
.confetti { position: absolute; top: -30px; font-size: 25px; animation: confetti-fall 1.4s ease-in forwards; }
@keyframes confetti-fall { to { transform: translateY(105vh) rotate(540deg); opacity: .2; } }

@media (max-width: 700px) {
  .topbar { height: 68px; padding: 8px 14px; }
  .brand { font-size: 19px; }.brand-car { font-size: 28px; }
  .stars-total { min-width: 65px; padding: 7px 10px; }
  .sound-button { width: 43px; height: 43px; }
  .screen { min-height: calc(100vh - 68px); }
  .home-screen { padding-top: 26px; }
  .game-cards { grid-template-columns: minmax(0, 470px); }
  .game-card { min-height: 195px; grid-template-columns: 130px 1fr auto; grid-template-rows: 1fr; align-items: center; padding: 18px; border-radius: 28px; }
  .card-art { grid-column: auto; }
  .mini-clock { width: 105px; height: 105px; border-width: 8px; }
  .mini-road { width: 125px; height: 95px; }
  .mini-car { font-size: 45px; }
  .card-text strong { font-size: 25px; }
  .card-text small { font-size: 14px; }
  .play-dot { width: 42px; height: 42px; }
  .tip { margin-top: 24px; }
  .game-screen { padding: 14px 12px 25px; }
  .game-heading { margin-bottom: 12px; grid-template-columns: 50px 1fr 50px; gap: 8px; }
  .back-button { width: 48px; height: 48px; }
  .clock-layout { grid-template-columns: 1fr; gap: 18px; }
  .clock-wrap { padding: 2px; }
  .analog-clock { width: min(72vw, 310px); border-width: 12px; }
  .clock-mascot { right: -5px; bottom: -5px; }
  .clock-question > p { margin-bottom: 10px; }
  .time-options { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .time-button { min-height: 63px; border-radius: 18px; }
  .feedback { min-height: 37px; padding-top: 10px; font-size: 18px; }
  .next-button { padding: 14px; }
  .road-shell { height: min(54vh, 510px); border-width: 5px; border-radius: 22px; }
  .drive-controls { margin-top: 15px; }
  .control-button { border-width: 3px; border-radius: 19px; }
  .pedal { border-radius: 50%; }
}

@media (max-width: 430px) {
  .game-card { grid-template-columns: 105px 1fr 38px; }
  .mini-clock { width: 90px; height: 90px; }
  .mini-road { width: 100px; height: 80px; }
  .card-text strong { font-size: 22px; }
  .card-text small { display: none; }
  .play-dot { width: 38px; height: 38px; }
  .game-heading .eyebrow { font-size: 12px; }
  .game-heading h2 { font-size: 25px; }
  .drive-score { min-width: 62px; padding: 7px 8px; }
}

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