/* ==========================================================================
   PLANET MERGE GAME - CSS STYLESHEET
   Dark Space Aesthetic, Glassmorphism, Responsive Mobile & Desktop Layout
   ========================================================================== */

:root {
  --bg-color: #05060d;
  --panel-bg: rgba(18, 22, 40, 0.65);
  --panel-border: rgba(255, 255, 255, 0.12);
  --glass-glow: rgba(99, 102, 241, 0.15);
  
  --primary-accent: #6366f1;
  --secondary-accent: #ec4899;
  --gold-accent: #f59e0b;
  --danger-color: #ef4444;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;

  --font-display: 'Orbitron', -apple-system, sans-serif;
  --font-body: 'Zen Kaku Gothic New', -apple-system, sans-serif;

  --app-max-width: 480px;
}

* {
  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);
  color: var(--text-main);
  font-family: var(--font-body);
}

/* Background Animated Space */
.stars-bg {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at bottom, #1b2735 0%, #090a0f 100%);
  z-index: -2;
}

.twinkle-bg {
  position: fixed;
  inset: 0;
  background-image: 
    radial-gradient(2px 2px at 20px 30px, #ffffff, rgba(0,0,0,0)),
    radial-gradient(2px 2px at 40px 70px, rgba(255,255,255,0.8), rgba(0,0,0,0)),
    radial-gradient(1px 1px at 90px 40px, #ffffff, rgba(0,0,0,0)),
    radial-gradient(2px 2px at 160px 120px, rgba(255,255,255,0.9), rgba(0,0,0,0)),
    radial-gradient(1.5px 1.5px at 230px 190px, #ffffff, rgba(0,0,0,0)),
    radial-gradient(2px 2px at 310px 80px, rgba(255,255,255,0.7), rgba(0,0,0,0)),
    radial-gradient(1px 1px at 370px 240px, #ffffff, rgba(0,0,0,0));
  background-repeat: repeat;
  background-size: 400px 300px;
  opacity: 0.6;
  z-index: -1;
  animation: twinkle 8s ease-in-out infinite alternate;
}

@keyframes twinkle {
  0% { opacity: 0.4; transform: translateY(0); }
  100% { opacity: 0.8; transform: translateY(-10px); }
}

/* Main Container */
.app-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: var(--app-max-width);
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  padding: 8px 12px 12px 12px;
  position: relative;
}

/* Header */
.game-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 8px 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.logo-group {
  display: flex;
  flex-direction: column;
}

.game-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: 1px;
  background: linear-gradient(135deg, #a5b4fc, #38bdf8, #f472b6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 16px rgba(99, 102, 241, 0.4);
}

.game-subtitle {
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

/* Score Board */
.score-board {
  display: flex;
  gap: 8px;
}

.score-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 4px 10px;
  min-width: 60px;
}

.score-card.highlight {
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.08);
}

.score-label {
  font-family: var(--font-display);
  font-size: 0.55rem;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.score-value {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-main);
}

.score-card.highlight .score-value {
  color: #fbbf24;
}

/* Header Buttons */
.header-actions {
  display: flex;
  gap: 6px;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-main);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

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

/* Next Preview Bar */
.next-preview-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 6px 0;
  padding: 4px 16px;
  background: rgba(18, 22, 40, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
}

.preview-label {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.next-planet-display {
  display: flex;
  align-items: center;
  gap: 8px;
}

.next-planet-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 0 10px currentColor;
  transition: all 0.3s ease;
}

.next-planet-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
}

/* Game Canvas Container */
.game-container {
  width: 100%;
  flex: 1;
  max-height: calc(100vh - 160px);
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(10, 13, 26, 0.75);
  backdrop-filter: blur(8px);
  border: 1.5px solid var(--panel-border);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6), inset 0 0 40px rgba(99, 102, 241, 0.05);
}

#game-canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  touch-action: none;
  display: block;
}

/* Danger Line Warning */
.danger-line {
  position: absolute;
  top: 15.91%;
  left: 0;
  right: 0;
  height: 2px;
  border-top: 2px dashed rgba(239, 68, 68, 0.4);
  pointer-events: none;
  z-index: 5;
  transition: all 0.3s ease;
}

.danger-line.warning {
  border-top-color: #ef4444;
  box-shadow: 0 0 12px #ef4444;
  animation: pulse-danger 0.6s infinite alternate;
}

@keyframes pulse-danger {
  0% { opacity: 0.4; }
  100% { opacity: 1; }
}

/* Controls Hint Footer */
.controls-hint {
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  letter-spacing: 0.5px;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 14, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 1;
  transition: opacity 0.3s ease;
}

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

.modal-card {
  background: rgba(18, 22, 40, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 24px;
  padding: 20px;
  width: 92%;
  max-width: 440px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  transform: translateY(0);
  transition: transform 0.3s ease;
}

.modal-backdrop.hidden .modal-card {
  transform: translateY(20px);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
}

.modal-body {
  font-size: 0.85rem;
  line-height: 1.5;
  color: #cbd5e1;
}

.info-desc {
  margin-bottom: 14px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Evolution Grid Table */
.evolution-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.45);
  padding: 12px 6px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  max-height: 280px;
  overflow-y: auto;
}

.evolution-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 6px 4px;
  width: 58px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.evolution-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.3);
}

.evolution-card.highlight-sun {
  background: rgba(251, 191, 36, 0.12);
  border-color: rgba(251, 191, 36, 0.4);
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.25);
}

.evo-canvas {
  width: 48px;
  height: 48px;
  display: block;
}

.evo-name {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 2px;
}

.evo-score {
  font-family: var(--font-display);
  font-size: 0.6rem;
  color: #38bdf8;
  margin-top: 1px;
}

.evo-arrow {
  color: var(--text-muted);
  font-size: 0.65rem;
  opacity: 0.5;
}

.modal-footer {
  margin-top: 20px;
}

.primary-btn {
  width: 100%;
  padding: 12px;
  border-radius: 14px;
  border: none;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #ffffff;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
}

.primary-btn.glow {
  background: linear-gradient(135deg, #ec4899, #8b5cf6);
  box-shadow: 0 0 20px rgba(236, 72, 153, 0.4);
}

/* Game Over Card */
.gameover-card {
  text-align: center;
}

.gameover-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 900;
  color: #ef4444;
  text-shadow: 0 0 20px rgba(239, 68, 68, 0.5);
}

.gameover-sub {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 4px;
  margin-bottom: 20px;
}

.final-scores {
  background: rgba(0, 0, 0, 0.4);
  border-radius: 16px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.score-row.highlight {
  color: var(--text-main);
}

.score-row .val {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--text-main);
}

.score-row.highlight .val {
  color: #fbbf24;
}

.planet-tag {
  font-family: var(--font-body) !important;
  color: #38bdf8 !important;
}

/* Utilities */
.hidden {
  display: none !important;
}
