* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: #000;
  overflow: hidden;
  font-family: 'Press Start 2P', monospace;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
}

#game-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* FILE SELECT SCREEN */
#file-select-screen {
  position: absolute;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #0a0a3a 0%, #1a1a6a 50%, #0a0a3a 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#stars-bg {
  position: absolute;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#game-title {
  font-size: clamp(20px, 5vw, 48px);
  color: #FFD700;
  text-shadow: 4px 4px 0px #8B6914, 0 0 30px rgba(255,215,0,0.5);
  animation: titleWobble 2s ease-in-out infinite;
  margin-bottom: 30px;
  z-index: 1;
  letter-spacing: 2px;
}

@keyframes titleWobble {
  0%, 100% { transform: rotate(-1deg) scale(1); }
  50% { transform: rotate(1deg) scale(1.02); }
}

#save-slots {
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 1;
  width: 90%;
  max-width: 400px;
}

.save-slot {
  background: rgba(20, 20, 80, 0.8);
  border: 3px solid #4444aa;
  border-radius: 12px;
  padding: 14px 20px;
  color: #fff;
  font-size: clamp(8px, 2vw, 12px);
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.save-slot:hover, .save-slot:focus {
  background: rgba(40, 40, 120, 0.9);
  border-color: #FFD700;
  transform: scale(1.03);
  box-shadow: 0 0 20px rgba(255,215,0,0.3);
}

.save-slot .slot-info {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: clamp(6px, 1.5vw, 9px);
  color: #aaa;
}

#city-tour-btn {
  margin-top: 8px;
  width: 90%;
  max-width: 400px;
  z-index: 1;
}

#start-hint {
  color: #8888cc;
  font-size: clamp(7px, 1.5vw, 10px);
  margin-top: 24px;
  animation: blink 1s step-end infinite;
  z-index: 1;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* GAME SCREEN */
#game-screen {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#viewport-container {
  position: relative;
  background: #000;
  overflow: hidden;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
}

#game-canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
}

#crt-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(0,0,0,0.12) 0px,
    rgba(0,0,0,0.12) 1px,
    transparent 1px,
    transparent 3px
  );
  z-index: 5;
}

/* HUD */
#hud {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 10;
  font-family: 'Press Start 2P', monospace;
}

#hud-health {
  position: absolute;
  top: 12px; left: 12px;
}

#hud-stars {
  position: absolute;
  top: 12px; right: 12px;
  color: #FFD700;
  font-size: clamp(8px, 2vw, 14px);
  text-shadow: 2px 2px 0 #000;
  background: rgba(0,0,0,0.3);
  padding: 6px 10px;
  border-radius: 6px;
}

#hud-coins {
  position: absolute;
  bottom: 12px; left: 12px;
  color: #FFD700;
  font-size: clamp(8px, 2vw, 12px);
  text-shadow: 2px 2px 0 #000;
  background: rgba(0,0,0,0.3);
  padding: 6px 10px;
  border-radius: 6px;
}

#coin-icon {
  display: inline-block;
  animation: coinSpin 0.6s linear infinite;
}

@keyframes coinSpin {
  0%, 100% { transform: scaleX(1); }
  50% { transform: scaleX(0.1); }
}

#hud-district {
  position: absolute;
  bottom: 12px; right: 12px;
  color: #fff;
  font-size: clamp(6px, 1.5vw, 10px);
  text-shadow: 2px 2px 0 #000;
  background: rgba(0,0,0,0.3);
  padding: 6px 10px;
  border-radius: 6px;
  opacity: 0;
  transition: opacity 0.5s;
}

#hud-district.visible {
  opacity: 1;
}

#hud-timer {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  color: #ff3333;
  font-size: clamp(12px, 3vw, 20px);
  text-shadow: 2px 2px 0 #000;
}

/* STAR MODAL */
#star-modal {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: radial-gradient(circle, rgba(255,215,0,0.2) 0%, rgba(0,0,0,0.7) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

#star-modal-star {
  font-size: clamp(60px, 15vw, 120px);
  color: #FFD700;
  text-shadow: 0 0 40px rgba(255,215,0,0.8), 0 0 80px rgba(255,200,0,0.4);
  animation: starSpin 2s linear infinite;
}

@keyframes starSpin {
  0% { transform: rotateY(0deg); }
  100% { transform: rotateY(360deg); }
}

#star-modal-name {
  color: #fff;
  font-size: clamp(8px, 2vw, 14px);
  text-shadow: 2px 2px 0 #000;
  margin-top: 20px;
  text-align: center;
  padding: 0 20px;
}

/* PAUSE MENU */
#pause-menu {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(20, 20, 60, 0.88);
  z-index: 60;
  display: flex;
  flex-direction: column;
  padding: 20px;
}

#pause-tabs {
  display: flex;
  gap: 4px;
  justify-content: center;
  margin-bottom: 16px;
}

.pause-tab {
  padding: 8px 16px;
  color: #888;
  font-size: clamp(7px, 1.8vw, 11px);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.15s;
}

.pause-tab.active {
  color: #FFD700;
  border-bottom-color: #FFD700;
}

.pause-tab:hover {
  color: #fff;
}

#pause-content {
  flex: 1;
  overflow-y: auto;
  color: #ccc;
  font-size: clamp(6px, 1.5vw, 9px);
  line-height: 1.8;
  padding: 10px;
}

#pause-content::-webkit-scrollbar { width: 6px; }
#pause-content::-webkit-scrollbar-track { background: rgba(0,0,0,0.3); }
#pause-content::-webkit-scrollbar-thumb { background: #FFD700; border-radius: 3px; }

#pause-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 12px;
}

.pause-btn {
  padding: 10px 20px;
  background: rgba(40, 40, 100, 0.8);
  border: 2px solid #4444aa;
  border-radius: 8px;
  color: #fff;
  font-size: clamp(7px, 1.5vw, 10px);
  cursor: pointer;
  font-family: 'Press Start 2P', monospace;
  transition: all 0.15s;
}

.pause-btn:hover {
  border-color: #FFD700;
  background: rgba(60, 60, 140, 0.9);
}

/* CONTROLS OVERLAY */
#controls-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(255, 248, 220, 0.92);
  z-index: 55;
  display: flex;
  align-items: center;
  justify-content: center;
}

#controls-content {
  max-width: 360px;
  padding: 20px;
}

#controls-content h2 {
  color: #333;
  font-size: clamp(10px, 2.5vw, 16px);
  margin-bottom: 16px;
  text-align: center;
  border-bottom: 3px solid #333;
  padding-bottom: 8px;
}

.control-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: clamp(6px, 1.5vw, 9px);
  color: #444;
  border-bottom: 1px dashed #ccc;
}

.control-row span:first-child {
  color: #E52521;
  font-weight: bold;
}

.controls-section-label {
  font-size: clamp(7px, 1.8vw, 10px);
  color: #222;
  font-weight: bold;
  padding: 4px 0 2px 0;
  border-bottom: 2px solid #E52521;
  margin-bottom: 4px;
  letter-spacing: 1px;
}

.controls-haptic-note {
  margin-top: 10px;
  font-size: clamp(5px, 1.2vw, 7px);
  color: #888;
  text-align: center;
  font-style: italic;
  padding: 6px;
  background: rgba(0,0,0,0.05);
  border-radius: 4px;
}

/* MOBILE CONTROLS */
#mobile-controls {
  position: fixed;
  bottom: 0; left: 0;
  width: 100%;
  height: 160px;
  pointer-events: none;
  z-index: 20;
}

#joystick-zone {
  position: absolute;
  bottom: 20px; left: 20px;
  pointer-events: all;
}

#joystick-base {
  width: 100px; height: 100px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: 2px solid rgba(255,255,255,0.3);
  position: relative;
}

#joystick-knob {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.4);
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}

#action-buttons {
  position: absolute;
  bottom: 20px; right: 20px;
  display: flex;
  gap: 10px;
  pointer-events: all;
}

.action-btn {
  width: 50px; height: 50px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  border: 2px solid rgba(255,255,255,0.4);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-family: 'Press Start 2P', monospace;
}

/* HEALTH PIE */
.health-pie {
  width: clamp(40px, 8vw, 56px);
  height: clamp(40px, 8vw, 56px);
}

/* FOOTER */
#game-footer {
  position: fixed;
  bottom: 4px;
  z-index: 2;
  text-align: center;
}

#game-footer a {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: #444;
  text-decoration: none;
}

#game-footer a:hover {
  color: #888;
}

/* MAP STYLES */
.map-container {
  position: relative;
  width: 100%;
  max-width: 300px;
  margin: 0 auto;
}

.map-container svg {
  width: 100%;
}

.star-list-item {
  padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.star-list-item.collected {
  color: #FFD700;
}

.star-list-item.uncollected {
  color: #555;
}

.sound-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.toggle-switch {
  width: 40px;
  height: 20px;
  background: #333;
  border-radius: 10px;
  cursor: pointer;
  position: relative;
  transition: background 0.2s;
}

.toggle-switch.on {
  background: #4CAF50;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  top: 2px; left: 2px;
  transition: transform 0.2s;
}

.toggle-switch.on::after {
  transform: translateX(20px);
}

.volume-bar {
  display: flex;
  gap: 3px;
  margin-top: 4px;
}

.volume-segment {
  width: 16px; height: 12px;
  background: #333;
  cursor: pointer;
  transition: background 0.1s;
}

.volume-segment.active {
  background: #4CAF50;
}