:root {
  --bg-dark: #090c15;
  --bg-panel: rgba(16, 22, 38, 0.85);
  --bg-card: rgba(25, 35, 58, 0.7);
  --accent-cyan: #00f0ff;
  --accent-magenta: #ff0055;
  --accent-amber: #ffb700;
  --accent-green: #00ff88;
  --text-main: #f0f6fc;
  --text-muted: #8b949e;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-family);
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle at center, #141b2d 0%, var(--bg-dark) 100%);
}

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

/* UI Overlay Layer */
.ui-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px;
}

.ui-layer * {
  pointer-events: auto;
}

/* Top HUD */
.hud-bar {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(0, 240, 255, 0.2);
  border-radius: 14px;
  padding: 10px 18px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), inset 0 0 12px rgba(0, 240, 255, 0.05);
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 16px;
}

.hud-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
}

.stat-value {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--accent-cyan);
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.4);
}

/* Progress Bar Components */
.bar-container {
  width: 130px;
  height: 12px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.bar-fill {
  height: 100%;
  width: 100%;
  transition: width 0.2s ease-out, background-color 0.2s ease-out;
  border-radius: 5px;
}

.hp-fill {
  background: linear-gradient(90deg, #ff0055, #ff5500);
  box-shadow: 0 0 10px rgba(255, 0, 85, 0.6);
}

.energy-fill {
  background: linear-gradient(90deg, #00f0ff, #00ff88);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.6);
}

/* Mobile Action Controls */
.mobile-controls {
  width: 100%;
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
  padding: 10px;
}

.btn-action {
  background: radial-gradient(circle, rgba(0,240,255,0.25) 0%, rgba(0,120,255,0.15) 100%);
  border: 2px solid var(--accent-cyan);
  color: #ffffff;
  padding: 14px 28px;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  border-radius: 30px;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.3), inset 0 0 10px rgba(0, 240, 255, 0.2);
  transition: transform 0.1s ease, box-shadow 0.2s ease, background 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-action:active {
  transform: scale(0.95);
  box-shadow: 0 0 30px rgba(0, 240, 255, 0.6);
}

.btn-action:disabled {
  opacity: 0.4;
  border-color: var(--text-muted);
  box-shadow: none;
  cursor: not-allowed;
}

/* Modal Overlay Screens */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 100;
  background: rgba(8, 11, 20, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  opacity: 1;
  pointer-events: auto;
  transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
  display: none !important;
  opacity: 0;
  pointer-events: none !important;
}

.modal-card {
  background: var(--bg-panel);
  border: 1px solid rgba(0, 240, 255, 0.3);
  border-radius: 20px;
  padding: 32px;
  max-width: 520px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7), 0 0 30px rgba(0, 240, 255, 0.15);
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  from { transform: scale(0.9) translateY(20px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-title {
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: 2px;
  text-transform: uppercase;
  background: linear-gradient(135deg, #ffffff 0%, var(--accent-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 20px rgba(0, 240, 255, 0.4);
}

.modal-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.instruction-box {
  background: rgba(0, 0, 0, 0.3);
  border: 1px dashed rgba(0, 240, 255, 0.3);
  border-radius: 12px;
  padding: 16px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.instruction-item {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
  color: var(--text-main);
}

.instruction-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: rgba(0, 240, 255, 0.15);
  border: 1px solid var(--accent-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-cyan);
  font-weight: bold;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.btn-primary {
  background: linear-gradient(135deg, #00f0ff 0%, #0077ff 100%);
  color: #000000;
  border: none;
  border-radius: 12px;
  padding: 16px;
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.4);
  transition: transform 0.15 ease, box-shadow 0.15s ease;
}

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

.btn-primary:active {
  transform: translateY(1px);
}

/* Upgrade Selection Grid */
.upgrades-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.upgrade-card {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.upgrade-card:hover {
  border-color: var(--accent-cyan);
  background: rgba(0, 240, 255, 0.1);
  transform: translateX(4px);
}

.upgrade-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: rgba(0, 240, 255, 0.2);
  border: 1px solid var(--accent-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.upgrade-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.upgrade-title {
  font-size: 1rem;
  font-weight: 800;
  color: #ffffff;
}

.upgrade-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Utilities */
.btn-icon {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text-main);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn-icon:hover {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

@media (max-width: 600px) {
  .hud-bar {
    padding: 8px 12px;
  }
  .hud-group {
    gap: 8px;
  }
  .bar-container {
    width: 80px;
  }
  .stat-value {
    font-size: 1rem;
  }
  .modal-card {
    padding: 20px;
  }
  .modal-title {
    font-size: 1.6rem;
  }
}
