:root {
  color-scheme: dark;
  --bg: #070a12;
  --panel: #101726;
  --line: #50647f;
  --text: #f5f8ff;
  --muted: #91a0b7;
  --cyan: #34d7ff;
  --green: #7cff8a;
  --danger: #ff4d6d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(circle at 50% -20%, #1a2741 0, var(--bg) 55%);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body { padding: 12px 10px 30px; }
button, select { font: inherit; }

.app { width: 100%; margin: 0 auto; }
.topbar { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 12px; }
h1 { margin: 0; font-size: clamp(30px, 5vw, 52px); line-height: 1; letter-spacing: .08em; }
.stage-picker { display: grid; gap: 4px; min-width: min(42vw, 360px); }
.stage-picker span { color: var(--muted); font-size: 13px; font-weight: 800; letter-spacing: .12em; }
.stage-picker select {
  width: 100%;
  border: 1px solid #405371;
  border-radius: 12px;
  background: #182238;
  color: var(--text);
  padding: 11px 36px 11px 14px;
  font-size: clamp(16px, 2vw, 21px);
  font-weight: 800;
}

.hud { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 10px; }
.hud div, .hud label { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 13px; background: color-mix(in srgb, var(--panel) 88%, transparent); border: 1px solid #24334b; border-radius: 12px; }
.hud span { color: var(--muted); font-size: 12px; }
.hud strong { font-size: 14px; }
.hud select { border: 0; background: transparent; color: var(--text); font-weight: 800; text-align: right; }

.game-shell { position: relative; overflow: hidden; border: 1px solid #263751; border-radius: 18px; background: #090f1b; box-shadow: 0 18px 60px #0008, inset 0 0 50px #07101e; }
canvas { display: block; width: 100%; height: auto; touch-action: none; }

.start-prompt {
  position: absolute;
  left: 50%;
  bottom: 18px;
  z-index: 2;
  padding: 9px 16px;
  border: 1px solid #ff7188;
  border-radius: 999px;
  background: #190b15dc;
  color: #ffd8df;
  font-size: clamp(13px, 2vw, 17px);
  font-weight: 800;
  letter-spacing: .04em;
  transform: translateX(-50%);
  box-shadow: 0 0 20px #ff365544;
  white-space: nowrap;
  pointer-events: none;
}
.start-prompt[hidden] { display: none; }

.message { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; background: #050914b8; backdrop-filter: blur(4px); }
.message[hidden] { display: none; }
.message p { margin: 0 0 20px; color: var(--green); font-size: clamp(38px, 10vw, 78px); font-weight: 900; letter-spacing: .08em; text-shadow: 0 0 28px #7cff8a77; }
.message button, .controls button { border: 1px solid #405371; border-radius: 11px; background: #182238; color: white; padding: 10px 15px; }
.message button { border-color: var(--green); cursor: pointer; }

.steering-panel { display: grid; justify-items: center; margin: 14px auto 8px; }
.steering-panel > p { margin: 0 0 6px; color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .12em; }
.steering {
  position: relative;
  width: 170px;
  height: 170px;
  border: 14px solid #a7d9ad;
  border-radius: 50%;
  background: #0b1220;
  box-shadow: inset 0 0 26px #0008, 0 0 28px #8cff9a1f;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.steering:active { cursor: grabbing; }
.direction-arrow {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 3px;
  border-radius: 2px;
  background: #d9ffe0;
  transform-origin: left center;
  pointer-events: none;
}
.direction-arrow::after {
  content: "";
  position: absolute;
  right: -1px;
  top: 50%;
  width: 10px;
  height: 10px;
  border-top: 3px solid #d9ffe0;
  border-right: 3px solid #d9ffe0;
  transform: translateY(-50%) rotate(45deg);
}
.steering-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  border: 3px solid #ffb0bb;
  border-radius: 50%;
  background: #e31837;
  box-shadow: 0 0 16px #ff3655;
  pointer-events: none;
}
.guide { margin: 8px 4px 12px; color: var(--muted); font-size: 14px; text-align: center; }
.guide b { color: var(--green); }
.player-dot { display: inline-block; width: 11px; height: 11px; margin-right: 6px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 10px var(--danger); }
.controls { display: flex; align-items: center; justify-content: center; gap: 12px; }
.controls button { cursor: pointer; }

@media (max-width: 900px) {
  body { padding: 8px 6px 205px; }
  .topbar { align-items: center; margin: 0 4px 10px; }
  h1 { font-size: clamp(28px, 9vw, 40px); }
  .stage-picker { min-width: 52vw; }
  .stage-picker select { padding: 9px 30px 9px 10px; font-size: 16px; }
  .hud { gap: 5px; margin-bottom: 6px; }
  .hud div { display: grid; justify-content: center; text-align: center; padding: 7px 5px; }
  .hud label { padding: 7px 9px; }
  .game-shell { border-radius: 12px; }
  .start-prompt { bottom: 10px; max-width: calc(100% - 20px); white-space: normal; text-align: center; }
  .guide { min-height: 40px; }
  .steering-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    margin: 0;
    padding: 6px 0 calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid #263751;
    background: #070b13ee;
    box-shadow: 0 -12px 35px #0009;
    backdrop-filter: blur(8px);
  }
  .steering-panel > p { margin-bottom: 3px; }
  .steering { width: 142px; height: 142px; border-width: 13px; }
}
