:root {
  --bg-deep: #0B0E14;
  --card-bg: rgba(18, 24, 38, 0.92);
  --border-color: rgba(255, 255, 255, 0.12);
  --accent-cyan: #38BDF8;
  --accent-gold: #FBBF24;
  --accent-green: #34D399;
  --text-main: #F1F5F9;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

/* ─── Arcade Frame ─── */
.game-wrapper {
  position: relative;
  width: 100%;
  max-width: 400px;
  height: 100%;
  max-height: 640px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
}

canvas {
  width: 100%;
  height: 100%;
  max-width: 380px;
  max-height: 600px;
  aspect-ratio: 380 / 600;
  background: #1E293B;
  border: 2px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.6);
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

/* ─── In-Game Top HUD ─── */
.hud-score {
  position: absolute;
  top: 48px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2.6rem;
  font-weight: 800;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  color: #FFFFFF;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8), 0 0 12px rgba(56, 189, 248, 0.5);
  pointer-events: none;
  z-index: 10;
}

/* ─── Phase Badge HUD ─── */
.hud-phase {
  position: absolute;
  top: 14px;
  left: 15px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 4px 8px;
  border-radius: 6px;
  z-index: 25;
  transition: all 0.3s ease;
  backdrop-filter: blur(4px);
  pointer-events: none;
}
.hud-phase.phase-1 {
  background: rgba(2, 132, 199, 0.35);
  border: 1px solid rgba(56, 189, 248, 0.5);
  color: #BAE6FD;
}
.hud-phase.phase-2 {
  background: rgba(194, 65, 12, 0.4);
  border: 1px solid rgba(249, 115, 22, 0.6);
  color: #FED7AA;
  box-shadow: 0 0 8px rgba(249, 115, 22, 0.4);
}
.hud-phase.phase-3 {
  background: rgba(13, 148, 136, 0.45);
  border: 1px solid rgba(6, 182, 212, 0.7);
  color: #67E8F9;
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.5);
}

/* ─── Shield Active Indicator ─── */
.shield-indicator {
  position: absolute;
  top: 86px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 9px;
  background: rgba(245, 158, 11, 0.35);
  border: 1px solid #F59E0B;
  color: #FEF08A;
  border-radius: 12px;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
  z-index: 12;
  display: none;
  pointer-events: none;
  animation: pulseShield 1s infinite alternate;
}
.shield-indicator.active {
  display: block;
}
@keyframes pulseShield {
  from { transform: translateX(-50%) scale(0.96); opacity: 0.85; }
  to { transform: translateX(-50%) scale(1.04); opacity: 1; }
}

/* ─── Top Control Bar ─── */
.top-bar {
  position: absolute;
  top: 10px;
  right: 12px;
  display: flex;
  gap: 5px;
  z-index: 25;
}

.btn-top {
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--border-color);
  color: #E2E8F0;
  font-size: 0.75rem;
  padding: 4px 8px;
  border-radius: 12px;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn-top:hover {
  background: rgba(30, 41, 59, 0.8);
  border-color: var(--accent-cyan);
}

/* ─── Overlays (Start, Pause & Game Over) ─── */
.overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(11, 14, 20, 0.86);
  backdrop-filter: blur(6px);
  z-index: 20;
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  animation: fadeIn 0.2s ease;
}

.overlay.active {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.title-badge {
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-cyan);
  margin-bottom: 6px;
  font-weight: 700;
}

.main-title {
  font-size: 1.85rem;
  font-weight: 800;
  color: #FFFFFF;
  line-height: 1.2;
  margin-bottom: 8px;
}

.subtitle {
  font-size: 0.86rem;
  color: #94A3B8;
  margin-bottom: 18px;
  line-height: 1.4;
  max-width: 320px;
}

/* Character Avatar Preview */
.avatar-preview {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #1E293B;
  border: 2px solid var(--accent-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.4);
}

/* Feature Pills in Start Screen */
.feature-pills {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}
.pill-item {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #E2E8F0;
}
.pill-item.gold {
  border-color: rgba(251, 191, 36, 0.4);
  background: rgba(245, 158, 11, 0.15);
  color: #FDE047;
}

/* Stat Card */
.stat-card {
  width: 100%;
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 18px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  font-size: 0.92rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.stat-row:last-child { border-bottom: none; }
.stat-val { font-weight: 700; font-family: ui-monospace, monospace; }

/* Buttons */
.btn-play {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  padding: 13px 20px;
  border-radius: 12px;
  background: linear-gradient(135deg, #38BDF8, #2563EB);
  border: none;
  color: #FFFFFF;
  font-size: 1.02rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
  transition: transform 0.1s ease, filter 0.1s ease;
}

.btn-play:active {
  transform: scale(0.98);
  filter: brightness(0.95);
}

.instruction-hint {
  margin-top: 14px;
  font-size: 0.78rem;
  color: #64748B;
}
