:root {
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  background: #10131a;
  font-family: system-ui, 'Segoe UI', Roboto, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

#app {
  position: fixed;
  inset: 0;
  touch-action: none;
}

#scene {
  position: absolute;
  inset: 0;
  display: block;
  touch-action: none;
}

/* Right half: each new press queues a pedal stroke; holding and dragging steers. */
#move-zone {
  position: absolute;
  top: 0;
  right: 0;
  width: 55%;
  height: 100%;
  touch-action: none;
}

/* Steering drag visual: a ring at the press origin and a dot that tracks the
   thumb. It communicates steering only; drag distance does not set speed. */
#stick-origin,
#stick-thumb {
  position: fixed;
  top: 0;
  left: 0;
  pointer-events: none;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.12s ease;
}

#stick-origin.visible,
#stick-thumb.visible {
  opacity: 1;
}

#stick-origin {
  width: 64px;
  height: 64px;
  margin: -32px 0 0 -32px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.06);
}

#stick-thumb {
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  background: rgba(120, 200, 255, 0.85);
  border: 2px solid rgba(255, 255, 255, 0.9);
}

/* Same rubber-band visual for the Brake thumb, color-coded by zone: neutral
   while light-braking, amber once past the endo threshold, red at lockup. */
#brake-stick-origin,
#brake-stick-thumb {
  position: fixed;
  top: 0;
  left: 0;
  pointer-events: none;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.12s ease, background 0.1s ease, border-color 0.1s ease;
}

#brake-stick-origin.visible,
#brake-stick-thumb.visible {
  opacity: 1;
}

#brake-stick-origin {
  width: 64px;
  height: 64px;
  margin: -32px 0 0 -32px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.06);
}

#brake-stick-thumb {
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  background: rgba(160, 170, 180, 0.85);
  border: 2px solid rgba(255, 255, 255, 0.9);
}

#brake-stick-thumb.zone-endo {
  background: rgba(255, 170, 60, 0.9);
}

#brake-stick-thumb.zone-lockup {
  background: rgba(255, 70, 60, 0.95);
}

/* Left side: button cluster lives here, anchored to the bottom-left. */
#button-zone {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 45%;
  height: 55%;
  touch-action: none;
  pointer-events: none;
}

#button-zone .hud-button {
  position: absolute;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: rgba(20, 22, 30, 0.4);
  color: #eef1f8;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  -webkit-tap-highlight-color: transparent;
}

#button-zone .hud-button[hidden] {
  display: none;
}

#button-zone .hud-button.active {
  background: rgba(120, 170, 255, 0.55);
  border-color: rgba(200, 220, 255, 0.9);
}

#button-zone .hud-button.brake {
  width: 100px;
  height: 100px;
}

#button-zone .pos-brake {
  left: 62%;
  bottom: 20%;
  transform: translateX(-50%);
}

#button-zone .pos-pass {
  left: 8%;
  top: 8%;
}

#button-zone .pos-shoot {
  left: 56%;
  top: 8%;
}

#button-zone .pos-poke {
  left: 32%;
  top: 8%;
}

#button-zone .pos-hop,
#button-zone .pos-tap {
  left: 3%;
  bottom: 46%;
}

/* Debug panel is a tray: closed by default (slid off-screen) so it doesn't
   eat into the game view, opened by tapping the always-visible tab. */
#debug-panel {
  position: absolute;
  top: 0;
  left: 0;
  max-width: 46vw;
  max-height: 100vh;
  overflow-y: auto;
  touch-action: pan-y;
  pointer-events: auto;
  background: rgba(10, 11, 16, 0.85);
  color: #d7dbe6;
  font: 11px/1.4 ui-monospace, Consolas, monospace;
  padding: 8px 10px;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
}

#debug-panel.open {
  transform: translateX(0);
}

#debug-tab {
  position: absolute;
  top: 8px;
  left: 0;
  pointer-events: auto;
  background: rgba(10, 11, 16, 0.6);
  color: #8fb8ff;
  font: 12px/1.4 ui-monospace, Consolas, monospace;
  padding: 8px 7px;
  border-radius: 0 6px 6px 0;
  -webkit-tap-highlight-color: transparent;
  transition: left 0.25s ease;
  z-index: 2;
}

#debug-tab.open {
  left: 46vw;
}

#debug-panel h1 {
  font-size: 11px;
  margin: 0 0 6px;
  color: #8fb8ff;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

#debug-panel .row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

#debug-panel .row label {
  flex: 0 0 108px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#debug-panel .row input[type='range'] {
  flex: 1 1 auto;
  width: 100px;
}

#debug-panel .row .val {
  flex: 0 0 46px;
  text-align: right;
}

#hud-state {
  position: absolute;
  top: 8px;
  right: 8px;
  pointer-events: none;
  color: #d7dbe6;
  font: 12px/1.4 ui-monospace, Consolas, monospace;
  background: rgba(10, 11, 16, 0.55);
  padding: 6px 8px;
  border-radius: 4px;
  text-align: right;
}

#balance-state {
  position: absolute;
  top: 48px;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  color: #d7dbe6;
  font: 12px/1.4 ui-monospace, Consolas, monospace;
  background: rgba(10, 11, 16, 0.65);
  padding: 5px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

#balance-state.penalty {
  color: #ffcf3f;
  background: rgba(80, 20, 16, 0.82);
}

@media (max-width: 600px) {
  #hud-state {
    top: 52px;
  }

  #balance-state {
    top: 92px;
  }
}
