/* ===== 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: #1a1a2e;
  /* sizing handled by JS */
}

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

.screen.active {
  display: flex;
}

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

/* ===== TYPOGRAPHY ===== */
.game-title {
  font-size: clamp(2.4rem, 8vw, 3.5rem);
  font-weight: 900;
  letter-spacing: 0.05em;
  line-height: 1;
  text-transform: uppercase;
}

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

.over-title {
  font-size: clamp(1.8rem, 6vw, 2.8rem);
  font-weight: 900;
  letter-spacing: 0.1em;
  color: #ff4d4d;
}

.subtitle {
  color: #aab0c0;
  font-size: 0.95rem;
  line-height: 1.5;
}

/* ===== SCORE BLOCKS ===== */
.score-block {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 12px 32px;
  width: 100%;
}

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

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

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

/* ===== CONTROLS HINT ===== */
.controls-hint {
  display: flex;
  gap: 16px;
  color: #7a8099;
  font-size: 0.8rem;
}

/* ===== 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%);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 10px 16px;
  background: linear-gradient(to bottom, rgba(15,17,23,0.85) 60%, transparent);
  z-index: 10;
  pointer-events: none;
}

.hud-left, .hud-center, .hud-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 70px;
}

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

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

#hudSpeed {
  color: #305CDE;
}

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

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

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

.mobile-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px solid rgba(48, 92, 222, 0.6);
  background: rgba(48, 92, 222, 0.18);
  color: #305CDE;
  font-size: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: all;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: background 0.1s;
  font-family: inherit;
}

.mobile-btn:active {
  background: rgba(48, 92, 222, 0.4);
}

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

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
  .screen-inner {
    padding: 24px 16px;
    gap: 12px;
  }

  .score-value {
    font-size: 1.5rem;
  }
}
