@font-face {
  font-family: "Press Start 2P";
  src: url("fonts/PressStart2P-Regular.woff2") format("woff2");
  font-display: swap;
}
@font-face {
  font-family: "Fredoka";
  src: url("fonts/fredoka-bold.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}
/* Fredoka has no Cyrillic: Bulgarian letters come from Nunito ExtraBold (OFL), cut down to Cyrillic only */
@font-face {
  font-family: "Fredoka";
  src: url("fonts/nunito-cyrillic-800.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0400-045F, U+0490-0491, U+2116;
}

:root {
  --ink: #2b1d3a;
  --panel: rgba(36, 22, 70, 0.82);
  --sun: #ffd23f;
  --sun-dark: #c9962a;
  --pink: #ff3b8d;
  --white: #ffffff;
  --muted: #d9ccff;
  font-family: Fredoka, "Segoe UI", system-ui, sans-serif;
  color: var(--white);
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
body:not(.ready) {
  background: linear-gradient(#62bdff, #ffe0ef);
}
#view {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: block;
  touch-action: none;
}
body.driving.idle,
body.driving.idle * {
  cursor: none;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 0;
}
button:focus-visible,
.switch input:focus-visible + .knob {
  outline: 4px solid var(--white);
  outline-offset: 3px;
}

/* ------------------------------------------------ screens */

.screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: radial-gradient(ellipse at center, rgba(43, 29, 58, 0.15), rgba(43, 29, 58, 0.55));
  overflow-y: auto;
}
.screen[hidden] {
  display: none;
}
.panel {
  width: min(560px, 100%);
  background: var(--panel);
  backdrop-filter: blur(6px);
  border: 3px solid rgba(255, 255, 255, 0.18);
  border-radius: 28px;
  padding: 26px 28px 22px;
  text-align: center;
  box-shadow: 0 18px 50px rgba(20, 10, 40, 0.45);
}
.panel.wide {
  width: min(820px, 100%);
}
h2 {
  margin: 0 0 14px;
  font-size: 30px;
}
h3 {
  margin: 18px 0 10px;
  font-size: 20px;
  color: var(--muted);
}
.logo {
  margin: 4px 0 10px;
  font-family: "Press Start 2P", monospace;
  font-weight: 400;
  font-size: clamp(38px, 9vw, 74px);
  line-height: 1.2;
  background: linear-gradient(180deg, #fff3a0 0 28%, #ffbe0b 28% 50%, #ff7a3d 50% 68%, #ff3b8d 68% 84%, #b06cff 84%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 5px 0 var(--ink)) drop-shadow(0 0 18px rgba(255, 120, 200, 0.35));
}
.logo.smaller {
  font-size: clamp(22px, 5vw, 40px);
}
.tagline {
  margin: 0 auto 18px;
  max-width: 440px;
  font-size: 18px;
  line-height: 1.35;
  color: var(--muted);
}

.big {
  display: inline-block;
  min-width: 220px;
  padding: 14px 34px;
  font-size: 30px;
  font-weight: 700;
  color: var(--ink);
  background: var(--sun);
  border-radius: 999px;
  box-shadow: 0 6px 0 var(--sun-dark);
  transition: transform 0.08s;
}
.big:hover {
  transform: translateY(-2px);
}
.big:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 var(--sun-dark);
}
.mid {
  padding: 10px 26px;
  font-size: 20px;
  color: var(--ink);
  background: var(--sun);
  border-radius: 999px;
  box-shadow: 0 4px 0 var(--sun-dark);
}
.small {
  padding: 8px 16px;
  font-size: 16px;
  background: rgba(255, 255, 255, 0.14);
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
}
.small:hover {
  background: rgba(255, 255, 255, 0.24);
}
.small.nudge {
  background: var(--pink);
  border-color: var(--pink);
  animation: nudge 1.4s ease-in-out infinite;
}
@keyframes nudge {
  50% {
    transform: scale(1.06);
  }
}
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-items: center;
  margin-top: 18px;
}

.switch {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px auto 6px;
  max-width: 400px;
  text-align: left;
  cursor: pointer;
}
.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.knob {
  flex: none;
  width: 56px;
  height: 32px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  position: relative;
  transition: background 0.15s;
}
.knob::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--white);
  transition: transform 0.15s;
}
.switch input:checked + .knob {
  background: #3ddc84;
}
.switch input:checked + .knob::after {
  transform: translateX(24px);
}
.switch b {
  display: block;
  font-size: 19px;
}
.switch small {
  display: block;
  font-size: 15px;
  color: var(--muted);
}

.wheel-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: center;
  margin-top: 14px;
  font-size: 16px;
}
#wheel-status {
  color: var(--muted);
}
#wheel-status.ok {
  color: #7dffb1;
}
.keys {
  margin: 14px 0 0;
  font-size: 14px;
  color: var(--muted);
  opacity: 0.85;
}
.langs {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 14px;
}
.langs button {
  padding: 4px 10px;
  font-size: 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
}
.langs button[aria-pressed="true"] {
  background: var(--sun);
  color: var(--ink);
}

.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 400px;
  margin: 14px auto 0;
  font-size: 18px;
}
.seg {
  display: flex;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 3px;
}
.seg button {
  padding: 6px 12px;
  font-size: 15px;
  border-radius: 999px;
  background: transparent;
}
.seg button[aria-pressed="true"],
#p-sound[aria-pressed="true"] {
  background: var(--sun);
  color: var(--ink);
}

.su-step p {
  min-height: 3.2em;
  margin: 6px 0 16px;
  font-size: 22px;
  line-height: 1.3;
}
.meter {
  height: 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  overflow: hidden;
}
.meter i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #3ddc84, var(--sun));
  transition: width 0.08s;
}
.su-step[data-step^="pad"] .meter,
.su-step[data-step="left"] .meter {
  visibility: hidden;
}
.su-step[data-step="done"] .meter i {
  width: 100% !important;
}

.stats {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 6px;
}
.stats div {
  min-width: 140px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 16px;
}
.stats .lbl {
  display: block;
  font-size: 14px;
  color: var(--muted);
}
.stats b {
  font-size: 28px;
}
.cards {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
}
.cards figure {
  margin: 0;
  width: 150px;
  padding: 6px 6px 4px;
  background: var(--white);
  color: var(--ink);
  border-radius: 6px;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.3);
}
.cards figure:nth-child(odd) {
  transform: rotate(-3deg);
}
.cards figure:nth-child(even) {
  transform: rotate(2.5deg);
}
.cards img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 3px;
}
.cards figcaption {
  font-size: 13px;
  padding-top: 4px;
}

/* ------------------------------------------------ HUD */

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
}
#hud[hidden] {
  display: none;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 22px;
  background: rgba(43, 29, 58, 0.55);
  border-radius: 999px;
  pointer-events: auto;
}
.hud-left {
  position: absolute;
  top: 12px;
  left: 14px;
  display: flex;
  gap: 8px;
}
.hud-right {
  position: absolute;
  top: 12px;
  right: 14px;
  display: flex;
  gap: 8px;
}
.progress {
  position: absolute;
  top: 26px;
  left: 50%;
  width: min(40vw, 520px);
  transform: translateX(-50%);
}
.progress .track {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  box-shadow: 0 2px 0 rgba(43, 29, 58, 0.35);
}
.mark {
  position: absolute;
  top: -14px;
  transform: translateX(-50%);
}
.mark canvas {
  width: 34px;
  height: 34px;
  display: block;
  background: var(--white);
  border-radius: 50%;
  border: 3px solid var(--ink);
}
.mark.unknown {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--white);
  border: 3px solid var(--ink);
  color: var(--ink);
  font-size: 20px;
  line-height: 28px;
  text-align: center;
}
#progress-car {
  position: absolute;
  top: 6px;
  font-size: 26px;
  transform: translateX(-50%) scaleX(-1);
  filter: drop-shadow(0 2px 0 rgba(43, 29, 58, 0.5));
  transition: left 0.2s linear;
}
.speedo {
  position: absolute;
  right: 18px;
  bottom: 14px;
  font-size: 18px;
  text-shadow: 0 2px 0 var(--ink);
}
.speedo b {
  font-size: 30px;
}

#banner {
  position: fixed;
  left: 50%;
  top: 19%;
  display: flex;
  align-items: center;
  gap: 16px;
  transform: translateX(-50%);
  font-size: clamp(30px, 6vw, 60px);
  font-weight: 700;
  white-space: nowrap;
  text-shadow: 0 4px 0 var(--ink), 0 0 24px rgba(43, 29, 58, 0.5);
  opacity: 0;
  pointer-events: none;
}
#banner canvas {
  width: clamp(60px, 9vw, 104px);
  height: auto;
  background: var(--white);
  border-radius: 50%;
  border: 4px solid var(--ink);
}
#banner.on {
  animation: banner 2.8s ease-out forwards;
}
#banner.fork.on {
  animation-duration: 4.2s;
}
@keyframes banner {
  0% {
    opacity: 0;
    transform: translateX(-50%) scale(0.6);
  }
  10% {
    opacity: 1;
    transform: translateX(-50%) scale(1.08);
  }
  16%,
  82% {
    opacity: 1;
    transform: translateX(-50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) scale(1);
  }
}

.radio {
  position: fixed;
  top: 64px;
  right: 16px;
  padding: 6px 14px;
  font-size: 18px;
  background: rgba(43, 29, 58, 0.6);
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
}
.radio.on {
  animation: fadeout 2.4s ease-in forwards;
}
@keyframes fadeout {
  0%,
  70% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

#toast {
  position: fixed;
  left: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 8px 6px;
  background: var(--white);
  color: var(--ink);
  border-radius: 6px;
  font-size: 18px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  transform: translateY(160%) rotate(-5deg);
  pointer-events: none;
}
#toast img {
  width: min(220px, 40vw);
  aspect-ratio: 16 / 9;
  border-radius: 3px;
}
#toast.on {
  animation: toast 2.6s ease-in-out forwards;
}
@keyframes toast {
  0% {
    transform: translateY(160%) rotate(-5deg);
  }
  15%,
  80% {
    transform: translateY(0) rotate(-5deg);
  }
  100% {
    transform: translateY(160%) rotate(-5deg);
  }
}
#flash {
  position: fixed;
  inset: 0;
  background: var(--white);
  opacity: 0;
  pointer-events: none;
}
#flash.on {
  animation: flash 0.45s ease-out;
}
@keyframes flash {
  0% {
    opacity: 0.85;
  }
  100% {
    opacity: 0;
  }
}
#sound-hint {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  padding: 8px 18px;
  font-size: 17px;
  background: rgba(43, 29, 58, 0.7);
  border-radius: 999px;
}

@media (max-width: 640px) {
  .panel {
    padding: 20px 16px 16px;
  }
  .pill {
    font-size: 17px;
    padding: 4px 10px;
  }
  .progress {
    top: 58px;
    width: calc(100vw - 60px);
  }
  .speedo {
    display: none;
  }
  .keys {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .small.nudge {
    animation: none;
  }
}
