* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: #8fd3f4;
  font-family: 'Trebuchet MS', 'Segoe UI', sans-serif;
  overflow: hidden;
}

#game-wrap {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#scene {
  position: absolute;
  inset: 0;
}

#scene canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle, transparent 55%, rgba(200,0,0,0) 75%);
  opacity: 0;
  transition: opacity 0.08s;
}

#vignette.hit {
  background: radial-gradient(circle, transparent 40%, rgba(200,0,0,0.55) 100%);
  opacity: 1;
}

#hud {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  font-weight: bold;
  font-size: 24px;
  color: #fff;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.35);
  pointer-events: none;
  z-index: 5;
}

#park-name {
  font-size: 14px;
  font-weight: normal;
  opacity: 0.9;
  margin-top: 2px;
}

#combo {
  font-size: 28px;
  color: #fff176;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.5);
}

#lives {
  font-size: 26px;
  text-align: right;
}

#map-btn {
  pointer-events: auto;
  margin-top: 6px;
  padding: 6px 14px;
  font-size: 14px;
  box-shadow: 0 3px 0 #c4472a;
  display: block;
  margin-left: auto;
}

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(20, 20, 35, 0.72);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  gap: 8px;
  overflow-y: auto;
  z-index: 10;
}

.overlay.hidden {
  display: none;
}

.overlay h1 {
  margin: 0 0 6px 0;
  font-size: clamp(24px, 5vw, 44px);
}

.equipment-picker {
  display: flex;
  gap: 10px;
  margin: 10px 0;
}

.equip-btn {
  margin-top: 0;
  padding: 10px 16px;
  font-size: 15px;
  line-height: 1.5;
  border-radius: 14px;
  background: rgba(255,255,255,0.12);
  color: #fff;
  box-shadow: none;
  border: 2px solid transparent;
}

.equip-btn:active {
  transform: none;
}

.equip-btn.active {
  background: #ff7043;
  border-color: #ffcab0;
  box-shadow: 0 4px 0 #c4472a;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 24px;
  margin: 14px 0;
  font-size: clamp(13px, 2.4vw, 16px);
  background: rgba(255,255,255,0.1);
  padding: 12px 20px;
  border-radius: 10px;
}

.hint {
  font-size: 14px;
  opacity: 0.85;
  max-width: 420px;
}

button {
  margin-top: 10px;
  padding: 12px 28px;
  font-size: 20px;
  font-weight: bold;
  border: none;
  border-radius: 999px;
  background: #ff7043;
  color: white;
  cursor: pointer;
  box-shadow: 0 4px 0 #c4472a;
  transition: transform 0.08s;
}

button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #c4472a;
}

#map-area {
  position: relative;
  width: min(70vw, 340px);
  height: min(70vw, 340px);
  background: rgba(255,255,255,0.08);
  border: 2px dashed rgba(255,255,255,0.3);
  border-radius: 16px;
  margin: 10px 0;
}

.map-pin {
  position: absolute;
  transform: translate(-50%, -50%);
  margin: 0;
  padding: 10px 14px;
  font-size: 13px;
  border-radius: 12px;
  background: #4a4a6a;
  box-shadow: 0 3px 0 #2f2f47;
}

.map-pin.here {
  background: #ff7043;
  box-shadow: 0 3px 0 #c4472a;
}

.map-pin.here::after {
  content: '📍';
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 18px;
}

#trick-popup {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 38px;
  font-weight: bold;
  color: #fff;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.5);
  pointer-events: none;
  opacity: 0;
  z-index: 5;
}

@media (max-width: 520px) {
  #hud { font-size: 17px; }
  #combo { font-size: 19px; }
}

/* Touch controls — only shown on real touch devices (phones/tablets), never
   on a mouse+keyboard computer, so it never gets in the way there. */
#touch-controls {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 3;
}

@media (hover: none) and (pointer: coarse) {
  #touch-controls {
    display: block;
  }
}

/* Joystick — bottom-left, raised off the very edge so a thumb has room and
   doesn't fight the phone's home-bar area. Dragging the knob sets keysHeld
   in both axes at once (steer AND forward/back), same as a real game pad. */
#touch-joystick {
  position: absolute;
  left: 28px;
  bottom: 130px;
  width: 120px;
  height: 120px;
  z-index: 2;
}

#joystick-base {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: 3px solid rgba(255, 255, 255, 0.4);
}

#joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  margin-left: -27px;
  margin-top: -27px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.85);
  pointer-events: none;
}

/* Trick buttons — a grid on the right, one per trick key, filled in by
   game.js from the same trick list the start-screen hint text uses. */
#touch-tricks {
  position: absolute;
  right: 16px;
  bottom: 132px;
  display: grid;
  grid-template-columns: repeat(4, 46px);
  grid-auto-rows: 46px;
  gap: 8px;
  z-index: 2;
}

.trick-btn {
  margin: 0;
  padding: 0;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  border: 2px solid rgba(255, 255, 255, 0.5);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.trick-btn:active {
  transform: none;
  background: rgba(255, 255, 255, 0.45);
}

#touch-jump {
  position: absolute;
  right: 16px;
  bottom: 24px;
  width: 84px;
  height: 84px;
  margin: 0;
  padding: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  border: 3px solid rgba(255, 255, 255, 0.65);
  color: #fff;
  font-size: 14px;
  font-weight: bold;
  box-shadow: none;
  z-index: 2;
}

#touch-jump:active {
  transform: none;
  background: rgba(255, 255, 255, 0.5);
}
