/* ===== RESET & BASE ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0F1117;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: #fff;
  touch-action: none;
}

/* ===== LAYOUT ===== */
#game-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#gameCanvas {
  display: block;
  background: #0a0a14;
}

/* ===== SCREENS ===== */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 20, 0.93);
  backdrop-filter: blur(8px);
  z-index: 20;
}

.screen.active {
  display: flex;
}

.screen-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 32px 24px;
  max-width: 340px;
  width: 100%;
  text-align: center;
}

/* ===== TITLE ===== */
.title-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.star-icon {
  font-size: 2.4rem;
  color: #305CDE;
  text-shadow: 0 0 20px rgba(48,92,222,0.8);
  animation: starPulse 2s ease-in-out infinite;
}

@keyframes starPulse {
  0%, 100% { text-shadow: 0 0 20px rgba(48,92,222,0.8); }
  50%       { text-shadow: 0 0 40px rgba(48,92,222,1), 0 0 60px rgba(48,92,222,0.4); }
}

.game-title {
  font-size: clamp(2.2rem, 7vw, 3.2rem);
  font-weight: 900;
  letter-spacing: 0.05em;
  line-height: 1;
  text-transform: uppercase;
}

.game-title span {
  color: #305CDE;
}

.over-title {
  font-size: clamp(1.6rem, 5.5vw, 2.5rem);
  font-weight: 900;
  letter-spacing: 0.1em;
  color: #ff4d6d;
  line-height: 1.15;
}

.subtitle {
  color: #aab0c0;
  font-size: 0.9rem;
  line-height: 1.55;
}

/* ===== CONTROLS GRID ===== */
.controls-grid {
  display: flex;
  gap: 20px;
}

.ctrl-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.ctrl-key {
  display: inline-block;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.8rem;
  font-weight: 600;
}

.ctrl-label {
  font-size: 0.7rem;
  color: #7a8099;
}

/* ===== SCORE BLOCKS ===== */
.scores-row {
  display: flex;
  gap: 12px;
  width: 100%;
}

.score-block {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 12px 16px;
  flex: 1;
}

.score-block.full {
  width: 100%;
  flex: none;
}

.score-label {
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  color: #7a8099;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.score-value {
  font-size: 1.6rem;
  font-weight: 800;
}

.score-value.accent {
  color: #305CDE;
}

/* ===== BUTTONS ===== */
.btn-primary {
  display: inline-block;
  width: 100%;
  padding: 14px 24px;
  background: #305CDE;
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  font-family: inherit;
}

.btn-primary:hover  { background: #4470f0; }
.btn-primary:active { transform: scale(0.97); }

.btn-secondary {
  display: inline-block;
  color: #7a8099;
  text-decoration: none;
  font-size: 0.85rem;
  padding: 6px 0;
  border-bottom: 1px solid rgba(122,128,153,0.3);
  transition: color 0.15s;
}

.btn-secondary:hover { color: #fff; }

/* ===== HUD ===== */
#hud {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(480px, 100%);
  z-index: 10;
  pointer-events: none;
}

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 10px 16px 6px;
  background: linear-gradient(to bottom, rgba(10,10,20,0.88) 50%, transparent);
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 64px;
}

.hud-label {
  font-size: 0.58rem;
  letter-spacing: 0.14em;
  color: #7a8099;
  text-transform: uppercase;
}

.hud-value {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  margin-top: 2px;
}

.hud-value.accent {
  color: #305CDE;
}

.hud-lives {
  font-size: 1.2rem;
  letter-spacing: 4px;
}

.hud-powerup {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  padding: 2px 0 4px;
  min-height: 20px;
  color: #f5c518;
  text-shadow: 0 0 8px rgba(245,197,24,0.7);
}

/* ===== HIGH SCORE ===== */
.high-score-display {
  font-size: 0.8rem;
  color: #7a8099;
}

/* ===== PREVIEW CANVAS ===== */
#previewCanvas {
  border-radius: 8px;
}

/* ===== MOBILE CONTROLS ===== */
#mobileControls {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(480px, 100%);
  height: 120px;
  display: flex;
  z-index: 10;
  pointer-events: none;
}

.touch-zone {
  flex: 1;
  pointer-events: all;
  -webkit-tap-highlight-color: transparent;
}

.touch-labels {
  position: absolute;
  bottom: 16px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  padding: 0 24px;
  font-size: 0.7rem;
  color: rgba(122,128,153,0.5);
  pointer-events: none;
  letter-spacing: 0.08em;
}

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

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
  .screen-inner {
    padding: 20px 14px;
    gap: 10px;
  }
  .score-value { font-size: 1.3rem; }
}
