:root {
  --bg: #050508;
  --text: #e0e0e0;
  --accent: #00ff88;
  --accent2: #0088ff;
  --danger: #ff4466;
  --panel-bg: rgba(8, 8, 14, 0.95);
  --panel-border: rgba(0, 255, 136, 0.25);
  --font-mono: 'JetBrains Mono', monospace;
  --font-sans: 'Space Grotesk', sans-serif;
}

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

body {
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  cursor: crosshair;
  user-select: none;
}

/* ===== GAME CANVAS ===== */
#game-canvas {
  display: block;
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  z-index: 1;
}

/* ===== LOADING SCREEN ===== */
#loading-screen {
  position: fixed; inset: 0;
  z-index: 900;
  background: #030305;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.6s ease, visibility 0.6s;
  cursor: pointer;
}
#loading-screen.fade-out {
  opacity: 0; visibility: hidden; pointer-events: none;
}
.loader-content { text-align: center; max-width: 460px; }
.loader-icon {
  font-family: var(--font-mono);
  font-size: 2.5rem; font-weight: 800;
  color: var(--accent);
  letter-spacing: 6px;
  margin-bottom: 16px;
  animation: bounce 1.2s ease-in-out infinite;
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
.loader-title {
  font-family: var(--font-sans);
  font-size: 2.2rem; font-weight: 800;
  letter-spacing: 3px;
  color: #fff;
  margin-bottom: 10px;
}
.loader-subtitle {
  color: #aaa; font-size: 0.8rem;
  letter-spacing: 2px; text-transform: uppercase;
  margin-bottom: 28px;
}
.loader-bar-track {
  width: 260px; height: 3px;
  background: #151520;
  margin: 0 auto 22px; overflow: hidden;
}
.loader-bar-fill {
  width: 0%; height: 100%;
  background: var(--accent);
  transition: width 0.3s ease;
}
.loader-hint {
  color: #888; font-size: 0.7rem;
  letter-spacing: 1px; text-transform: uppercase;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* ===== BIOME ANNOUNCEMENT ===== */
.biome-announce {
  position: fixed;
  top: 30px; left: 50%;
  transform: translate(-50%, -10px) scale(0.95);
  z-index: 50;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.biome-announce.active {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}
.biome-announce-depth {
  font-size: 0.75rem;
  letter-spacing: 5px;
  color: var(--accent);
  margin-bottom: 6px;
}
.biome-announce-name {
  font-family: var(--font-sans);
  font-size: 1.6rem; font-weight: 800;
  letter-spacing: 2px; color: #fff;
  text-shadow: 0 0 30px rgba(0,255,136,0.4), 0 0 60px rgba(0,136,255,0.2);
  margin-bottom: 3px;
}
.biome-announce-desc {
  font-size: 0.8rem; color: #ccc;
  letter-spacing: 1px;
}

/* ===== HUD ===== */
#hud {
  position: fixed;
  top: 14px; left: 14px;
  z-index: 100;
  pointer-events: none;
  background: rgba(5,5,10,0.7);
  padding: 10px 16px;
  border: 1px solid rgba(0,255,136,0.1);
  backdrop-filter: blur(6px);
}
.hud-top {
  display: flex; gap: 28px;
  margin-bottom: 8px;
}
.hud-stat { display: flex; flex-direction: column; }
.hud-label {
  font-size: 0.55rem; letter-spacing: 3px;
  color: #bbb; text-transform: uppercase;
}
.hud-value {
  font-size: 1.05rem; font-weight: 700;
  color: var(--accent);
  text-shadow: 0 0 8px rgba(0,255,136,0.25);
}
.hud-biome-progress {
  display: flex; align-items: center; gap: 10px;
}
.hud-progress-track {
  width: 180px; height: 2px;
  background: #1a1a2e; overflow: hidden;
}
.hud-progress-fill {
  width: 0%; height: 100%;
  background: var(--accent);
  transition: width 0.15s ease;
}
.hud-progress-label {
  font-size: 0.55rem; color: #aaa;
  letter-spacing: 1px;
}

/* ===== BANDWIDTH POPUPS ===== */
#bandwidth-popups {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 80;
}
.bw-popup {
  position: absolute;
  font-size: 0.8rem; font-weight: 700;
  color: var(--accent);
  text-shadow: 0 0 6px rgba(0,255,136,0.4);
  pointer-events: none;
  animation: bw-float 0.8s ease-out forwards;
  white-space: nowrap;
}
@keyframes bw-float {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-40px) scale(0.7); }
}

/* ===== SHOP BUTTON ===== */
#shop-btn {
  position: fixed;
  bottom: 20px; right: 20px;
  z-index: 100;
  background: rgba(8,8,14,0.85);
  border: 1px solid var(--panel-border);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.8rem; font-weight: 700;
  padding: 10px 18px;
  cursor: pointer;
  letter-spacing: 2px;
  transition: all 0.15s ease;
  backdrop-filter: blur(6px);
}
#shop-btn:hover {
  background: rgba(0,255,136,0.1);
  border-color: var(--accent);
  box-shadow: 0 0 16px rgba(0,255,136,0.12);
  transform: translateY(-2px);
}

/* ===== SHOP OVERLAY ===== */
#shop-overlay {
  position: fixed; inset: 0;
  z-index: 500;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.25s ease;
}
#shop-overlay.hidden {
  opacity: 0; pointer-events: none;
}
#map-overlay {
  position: fixed; inset: 0;
  z-index: 500;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.25s ease;
}
#map-overlay.hidden {
  opacity: 0; pointer-events: none;
}
#map-panel::-webkit-scrollbar { width: 3px; }
#map-panel::-webkit-scrollbar-thumb { background: #08f; }
#map-list::-webkit-scrollbar { width: 3px; }
#map-list::-webkit-scrollbar-thumb { background: #08f; }
#map-btn:hover {
  background: rgba(0,136,255,0.1) !important;
  border-color: #08f !important;
  box-shadow: 0 0 16px rgba(0,136,255,0.12) !important;
  transform: translateY(-2px);
}
.map-biome-item {
  display: flex; align-items: stretch;
  background: rgba(20,20,30,0.8);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.05);
}
.map-biome-color-bar {
  width: 12px;
  flex-shrink: 0;
}
.map-biome-info {
  padding: 12px 16px;
  flex: 1;
}
.map-biome-name {
  font-size: 1.1rem; font-weight: bold; margin-bottom: 4px;
}
.map-biome-depth {
  font-size: 0.75rem; color: #aaa; letter-spacing: 1px; margin-bottom: 8px; font-family: var(--font-mono);
}
.map-biome-desc {
  font-size: 0.85rem; color: #ccc; line-height: 1.4;
}
#shop-panel {
  width: 90%; max-width: 660px; max-height: 78vh;
  background: #0a0a12;
  border: 1px solid var(--panel-border);
  overflow-y: auto;
  display: flex; flex-direction: column;
}
#shop-panel::-webkit-scrollbar { width: 3px; }
#shop-panel::-webkit-scrollbar-thumb { background: var(--accent); }

.shop-header {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(0,255,136,0.1);
  position: sticky; top: 0;
  background: #0a0a12; z-index: 1;
}
.shop-header h2 {
  font-family: var(--font-sans);
  font-size: 0.9rem; font-weight: 700;
  letter-spacing: 3px; color: var(--accent);
}
.shop-balance {
  display: flex; gap: 8px; align-items: center;
}
.shop-balance-label {
  font-size: 0.65rem; color: #aaa; letter-spacing: 1px;
}
#shop-balance-value {
  font-size: 0.85rem; font-weight: 700; color: var(--accent);
}
#shop-close, #map-close {
  background: none;
  border: 1px solid #333;
  color: #bbb;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 5px 9px;
  cursor: pointer;
  transition: all 0.15s;
}
#shop-close:hover, #map-close:hover {
  color: var(--danger); border-color: var(--danger);
}

.shop-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px; padding: 14px;
}
.shop-item {
  background: #0e0e18;
  border: 1px solid #1a1a28;
  padding: 14px;
  display: flex; flex-direction: column; gap: 6px;
  transition: all 0.12s; cursor: pointer;
}
.shop-item:hover {
  border-color: var(--panel-border);
  background: #12121e;
}
.shop-item.locked {
  opacity: 0.35; cursor: not-allowed;
}
.shop-item-header {
  display: flex; justify-content: space-between; align-items: center;
}
.shop-item-name {
  font-size: 0.75rem; font-weight: 700;
  letter-spacing: 1px; color: #ddd;
}
.shop-item-level {
  font-size: 0.6rem; color: var(--accent2); letter-spacing: 1px;
}
.shop-item-desc {
  font-size: 0.65rem; color: #aaa; line-height: 1.4;
}
.shop-item-effect {
  font-size: 0.65rem; color: var(--accent2);
}
.shop-item-cost {
  font-size: 0.7rem; font-weight: 700;
  color: var(--accent); margin-top: auto;
}
.shop-item-tag {
  font-size: 0.6rem; font-weight: 700;
  letter-spacing: 2px; color: #888;
  margin-bottom: 2px;
}

/* ===== SCREEN SHAKE ===== */
@keyframes shake {
  0%, 100% { transform: translate(0); }
  10% { transform: translate(-3px, 2px); }
  30% { transform: translate(3px, -2px); }
  50% { transform: translate(-2px, 3px); }
  70% { transform: translate(2px, -3px); }
  90% { transform: translate(-1px, 1px); }
}
body.shake { animation: shake 0.12s ease-in-out; }

/* ===== RESPONSIVE ===== */
@media (max-width: 700px) {
  .hud-top { flex-direction: column; gap: 2px; }
  .hud-value { font-size: 0.85rem; }
  .shop-grid { grid-template-columns: 1fr; }
  .biome-announce-name { font-size: 1.8rem; }
  #hud { padding: 8px 10px; }
}
