/* DevKart Grand Prix - Mario Kart Style Arcade CSS */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #09081e;
  font-family: 'Fredoka', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #ffffff;
}

#canvas-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.hidden {
  display: none !important;
}

/* UI Screens */
.ui-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: auto;
}

/* ================= LOBBY & MENU ================= */
#lobby-screen {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: radial-gradient(circle at center, rgba(30, 20, 70, 0.85) 0%, rgba(5, 4, 16, 0.96) 100%);
  padding: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.lobby-modal {
  margin: auto 0;
  width: 100%;
  max-width: 980px;
  background: rgba(22, 24, 45, 0.9);
  border: 3px solid #ff4757;
  box-shadow: 0 0 35px rgba(255, 71, 87, 0.4), inset 0 0 15px rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  padding: 24px;
  backdrop-filter: blur(16px);
}

.lobby-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 16px;
  margin-bottom: 20px;
}

.game-logo {
  font-family: 'Titan One', cursive, sans-serif;
  font-size: 38px;
  letter-spacing: 2px;
  color: #fffa65;
  text-shadow: 3px 3px 0 #eb4d4b, 6px 6px 0 #222f3e;
  line-height: 1;
}

.game-logo span {
  display: block;
  font-size: 16px;
  letter-spacing: 6px;
  color: #ffffff;
  text-shadow: 2px 2px 0 #ff4757;
  margin-top: 4px;
}

.room-badge {
  background: linear-gradient(135deg, #ff4757, #ff6b81);
  padding: 8px 18px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 1px;
  box-shadow: 0 4px 12px rgba(255, 71, 87, 0.4);
}

.lobby-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.lobby-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-box {
  background: rgba(30, 39, 46, 0.7);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 16px;
}

.panel-title {
  font-size: 16px;
  letter-spacing: 1px;
  margin-bottom: 12px;
  color: #fffa65;
  text-transform: uppercase;
}

.input-group {
  margin-bottom: 12px;
}

.input-group label {
  display: block;
  font-size: 13px;
  opacity: 0.8;
  margin-bottom: 6px;
}

.input-group input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.4);
  color: #ffffff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  outline: none;
  transition: border-color 0.2s;
}

.input-group input:focus {
  border-color: #fffa65;
}

.room-input-row {
  display: flex;
  gap: 8px;
}

.btn-secondary {
  background: #3742fa;
  color: #ffffff;
  border: none;
  padding: 0 16px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, background 0.2s;
}

.btn-secondary:hover {
  background: #5352ed;
  transform: translateY(-1px);
}

/* Character Grid */
.char-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.char-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid transparent;
  padding: 8px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.char-card:hover {
  background: rgba(255, 255, 255, 0.1);
}

.char-card.selected {
  border-color: #fffa65;
  background: rgba(255, 250, 101, 0.15);
  box-shadow: 0 0 14px rgba(255, 250, 101, 0.3);
}

.char-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.char-name {
  font-weight: 700;
  font-size: 15px;
}

.char-spec {
  font-size: 12px;
  opacity: 0.75;
}

/* Track Cards */
.track-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.track-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid transparent;
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.track-card.selected {
  border-color: #2ed573;
  background: rgba(46, 213, 115, 0.15);
  box-shadow: 0 0 14px rgba(46, 213, 115, 0.3);
}

.track-thumb {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background: rgba(0, 0, 0, 0.4);
}

.track-name {
  font-weight: 700;
  font-size: 15px;
}

.track-desc {
  font-size: 12px;
  opacity: 0.75;
}

/* Starting Grid & Bot Controls */
.lobby-players-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 110px;
  overflow-y: auto;
  margin-bottom: 12px;
}

.lobby-player-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.3);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
}

.char-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.bot-control-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.25);
  padding: 8px 12px;
  border-radius: 10px;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.step-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: #ff4757;
  color: white;
  border: none;
  font-weight: bold;
  cursor: pointer;
}

.controls-guide {
  background: rgba(0, 0, 0, 0.35);
  border-radius: 10px;
  padding: 10px;
  font-size: 12px;
  line-height: 1.4;
  color: #dcdde1;
}

.guide-item {
  margin-bottom: 4px;
}

.btn-primary-action {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, #ff4757 0%, #ff6b81 100%);
  color: #ffffff;
  border: none;
  border-radius: 16px;
  font-family: 'Titan One', cursive, sans-serif;
  font-size: 24px;
  letter-spacing: 2px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(255, 71, 87, 0.5);
  text-shadow: 2px 2px 0 #eb4d4b;
  transition: all 0.15s;
}

.btn-primary-action:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(255, 71, 87, 0.7);
}

.btn-primary-action:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ================= IN-GAME HUD ================= */
#hud-screen {
  pointer-events: none;
}

.hud-top-left {
  position: absolute;
  top: 20px;
  left: 20px;
}

.hud-lap-badge {
  background: rgba(0, 0, 0, 0.65);
  border: 3px solid #fffa65;
  border-radius: 14px;
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.hud-label {
  font-size: 12px;
  letter-spacing: 2px;
  color: #fffa65;
  font-weight: 700;
}

.hud-lap-value {
  font-family: 'Titan One', cursive, sans-serif;
  font-size: 28px;
  color: #ffffff;
}

.hud-top-center {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
}

.hud-item-slot {
  width: 74px;
  height: 74px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.25) 0%, rgba(0, 0, 0, 0.7) 100%);
  border: 4px solid #fffa65;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(255, 250, 101, 0.4);
}

.item-slot-icon {
  font-size: 42px;
}

.hud-top-right {
  position: absolute;
  top: 20px;
  right: 20px;
}

.minimap-container {
  width: 140px;
  height: 140px;
  background: rgba(0, 0, 0, 0.6);
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

#hud-minimap-canvas {
  width: 100%;
  height: 100%;
}

.hud-bottom-left {
  position: absolute;
  bottom: 24px;
  left: 24px;
}

.hud-rank-container {
  font-family: 'Titan One', cursive, sans-serif;
  font-size: 80px;
  line-height: 1;
  text-shadow: 4px 4px 0 #000000, 6px 6px 0 rgba(0, 0, 0, 0.4);
}

.hud-rank-container span span {
  font-size: 34px;
  vertical-align: super;
}

.pos-1st { color: #f1c40f; }
.pos-2nd { color: #bdc3c7; }
.pos-3rd { color: #e67e22; }
.pos-other { color: #3498db; }

.hud-bottom-right {
  position: absolute;
  bottom: 24px;
  right: 24px;
}

.hud-speedometer {
  background: rgba(0, 0, 0, 0.65);
  border: 3px solid #ff4757;
  border-radius: 16px;
  padding: 8px 18px;
  text-align: right;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.speed-num-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

#hud-speed-num {
  font-family: 'Titan One', cursive, sans-serif;
  font-size: 42px;
  color: #fffa65;
}

.speed-unit {
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  opacity: 0.8;
}

/* Center Banners */
.hud-center-countdown {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Titan One', cursive, sans-serif;
  font-size: 140px;
  text-shadow: 6px 6px 0 #000, 10px 10px 0 rgba(0, 0, 0, 0.5);
  z-index: 20;
}

.pop-anim {
  animation: popBounce 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes popBounce {
  0% { transform: translate(-50%, -50%) scale(0.2); opacity: 0; }
  50% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.0); opacity: 1; }
}

.hud-center-banner {
  position: absolute;
  top: 25%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.8);
  border: 3px solid #ff4757;
  padding: 14px 36px;
  border-radius: 20px;
  font-family: 'Titan One', cursive, sans-serif;
  font-size: 34px;
  letter-spacing: 2px;
  box-shadow: 0 0 30px rgba(255, 71, 87, 0.6);
  z-index: 20;
}

/* ================= MOBILE CONTROLS ================= */
.mobile-controls-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.touch-joy-zone {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 50%;
  height: 75%;
  pointer-events: auto;
  touch-action: none;
}

.touch-joy-base {
  position: absolute;
  left: 90px;
  bottom: 90px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.15) 0%, rgba(0, 0, 0, 0.5) 100%);
  border: 3px solid rgba(255, 255, 255, 0.4);
  transform: translate(-50%, 50%);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.35;
  pointer-events: none;
}

.touch-joy-knob {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff4757, #ff6b81);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  border: 2px solid #ffffff;
  pointer-events: none;
}

/* Steering Arrow Buttons */
.touch-steer-cluster {
  position: absolute;
  bottom: 24px;
  left: 20px;
  display: flex;
  gap: 16px;
  pointer-events: auto;
  z-index: 15;
  touch-action: none;
}

.touch-steer-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.9);
  background: linear-gradient(135deg, rgba(30, 144, 255, 0.85), rgba(70, 100, 240, 0.9));
  color: #ffffff;
  font-size: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  transition: transform 0.06s, background 0.06s;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.touch-steer-btn:active, .touch-steer-btn.pressed {
  transform: scale(0.88);
  background: linear-gradient(135deg, #ff4757, #eb2f06);
  box-shadow: 0 0 20px rgba(255, 71, 87, 0.8);
}

.touch-action-cluster {
  position: absolute;
  bottom: 20px;
  right: 20px;
  display: grid;
  grid-template-columns: repeat(3, 68px);
  grid-template-rows: repeat(2, 68px);
  gap: 12px;
  pointer-events: auto;
  z-index: 15;
  touch-action: none;
}

.touch-circle-btn {
  border-radius: 50%;
  border: 3px solid #ffffff;
  color: #ffffff;
  font-family: 'Titan One', cursive, sans-serif;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  transition: transform 0.06s, filter 0.06s;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.touch-circle-btn:active, .touch-circle-btn.pressed {
  transform: scale(0.88);
  filter: brightness(1.25);
  box-shadow: 0 0 22px rgba(255, 255, 255, 0.7);
}

.btn-gas-action {
  background: linear-gradient(135deg, #2ed573, #26af5f);
  grid-column: 3;
  grid-row: 2;
  font-size: 24px;
  border-color: #7bed9f;
}

.btn-brake-action {
  background: linear-gradient(135deg, #ff4757, #eb2f06);
  grid-column: 2;
  grid-row: 2;
  font-size: 24px;
}

.btn-drift-action {
  background: linear-gradient(135deg, #1e90ff, #3742fa);
  grid-column: 3;
  grid-row: 1;
  font-size: 24px;
}

.btn-item-action {
  background: radial-gradient(circle, #ffa502 0%, #ff7f50 100%);
  border-color: #fffa65;
  grid-column: 2;
  grid-row: 1;
  font-size: 28px;
}

.btn-mini {
  background: rgba(47, 53, 66, 0.85);
  font-size: 20px;
}

/* ================= RESULTS SCREEN ================= */
#results-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 4, 16, 0.9);
  padding: 20px;
}

.results-modal {
  width: 100%;
  max-width: 580px;
  background: rgba(22, 24, 45, 0.95);
  border: 3px solid #f1c40f;
  box-shadow: 0 0 35px rgba(241, 196, 15, 0.4);
  border-radius: 24px;
  padding: 28px;
  text-align: center;
}

.results-title {
  font-family: 'Titan One', cursive, sans-serif;
  font-size: 36px;
  color: #f1c40f;
  margin-bottom: 20px;
  letter-spacing: 2px;
}

.results-podium-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 18px;
  background: rgba(255, 255, 255, 0.05);
}

.rank-1 {
  background: linear-gradient(90deg, rgba(241, 196, 15, 0.3) 0%, rgba(241, 196, 15, 0.05) 100%);
  border: 2px solid #f1c40f;
  font-size: 22px;
}

.rank-2 {
  background: linear-gradient(90deg, rgba(189, 195, 199, 0.3) 0%, rgba(189, 195, 199, 0.05) 100%);
  border: 2px solid #bdc3c7;
}

.rank-3 {
  background: linear-gradient(90deg, rgba(230, 126, 34, 0.3) 0%, rgba(230, 126, 34, 0.05) 100%);
  border: 2px solid #e67e22;
}

/* ================= RESPONSIVE DESIGN ================= */
@media (max-width: 900px) {
  .lobby-content {
    grid-template-columns: 1fr;
  }
  .lobby-modal {
    padding: 16px;
  }
  .game-logo {
    font-size: 28px;
  }
  .hud-rank-container {
    font-size: 56px;
    bottom: 120px;
  }
  .hud-speedometer {
    bottom: 120px;
    padding: 6px 12px;
  }
  #hud-speed-num {
    font-size: 32px;
  }
  .minimap-container {
    width: 100px;
    height: 100px;
  }
  .hud-item-slot {
    width: 60px;
    height: 60px;
  }
  .item-slot-icon {
    font-size: 34px;
  }
}
