/* ============================================================
   RETRO PIXEL THEME
   ============================================================ */

:root {
  --bg: #0d0b16;
  --panel: #171425;
  --panel-edge: #2a2440;
  --ink: #eae6ff;
  --muted: #8f88b8;
  --yellow: #ffd23f;
  --red: #ff4757;
  --green: #2ed573;
  --blue: #54a0ff;
  --purple: #a55eea;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(84, 160, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(84, 160, 255, 0.045) 1px, transparent 1px);
  background-size: 32px 32px;
  color: var(--ink);
  font-family: "Press Start 2P", monospace;
  font-size: 12px;
  overflow-x: hidden;
  min-height: 100vh;
}

/* CRT overlay: scanlines + vignette */
#crt {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background:
    radial-gradient(ellipse at center, rgba(0,0,0,0) 55%, rgba(0,0,0,0.45) 100%),
    repeating-linear-gradient(0deg, rgba(0,0,0,0.20) 0 2px, transparent 2px 4px);
  animation: crt-flicker 4s infinite;
}
@keyframes crt-flicker {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.96; }
}

.hidden { display: none !important; }

/* ---------------- HUD ---------------- */

#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  background: rgba(13, 11, 22, 0.92);
  border-bottom: 4px solid #000;
  box-shadow: 0 4px 0 rgba(84, 160, 255, 0.25);
  z-index: 100;
}

#logo {
  color: var(--yellow);
  font-size: 20px;
  text-shadow: 3px 3px 0 #000;
  cursor: pointer;
  user-select: none;
  padding: 6px;
}

#hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
#hud-mission {
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 46vw;
}
#hud-quest { font-size: 10px; color: var(--blue); letter-spacing: 2px; }

#hud-right { display: flex; align-items: center; gap: 10px; }

#easter-coin {
  opacity: 0;
  cursor: pointer;
  color: var(--yellow);
  padding: 8px;
  user-select: none;
}
#hud-right:hover #easter-coin { opacity: 0.35; }
#easter-coin:hover { opacity: 1 !important; }

.hud-btn {
  font: inherit;
  font-size: 8px;
  background: var(--panel);
  color: var(--ink);
  border: 3px solid #000;
  box-shadow: 0 3px 0 #000;
  padding: 8px 10px;
  cursor: pointer;
}
.hud-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #000; }

/* ---------------- screens ---------------- */

#stage { padding-top: 56px; min-height: 100vh; position: relative; }

.screen { min-height: calc(100vh - 56px); position: relative; }

/* full-screen flash when answers are right/wrong */
#stage::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  z-index: 90;
}
#stage.flash-red::after  { background: rgba(255, 71, 87, 0.30);  animation: fadeout 0.55s forwards; }
#stage.flash-green::after{ background: rgba(46, 213, 115, 0.25); animation: fadeout 0.55s forwards; }
@keyframes fadeout { from { opacity: 1; } to { opacity: 0; } }

/* ---------------- opener ---------------- */

#screen-opener { overflow: hidden; }
#wall-canvas {
  position: fixed;
  inset: 0;
  touch-action: none;
  display: block;
}
body.armed #wall-canvas { cursor: none; }

#toast-layer {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  z-index: 120;
  pointer-events: none;
  width: min(90vw, 560px);
  text-align: center;
}
.toast {
  display: inline-block;
  background: var(--panel);
  border: 4px solid #000;
  box-shadow: 0 6px 0 #000, inset 0 0 0 3px var(--panel-edge);
  color: var(--yellow);
  font-size: 10px;
  line-height: 1.8;
  padding: 14px 18px;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ---------------- quiz ---------------- */

#screen-quiz {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 80px;
}

.panel {
  background: var(--panel);
  border: 4px solid #000;
  box-shadow: 0 8px 0 #000, inset 0 0 0 4px var(--panel-edge);
  padding: 28px;
  width: 100%;
  max-width: 720px;
}

#quiz-box.shake { animation: shake 0.4s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-12px); }
  40% { transform: translateX(10px); }
  60% { transform: translateX(-7px); }
  80% { transform: translateX(5px); }
}

#quiz-progress {
  color: var(--blue);
  font-size: 9px;
  letter-spacing: 2px;
  margin-bottom: 20px;
}

#quiz-text {
  font-size: 13px;
  line-height: 2;
  min-height: 96px;
  color: var(--ink);
}
.typing::after {
  content: "▋";
  color: var(--yellow);
  animation: blink 0.7s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

#quiz-hint {
  margin-top: 18px;
  color: var(--yellow);
  font-size: 9px;
  line-height: 2;
  background: rgba(255, 210, 63, 0.07);
  border-left: 4px solid var(--yellow);
  padding: 12px 14px;
}

#quiz-form {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  flex-wrap: wrap;
}

#quiz-input {
  flex: 1;
  min-width: 200px;
  background: #0a0812;
  color: var(--ink);
  border: 4px solid #000;
  box-shadow: inset 0 0 0 2px #3a3355;
  padding: 14px;
  font: inherit;
  font-size: 11px;
  text-transform: uppercase;
  outline: none;
}
#quiz-input:focus { box-shadow: inset 0 0 0 2px var(--yellow); }
#quiz-input::placeholder { color: #565078; }

.btn {
  font: inherit;
  font-size: 10px;
  background: var(--yellow);
  color: #111;
  border: 4px solid #000;
  box-shadow: 0 6px 0 #000;
  padding: 14px 18px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #000; }
.btn-secondary { background: var(--blue); color: #fff; }
.btn-small { font-size: 8px; padding: 10px 12px; box-shadow: 0 4px 0 #000; }

#quiz-feedback {
  margin-top: 18px;
  font-size: 10px;
  min-height: 18px;
  color: var(--red);
}
#quiz-feedback.good { color: var(--green); }

/* ---------------- reveal ---------------- */

#screen-reveal { padding: 30px 16px 90px; }

#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 80;
}

#reveal-title {
  text-align: center;
  font-size: clamp(15px, 4vw, 28px);
  color: var(--yellow);
  text-shadow: 4px 4px 0 #000;
  margin: 26px auto 44px;
  max-width: 900px;
  line-height: 1.8;
}

#reveal-cards {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 1100px;
  margin: 0 auto;
}

.reveal-card {
  background: var(--panel);
  border: 4px solid #000;
  box-shadow: 0 8px 0 #000, inset 0 0 0 4px var(--panel-edge);
  padding: 24px;
  width: 300px;
  opacity: 0;
  transform: translateY(34px) scale(0.9);
}
.reveal-card.flip-in { animation: flipIn 0.6s cubic-bezier(0.2, 1.4, 0.4, 1) forwards; }
@keyframes flipIn { to { opacity: 1; transform: none; } }

.rc-label { color: var(--blue); font-size: 10px; letter-spacing: 4px; margin-bottom: 14px; }
.rc-icon { font-size: 28px; }
.rc-value { font-size: 13px; line-height: 1.9; margin-top: 12px; }
.rc-detail { font-size: 9px; line-height: 2; color: var(--muted); margin-top: 12px; }
.rc-chips { margin-top: 12px; }
.rc-extra { margin-top: 16px; }

.who-chip {
  display: inline-block;
  background: var(--panel-edge);
  border: 2px solid #000;
  padding: 7px 10px;
  margin: 4px 4px 0 0;
  font-size: 9px;
}

#reveal-media {
  display: flex;
  gap: 22px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 54px auto 0;
  max-width: 1100px;
}

.polaroid {
  background: #f5f0e6;
  padding: 12px 12px 14px;
  border: 4px solid #000;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.6);
  color: #111;
}
.polaroid img {
  width: 240px;
  height: 180px;
  object-fit: cover;
  display: block;
  background: #d8d2c4;
}
.polaroid .caption { font-size: 8px; margin-top: 10px; color: #333; line-height: 1.6; }

.photo-slot {
  width: 248px;
  height: 188px;
  border: 4px dashed #4a4370;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 8px;
  line-height: 1.8;
  color: #7a739f;
  padding: 12px;
  background: rgba(255, 255, 255, 0.03);
}

#reveal-stats {
  margin: 44px auto 0;
  text-align: center;
  font-size: 9px;
  line-height: 2.2;
  color: var(--muted);
  max-width: 680px;
}

#reveal-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 42px 0 30px;
}

/* ---------------- footer / misc ---------------- */

#footer {
  position: fixed;
  bottom: 8px;
  right: 12px;
  z-index: 100;
  font-size: 8px;
  color: #4a4370;
}
#reset-save { cursor: pointer; }
#reset-save:hover { color: var(--red); text-decoration: underline; }

/* rainbow mode easter egg */
body.rainbow #hud,
body.rainbow .btn,
body.rainbow .reveal-card { animation: hue 1.2s linear infinite; }
@keyframes hue { to { filter: hue-rotate(360deg); } }

/* ---------------- responsive ---------------- */

@media (max-width: 640px) {
  .panel { padding: 18px; }
  #quiz-text { font-size: 11px; min-height: 110px; }
  #quiz-input { font-size: 10px; }
  .reveal-card { width: 100%; }
  #hud-mission { max-width: 34vw; }
  #toast-layer { bottom: 72px; }
}
