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

body {
  overflow: hidden;
  background: #0a0a1a;
  font-family: 'Press Start 2P', monospace;
  color: #fff;
  cursor: none;
  user-select: none;
  -webkit-user-select: none;
}

#scene-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

#scene-container canvas {
  display: block;
}

/* TITLE SCREEN */
#title-screen {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

#title-bg {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: linear-gradient(180deg, #1a0a2e 0%, #2d1b4e 30%, #c2542d 70%, #f4a236 100%);
  animation: bgPulse 8s ease-in-out infinite alternate;
}

@keyframes bgPulse {
  0% { filter: brightness(0.8) hue-rotate(0deg); }
  100% { filter: brightness(1.1) hue-rotate(10deg); }
}

#title-content {
  position: relative;
  z-index: 1;
  text-align: center;
}

#title-text {
  font-size: 4rem;
  text-shadow: 4px 4px 0 #000, 0 0 40px rgba(255,200,50,0.5);
  color: #ffd700;
  letter-spacing: 4px;
  animation: titleFloat 3s ease-in-out infinite;
}

.title-dot {
  color: #ff4444;
}

@keyframes titleFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

#subtitle-text {
  font-size: 1.2rem;
  color: #ffccaa;
  margin-top: 16px;
  letter-spacing: 8px;
  text-shadow: 2px 2px 0 #000;
}

#loading-bar-container {
  width: 300px;
  height: 24px;
  margin: 40px auto 0;
  background: #111;
  border: 3px solid #ffd700;
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}

#loading-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ffd700, #ffaa00);
  transition: width 0.3s;
  border-radius: 2px;
}

#loading-text {
  font-size: 0.6rem;
  margin-top: 12px;
  color: #aaa;
}

#start-prompt {
  font-size: 0.8rem;
  margin-top: 30px;
  color: #fff;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

#title-footer {
  margin-top: 40px;
}

#title-footer a {
  color: #998;
  font-size: 0.5rem;
  text-decoration: none;
}

#title-footer a:hover {
  color: #ffd700;
}

.hidden { display: none !important; }

/* HUD */
#hud {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 100;
}

#coin-counter {
  position: absolute;
  top: 20px; left: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.2rem;
  text-shadow: 2px 2px 0 #000;
}

#coin-icon {
  font-size: 1.6rem;
  color: #ffd700;
  animation: coinSpin 2s linear infinite;
  text-shadow: 0 0 10px rgba(255,215,0,0.6);
}

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

.coin-bounce {
  animation: bounce 0.3s ease !important;
}

@keyframes bounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.4); }
}

#shard-counter {
  position: absolute;
  top: 20px; right: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  text-shadow: 2px 2px 0 #000;
}

#shard-stars {
  display: flex;
  gap: 2px;
}

.shard-pip {
  width: 12px; height: 12px;
  display: inline-block;
  color: #444;
  font-size: 12px;
  line-height: 12px;
  transition: color 0.3s, text-shadow 0.3s;
}

.shard-pip.collected {
  color: #ffd700;
  text-shadow: 0 0 8px rgba(255,215,0,0.8);
}

.shard-flash {
  animation: shardFlash 0.5s ease;
}

@keyframes shardFlash {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(3); }
}

#district-toast {
  position: absolute;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.7);
  padding: 12px 30px;
  border-radius: 8px;
  font-size: 1rem;
  letter-spacing: 4px;
  text-shadow: 2px 2px 0 #000;
  border: 1px solid rgba(255,215,0,0.3);
  animation: toastIn 0.3s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

#context-prompt {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.75);
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 0.55rem;
  transition: opacity 0.3s;
}

#mini-map {
  position: absolute;
  bottom: 20px; right: 20px;
  width: 120px; height: 120px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid rgba(255,255,255,0.3);
  background: rgba(0,0,0,0.6);
}

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

#stats-display {
  position: absolute;
  bottom: 20px; left: 20px;
  font-size: 0.5rem;
  opacity: 0.5;
}

/* PAUSE MENU */
#pause-menu {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}

#pause-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
}

#pause-panel {
  position: relative;
  z-index: 1;
  width: 500px;
  max-width: 90vw;
  max-height: 80vh;
  background: linear-gradient(180deg, #1a1a3a 0%, #0d0d2a 100%);
  border: 3px solid #ffd700;
  border-radius: 12px;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(255,215,0,0.2);
}

#pause-tabs {
  display: flex;
  border-bottom: 2px solid #333;
}

.pause-tab {
  flex: 1;
  padding: 12px 4px;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.5rem;
  background: transparent;
  color: #888;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  pointer-events: auto;
}

.pause-tab.active {
  color: #ffd700;
  background: rgba(255,215,0,0.1);
  border-bottom: 2px solid #ffd700;
}

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

#pause-content {
  padding: 20px;
  min-height: 300px;
  max-height: 50vh;
  overflow-y: auto;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

#fullmap-canvas {
  width: 100%;
  max-width: 400px;
  display: block;
  margin: 0 auto;
  border-radius: 8px;
}

#shards-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.shard-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: rgba(255,255,255,0.05);
  border-radius: 6px;
  font-size: 0.5rem;
  line-height: 1.6;
}

.shard-item-icon {
  font-size: 1.2rem;
  min-width: 30px;
  text-align: center;
}

.shard-item.collected .shard-item-icon {
  color: #ffd700;
  text-shadow: 0 0 10px rgba(255,215,0,0.5);
}

.shard-item.uncollected {
  opacity: 0.5;
}

.slider-group {
  margin-bottom: 20px;
  pointer-events: auto;
}

.slider-group label {
  display: block;
  font-size: 0.55rem;
  margin-bottom: 8px;
  color: #ccc;
}

.slider-group input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  height: 8px;
  background: #333;
  border-radius: 4px;
  outline: none;
}

.slider-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  background: #ffd700;
  border-radius: 4px;
  cursor: pointer;
}

.vol-val {
  font-size: 0.5rem;
  color: #aaa;
  float: right;
  margin-top: -20px;
}

.radio-group {
  pointer-events: auto;
}

.radio-group label {
  display: block;
  font-size: 0.55rem;
  padding: 10px;
  margin-bottom: 4px;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.2s;
}

.radio-group label:hover {
  background: rgba(255,255,255,0.05);
}

.beta-tag {
  color: #ff6b6b;
  font-size: 0.45rem;
}

.toggle-group {
  pointer-events: auto;
  margin-top: 16px;
}

.toggle-group label {
  font-size: 0.55rem;
  cursor: pointer;
}

#stats-board {
  font-size: 0.5rem;
  line-height: 2.4;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.stat-label { color: #aaa; }
.stat-value { color: #ffd700; }

#pause-bottom {
  display: flex;
  justify-content: space-between;
  padding: 16px 20px;
  border-top: 2px solid #333;
  pointer-events: auto;
}

#pause-bottom button {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.5rem;
  padding: 10px 16px;
  border: 2px solid #555;
  background: transparent;
  color: #ccc;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

#pause-bottom button:hover {
  border-color: #ffd700;
  color: #ffd700;
}

#reset-btn { border-color: #ff4444; color: #ff4444; }
#reset-btn:hover { background: rgba(255,68,68,0.1); }

/* Controls Overlay */
#controls-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.85);
}

#controls-panel {
  text-align: center;
  max-width: 500px;
}

#controls-panel h3 {
  font-size: 1.2rem;
  color: #ffd700;
  margin-bottom: 24px;
}

.controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  text-align: left;
  margin-bottom: 30px;
}

.ctrl {
  font-size: 0.5rem;
  line-height: 1.8;
}

kbd {
  background: #333;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid #555;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.45rem;
  color: #ffd700;
}

#controls-panel > p {
  font-size: 0.5rem;
  color: #888;
  animation: pulse 2s ease-in-out infinite;
}

/* Mobile Controls */
#mobile-controls {
  position: fixed;
  bottom: 0; left: 0;
  width: 100%; height: 200px;
  z-index: 200;
  pointer-events: none;
}

#joystick-area {
  position: absolute;
  bottom: 30px; left: 30px;
  width: 120px; height: 120px;
  pointer-events: auto;
}

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

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

#mobile-buttons {
  position: absolute;
  bottom: 30px; right: 30px;
  display: flex;
  gap: 12px;
  align-items: flex-end;
  pointer-events: auto;
}

.mobile-btn {
  width: 60px; height: 60px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.7rem;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}

.btn-small {
  width: 44px; height: 44px;
  font-size: 0.5rem;
}

.mobile-btn:active {
  background: rgba(255,215,0,0.3);
  border-color: #ffd700;
}

.mobile-btn-pause {
  position: absolute;
  top: -160px; right: 10px;
  width: 40px; height: 40px;
  border-radius: 8px;
  border: 2px solid rgba(255,255,255,0.2);
  background: rgba(0,0,0,0.4);
  color: #fff;
  font-size: 1.2rem;
  pointer-events: auto;
}

@media (max-width: 768px) {
  #title-text { font-size: 2.4rem; }
  #subtitle-text { font-size: 0.7rem; letter-spacing: 4px; }
  #loading-bar-container { width: 200px; }
  #coin-counter { font-size: 0.9rem; top: 12px; left: 12px; }
  #shard-counter { font-size: 0.7rem; top: 12px; right: 12px; }
  #mini-map { width: 80px; height: 80px; bottom: 160px; right: 12px; }
  #minimap-canvas { width: 80px; height: 80px; }
  .controls-grid { grid-template-columns: 1fr; }
  #pause-panel { max-width: 95vw; }
  #pause-content { padding: 12px; }
  .pause-tab { font-size: 0.4rem; padding: 8px 2px; }
}