/* =============================================================
   PROMPT TO CLOSE — retro arcade theme
   ============================================================= */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --purple: #4a0e8f;
  --pink: #ff1e8c;
  --neon: #39ff14;
  --cyan: #00e5ff;
  --gold: #ffd700;
  --ink: #12002b;
  --panel: rgba(18, 0, 43, 0.82);
  --pixel: 'Press Start 2P', monospace;
  --body: 'Inter', -apple-system, sans-serif;
}

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--body);
  color: #fff;
  min-height: 100vh;
  background: linear-gradient(160deg, var(--purple) 0%, #7a1fa2 45%, var(--pink) 100%) fixed;
}

/* CRT scanlines over everything */
.scanlines {
  position: fixed; inset: 0; pointer-events: none; z-index: 5;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,0.09) 0 1px, transparent 1px 3px);
}

.screen { display: none; min-height: 100vh; padding: 24px 16px 80px; }
.screen.active { display: block; }

.pixel-title, .pixel-h2, .pixel-small { font-family: var(--pixel); }

/* ---------------- GATE ---------------- */
.gate-wrap { max-width: 640px; margin: 0 auto; text-align: center; padding-top: 6vh; }

.gate-presents { font-family: var(--pixel); font-size: 10px; color: var(--cyan); letter-spacing: 2px; margin-bottom: 22px; }

.pixel-title {
  font-size: clamp(30px, 8vw, 58px);
  line-height: 1.25;
  color: var(--neon);
  text-shadow: 4px 4px 0 var(--ink), 8px 8px 0 rgba(0,0,0,0.35);
  margin-bottom: 18px;
}

.gate-sub { font-family: var(--pixel); font-size: clamp(9px, 2.4vw, 13px); color: #fff; margin-bottom: 26px; line-height: 1.8; }

.gate-pitch {
  background: var(--panel);
  border: 4px solid var(--neon);
  box-shadow: 6px 6px 0 var(--ink);
  padding: 20px 22px;
  margin-bottom: 26px;
  font-size: 16px;
  line-height: 1.6;
}
.gate-pitch p + p { margin-top: 10px; }
.gate-warn { color: var(--gold); font-weight: 600; }

#gate-form { display: flex; flex-direction: column; gap: 12px; }
#gate-gotcha { position: absolute; left: -9999px; height: 0; opacity: 0; }

#gate-form input:not(#gate-gotcha) {
  font-family: var(--pixel); font-size: 11px;
  padding: 16px 14px;
  background: var(--ink); color: var(--neon);
  border: 3px solid var(--pink);
  outline: none; caret-color: var(--neon);
}
#gate-form input::placeholder { color: rgba(57,255,20,0.45); }
#gate-form input:focus { border-color: var(--neon); box-shadow: 0 0 12px rgba(57,255,20,0.5); }

.gate-error { font-family: var(--pixel); font-size: 9px; color: var(--gold); min-height: 12px; line-height: 1.6; }

.btn-start {
  font-family: var(--pixel); font-size: 15px;
  padding: 20px 26px;
  background: var(--neon); color: var(--ink);
  border: none; cursor: pointer;
  box-shadow: 5px 5px 0 var(--ink);
  transition: transform 0.06s;
}
.btn-start:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--ink); }
.blink-slow { animation: blink 1.6s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.75; } }

.gate-fineprint { font-size: 12px; opacity: 0.75; margin-top: 6px; }

/* ---------------- HUD ---------------- */
.hud {
  position: sticky; top: 0; z-index: 20;
  background: var(--panel);
  backdrop-filter: blur(6px);
  border-bottom: 4px solid var(--neon);
  margin: -24px -16px 22px; padding: 12px 16px;
}
.hud-row {
  max-width: 980px; margin: 0 auto;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.hud-rank { display: flex; align-items: center; gap: 10px; min-width: 170px; }
.hud-rank-emoji { font-size: 30px; }
.hud-rank-title { font-family: var(--pixel); font-size: 11px; color: var(--gold); }
.hud-next-rank { font-size: 11px; opacity: 0.8; margin-top: 4px; }

.hud-center { flex: 1; min-width: 180px; }
.xp-bar {
  height: 20px; background: var(--ink);
  border: 3px solid #fff; box-shadow: 3px 3px 0 rgba(0,0,0,0.4);
  overflow: hidden;
}
.xp-fill {
  height: 100%; width: 0%;
  background: repeating-linear-gradient(90deg, var(--neon) 0 12px, #2bd60f 12px 24px);
  box-shadow: 0 0 14px rgba(57,255,20,0.8);
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
.xp-fill.maxed { animation: maxpulse 1.4s ease-in-out infinite; }
@keyframes maxpulse { 50% { filter: brightness(1.45); } }
.xp-label { font-family: var(--pixel); font-size: 9px; margin-top: 6px; color: var(--neon); }

.hud-right { display: flex; align-items: center; gap: 14px; }
.hud-streak {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--pixel); font-size: 16px;
}
.hud-streak.dead { filter: grayscale(1); opacity: 0.75; }
.flame { display: inline-block; font-size: 26px; animation: flame-bounce 0.7s ease-in-out infinite; }
@keyframes flame-bounce {
  0%, 100% { transform: translateY(0) scaleY(1); }
  40% { transform: translateY(-9px) scaleY(1.08); }
  55% { transform: translateY(0) scaleY(0.9) scaleX(1.08); }
  70% { transform: translateY(0) scaleY(1); }
}
.streak-count { color: var(--gold); }
.hud-day { font-family: var(--pixel); font-size: 10px; color: var(--cyan); }
.mute-btn { background: none; border: none; font-size: 20px; cursor: pointer; }

/* ---------------- MAP ---------------- */
.map-title {
  text-align: center; color: #fff; font-size: clamp(16px, 4vw, 24px);
  text-shadow: 3px 3px 0 var(--ink); margin-bottom: 26px;
}
.map-weeks { max-width: 980px; margin: 0 auto; display: flex; flex-direction: column; gap: 30px; }

.week-label {
  font-family: var(--pixel); font-size: clamp(9px, 2.2vw, 12px);
  color: var(--cyan); text-shadow: 2px 2px 0 var(--ink);
  margin-bottom: 14px;
}
.week-grid { display: flex; flex-wrap: wrap; gap: 14px; }

.node {
  position: relative;
  width: 86px; height: 86px;
  background: var(--panel);
  border: 3px solid var(--cyan);
  box-shadow: 4px 4px 0 var(--ink);
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  transition: transform 0.08s;
}
.node:hover { transform: translateY(-3px); }
.node-day { font-size: 26px; }
.node-num { font-family: var(--pixel); font-size: 9px; color: #fff; }

.node.boss { width: 104px; height: 104px; border-color: var(--gold); }
.node.boss .node-day { font-size: 34px; }

.node.done { border-color: var(--neon); box-shadow: 0 0 16px rgba(57,255,20,0.55), 4px 4px 0 var(--ink); }
.node.today { border-color: var(--neon); animation: today-pulse 1.2s ease-in-out infinite; }
@keyframes today-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(57,255,20,0.8), 4px 4px 0 var(--ink); }
  50% { box-shadow: 0 0 0 10px rgba(57,255,20,0), 4px 4px 0 var(--ink); }
}
.node-flag {
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  font-family: var(--pixel); font-size: 7px;
  background: var(--neon); color: var(--ink); padding: 3px 6px;
}
.node.missed { filter: grayscale(0.9); border-color: #888; }
.node.locked { opacity: 0.45; cursor: not-allowed; }
.node.shake { animation: shake 0.3s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.arcade-footer {
  text-align: center; margin-top: 60px;
  font-family: var(--pixel); font-size: 8px; line-height: 1.8; opacity: 0.8;
}
.arcade-footer a { color: var(--neon); text-decoration: none; }

/* +XP pop */
.xp-pop {
  position: fixed; top: 34%; left: 50%; transform: translateX(-50%);
  font-family: var(--pixel); font-size: 30px; color: var(--neon);
  text-shadow: 3px 3px 0 var(--ink);
  opacity: 0; pointer-events: none; z-index: 60;
}
.xp-pop.show { animation: xp-rise 1.3s ease-out forwards; }
@keyframes xp-rise {
  0% { opacity: 0; transform: translate(-50%, 20px) scale(0.6); }
  20% { opacity: 1; transform: translate(-50%, 0) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -70px) scale(1); }
}

/* ---------------- MISSION MODAL ---------------- */
.modal {
  display: none; position: fixed; inset: 0; z-index: 40;
  background: rgba(10, 0, 26, 0.85);
  padding: 20px; overflow-y: auto;
}
.modal.open { display: flex; align-items: flex-start; justify-content: center; }

.modal-card {
  position: relative;
  max-width: 680px; width: 100%;
  margin: 4vh 0 40px;
  background: var(--panel);
  border: 4px solid var(--pink);
  box-shadow: 8px 8px 0 var(--ink);
  padding: 28px 26px;
}
.modal-close {
  position: absolute; top: 12px; right: 12px;
  font-family: var(--pixel); font-size: 14px;
  background: var(--pink); color: #fff; border: none;
  width: 36px; height: 36px; cursor: pointer;
}
.mission-day { font-size: 9px; color: var(--cyan); margin-bottom: 12px; }
.mission-title { font-size: clamp(20px, 5vw, 27px); font-weight: 800; margin-bottom: 10px; }
.mission-status { font-size: 13px; color: var(--gold); min-height: 8px; margin-bottom: 8px; }
.mission-lesson { font-size: 15.5px; line-height: 1.65; margin-bottom: 18px; opacity: 0.95; }

.prompt-terminal { border: 3px solid var(--neon); background: #050510; margin-bottom: 14px; }
.terminal-bar {
  font-family: var(--pixel); font-size: 8px; color: #999;
  background: #16162a; padding: 8px 10px;
  display: flex; align-items: center; gap: 6px;
}
.terminal-bar span { width: 10px; height: 10px; border-radius: 50%; background: #555; display: inline-block; }
.terminal-bar span:nth-child(1) { background: #ff5f57; }
.terminal-bar span:nth-child(2) { background: #febc2e; }
.terminal-bar span:nth-child(3) { background: #28c840; }
.prompt-terminal pre {
  padding: 16px 14px;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 13.5px; line-height: 1.6;
  color: var(--neon);
  white-space: pre-wrap; word-break: break-word;
  max-height: 320px; overflow-y: auto;
}

.btn-copy {
  font-family: var(--pixel); font-size: 11px;
  padding: 14px 18px; width: 100%;
  background: var(--ink); color: var(--neon);
  border: 3px solid var(--neon); cursor: pointer;
  margin-bottom: 20px;
}
.btn-copy:active { transform: translate(2px, 2px); }

.mission-tip-label { font-size: 9px; color: var(--gold); margin-bottom: 8px; }
.mission-tip { font-size: 14px; line-height: 1.6; opacity: 0.9; margin-bottom: 22px; }

.btn-complete {
  font-family: var(--pixel); font-size: 13px;
  padding: 20px; width: 100%;
  background: linear-gradient(90deg, var(--neon), #2bd60f);
  color: var(--ink); border: none; cursor: pointer;
  box-shadow: 5px 5px 0 var(--ink);
}
.btn-complete:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--ink); }

/* ---------------- PROOF OF WORK ---------------- */
.proof-section { margin-bottom: 22px; }
.proof-explainer { font-size: 13.5px; opacity: 0.85; line-height: 1.55; margin-bottom: 10px; }
.proof-input {
  width: 100%; resize: vertical;
  background: #050510; color: #d8ffd0;
  border: 3px solid var(--cyan);
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 13px; line-height: 1.55;
  padding: 12px; outline: none;
}
.proof-input:focus { border-color: var(--neon); box-shadow: 0 0 10px rgba(57,255,20,0.4); }
.proof-counter { font-size: 8px; color: var(--cyan); margin-top: 8px; }

.btn-complete.locked, .btn-complete:disabled {
  background: #3a3a44; color: #9a9aa8;
  cursor: not-allowed; box-shadow: 4px 4px 0 rgba(0,0,0,0.4);
}
.btn-battle { background: linear-gradient(90deg, var(--pink), #c026d3); color: #fff; margin-top: 10px; }

/* ---------------- BOSS BATTLE ---------------- */
.overlay.battle { background: rgba(10, 0, 26, 0.96); overflow-y: auto; }
.overlay.battle.open { align-items: flex-start; }

.battle-frame {
  max-width: 640px; width: 100%;
  margin: 5vh auto 40px;
  background: var(--panel);
  border: 4px solid var(--gold);
  box-shadow: 8px 8px 0 var(--ink);
  padding: 22px;
}

.battle-header { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.battle-boss-emoji { font-size: 54px; line-height: 1; }
.battle-boss-emoji.shake { animation: boss-shake 0.4s; }
@keyframes boss-shake {
  20% { transform: translateX(-6px) rotate(-6deg); }
  50% { transform: translateX(6px) rotate(5deg); filter: brightness(1.6) hue-rotate(60deg); }
  80% { transform: translateX(-3px); }
}
.battle-boss-meta { flex: 1; }
.battle-boss-name { font-size: 11px; color: var(--gold); margin-bottom: 8px; }

.battle-hp { display: flex; gap: 5px; }
.hp-seg {
  flex: 1; height: 14px; max-width: 60px;
  background: #7a0c2e;
  border: 2px solid #fff;
}
.hp-seg.hit { background: #222; opacity: 0.5; }

.battle-flee {
  background: none; border: 2px solid rgba(255,255,255,0.35);
  color: rgba(255,255,255,0.7); font-size: 8px;
  padding: 8px 10px; cursor: pointer;
}

.battle-intro { display: none; text-align: center; padding: 18px 6px 10px; }
.battle-intro.open { display: block; }
.battle-intro.open ~ .battle-arena { display: none; }
.battle-intro-text { font-size: 16px; line-height: 1.65; margin-bottom: 24px; opacity: 0.95; }

.battle-arena.hurt { animation: arena-hurt 0.45s; }
@keyframes arena-hurt {
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); box-shadow: inset 0 0 60px rgba(255, 30, 60, 0.6); }
  70% { transform: translateX(-4px); }
}

.battle-status-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.battle-hearts { font-size: 20px; letter-spacing: 3px; }
.battle-combo { font-size: 10px; color: var(--gold); animation: combo-pop 0.3s; }
@keyframes combo-pop { 0% { transform: scale(2); } 100% { transform: scale(1); } }

.battle-timer { height: 12px; background: var(--ink); border: 2px solid #fff; margin-bottom: 16px; }
.battle-timer-fill { height: 100%; width: 100%; background: var(--neon); transition: width 0.1s linear; }
.battle-timer-fill.danger { background: #ff3355; }

.battle-mode-hint { font-size: 8px; color: var(--cyan); margin-bottom: 10px; }
.battle-question { font-size: 17px; font-weight: 800; line-height: 1.5; margin-bottom: 16px; }

.battle-answers { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.battle-answer {
  text-align: left;
  font-family: var(--body); font-size: 14.5px; line-height: 1.5;
  padding: 13px 14px;
  background: var(--ink); color: #fff;
  border: 3px solid var(--cyan);
  cursor: pointer;
  transition: transform 0.06s;
}
.battle-answer:hover { transform: translateX(3px); border-color: #fff; }
.battle-answer.right { border-color: var(--neon); background: #0a3a0a; }
.battle-answer.wrong { border-color: #ff3355; background: #3a0a14; animation: shake 0.3s; }
.battle-answer.order.right { opacity: 0.75; }
.battle-answer:disabled { cursor: default; }

.battle-feedback { min-height: 22px; font-size: 14px; font-weight: 600; line-height: 1.5; }
.battle-feedback.good { color: var(--neon); }
.battle-feedback.bad { color: #ff6680; }

.battle-result { display: none; text-align: center; padding: 20px 6px 10px; }
.battle-result.open { display: block; }
.battle-result-emoji { font-size: 60px; margin-bottom: 14px; }
.battle-result-title { font-size: clamp(16px, 4.5vw, 24px); color: #ff5f57; text-shadow: 3px 3px 0 var(--ink); margin-bottom: 12px; }
.battle-result-sub { font-size: 15px; line-height: 1.6; opacity: 0.9; margin-bottom: 24px; }

/* ---------------- OVERLAYS ---------------- */
.overlay {
  display: none; position: fixed; inset: 0; z-index: 50;
  background: rgba(10, 0, 26, 0.92);
  padding: 20px;
}
.overlay.open { display: flex; align-items: center; justify-content: center; }
.overlay-inner { text-align: center; max-width: 560px; }
.overlay-label { font-size: 12px; color: var(--cyan); margin-bottom: 16px; letter-spacing: 2px; }

.rankup-old { font-size: 16px; text-decoration: line-through; opacity: 0.6; margin-bottom: 12px; }
.rankup-new {
  font-size: clamp(18px, 5vw, 30px); color: var(--gold);
  text-shadow: 3px 3px 0 var(--ink);
  margin-bottom: 30px;
  animation: slam-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes slam-in {
  0% { transform: scale(3); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.crown {
  font-size: 64px;
  animation: crown-drop 1s cubic-bezier(0.34, 1.56, 0.64, 1), crown-glow 1.8s ease-in-out 1s infinite;
}
@keyframes crown-drop {
  0% { transform: translateY(-120px) rotate(-14deg); opacity: 0; }
  60% { transform: translateY(8px) rotate(4deg); opacity: 1; }
  100% { transform: translateY(0) rotate(0); }
}
@keyframes crown-glow {
  50% { filter: drop-shadow(0 0 18px var(--gold)) brightness(1.2); transform: rotate(3deg); }
}

/* streak death */
.tombstone {
  display: inline-block;
  background: #3a3a44;
  border: 4px solid #23232b;
  border-radius: 60px 60px 4px 4px;
  padding: 22px 30px 16px;
  margin-bottom: 24px;
  box-shadow: 6px 6px 0 rgba(0,0,0,0.5);
}
.tombstone-top { font-size: 52px; margin-bottom: 8px; }
.tombstone-text { font-size: 10px; color: #cfcfe0; line-height: 1.7; }
.death-title { font-size: clamp(15px, 4.4vw, 24px); color: #ff5f57; text-shadow: 3px 3px 0 var(--ink); margin-bottom: 14px; }
.death-sub { font-size: 15px; opacity: 0.85; margin-bottom: 28px; line-height: 1.6; }

/* ---------------- CERTIFICATE ---------------- */
#screen-certificate { display: none; }
#screen-certificate.active { display: flex; flex-direction: column; align-items: center; }

.cert-frame {
  max-width: 760px; width: 100%;
  background: #0d0322;
  border: 6px double var(--gold);
  outline: 3px solid var(--gold);
  outline-offset: 6px;
  padding: clamp(24px, 6vw, 56px);
  text-align: center;
  margin: 4vh auto 26px;
}
.cert-label { font-size: 9px; color: var(--gold); letter-spacing: 1px; margin-bottom: 22px; line-height: 1.8; }
.cert-heading { font-size: clamp(14px, 3.6vw, 22px); color: #fff; line-height: 1.7; margin-bottom: 26px; text-shadow: 2px 2px 0 var(--ink); }
.cert-presented { font-family: var(--pixel); font-size: 9px; opacity: 0.8; margin-bottom: 18px; }

.cert-name {
  font-size: clamp(34px, 8vw, 62px);
  font-weight: 800;
  margin-bottom: 20px;
  line-height: 1.15;
}
.glitter {
  background: linear-gradient(45deg, #b8860b 0%, #ffd700 25%, #fff8dc 50%, #ffd700 75%, #b8860b 100%);
  background-size: 300% 300%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: shimmer 3s ease-in-out infinite;
  position: relative;
}
@keyframes shimmer { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }

.cert-body { font-size: 16px; opacity: 0.9; margin-bottom: 14px; }
.cert-rank-line { margin-bottom: 30px; }
.cert-rank { font-family: var(--pixel); font-size: clamp(13px, 3vw, 18px); color: var(--gold); }

.cert-stats {
  display: flex; justify-content: center; gap: clamp(18px, 5vw, 48px);
  flex-wrap: wrap; margin-bottom: 30px;
}
.cert-stats > div { display: flex; flex-direction: column; gap: 8px; }
.cert-stat-label { font-family: var(--pixel); font-size: 8px; opacity: 0.7; }
.cert-stat { font-family: var(--pixel); font-size: 13px; color: var(--neon); }

.cert-sig { font-family: var(--pixel); font-size: 8px; opacity: 0.7; letter-spacing: 1px; line-height: 1.8; }

.cert-actions { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; padding-bottom: 40px; }
.cert-actions .btn-copy { width: auto; margin: 0; }

/* ---------------- DEBUG ---------------- */
.debug-strip {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 90;
  background: #000; color: var(--neon);
  font-family: var(--pixel); font-size: 9px;
  padding: 10px 14px; gap: 12px; align-items: center;
}
.debug-strip button, .debug-strip input {
  font-family: var(--pixel); font-size: 9px;
  background: var(--ink); color: var(--neon);
  border: 2px solid var(--neon); padding: 6px 10px; cursor: pointer;
}

/* ---------------- PRINT (certificate only) ---------------- */
@media print {
  body { background: #fff !important; }
  body * { visibility: hidden; }
  .cert-frame, .cert-frame * { visibility: visible; }
  .cert-frame {
    position: absolute; inset: 0; margin: 0;
    background: #fff !important;
    border-color: #b8860b; outline-color: #b8860b;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  .cert-heading, .cert-body, .cert-presented, .cert-label, .cert-sig, .cert-stat-label { color: #1a1a2e !important; opacity: 1; text-shadow: none; }
  .cert-stat { color: #0a7d00 !important; }
  .cert-rank { color: #b8860b !important; }
  .glitter { -webkit-text-fill-color: transparent; }
  .scanlines, .no-print { display: none !important; }
}

/* ---------------- MOBILE ---------------- */
@media (max-width: 480px) {
  .node { width: calc(25% - 11px); height: 76px; }
  .node.boss { width: calc(33% - 10px); height: 88px; }
  .hud-row { gap: 10px; }
  .hud-rank { min-width: 0; }
  .hud-next-rank { display: none; }
  .modal-card { padding: 22px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .flame, .blink-slow, .xp-fill.maxed, .node.today, .glitter, .crown { animation: none !important; }
}
