:root {
  --neon-pink: #FF0055;
  --neon-blue: #00FFDD;
  --bg-color: #050510;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none; /* No selecting text on mobile */
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

body {
  background-color: var(--bg-color);
  color: #fff;
  font-family: 'Outfit', sans-serif;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  position: relative;
  touch-action: none; /* Disables browser scrolling */
}

.grid-overlay {
  position: absolute;
  bottom: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background-image: 
    linear-gradient(rgba(255, 0, 85, 0.2) 2px, transparent 2px),
    linear-gradient(90deg, rgba(255, 0, 85, 0.2) 2px, transparent 2px);
  background-size: 40px 40px;
  transform: rotateX(60deg);
  z-index: -1;
}

.screen {
  display: none;
  height: 100%;
  width: 100%;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow-y: auto;
  padding: 40px 0;
}

.screen.active {
  display: flex;
}

#join-screen h1 {
  font-family: 'Press Start 2P', cursive;
  font-size: 1.5rem;
  color: var(--neon-blue);
  text-shadow: 0 0 10px var(--neon-blue);
  margin-bottom: 3rem;
  text-align: center;
}

.input-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 2rem;
  width: 80%;
  max-width: 300px;
}

.input-group label {
  font-family: 'Press Start 2P', cursive;
  font-size: 0.8rem;
  margin-bottom: 1rem;
  color: #aaa;
}

#room-code-input, #driver-name-input {
  width: 100%;
  background: rgba(0,0,0,0.5);
  border: 2px solid var(--neon-blue);
  color: var(--neon-blue);
  font-family: 'Press Start 2P', cursive;
  font-size: 2rem;
  text-align: center;
  padding: 1rem;
  text-transform: uppercase;
  outline: none;
  border-radius: 8px;
  box-shadow: inset 0 0 10px rgba(0, 255, 221, 0.2);
}

#room-code-input:focus, #driver-name-input:focus {
  box-shadow: inset 0 0 15px rgba(0, 255, 221, 0.5), 0 0 15px rgba(0, 255, 221, 0.5);
}

select {
  width: 100%;
  background: rgba(0,0,0,0.8);
  border: 2px solid var(--neon-blue);
  color: var(--neon-blue);
  font-family: 'Press Start 2P', cursive;
  font-size: 0.8rem;
  padding: 1rem;
  outline: none;
  border-radius: 8px;
  appearance: none;
  text-align: center;
  box-shadow: inset 0 0 10px rgba(0, 255, 221, 0.2);
}

select:focus {
  box-shadow: inset 0 0 15px rgba(0, 255, 221, 0.5), 0 0 15px rgba(0, 255, 221, 0.5);
}

.btn {
  display: inline-block;
  padding: 1.2rem 2rem;
  font-family: 'Press Start 2P', cursive;
  font-size: 1rem;
  text-transform: uppercase;
  cursor: pointer;
  border: 2px solid var(--neon-pink);
  box-shadow: inset 0 0 15px rgba(255, 0, 85, 0.5), 0 0 15px rgba(255, 0, 85, 0.5);
  background: rgba(255, 0, 85, 0.1);
  color: #fff;
  transition: all 0.2s;
  border-radius: 8px;
  width: 80%;
  max-width: 300px;
}

.btn:active {
  transform: scale(0.95);
  background: var(--neon-pink);
  color: #000;
}

#error-msg {
  color: var(--neon-pink);
  margin-top: 1rem;
  font-family: 'Press Start 2P', cursive;
  font-size: 0.7rem;
  text-align: center;
  min-height: 1rem;
}

/* GAMEPAD STYLES */
#gamepad-screen {
  background: url('assets/kart_chassis.png') center bottom / cover no-repeat;
}

#speedometer-container {
  position: absolute;
  top: 15px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: baseline;
  gap: 5px;
  background: rgba(0, 0, 0, 0.6);
  padding: 10px 20px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 20px rgba(0,0,0,0.8);
  z-index: 10;
}

#speed-val {
  font-family: 'Outfit', sans-serif;
  font-variant-numeric: tabular-nums;
  font-size: 3rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 10px rgba(255,255,255,0.5);
}

.speed-unit {
  font-family: 'Press Start 2P', cursive;
  font-size: 0.8rem;
  color: #00ffdd;
}

.status-bar {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.color-indicator {
  width: 30px;
  height: 30px;
  border-radius: 5px;
  box-shadow: 0 0 15px currentColor;
  border: 2px solid white;
}

#connection-status {
  font-family: 'Press Start 2P', cursive;
  font-size: 0.8rem;
  color: var(--neon-blue);
  text-shadow: 0 0 10px var(--neon-blue);
}

.instruction {
  display: none; /* Removed for the graphical cockpit */
}

/* PORTRAIT LOCK OVERLAY */
.portrait-lock {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: black;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 2rem;
}

.portrait-lock .rotate-icon {
  font-size: 4rem;
  color: var(--neon-pink);
  margin-bottom: 2rem;
  animation: spin 2s infinite linear;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(90deg); }
}

.portrait-lock h1 {
  font-family: 'Press Start 2P', cursive;
  font-size: 1.2rem;
  color: #fff;
  margin-bottom: 1rem;
}

.portrait-lock p {
  color: #aaa;
  font-size: 0.9rem;
}

/* Hide portrait lock if in landscape */
@media screen and (orientation: landscape) {
  .portrait-lock {
    display: none !important;
  }
}

/* COCKPIT UI */
.cockpit {
  flex: 1;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: stretch; /* fill height */
  padding: 40px 20px 20px 20px;
}

.pedal-zone {
  position: absolute;
  top: 0;
  width: 30vw;
  height: 100vh;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto; 
  -webkit-tap-highlight-color: transparent;
}

.left-zone { left: 0; }
.right-zone { right: 0; }

.pedal-zone.active .pedal {
  transform: scale(0.9);
}

.pedal {
  font-family: 'Press Start 2P', cursive;
  font-size: 1.2rem;
  padding: 2rem 1rem;
  border-radius: 12px;
  color: #fff;
  writing-mode: vertical-rl;
  text-orientation: upright;
  box-shadow: inset 0 0 10px rgba(0,0,0,0.5), 0 0 15px currentColor;
  transition: transform 0.1s;
}

.brake {
  background: rgba(255, 0, 85, 0.4);
  border: 2px solid var(--neon-pink);
  color: var(--neon-pink);
}

.gas {
  background: rgba(0, 255, 221, 0.4);
  border: 2px solid var(--neon-blue);
  color: var(--neon-blue);
}

.steering-column {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none;
}

#steering-wheel {
  width: 100%;
  max-width: 350px;
  mix-blend-mode: multiply; /* Make white background transparent */
  transition: transform 0.5s ease-out; /* Smooth visual turn for touch controls */
  transform-origin: center center;
}
