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

:root {
  --c-bg:       #0d0d1a;
  --c-bg2:      #13132a;
  --c-panel:    #1a1a35;
  --c-border:   #2e2e6a;
  --c-purple:   #7f77dd;
  --c-purple2:  #534ab7;
  --c-teal:     #1d9e75;
  --c-amber:    #ef9f27;
  --c-red:      #e24b4a;
  --c-white:    #e8e8f0;
  --c-muted:    #7070a0;
  --font-pixel: 'Press Start 2P', monospace;
  --font-ui:    'Rajdhani', sans-serif;
}

html, body {
  width: 100%; height: 100%;
  background: var(--c-bg);
  color: var(--c-white);
  font-family: var(--font-ui);
  overflow: hidden;
}

#app {
  width: 100%; height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}

/* ── SCREENS ── */
.screen {
  display: none;
  width: 100%; max-width: 860px;
  height: 100dvh;
  position: absolute;
  top: 0; left: 50%; transform: translateX(-50%);
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.screen.active { display: flex; }
.screen-inner {
  padding: 2rem;
  max-width: 560px;
  width: 100%;
  text-align: center;
}
.screen-title {
  font-family: var(--font-pixel);
  font-size: clamp(14px, 3vw, 20px);
  color: var(--c-purple);
  margin-bottom: 1.5rem;
  letter-spacing: 2px;
}

/* ── MENU SCREEN ── */
.menu-bg {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 60%, #1a1040 0%, #0d0d1a 70%);
  overflow: hidden;
}
.scanlines {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    0deg, transparent, transparent 2px,
    rgba(0,0,0,0.15) 2px, rgba(0,0,0,0.15) 4px
  );
  pointer-events: none;
}
.stars { position: absolute; inset: 0; }
.star {
  position: absolute; border-radius: 50%;
  background: var(--c-white);
  animation: twinkle 2s ease-in-out infinite;
}
@keyframes twinkle { 0%,100%{opacity:.2} 50%{opacity:1} }

.menu-content {
  position: relative; z-index: 2;
  display: flex; flex-direction: column;
  align-items: center; gap: 1.5rem;
  padding: 2rem 1rem;
}
.logo-area { text-align: center; position: relative; }
.logo-sub {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-ui);
  font-size: clamp(11px, 2.2vw, 14px);
  font-weight: 700;
  letter-spacing: 1.4px;
  color: #d8eeff;
  margin-bottom: 12px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(127,119,221,0.55);
  background: linear-gradient(90deg, rgba(83,74,183,0.32), rgba(29,158,117,0.2));
  box-shadow: 0 0 18px rgba(83,74,183,0.3), inset 0 0 0 1px rgba(255,255,255,0.06);
  text-shadow: 0 0 8px rgba(129,196,255,0.45);
}
.logo-title {
  font-family: var(--font-pixel);
  font-size: clamp(24px, 7vw, 52px);
  line-height: 1.2;
  color: var(--c-white);
  text-shadow: 0 0 30px var(--c-purple2), 0 0 60px var(--c-purple2);
  animation: logoPulse 3s ease-in-out infinite;
}
.logo-title span { color: var(--c-purple); }
@keyframes logoPulse {
  0%,100%{ text-shadow: 0 0 20px var(--c-purple2), 0 0 40px var(--c-purple2); }
  50%{ text-shadow: 0 0 40px var(--c-purple), 0 0 80px var(--c-purple); }
}

.menu-card {
  background: var(--c-panel);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 1.5rem;
  width: 100%; max-width: 320px;
  display: flex; flex-direction: column; gap: 12px;
}
.hiscore-row {
  display: flex; justify-content: space-between;
  font-family: var(--font-pixel);
  font-size: 9px; color: var(--c-amber);
  border-bottom: 1px solid var(--c-border);
  padding-bottom: 12px; margin-bottom: 4px;
}
.menu-chars { opacity: 0.85; }

.mode-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 2px;
}

.mode-btn {
  border: 1px solid var(--c-border);
  background: var(--c-bg2);
  color: var(--c-muted);
  border-radius: 6px;
  padding: 8px 6px;
  font-family: var(--font-pixel);
  font-size: 8px;
  letter-spacing: 1px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.mode-btn.active {
  border-color: var(--c-teal);
  color: #c8fff0;
  background: rgba(29, 158, 117, 0.2);
}

.mode-btn:hover {
  color: var(--c-white);
  border-color: var(--c-purple);
}

/* ── BUTTONS ── */
.btn {
  font-family: var(--font-pixel);
  font-size: clamp(8px, 2vw, 10px);
  padding: 12px 20px;
  border-radius: 4px;
  border: none; cursor: pointer;
  letter-spacing: 1px;
  transition: transform 0.1s, box-shadow 0.1s;
  width: 100%;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--c-purple2);
  color: var(--c-white);
  box-shadow: 0 4px 0 #26215c, 0 0 20px rgba(83,74,183,0.4);
}
.btn-primary:hover { background: var(--c-purple); box-shadow: 0 4px 0 #3c3489, 0 0 30px rgba(127,119,221,0.5); }
.btn-secondary {
  background: transparent;
  color: var(--c-muted);
  border: 1px solid var(--c-border);
}
.btn-secondary:hover { color: var(--c-white); border-color: var(--c-purple); }

/* ── HOW TO PLAY ── */
.how-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px; margin-bottom: 1.5rem;
  text-align: left;
}
.how-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--c-panel);
  border: 1px solid var(--c-border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px; font-weight: 600;
  color: var(--c-white);
}
.how-key {
  font-family: var(--font-pixel);
  font-size: 7px;
  background: var(--c-bg2);
  border: 1px solid var(--c-border);
  border-radius: 4px;
  padding: 4px 6px;
  white-space: nowrap;
  color: var(--c-amber);
}
.how-icon {
  width: 30px; height: 30px; min-width: 30px;
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-pixel); font-size: 8px;
  color: #fff; font-weight: 700;
}
.boost-icon { background: #1D9E75; font-size: 16px; }
.how-note {
  font-size: 12px; color: var(--c-muted);
  margin-bottom: 1.5rem; line-height: 1.8;
}

.how-esc {
  font-size: 12px;
  color: #c8fff0;
  background: rgba(29, 158, 117, 0.16);
  border: 1px solid rgba(29, 158, 117, 0.55);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 10px;
}

/* ── HUD ── */
#hud {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 16px;
  background: rgba(13,13,26,0.95);
  border-bottom: 1px solid var(--c-border);
  width: 100%;
  position: absolute; top: 0; left: 0; z-index: 10;
}
.hud-left, .hud-right {
  display: flex; gap: 20px;
}
.hud-item, .cgpa-display {
  display: flex; flex-direction: column; align-items: center;
}
.cgpa-display { flex-direction: row; gap: 6px; align-items: baseline; }
.hud-label {
  font-family: var(--font-pixel);
  font-size: 7px; color: var(--c-muted);
  letter-spacing: 1px;
}
.hud-val {
  font-family: var(--font-pixel);
  font-size: 12px; color: var(--c-white);
}
.hud-val.big { font-size: 18px; color: var(--c-teal); }

#boostHud {
  position: absolute; top: 46px; left: 0; right: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: 4px 16px;
  background: rgba(13,13,26,0.9);
  border-bottom: 1px solid var(--c-border);
  font-size: 12px;
}
#boostTrack {
  flex: 1; height: 6px;
  background: var(--c-bg2);
  border: 1px solid var(--c-border);
  border-radius: 99px; overflow: hidden;
}
#boostBar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--c-teal), #5DCAA5);
  border-radius: 99px;
  transition: width 0.1s;
}
#boostPct {
  font-family: var(--font-pixel);
  font-size: 7px; color: var(--c-teal);
  min-width: 30px;
}

/* ── GAME CANVAS ── */
#gameScreen {
  position: relative;
  display: none;
  flex-direction: column;
  max-width: none;
  left: 0;
  transform: none;
}
#gameScreen.active { display: flex; }
#gameCanvas {
  display: block;
  width: 100%;
  flex: 1;
  margin-top: 68px;
}

/* ── MESSAGE BANNER ── */
#msgBanner {
  position: absolute;
  top: 80px; left: 50%; transform: translateX(-50%);
  background: var(--c-red);
  color: #fff;
  font-family: var(--font-pixel);
  font-size: 9px;
  padding: 8px 20px;
  border-radius: 4px;
  z-index: 20;
  white-space: nowrap;
  animation: bannerPop 0.3s cubic-bezier(.36,1.8,.58,1) both;
}
@keyframes bannerPop { from{transform:translateX(-50%) scale(0)} to{transform:translateX(-50%) scale(1)} }
.hidden { display: none !important; }

/* ── MODAL OVERLAY ── */
#modalOverlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
#modalBox {
  background: var(--c-panel);
  border: 1px solid var(--c-purple);
  border-radius: 10px;
  padding: 2rem;
  max-width: 400px; width: 90%;
  text-align: center;
  box-shadow: 0 0 60px rgba(83,74,183,0.4);
  animation: modalIn 0.3s cubic-bezier(.36,1.4,.58,1) both;
}
@keyframes modalIn { from{transform:scale(0.8);opacity:0} to{transform:scale(1);opacity:1} }
#modalBadge {
  display: inline-block;
  padding: 4px 14px;
  background: var(--c-bg2);
  border: 1px solid var(--c-border);
  border-radius: 99px;
  font-family: var(--font-pixel);
  font-size: 8px;
  color: var(--c-amber);
  margin-bottom: 12px;
}
#modalTitle {
  font-family: var(--font-pixel);
  font-size: clamp(13px, 3vw, 18px);
  color: var(--c-white);
  margin-bottom: 10px;
}
#modalMsg {
  font-size: 15px; font-weight: 600;
  color: var(--c-muted);
  margin-bottom: 16px;
  line-height: 1.6;
}
#modalStats {
  display: flex; gap: 10px; justify-content: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.stat-box {
  background: var(--c-bg2);
  border: 1px solid var(--c-border);
  border-radius: 6px;
  padding: 8px 14px;
  text-align: center;
}
.stat-label {
  font-family: var(--font-pixel);
  font-size: 7px; color: var(--c-muted);
  display: block; margin-bottom: 4px;
}
.stat-val {
  font-family: var(--font-pixel);
  font-size: 14px; color: var(--c-teal);
}
.modal-btns { display: flex; flex-direction: column; gap: 8px; }

/* ── RESPONSIVE ── */
@media (max-width: 480px) {
  .logo-sub {
    letter-spacing: 1px;
    padding: 7px 10px;
  }
  #howScreen .screen-inner {
    max-height: 100dvh;
    overflow-y: auto;
    padding-bottom: 1rem;
  }
  .how-grid { grid-template-columns: 1fr; }
  .hud-left, .hud-right { gap: 10px; }
  .hud-val { font-size: 10px; }
  .hud-val.big { font-size: 14px; }
}
