/* Stellar Sentinel - Styling & Design System */

:root {
  --bg-color: #05070f;
  --panel-bg: rgba(13, 19, 36, 0.85);
  --panel-border: rgba(56, 189, 248, 0.25);
  --accent-cyan: #38bdf8;
  --accent-amber: #fbbf24;
  --accent-rose: #f43f5e;
  --accent-emerald: #10b981;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --shadow-glow: 0 0 20px rgba(56, 189, 248, 0.3);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

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

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, #0d1527 0%, #05070f 100%);
}

/* Game Canvas */
#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  cursor: crosshair;
}

/* HUD Overlay Header */
#hudHeader {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
  z-index: 10;
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  padding: 8px 16px;
  border-radius: 9999px;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  pointer-events: auto;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.hud-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.hud-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-cyan);
}

/* Health Bar */
.health-container {
  width: 120px;
  height: 10px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  overflow: hidden;
  margin-top: 2px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.health-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--accent-emerald), var(--accent-cyan));
  transition: width 0.2s ease, background 0.3s ease;
}

.health-fill.low {
  background: linear-gradient(90deg, var(--accent-rose), var(--accent-amber));
}

/* Pylon Indicators */
.pylon-dots {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.pylon-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid var(--text-muted);
  transition: all 0.3s ease;
}

.pylon-dot.active {
  background: var(--accent-amber);
  border-color: #fff;
  box-shadow: 0 0 8px var(--accent-amber);
}

/* Header Control Buttons */
.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  transition: all 0.2s ease;
  backdrop-filter: blur(8px);
}

.btn-icon:hover, .btn-icon:focus-visible {
  border-color: var(--accent-cyan);
  box-shadow: var(--shadow-glow);
  transform: scale(1.05);
  outline: none;
}

.btn-icon:active {
  transform: scale(0.95);
}

/* Touch Control Overlay (Bottom) */
#touchControls {
  position: absolute;
  bottom: 20px;
  left: 20px;
  right: 20px;
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
  z-index: 10;
}

.touch-cluster {
  display: flex;
  gap: 12px;
  pointer-events: auto;
}

.btn-touch {
  min-width: 64px;
  height: 64px;
  padding: 0 16px;
  border-radius: 32px;
  background: var(--panel-bg);
  border: 2px solid var(--panel-border);
  color: var(--text-main);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.05em;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(12px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
  transition: all 0.15s ease;
}

.btn-touch:hover, .btn-touch:focus-visible {
  border-color: var(--accent-cyan);
  box-shadow: var(--shadow-glow);
  outline: none;
}

.btn-touch:active {
  transform: scale(0.92);
  background: rgba(56, 189, 248, 0.2);
}

.btn-pulse {
  width: 80px;
  height: 80px;
  border-radius: 40px;
  border-color: var(--accent-cyan);
  background: radial-gradient(circle, rgba(56, 189, 248, 0.3) 0%, var(--panel-bg) 80%);
}

.btn-pulse.cooldown {
  opacity: 0.5;
  border-color: var(--text-muted);
}

.btn-subtext {
  font-size: 9px;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 2px;
}

/* Modals & Overlays */
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(5, 7, 15, 0.85);
  backdrop-filter: blur(12px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  display: flex;
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  padding: 32px;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), var(--shadow-glow);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 20px;
  transform: translateY(20px);
  transition: transform 0.3s ease;
}

.modal-overlay.active .modal-card {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.modal-logo {
  width: 44px;
  height: 44px;
}

.modal-title {
  font-size: 28px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-amber));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.02em;
}

.modal-body {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted);
  text-align: left;
}

.modal-body p {
  margin-bottom: 12px;
}

.instructions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.instruction-box {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 12px;
  border-radius: 12px;
  font-size: 12px;
}

.instruction-box strong {
  display: block;
  color: var(--accent-cyan);
  margin-bottom: 4px;
  font-size: 13px;
}

/* Primary Action Buttons */
.btn-primary {
  width: 100%;
  padding: 16px 24px;
  border-radius: 14px;
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  border: 1px solid var(--accent-cyan);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.4);
  transition: all 0.2s ease;
}

.btn-primary:hover, .btn-primary:focus-visible {
  background: linear-gradient(135deg, #38bdf8 0%, #0284c7 100%);
  box-shadow: 0 6px 20px rgba(56, 189, 248, 0.5);
  transform: translateY(-2px);
  outline: none;
}

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

.btn-secondary {
  width: 100%;
  padding: 12px 20px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-main);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover, .btn-secondary:focus-visible {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--text-main);
  outline: none;
}

/* Stat Grid for Game Over / Victory */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  background: rgba(0, 0, 0, 0.3);
  padding: 16px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-num {
  font-size: 20px;
  font-weight: 800;
  color: var(--accent-amber);
}

.stat-lbl {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* Control Hint Floating Toast */
#controlHint {
  position: absolute;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(13, 19, 36, 0.9);
  border: 1px solid var(--panel-border);
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-muted);
  pointer-events: none;
  z-index: 10;
  opacity: 1;
  transition: opacity 1s ease;
}

/* Screen Size Specific Adjustments */
@media (max-width: 600px) {
  #hudHeader {
    top: 8px;
    left: 8px;
    right: 8px;
  }
  .hud-group {
    padding: 6px 12px;
  }
  .hud-value {
    font-size: 14px;
  }
  .health-container {
    width: 80px;
  }
  .btn-touch {
    min-width: 56px;
    height: 56px;
    font-size: 12px;
  }
  .btn-pulse {
    width: 70px;
    height: 70px;
  }
  .modal-card {
    padding: 20px;
  }
}
