/**
 * @fileoverview index-game.css — Star Game stylesheet
 * Colours and recurring values are exposed as CSS custom properties
 * for easy theming and maintainability.
 */

/* ══════════════════════════════════════════════════════════════════
   Design tokens (CSS custom properties)
   ══════════════════════════════════════════════════════════════════ */

:root {
  /* Palette */
  --c-bg-deep: #1a0f1e;
  --c-bg-mid: #2d1b2e;
  --c-surface: rgba(30, 15, 35, 0.65);
  --c-surface-strong: rgba(40, 20, 45, 0.6);
  --c-border: rgba(255, 200, 220, 0.2);
  --c-border-strong: rgba(255, 200, 220, 0.25);
  --c-text: #ffb8d4;
  --c-text-muted: rgba(255, 200, 220, 0.45);
  --c-text-dim: rgba(255, 200, 220, 0.55);
  --c-accent: #e85a8a;
  --c-accent-dark: #c94d7a;
  --c-warn: #ff6b6b;
  --c-negative: #ff4444;
  --c-timer: #ffd166;
  --c-glow-positive: rgba(255, 120, 180, 0.6);
  --c-glow-negative: rgba(255, 60, 60, 0.9);
  --c-shadow: rgba(0, 0, 0, 0.5);
  --c-shadow-inner: rgba(255, 255, 255, 0.08);

  /* Timing */
  --t-fast: 0.2s;
  --t-normal: 0.35s;
  --t-slow: 0.6s;
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.22, 1, 0.36, 1);

  /* Layout */
  --z-bg: 0;
  --z-shooting: 1;
  --z-game: 2;
  --z-hud: 50;
  --z-float: 60;
  --z-start: 100;
  --z-result: 55;
}

/* ══════════════════════════════════════════════════════════════════
   Reset / base
   ══════════════════════════════════════════════════════════════════ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  background: radial-gradient(
    ellipse at 50% 30%,
    var(--c-bg-deep) 0%,
    var(--c-bg-mid) 40%,
    var(--c-bg-deep) 100%
  );
  overflow: hidden;
  position: relative;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  cursor: crosshair;
  touch-action: manipulation;
}

/* ══════════════════════════════════════════════════════════════════
   Background stars
   ══════════════════════════════════════════════════════════════════ */

.stars-bg {
  position: fixed;
  inset: 0;
  z-index: var(--z-bg);
  pointer-events: none;
  overflow: hidden;
}

.star {
  position: absolute;
  background: white;
  border-radius: 50%;
  animation: twinkle var(--dur) ease-in-out infinite;
  opacity: 0;
  box-shadow: 0 0 6px rgba(255, 200, 220, 0.8);
}

@keyframes twinkle {
  0%,
  100% {
    opacity: 0.1;
    transform: scale(0.6);
  }
  50% {
    opacity: 0.9;
    transform: scale(1.2);
  }
}

/* ══════════════════════════════════════════════════════════════════
   Shooting star
   ══════════════════════════════════════════════════════════════════ */

.shooting-star {
  position: fixed;
  width: 2px;
  height: 2px;
  background: white;
  border-radius: 50%;
  z-index: var(--z-shooting);
  pointer-events: none;
  box-shadow: 0 0 8px 2px rgba(255, 180, 220, 0.9);
  animation: shoot var(--shoot-dur) linear forwards;
}

.shooting-star::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 80px;
  height: 2px;
  background: linear-gradient(90deg, rgba(255, 200, 220, 0.9), transparent);
  border-radius: 2px;
  transform-origin: left center;
}

@keyframes shoot {
  0% {
    transform: translate(0, 0) rotate(var(--angle));
    opacity: 1;
  }
  100% {
    transform: translate(var(--tx), var(--ty)) rotate(var(--angle));
    opacity: 0;
  }
}

/* ══════════════════════════════════════════════════════════════════
   Game area
   ══════════════════════════════════════════════════════════════════ */

.game-area {
  position: fixed;
  inset: 0;
  z-index: var(--z-game);
  overflow: hidden;
}

/* ══════════════════════════════════════════════════════════════════
   Collectible stars
   ══════════════════════════════════════════════════════════════════ */

.collect-star {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  will-change: transform, opacity;
  transform: translate(-50%, -50%) scale(0);
  animation: starAppear 0.5s var(--ease-bounce) forwards;
  pointer-events: auto;
  z-index: 10;
  filter: drop-shadow(0 0 15px var(--glow));
  transition: filter 0.2s;
}

.collect-star::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--glow) 0%, transparent 70%);
  opacity: 0.5;
  animation: pulseGlow 1.5s ease-in-out infinite;
  pointer-events: none;
}

@keyframes pulseGlow {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.4;
  }
  50% {
    transform: scale(1.4);
    opacity: 0.8;
  }
}

@keyframes starAppear {
  0% {
    transform: translate(-50%, -50%) scale(0) rotate(-180deg);
    opacity: 0;
  }
  70% {
    transform: translate(-50%, -50%) scale(1.15) rotate(10deg);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
    opacity: 1;
  }
}

.collect-star.fading {
  animation: starFade 0.7s ease-in forwards;
  pointer-events: none;
}

@keyframes starFade {
  0% {
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
    opacity: 1;
  }
  30% {
    transform: translate(-50%, -50%) scale(1.2) rotate(20deg);
    opacity: 0.8;
  }
  100% {
    transform: translate(-50%, -50%) scale(0.1) rotate(-60deg);
    opacity: 0;
  }
}

.collect-star.collected {
  animation: starCollect 0.5s cubic-bezier(0.6, -0.28, 0.735, 0.045) forwards;
  pointer-events: none;
}

@keyframes starCollect {
  0% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
  40% {
    transform: translate(-50%, -50%) scale(1.5);
    opacity: 1;
    filter: brightness(2);
  }
  100% {
    transform: translate(-50%, -50%) scale(0) rotate(180deg);
    opacity: 0;
  }
}

/* Negative star */
.collect-star.negative {
  filter: drop-shadow(0 0 20px var(--c-glow-negative)) !important;
}

.collect-star.negative::before {
  background: radial-gradient(circle, rgba(255, 60, 60, 0.7) 0%, transparent 70%) !important;
}

/* ══════════════════════════════════════════════════════════════════
   Burst particles & ring
   ══════════════════════════════════════════════════════════════════ */

.burst {
  position: fixed;
  pointer-events: none;
  z-index: 30;
  font-size: 1.1rem;
  animation: burstFly 0.8s ease-out forwards;
  transform: translate(-50%, -50%);
  will-change: transform, opacity;
}

@keyframes burstFly {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(0.2)
      rotate(var(--rot));
  }
}

.ring {
  position: fixed;
  border-radius: 50%;
  border: 2px solid var(--ring-color, rgba(255, 180, 220, 0.8));
  pointer-events: none;
  z-index: 25;
  animation: ringExpand 0.7s ease-out forwards;
  transform: translate(-50%, -50%);
  will-change: width, height, opacity;
}

@keyframes ringExpand {
  0% {
    width: 10px;
    height: 10px;
    opacity: 1;
    border-width: 3px;
  }
  100% {
    width: 140px;
    height: 140px;
    opacity: 0;
    border-width: 1px;
  }
}

/* ══════════════════════════════════════════════════════════════════
   HUD
   ══════════════════════════════════════════════════════════════════ */

.hud {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-hud);
  display: flex;
  gap: 10px;
  align-items: center;
  pointer-events: none;
}

.hud-item {
  background: var(--c-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 18px;
  padding: 8px 18px;
  border: 1px solid var(--c-border);
  box-shadow:
    0 8px 32px var(--c-shadow),
    inset 0 1px 0 var(--c-shadow-inner);
  text-align: center;
  transition: transform 0.2s;
  min-width: 75px;
}

.hud-item.bump {
  animation: hudBump 0.35s var(--ease-bounce);
}

@keyframes hudBump {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.15);
  }
}

.hud-label {
  font-size: 0.55rem;
  color: var(--c-text-dim);
  letter-spacing: 2px;
  font-weight: 600;
  text-transform: uppercase;
}

.hud-value {
  font-size: 1.5rem;
  color: var(--c-text);
  font-weight: 800;
  line-height: 1.2;
  text-shadow: 0 0 20px var(--c-glow-positive);
  font-variant-numeric: tabular-nums;
}

/* Timer */
.hud-item.timer-item .hud-value {
  color: var(--c-timer);
  text-shadow: 0 0 20px rgba(255, 209, 102, 0.5);
}

.hud-item.timer-item.warning .hud-value {
  color: var(--c-warn);
  text-shadow: 0 0 25px rgba(255, 107, 107, 0.8);
  animation: timerPulse 0.6s ease-in-out infinite;
}

@keyframes timerPulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.12);
  }
}

/* Negative score */
.hud-item.score-item.negative .hud-value {
  color: var(--c-negative);
  text-shadow: 0 0 25px rgba(255, 68, 68, 0.8);
}

/* ══════════════════════════════════════════════════════════════════
   Brand title
   ══════════════════════════════════════════════════════════════════ */

.brand {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: var(--z-hud);
  text-align: left;
  pointer-events: none;
}

.brand h1 {
  font-size: 1rem;
  font-weight: 800;
  color: var(--c-text);
  letter-spacing: 1px;
  text-shadow:
    0 0 25px var(--c-glow-positive),
    0 2px 4px rgba(0, 0, 0, 0.3);
  white-space: nowrap;
}

.brand p {
  font-size: 0.55rem;
  color: var(--c-text-muted);
  letter-spacing: 3px;
  font-weight: 300;
  margin-top: 3px;
}

/* ══════════════════════════════════════════════════════════════════
   Float message
   ══════════════════════════════════════════════════════════════════ */

.float-msg {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: var(--z-float);
  font-size: 2rem;
  font-weight: 900;
  color: var(--c-text);
  text-shadow:
    0 0 30px var(--c-glow-positive),
    0 0 60px rgba(255, 80, 150, 0.5);
  pointer-events: none;
  white-space: nowrap;
  animation: msgPop 1.3s var(--ease-smooth) forwards;
}

@keyframes msgPop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.3) rotate(-10deg);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.15) rotate(3deg);
  }
  35% {
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
  }
  75% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -130%) scale(0.7) rotate(-5deg);
  }
}

/* ══════════════════════════════════════════════════════════════════
   Start screen
   ══════════════════════════════════════════════════════════════════ */

.start-screen {
  position: fixed;
  inset: 0;
  z-index: var(--z-start);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  background: radial-gradient(
    ellipse at 50% 40%,
    rgba(45, 27, 46, 0.85),
    rgba(15, 8, 18, 0.95)
  );
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: opacity 0.6s ease, visibility 0.6s;
  padding: 2rem;
}

.start-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.start-card {
  background: var(--c-surface-strong);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border-radius: 40px;
  padding: 2.5rem 3rem;
  border: 1px solid var(--c-border);
  box-shadow:
    0 30px 80px var(--c-shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  text-align: center;
  max-width: 440px;
  width: 100%;
  animation: cardIn 0.9s var(--ease-smooth);
}

.logo-emoji {
  font-size: 4rem;
  display: block;
  margin-bottom: 0.8rem;
  animation: logoSpin 4s ease-in-out infinite;
  filter: drop-shadow(0 0 25px rgba(255, 150, 200, 0.6));
}

@keyframes logoSpin {
  0%,
  100% {
    transform: rotate(0deg) scale(1);
  }
  25% {
    transform: rotate(8deg) scale(1.08);
  }
  75% {
    transform: rotate(-8deg) scale(1.08);
  }
}

.start-card h2 {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--c-text);
  letter-spacing: 1px;
  margin-bottom: 0.2rem;
  text-shadow: 0 0 30px rgba(255, 120, 180, 0.5);
}

.start-card .subtitle {
  font-size: 0.7rem;
  color: rgba(255, 200, 220, 0.5);
  letter-spacing: 4px;
  font-weight: 300;
  margin-bottom: 1.2rem;
}

.start-card .instructions {
  font-size: 0.85rem;
  color: rgba(255, 220, 235, 0.75);
  line-height: 2;
  margin-bottom: 1.5rem;
  font-weight: 400;
}

.start-card .instructions .emoji-inline {
  font-size: 1.1rem;
  margin: 0 4px;
}

.start-card .warning-text {
  font-size: 0.8rem;
  color: rgba(255, 140, 140, 0.85);
  margin-bottom: 1.2rem;
  padding: 0.5rem 1rem;
  background: rgba(255, 60, 60, 0.1);
  border-radius: 12px;
  border: 1px solid rgba(255, 60, 60, 0.2);
}

.start-btn {
  background: linear-gradient(135deg, var(--c-accent), var(--c-accent-dark), var(--c-accent));
  background-size: 200% 200%;
  border: none;
  color: white;
  font-size: 1.1rem;
  font-weight: 700;
  padding: 0.9rem 2.8rem;
  border-radius: 50px;
  cursor: pointer;
  box-shadow:
    0 10px 35px rgba(232, 90, 138, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: transform 0.2s, box-shadow 0.2s;
  letter-spacing: 1px;
  font-family: inherit;
  animation: btnPulse 2.5s ease-in-out infinite;
}

.start-btn:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 16px 45px rgba(232, 90, 138, 0.65);
}

.start-btn:active {
  transform: translateY(0) scale(0.97);
}

@keyframes btnPulse {
  0%,
  100% {
    box-shadow: 0 10px 35px rgba(232, 90, 138, 0.5);
  }
  50% {
    box-shadow: 0 10px 45px rgba(232, 90, 138, 0.8);
  }
}

 /* ══════════════════════════════════════════════════════════════════
   Restart / end button
   ══════════════════════════════════════════════════════════════════ */

.restart-btn {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  z-index: var(--z-hud);
  background: rgba(40, 20, 45, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--c-border-strong);
  color: var(--c-text);
  font-size: 1rem;
  font-weight: 700;
  padding: 0.85rem 2.5rem;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  transition:
    transform 0.4s var(--ease-smooth),
    opacity 0.4s,
    box-shadow 0.2s;
  font-family: inherit;
  letter-spacing: 1px;
  opacity: 0;
  pointer-events: none;
}

.restart-btn.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.restart-btn:hover {
  box-shadow: 0 15px 40px rgba(232, 90, 138, 0.4);
  border-color: rgba(255, 200, 220, 0.5);
}

.restart-btn:active {
  transform: translateX(-50%) scale(0.97);
}

/* ══════════════════════════════════════════════════════════════════
   Combo display
   ══════════════════════════════════════════════════════════════════ */

.combo-display {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: var(--z-result);
  pointer-events: none;
  font-size: 2.8rem;
  font-weight: 900;
  color: #ff6b9d;
  text-shadow:
    0 0 40px rgba(255, 100, 150, 0.9),
    0 0 80px rgba(255, 50, 120, 0.5);
  opacity: 0;
}

.combo-display.show {
  animation: comboShow 0.8s var(--ease-smooth) forwards;
}

@keyframes comboShow {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.3) rotate(-15deg);
  }
  30% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.3) rotate(5deg);
  }
  50% {
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -80%) scale(0.8);
  }
}

/* ══════════════════════════════════════════════════════════════════
   Responsive
   ══════════════════════════════════════════════════════════════════ */

@media (max-width: 600px) {
  .hud-item {
    padding: 6px 12px;
    min-width: 60px;
    border-radius: 14px;
  }
  .hud-value {
    font-size: 1.15rem;
  }
  .hud-label {
    font-size: 0.45rem;
    letter-spacing: 1.5px;
  }
  .brand h1 {
    font-size: 0.8rem;
  }
  .brand p {
    font-size: 0.45rem;
    letter-spacing: 2px;
  }
  .brand {
    top: 14px;
    right: 14px;
  }
  .hud {
    top: 14px;
    gap: 6px;
  }
  .start-card {
    padding: 1.8rem 1.5rem;
    border-radius: 28px;
  }
  .start-card .logo-emoji {
    font-size: 3rem;
  }
  .start-card h2 {
    font-size: 1.3rem;
  }
  .start-card .instructions {
    font-size: 0.78rem;
  }
  .start-btn {
    font-size: 0.95rem;
    padding: 0.8rem 2rem;
  }
  .float-msg {
    font-size: 1.5rem;
  }
  .combo-display {
    font-size: 2rem;
  }
  .restart-btn {
    font-size: 0.85rem;
    padding: 0.7rem 1.8rem;
  }
}

@media (max-width: 380px) {
  .hud-item {
    padding: 5px 8px;
    min-width: 50px;
  }
  .hud-value {
    font-size: 0.95rem;
  }
  .brand h1 {
    font-size: 0.7rem;
  }
  .start-card {
    padding: 1.3rem 1rem;
  }
  .start-card h2 {
    font-size: 1.1rem;
  }
}
