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

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: linear-gradient(160deg, #eef0f8 0%, #f8f9ff 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* ============================================================
   PAGE BACKGROUND GLOW
   ============================================================ */
.page-bg {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(80,100,220,0.06) 0%, transparent 70%);
}

/* ============================================================
   PHONE SHELL
   ============================================================ */
.phone-shell {
  position: relative;
  display: flex;
  align-items: stretch;
  background: #18181f;
  border-radius: 52px;
  box-shadow:
    0 40px 100px rgba(0,0,0,0.45),
    0 0 0 1px rgba(255,255,255,0.07),
    inset 0 0 0 1px rgba(0,0,0,0.6);
  height: min(92vh, calc(52vw * 16 / 9));
}

.phone-bezel-left,
.phone-bezel-right {
  width: 12px;
  flex-shrink: 0;
  position: relative;
}

/* Volume buttons on left bezel */
.phone-bezel-left::before,
.phone-bezel-left::after {
  content: '';
  position: absolute;
  left: 0;
  width: 4px;
  background: #2a2a35;
  border-radius: 3px;
}
.phone-bezel-left::before { height: 28px; top: 30%; }
.phone-bezel-left::after  { height: 28px; top: 45%; }

/* Power button on right bezel */
.phone-bezel-right::before {
  content: '';
  position: absolute;
  right: 0;
  width: 4px;
  height: 44px;
  background: #2a2a35;
  border-radius: 3px;
  top: 35%;
}

.phone-screen {
  display: flex;
  flex-direction: column;
  background: #f5f5fa;
  border-radius: 42px;
  overflow: hidden;
  flex: 1;
}

.phone-notch {
  height: 36px;
  background: #18181f;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  border-radius: 0 0 20px 20px;
  flex-shrink: 0;
  position: relative;
}

.phone-pill {
  width: 120px;
  height: 34px;
  background: #18181f;
  border-radius: 20px;
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
}

.phone-home-bar {
  height: 28px;
  background: #f5f5fa;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.phone-home-pill {
  width: 120px;
  height: 5px;
  background: rgba(0,0,0,0.2);
  border-radius: 10px;
}

/* ============================================================
   PHONE CONTAINER
   ============================================================ */
.phone-container {
  position: relative;
  background: #f5f5fa;
  overflow: hidden;
  flex: 1;
}

#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ============================================================
   OVERLAYS
   ============================================================ */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: rgba(245,245,250,0.96);
  z-index: 10;
  transition: opacity 0.3s ease;
}

.overlay.hidden { display: none; }

.title {
  font-size: clamp(2.4rem, 8vw, 3.6rem);
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.blue {
  color: #1565c0;
  text-shadow: 0 2px 12px rgba(21,101,192,0.18), 0 0 40px rgba(21,101,192,0.08);
}
.red {
  color: #b71c1c;
  text-shadow: 0 2px 12px rgba(183,28,28,0.18), 0 0 40px rgba(183,28,28,0.08);
}

.tagline {
  color: #5a6a8a;
  font-size: clamp(0.75rem, 2.5vw, 1rem);
  letter-spacing: 0.08em;
  text-align: center;
}

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

.overlay-title.red {
  color: #b71c1c;
  text-shadow: 0 2px 16px rgba(183,28,28,0.25);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-play {
  background: linear-gradient(135deg, #1565c0, #0d47a1);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 14px 48px;
  font-size: clamp(0.9rem, 3vw, 1.1rem);
  font-weight: 800;
  letter-spacing: 0.15em;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(21,101,192,0.35);
  transition: transform 0.1s, box-shadow 0.1s;
  animation: pulse-btn 2s ease-in-out infinite;
}

.btn-play:active { transform: scale(0.96); box-shadow: 0 4px 12px rgba(21,101,192,0.25); }
.btn-play.small  { padding: 10px 28px; font-size: clamp(0.75rem, 2.5vw, 0.9rem); animation: none; }

.btn-play.secondary {
  background: transparent;
  border: 2px solid rgba(21,101,192,0.3);
  color: #1565c0;
  box-shadow: none;
  animation: none;
}

.btn-back {
  position: absolute;
  top: 14px;
  left: 16px;
  background: none;
  border: none;
  color: #5a6a8a;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.05em;
}
.btn-back:hover { color: #1565c0; }

@keyframes pulse-btn {
  0%,100% { box-shadow: 0 8px 24px rgba(21,101,192,0.35); }
  50%      { box-shadow: 0 8px 36px rgba(21,101,192,0.6); }
}

.btn-row { display: flex; gap: 16px; }

.btn-icon {
  background: rgba(0,0,0,0.07);
  color: #1a1a2e;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover { background: rgba(0,0,0,0.12); }

/* ============================================================
   HUD
   ============================================================ */
.hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 10px;
  background: linear-gradient(to bottom, rgba(245,245,250,0.95) 60%, transparent);
  z-index: 5;
}

.hud.hidden { display: none; }

.hud-left, .hud-center, .hud-right {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #1a1a2e;
  font-size: clamp(0.7rem, 2.2vw, 0.85rem);
  font-weight: 700;
  letter-spacing: 0.1em;
}

.hud-timer {
  font-size: 0.8em;
  font-weight: 600;
  opacity: 0.5;
  letter-spacing: 0.05em;
}

.hud-deaths {
  font-size: clamp(0.65rem, 2vw, 0.8rem);
  font-weight: 700;
  color: #aab0c0;
  letter-spacing: 0.05em;
  transition: color 0.2s;
}

.hud-deaths.active { color: #e53935; }

.star { color: #c8ccd8; font-size: 1rem; transition: color 0.2s, text-shadow 0.2s; }
.star.lit { color: #f59e0b; text-shadow: 0 0 8px rgba(245,158,11,0.6); }

/* ============================================================
   CONTROL HINT
   ============================================================ */
.control-hint {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(0,0,0,0.35);
  font-size: clamp(0.6rem, 2vw, 0.75rem);
  letter-spacing: 0.08em;
  pointer-events: none;
  transition: opacity 1.5s ease;
  z-index: 5;
  white-space: nowrap;
}

.control-hint.fade { opacity: 0; }

/* ============================================================
   LEVEL SELECT
   ============================================================ */
.level-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
  padding: 8px;
  max-height: 72vh;
  overflow-y: auto;
  width: 90%;
}

.level-btn {
  background: #ffffff;
  border: 1px solid #e0e4f0;
  border-radius: 12px;
  color: #1a1a2e;
  font-size: clamp(0.65rem, 2vw, 0.8rem);
  font-weight: 700;
  padding: 8px 4px 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.level-btn:hover:not(.locked) {
  background: #eef1ff;
  border-color: #1565c0;
  box-shadow: 0 2px 8px rgba(21,101,192,0.15);
}
.level-btn.locked {
  opacity: 0.35;
  cursor: not-allowed;
  background: #f5f5fa;
}
.level-btn.endless {
  border-color: #00897b;
  color: #00695c;
}
.level-btn.endless:hover:not(.locked) {
  background: #e0f2f1;
  border-color: #00695c;
}

.level-btn .mini-stars { font-size: 0.55rem; color: #f59e0b; letter-spacing: 0; }
.level-btn .mini-time  { font-size: 0.5rem;  color: #8892aa; letter-spacing: 0; }

/* ============================================================
   LEVEL COMPLETE
   ============================================================ */
.star-row { display: flex; gap: 16px; }

.star-big {
  font-size: clamp(2rem, 7vw, 3rem);
  color: #dde0ec;
  transition: color 0.3s, text-shadow 0.3s, transform 0.3s;
  display: inline-block;
}

.star-big.lit {
  color: #f59e0b;
  text-shadow: 0 0 18px rgba(245,158,11,0.7);
  transform: scale(1.2);
}

.complete-time {
  color: #5a6a8a;
  font-size: clamp(0.75rem, 2.5vw, 0.9rem);
  letter-spacing: 0.08em;
}

/* ============================================================
   SCORE DISPLAY
   ============================================================ */
.score-display {
  color: #3a4a6a;
  font-size: clamp(0.85rem, 3vw, 1.1rem);
  font-weight: 700;
  letter-spacing: 0.1em;
}

/* ============================================================
   MOBILE CONTROLS
   ============================================================ */
.mobile-controls {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.mobile-controls.hidden { display: none; }

.mc-left, .mc-right, .mc-jump, .mc-jump-right {
  position: absolute;
  pointer-events: all;
  opacity: 0;
}

.mc-left  { left: 0;   top: 0; width: 33%; height: 80%; }
.mc-right { right: 0;  top: 0; width: 33%; height: 80%; }
.mc-jump  { left: 33%; right: 33%; top: 0; height: 80%; }

.mc-jump-right         { right: 0; bottom: 0; width: 50%; height: 20%; }
.mc-jump-right.visible { opacity: 0; pointer-events: all; }

/* ============================================================
   DEATH FLASH
   ============================================================ */
.death-flash {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0);
  pointer-events: none;
  z-index: 20;
  transition: background 0.08s;
}

.death-flash.flash { background: rgba(220,50,50,0.18); }

/* ============================================================
   SCREEN SHAKE
   ============================================================ */
@keyframes shake {
  0%,100% { transform: translate(0,0) rotate(0deg); }
  20%      { transform: translate(-4px, 2px) rotate(-0.5deg); }
  40%      { transform: translate(4px, -2px) rotate(0.5deg); }
  60%      { transform: translate(-3px, 3px) rotate(-0.3deg); }
  80%      { transform: translate(3px, -1px) rotate(0.3deg); }
}

.shake { animation: shake 0.35s ease-out; }

/* ============================================================
   PHONE SHELL RESPONSIVE
   ============================================================ */
@media (max-width: 480px) {
  .phone-shell {
    height: 100vh;
    border-radius: 0;
    box-shadow: none;
  }
  .phone-bezel-left,
  .phone-bezel-right { display: none; }
  .phone-screen { border-radius: 0; }
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
.level-grid::-webkit-scrollbar { width: 4px; }
.level-grid::-webkit-scrollbar-track { background: transparent; }
.level-grid::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); border-radius: 2px; }

/* ============================================================
   DASHBOARD — START SCREEN
   ============================================================ */
#startScreen {
  justify-content: flex-start;
  gap: 0;
  padding: 0;
  background: #f0f4ff;
}

.dash-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 6px;
  width: 100%;
  flex-shrink: 0;
}

.dash-title {
  font-size: clamp(1.4rem, 5vw, 1.9rem);
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.dash-tagline {
  color: #5a6a8a;
  font-size: clamp(0.62rem, 2vw, 0.78rem);
  letter-spacing: 0.06em;
  text-align: center;
  padding: 0 16px 10px;
  width: 100%;
  flex-shrink: 0;
}

/* ── Tab panels ─────────────────────────────────────────── */
.tab-panel {
  display: none;
  flex-direction: column;
  align-items: center;
  flex: 1;
  overflow-y: auto;
  width: 100%;
  padding-bottom: 8px;
}

.tab-panel.active { display: flex; }

/* ── Preview card ───────────────────────────────────────── */
.preview-card {
  width: calc(100% - 28px);
  margin: 0 14px 10px;
  border-radius: 20px;
  background: linear-gradient(160deg, #dbeafe 0%, #eff6ff 100%);
  box-shadow: 0 4px 20px rgba(21,101,192,0.12), 0 0 0 1px rgba(21,101,192,0.07);
  overflow: hidden;
  flex-shrink: 0;
  aspect-ratio: 16 / 7;
}

#previewCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.preview-pills {
  display: flex;
  gap: 6px;
  padding: 0 14px 10px;
  flex-wrap: wrap;
  justify-content: center;
  flex-shrink: 0;
  width: 100%;
}

.preview-pill {
  background: rgba(21,101,192,0.1);
  color: #1565c0;
  border-radius: 50px;
  padding: 3px 10px;
  font-size: clamp(0.55rem, 1.8vw, 0.68rem);
  font-weight: 700;
  letter-spacing: 0.06em;
}

/* ── Stat cards ─────────────────────────────────────────── */
.stat-cards {
  display: flex;
  gap: 8px;
  padding: 0 14px 10px;
  width: 100%;
  flex-shrink: 0;
}

.stat-card {
  flex: 1;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.07), 0 0 0 1px rgba(0,0,0,0.04);
  padding: 10px 6px 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.stat-card-label {
  font-size: clamp(0.48rem, 1.6vw, 0.6rem);
  font-weight: 800;
  color: #8892aa;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stat-card-value {
  font-size: clamp(0.9rem, 3vw, 1.15rem);
  font-weight: 900;
  color: #1a1a2e;
  letter-spacing: 0.04em;
}

/* ── CTA area ───────────────────────────────────────────── */
.dash-cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  width: 100%;
  flex-shrink: 0;
}

.dash-play {
  width: 100%;
  border-radius: 16px;
  padding: 16px;
  font-size: clamp(0.95rem, 3vw, 1.15rem);
  letter-spacing: 0.18em;
  animation: pulse-btn 2s ease-in-out infinite;
}

.unlock-hint {
  font-size: clamp(0.58rem, 1.9vw, 0.72rem);
  color: #8892aa;
  text-align: center;
  letter-spacing: 0.04em;
}

/* ── Bottom nav ─────────────────────────────────────────── */
.bottom-nav {
  display: flex;
  width: 100%;
  border-top: 1px solid rgba(0,0,0,0.07);
  background: #fff;
  flex-shrink: 0;
  margin-top: auto;
}

.bottom-nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 0 10px;
  background: none;
  border: none;
  color: #aab0c0;
  font-size: clamp(0.55rem, 1.8vw, 0.68rem);
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: color 0.15s;
}

.bottom-nav-tab .tab-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.bottom-nav-tab.active { color: #1565c0; }
.bottom-nav-tab:hover  { color: #1565c0; }

/* ── Levels panel ───────────────────────────────────────── */
.panel-title {
  font-size: clamp(1.1rem, 4vw, 1.5rem);
  padding: 12px 0 4px;
}

#panelLevels .level-grid {
  max-height: none;
  flex: 1;
  overflow-y: auto;
}

/* ── Shop / Coming Soon ─────────────────────────────────── */
.coming-soon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 8px;
  color: #8892aa;
}

.coming-soon-icon { font-size: 2.5rem; }
.coming-soon-title { font-size: 1.1rem; font-weight: 900; color: #1a1a2e; letter-spacing: 0.1em; }
.coming-soon-sub   { font-size: 0.78rem; letter-spacing: 0.08em; }

/* ── Settings panel ─────────────────────────────────────── */
.settings-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  width: 100%;
}

.settings-title {
  font-size: 1.1rem;
  font-weight: 900;
  color: #1a1a2e;
  letter-spacing: 0.1em;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(0,0,0,0.07);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
}

.settings-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: #1a1a2e;
  letter-spacing: 0.05em;
}

.btn-toggle {
  background: #1565c0;
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 6px 18px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-toggle.off { background: #aab0c0; }

.btn-danger {
  background: #fff;
  color: #b71c1c;
  border: 1.5px solid rgba(183,28,28,0.3);
  border-radius: 50px;
  padding: 6px 16px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-danger:hover { background: rgba(183,28,28,0.06); }
