/* Skibidi Sun Worm - Premium Cosmic Dark Theme */
:root {
  --bg-deep: #05060d;
  --panel-bg: rgba(13, 17, 33, 0.75);
  --panel-border: rgba(255, 215, 0, 0.25);
  --sun-gold: #ffd700;
  --sun-white: #ffffff;
  --sun-glow: rgba(255, 230, 100, 0.6);
  --flare-orange: #ff7700;
  --hazard-red: #ff3344;
  --void-purple: #8a2be2;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --font-display: 'Orbitron', 'Cinzel', sans-serif;
  --font-body: 'Outfit', -apple-system, 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-deep);
  color: var(--text-main);
  font-family: var(--font-body);
}

#gameWrapper {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at center, #090e24 0%, #03040a 100%);
  overflow: hidden;
}

/* Header HUD */
#cosmicHeader {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 64px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
  background: linear-gradient(180deg, rgba(5, 7, 18, 0.88) 0%, rgba(5, 7, 18, 0) 100%);
  z-index: 20;
  pointer-events: none;
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
}

.hud-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(10px);
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 0.9rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.tier-badge {
  border-color: rgba(255, 215, 0, 0.4);
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #fff6a9;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.mass-pill strong, .score-pill strong {
  font-family: var(--font-display);
  color: var(--sun-gold);
}

/* Solar Flare Energy Meter */
.flare-meter-wrap {
  display: flex;
  flex-direction: column;
  width: 110px;
  gap: 3px;
}

.meter-title {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #ff9d42;
}

.meter-outer {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(255, 119, 0, 0.3);
}

.meter-inner {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff7700, #ffd700);
  border-radius: 4px;
  transition: width 0.1s linear;
  box-shadow: 0 0 8px rgba(255, 119, 0, 0.8);
}

/* Black Hole Threat Indicator */
#blackHoleWarning {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 9999px;
  background: rgba(45, 10, 60, 0.85);
  border: 1px solid rgba(210, 40, 255, 0.6);
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  color: #f7a8ff;
  animation: pulseWarning 1s infinite alternate;
}

@keyframes pulseWarning {
  from {
    transform: scale(0.98);
    box-shadow: 0 0 10px rgba(180, 0, 255, 0.3);
  }
  to {
    transform: scale(1.04);
    box-shadow: 0 0 20px rgba(255, 0, 128, 0.7);
  }
}

.icon-btn {
  background: var(--panel-bg);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all 0.2s ease;
  backdrop-filter: blur(8px);
}

.icon-btn:hover {
  border-color: var(--sun-gold);
  transform: scale(1.08);
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.4);
}

/* Canvas Viewport */
#viewportContainer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

#starCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Mobile Touch Controls */
#mobileControls {
  position: absolute;
  bottom: 24px;
  left: 0;
  width: 100%;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  z-index: 25;
  pointer-events: none;
}

#joystickArea {
  width: 130px;
  height: 130px;
  pointer-events: auto;
}

#joyBase {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 215, 0, 0.08) 0%, rgba(255, 215, 0, 0.02) 100%);
  border: 2px dashed rgba(255, 215, 0, 0.35);
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
  touch-action: none;
}

#joyKnob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 50px;
  height: 50px;
  margin-left: -25px;
  margin-top: -25px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff 0%, #ffd700 60%, #ff8800 100%);
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.8);
  pointer-events: none;
}

#btnBoost {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffb703 0%, #fb8500 50%, #d00000 100%);
  border: 3px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 0 25px rgba(255, 119, 0, 0.8);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 900;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.1s ease;
  touch-action: none;
}

#btnBoost:active {
  transform: scale(0.92);
  box-shadow: 0 0 35px rgba(255, 60, 0, 1);
}

.boost-icon {
  font-size: 1.5rem;
}

.boost-text {
  font-size: 0.65rem;
  letter-spacing: 0.1em;
}

/* Modals */
.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(3, 4, 10, 0.85);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
  transition: opacity 0.3s ease;
}

.modal-backdrop.hidden {
  display: none;
  opacity: 0;
  pointer-events: none;
}

.modal-card {
  max-width: 540px;
  width: 100%;
  background: linear-gradient(135deg, rgba(20, 26, 50, 0.9) 0%, rgba(9, 12, 25, 0.95) 100%);
  border: 1px solid rgba(255, 215, 0, 0.35);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.8), 0 0 35px rgba(255, 215, 0, 0.2);
  border-radius: 20px;
  padding: 32px 28px;
  text-align: center;
  color: var(--text-main);
  animation: modalPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
  from { transform: scale(0.88); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.logo-icon {
  font-size: 3rem;
  filter: drop-shadow(0 0 15px rgba(255, 215, 0, 0.8));
  margin-bottom: 8px;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  background: linear-gradient(90deg, #ffffff 0%, #ffe875 50%, #ff9e00 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
}

.modal-subtitle {
  font-size: 0.85rem;
  letter-spacing: 0.15em;
  font-weight: 700;
  color: #ffaa33;
  margin-bottom: 22px;
}

.rules-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 24px;
  font-size: 0.9rem;
  line-height: 1.45;
}

.rule-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.rule-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.rule-text strong {
  color: #fff;
}

.rule-text span {
  color: var(--text-muted);
}

.primary-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(90deg, #ffd700 0%, #ff8800 100%);
  border: none;
  border-radius: 12px;
  color: #111;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(255, 170, 0, 0.4);
  transition: all 0.2s ease;
  margin-bottom: 14px;
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(255, 200, 0, 0.6);
}

.sub-link {
  display: inline-block;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  transition: color 0.2s;
}

.sub-link:hover {
  color: var(--sun-gold);
}

/* Game Over Stats */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 700;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--sun-gold);
}

/* Floating on-screen event banner */
#eventBanner {
  position: absolute;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 20px;
  border-radius: 9999px;
  background: rgba(18, 5, 30, 0.9);
  border: 1px solid rgba(255, 60, 120, 0.8);
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 800;
  color: #ff99bb;
  box-shadow: 0 0 25px rgba(255, 30, 100, 0.6);
  z-index: 30;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#eventBanner.show {
  opacity: 1;
  transform: translateX(-50%) translateY(5px);
}

@media (max-width: 600px) {
  #cosmicHeader {
    height: 54px;
    padding: 0 10px;
  }
  .hud-pill {
    padding: 4px 10px;
    font-size: 0.78rem;
  }
  .flare-meter-wrap {
    width: 75px;
  }
  .modal-card {
    padding: 24px 18px;
  }
  .modal-title {
    font-size: 1.5rem;
  }
}
