* { box-sizing: border-box; }
html, body { 
  margin: 0; 
  padding: 0; 
  height: 100vh; 
  width: 100vw;
  overflow: hidden;
  background: #0c0f17; 
  color: #e6e8ef; 
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif; 
}
a { color: inherit; }

.splash {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 50% 40%, #1b2040 0%, #0c0f17 55%, #090b12 100%);
  animation: fadeout 1.2s ease 2.8s forwards;
  z-index: 20;
}
.splash-inner { text-align: center; transform: translateY(-20px); animation: raise 0.8s ease 0.2s both; }
.splash h1 { margin: 0 0 8px; letter-spacing: 0.14em; font-weight: 800; font-size: 48px; }
.splash .byline { margin: 0; opacity: 0.9; }
.splash .hint { margin-top: 10px; opacity: 0.6; font-size: 14px; }
@keyframes fadeout { to { opacity: 0; visibility: hidden; } }
@keyframes raise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(-20px);} }

.hud {
  position: fixed; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center;
  padding: 12px 18px; background: rgba(9,11,18,0.8); backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255,255,255,0.1); z-index: 10;
}
.brand { font-weight: 800; letter-spacing: 0.12em; opacity: 0.95; }
.status { display: flex; gap: 12px; opacity: 0.8; }

.player-status {
  display: flex;
  gap: 8px;
  align-items: center;
}

.status-effect {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 12px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-effect.zone {
  background: rgba(91, 108, 255, 0.2);
  border-color: rgba(91, 108, 255, 0.4);
}

.status-effect.mutation {
  background: rgba(220, 90, 255, 0.2);
  border-color: rgba(220, 90, 255, 0.4);
}

.game-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
}

canvas#game {
  width: 100%;
  height: 100%;
  background:
    radial-gradient(800px 400px at 60% 20%, rgba(80,110,255,0.08), transparent 60%),
    radial-gradient(600px 320px at 20% 80%, rgba(220,90,255,0.08), transparent 60%),
    #0f1320;
  display: block;
}

.leaderboard-overlay {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 15;
  pointer-events: none;
}

.leaderboard-panel {
  background: rgba(9,11,18,0.9);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  padding: 16px;
  min-width: 200px;
  pointer-events: auto;
}

.leaderboard-panel h2 { 
  margin: 0 0 12px; 
  font-size: 16px; 
  opacity: 0.9; 
  text-align: center;
}

ol#leaderboard { 
  list-style: none; 
  margin: 0; 
  padding: 0; 
  display: grid; 
  gap: 6px; 
  max-height: 300px;
  overflow-y: auto;
}

ol#leaderboard li { 
  display: flex; 
  justify-content: space-between; 
  gap: 8px; 
  font-size: 14px; 
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(255,255,255,0.05);
}

ol#leaderboard .name { 
  opacity: 0.9; 
  overflow: hidden; 
  text-overflow: ellipsis; 
  white-space: nowrap; 
  max-width: 120px;
}

ol#leaderboard .mass { 
  opacity: 0.8; 
  font-weight: 600;
}

ol#leaderboard .npc { 
  opacity: 0.6; 
  font-style: italic;
}

.credits-overlay {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  background: rgba(9,11,18,0.8);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 12px;
  opacity: 0.7;
  pointer-events: none;
}

.name-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.8); display: grid; place-items: center; z-index: 1000;
}
.name-card {
  width: 360px; max-width: calc(100% - 32px); background: #0f1320; border: 1px solid rgba(255,255,255,0.09);
  border-radius: 14px; padding: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
}
.name-card h3 { margin: 0 0 12px; }
.name-card input {
  width: 100%; padding: 10px 12px; background: #0b0e18; border: 1px solid rgba(255,255,255,0.12); border-radius: 10px; color: #e6e8ef;
}
.name-card button {
  margin-top: 10px; width: 100%; padding: 10px 12px; background: #5b6cff; color: white; border: 0; border-radius: 10px; font-weight: 600; cursor: pointer;
}
.name-card .disclaimer { opacity: 0.6; font-size: 12px; margin-top: 8px; }

/* Mobile controls - Joystick */
.mobile-controls {
  position: fixed;
  bottom: 40px;
  left: 40px;
  display: none;
  z-index: 2000;
  pointer-events: none;
}

.joystick-container {
  pointer-events: auto;
}

.joystick-base {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  border: 2px solid rgba(255,255,255,0.2);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.joystick-thumb {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(91, 108, 255, 0.8);
  border: 2px solid rgba(255,255,255,0.3);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transition: transform 0.1s ease;
}

/* Landscape mode enforcement for mobile */
@media (max-width: 768px) and (orientation: portrait) {
  .game-container {
    display: none;
  }
  
  .hud, .leaderboard-overlay, .credits-overlay, .mobile-controls {
    display: none;
  }
  
  body::before {
    content: "Please rotate your device to landscape mode for the best gaming experience!";
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(9,11,18,0.95);
    color: #e6e8ef;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    font-size: 18px;
    z-index: 9999;
    max-width: 300px;
    line-height: 1.4;
  }
}

/* Mobile landscape mode styles */
@media (max-width: 768px) and (orientation: landscape) {
  .leaderboard-overlay {
    top: 70px;
    right: 10px;
    left: auto;
  }
  
  .leaderboard-panel {
    min-width: 180px;
    max-width: 200px;
    padding: 12px;
  }
  
  .leaderboard-panel h2 {
    font-size: 14px;
    margin-bottom: 8px;
  }
  
  ol#leaderboard {
    max-height: 200px;
    gap: 4px;
  }
  
  ol#leaderboard li {
    font-size: 12px;
    padding: 3px 6px;
  }
  
  ol#leaderboard .name {
    max-width: 100px;
  }
  
  .credits-overlay {
    bottom: 10px;
    left: 10px;
    right: 10px;
    transform: none;
    text-align: center;
    font-size: 11px;
    padding: 6px 12px;
  }
  
  .mobile-controls {
    bottom: 20px;
    left: 20px;
  }
  
  .joystick-base {
    width: 100px;
    height: 100px;
  }
  
  .joystick-thumb {
    width: 40px;
    height: 40px;
  }
  
  .hud {
    padding: 8px 12px;
  }
  
  .brand {
    font-size: 14px;
  }
  
  .status {
    font-size: 12px;
  }
}

@media (pointer: coarse) {
  .mobile-controls { display: block; }
}
