:root {
  color-scheme: dark;
  --ink: #fff4c8;
  --muted: #d6b46c;
  --panel: #213845;
  --panel-strong: #152736;
  --line: #6d4f32;
  --accent: #ffd45c;
  --accent-2: #65d6e8;
  font-family: "Trebuchet MS", Verdana, ui-sans-serif, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  touch-action: none;
  background: #06151f;
  color: var(--ink);
}

button {
  border: 0;
  color: inherit;
  font: inherit;
}

.game-shell {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #07324a;
  image-rendering: pixelated;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hud {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  pointer-events: none;
}

.metric {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #183648;
  box-shadow:
    inset 0 0 0 2px #2e5d67,
    4px 4px 0 rgba(0, 0, 0, 0.28);
}

.metric span,
.metric strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric span {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
  text-transform: uppercase;
}

.metric strong {
  margin-top: 2px;
  font-size: clamp(15px, 4vw, 19px);
  line-height: 1.1;
}

.mode-panel,
.race-result,
.about-panel {
  position: absolute;
  left: max(18px, env(safe-area-inset-left));
  right: max(18px, env(safe-area-inset-right));
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 4px solid #8b6b3d;
  border-radius: 0;
  background: var(--panel-strong);
  box-shadow:
    inset 0 0 0 3px #274f5b,
    8px 8px 0 rgba(0, 0, 0, 0.34);
}

.mode-panel[hidden],
.race-result[hidden],
.about-panel[hidden] {
  display: none;
}

h1,
h2,
p {
  margin: 0;
}

h1,
h2 {
  font-size: clamp(28px, 9vw, 42px);
  line-height: 0.95;
  letter-spacing: 0;
  color: #ffe483;
  text-shadow: 3px 3px 0 #743827;
}

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

.mode-tabs,
.course-tabs,
.difficulty {
  display: grid;
  gap: 6px;
  padding: 4px;
  border: 2px solid #6d4f32;
  border-radius: 0;
  background: #0f2431;
}

.mode-tabs {
  grid-template-columns: repeat(2, 1fr);
}

.difficulty {
  grid-template-columns: repeat(3, 1fr);
}

.course-tabs {
  grid-template-columns: repeat(3, 1fr);
}

.mode-button,
.course-button,
.difficulty-button,
.secondary,
.primary {
  min-height: 46px;
  border-radius: 0;
  cursor: pointer;
}

.mode-button,
.course-button,
.difficulty-button {
  background: #233c4b;
  color: var(--muted);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.28);
}

.menu-actions {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 8px;
}

.secondary {
  background: #233c4b;
  color: var(--ink);
  box-shadow:
    inset 0 -4px 0 #14212c,
    4px 4px 0 rgba(0, 0, 0, 0.24);
}

.mode-button.is-active,
.course-button.is-active,
.difficulty-button.is-active {
  background: #2d6f78;
  color: var(--ink);
  box-shadow: inset 0 0 0 2px #65d6e8;
}

.primary {
  background: #ffcc4d;
  color: #332114;
  font-weight: 800;
  box-shadow:
    inset 0 -5px 0 #b86f28,
    5px 5px 0 rgba(0, 0, 0, 0.28);
}

.controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(16px, env(safe-area-inset-bottom));
  display: grid;
  place-items: center;
  pointer-events: none;
}

.wheel-wrap {
  width: min(42vw, 154px);
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  pointer-events: auto;
  touch-action: none;
}

.wheel {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 10px solid rgba(103, 70, 35, 0.95);
  background:
    radial-gradient(circle at 50% 50%, #ffd45c 0 13%, transparent 14%),
    radial-gradient(circle at 50% 50%, #9a5b2d 0 39%, #513017 40% 47%, transparent 48%);
  box-shadow:
    inset 0 0 0 3px #ffd97a,
    6px 8px 0 rgba(0, 0, 0, 0.34);
  transform: rotate(0deg);
}

.wheel::before,
.wheel::after,
.wheel span {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 82%;
  border-radius: 999px;
  background: linear-gradient(180deg, #e7a84b, #7a411e);
  transform-origin: 50% 50%;
}

.wheel::before {
  transform: translate(-50%, -50%) rotate(0deg);
}

.wheel::after {
  transform: translate(-50%, -50%) rotate(90deg);
}

.wheel span:nth-child(1) {
  transform: translate(-50%, -50%) rotate(45deg);
}

.wheel span:nth-child(2) {
  transform: translate(-50%, -50%) rotate(135deg);
}

.wheel span:nth-child(3),
.wheel span:nth-child(4) {
  display: none;
}

@media (min-width: 720px) {
  .mode-panel,
  .race-result {
    left: 50%;
    right: auto;
    width: min(420px, calc(100vw - 36px));
    transform: translate(-50%, -50%);
  }

  .hud {
    left: 50%;
    right: auto;
    width: min(520px, calc(100vw - 24px));
    transform: translateX(-50%);
  }
}
