@import url("https://fonts.googleapis.com/css2?family=VT323&family=Press+Start+2P&display=swap");

* { box-sizing: border-box; }

/* Accessibility utility — content stays in the accessibility tree
   (and therefore search-index-able and screen-reader-readable) but is
   visually hidden. Standard sr-only pattern, not display:none, so it
   isn't penalized as cloaking. */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #05060a;
  color: #c8ffd4;
  font-family: "VT323", "Courier New", monospace;
  overflow: hidden;
  user-select: none;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---- boot screen ---- */
#boot {
  text-align: center;
  padding: 32px;
}
.crt {
  border: 2px solid #1aff7a;
  padding: 28px 48px;
  box-shadow: 0 0 40px #1aff7a55, inset 0 0 60px #1aff7a22;
  background: radial-gradient(ellipse at center, #021006 0%, #000 100%);
  position: relative;
}
.crt::after {
  content: "";
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0,0,0,0) 0,
    rgba(0,0,0,0) 2px,
    rgba(0,0,0,0.18) 3px,
    rgba(0,0,0,0) 4px
  );
  pointer-events: none;
}
.logo {
  color: #1aff7a;
  font-size: 12px;
  line-height: 1.05;
  text-shadow: 0 0 8px #1aff7a;
  margin: 0 0 12px;
}
#boot h1 {
  font-family: "Press Start 2P", monospace;
  color: #e6ffe6;
  font-size: 22px;
  margin: 18px 0 4px;
  text-shadow: 0 0 12px #1aff7a;
}
#boot h2 {
  color: #8effb3;
  font-size: 22px;
  margin: 0 0 16px;
  font-weight: normal;
}
#boot .warn {
  color: #ffbb55;
  max-width: 520px;
  margin: 0 auto 24px;
  font-size: 20px;
  line-height: 1.2;
}
.boot-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
#startBtn, #lbBtn {
  font-family: "Press Start 2P", monospace;
  background: transparent;
  border: 2px solid #1aff7a;
  color: #1aff7a;
  padding: 14px 22px;
  cursor: pointer;
  font-size: 14px;
  letter-spacing: 1px;
  transition: all .12s;
  text-shadow: 0 0 6px #1aff7a;
}
#startBtn:hover, #lbBtn:hover {
  background: #1aff7a;
  color: #021006;
  box-shadow: 0 0 24px #1aff7a;
}
#lbBtn {
  border-color: #ffd966;
  color: #ffd966;
  text-shadow: 0 0 6px #ffd966;
}
#lbBtn:hover {
  background: #ffd966;
  color: #2a1a06;
  box-shadow: 0 0 24px #ffd966;
}
.hint {
  color: #6fc28a;
  margin-top: 20px;
  font-size: 18px;
}

/* Mobile-only "play in landscape" banner — visible on the boot screen */
.mobile-tip { display: none; }
@media (pointer: coarse), (max-width: 820px) {
  .mobile-tip {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: rgba(255, 217, 102, 0.12);
    border: 2px solid #ffd966;
    color: #ffd966;
    padding: 12px 16px;
    margin: 14px auto 18px;
    font-family: "Press Start 2P", monospace;
    font-size: 12px;
    text-shadow: 0 0 6px #ffd96688;
    max-width: 92%;
    animation: tipPulse 2.5s ease-in-out infinite;
  }
  .mobile-tip b { color: #ffe49a; }
  .mobile-tip .rot-icon {
    font-size: 22px;
    display: inline-block;
    animation: tipRotate 2.8s ease-in-out infinite;
  }
}
@keyframes tipPulse {
  0%, 100% { box-shadow: 0 0 0 rgba(255, 217, 102, 0); }
  50%      { box-shadow: 0 0 22px rgba(255, 217, 102, 0.4); }
}
@keyframes tipRotate {
  0%, 55%, 100% { transform: rotate(0deg); }
  70%, 90%      { transform: rotate(-90deg); }
}

/* ---- game ---- */
/* Default sizing — JS overrides on resize/orientationchange.
   This is the desktop fallback. */
#game {
  position: relative;
  width: 960px;
  height: 540px;
  max-width: 100vw;
  max-height: 100vh;
}
canvas#stage {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  background: #000;
  box-shadow: 0 0 60px #1aff7a33;
  touch-action: none;
}

#hud {
  position: absolute;
  top: 12px; left: 12px; right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  font-family: "Press Start 2P", monospace;
  font-size: 11px;
  color: #d3ffe5;
  text-shadow: 0 0 6px #000;
  gap: 12px;
}
#hudLeft, #hudCenter, #hudRight {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
#hudCenter { align-items: center; flex: 1; }
#hudRight  { align-items: flex-end; }
#timerWrap {
  width: 260px;
  height: 18px;
  background: rgba(0,0,0,0.5);
  border: 1px solid #1aff7a;
  position: relative;
  overflow: hidden;
}
#timerBar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #1aff7a, #d9ff66);
  transition: width .1s linear, background .2s;
}
#timerText {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  font-size: 12px;
  color: #021006;
  font-family: "Press Start 2P", monospace;
  mix-blend-mode: difference;
  color: #fff;
}
#hudStats {
  display: flex;
  gap: 18px;
  font-family: "Press Start 2P", monospace;
  font-size: 11px;
  color: #c8ffd4;
}
#hudStats b { color: #ffd966; font-weight: normal; }

/* ---- dialog ----
   Anchored to the bottom of the canvas so the room + stress visuals
   stay visible behind it (no fullscreen dim, no backdrop blur). */
[hidden] { display: none !important; }
#dialog {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
}
#dialog .panel { pointer-events: auto; }

#result {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.35);
}

.panel {
  background: rgba(5, 11, 8, 0.86);
  border: 2px solid #1aff7a;
  box-shadow: 0 0 30px #1aff7a66, 0 8px 0 #021006;
  padding: 16px 20px;
  width: 100%;
  max-width: 880px;
  color: #d8ffe6;
  font-size: 19px;
  line-height: 1.2;
}
#dialog .panel {
  backdrop-filter: blur(1px);
}
.scenario {
  color: #ffd58a;
  margin-bottom: 10px;
  white-space: pre-wrap;
  font-size: 18px;
}
.question {
  color: #b8f5ff;
  margin-bottom: 12px;
  border-top: 1px dashed #1aff7a55;
  padding-top: 8px;
  font-style: italic;
  font-size: 18px;
}
.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.choice {
  background: rgba(10, 26, 16, 0.92);
  border: 2px solid #1aff7a;
  color: #c8ffd4;
  padding: 10px 12px;
  font-family: "VT323", monospace;
  font-size: 18px;
  text-align: left;
  cursor: pointer;
  transition: all .1s;
  line-height: 1.15;
}
.choice:hover {
  background: #1aff7a;
  color: #021006;
  transform: translateY(-1px);
}
.choice:disabled {
  opacity: .5; cursor: not-allowed;
}
.loading {
  margin-top: 14px;
  color: #8effb3;
  font-size: 18px;
}
.dots {
  display: inline-block;
  animation: blink 1.2s infinite steps(3);
}
@keyframes blink {
  0% { opacity: 0; }
  50% { opacity: 1; }
}

#result .panel {
  text-align: center;
  border-color: #ff3355;
  box-shadow: 0 0 30px #ff335599;
  cursor: pointer;
}
#result.win .panel {
  border-color: #1aff7a;
  box-shadow: 0 0 30px #1aff7a99;
}
.continue-cta {
  display: inline-block;
  color: #1aff7a;
  font-family: "Press Start 2P", monospace;
  font-size: 14px;
  letter-spacing: 1px;
  text-shadow: 0 0 8px #1aff7a;
  animation: ctaPulse 1.1s ease-in-out infinite;
}
#result.lose .continue-cta { color: #ff6677; text-shadow: 0 0 8px #ff3355; }
@keyframes ctaPulse {
  0%, 100% { opacity: 1; transform: translateX(0); }
  50%      { opacity: 0.55; transform: translateX(2px); }
}
#resultText {
  font-size: 26px;
  margin-bottom: 18px;
  color: #ffe6e6;
  white-space: pre-wrap;
}
#result.win #resultText { color: #d6ffe2; }
#redirecting {
  font-family: "Press Start 2P", monospace;
  font-size: 16px;
  color: #ffbb55;
  letter-spacing: 1px;
}

/* ---- stress visuals (added by JS) ---- */
.stress-1 #stage { filter: hue-rotate(-8deg) contrast(1.05) saturate(1.1); }
.stress-2 #stage { filter: hue-rotate(-20deg) contrast(1.15) saturate(1.3); }
.stress-3 #stage { filter: hue-rotate(-40deg) contrast(1.3) saturate(1.6); }
.stress-3 #timerBar { background: linear-gradient(90deg, #ff3355, #ffbb33); }
.stress-2 #timerBar { background: linear-gradient(90deg, #ffaa44, #ffd966); }

@keyframes shake {
  0%,100% { transform: translate(0,0); }
  20%  { transform: translate(-3px, 1px); }
  40%  { transform: translate(2px, -2px); }
  60%  { transform: translate(-2px, 2px); }
  80%  { transform: translate(3px, 1px); }
}
.stress-3 canvas#stage { animation: shake .12s infinite; }
.stress-2 canvas#stage { animation: shake .25s infinite; }

@keyframes glitch {
  0%   { clip-path: inset(0 0 0 0); }
  20%  { clip-path: inset(20% 0 30% 0); transform: translate(4px); }
  40%  { clip-path: inset(60% 0 5% 0);  transform: translate(-3px); }
  60%  { clip-path: inset(10% 0 75% 0); transform: translate(2px); }
  80%  { clip-path: inset(45% 0 25% 0); transform: translate(-2px); }
  100% { clip-path: inset(0 0 0 0); }
}

/* ---- game over / leaderboard ---- */
#gameover {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.78);
}
#gameover .panel {
  max-width: 520px;
  border-color: #ff3355;
  box-shadow: 0 0 40px #ff335599;
  background: rgba(8, 4, 6, 0.96);
}
.gameover-title {
  font-family: "Press Start 2P", monospace;
  font-size: 22px;
  color: #ff3355;
  text-align: center;
  margin-bottom: 12px;
  text-shadow: 0 0 12px #ff335588;
}
#finalStats {
  text-align: center;
  font-size: 20px;
  color: #ffd966;
  margin-bottom: 14px;
  line-height: 1.4;
}
#finalStats b { color: #fff; }
#finalStats .run-tag {
  display: inline-block;
  font-family: "Press Start 2P", monospace;
  font-size: 9px;
  color: #8effb3;
  background: rgba(26, 255, 122, 0.1);
  border: 1px solid #1aff7a55;
  padding: 4px 8px;
  margin-top: 4px;
  letter-spacing: 1px;
}
.lb-save {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.lb-save input {
  flex: 1;
  background: #0a1a10;
  border: 2px solid #1aff7a;
  color: #d8ffe6;
  font-family: "Press Start 2P", monospace;
  font-size: 12px;
  padding: 8px 10px;
  text-transform: uppercase;
}
.lb-save input:focus { outline: none; box-shadow: 0 0 0 2px #1aff7a55; }
.lb-save button {
  background: #1aff7a;
  border: 2px solid #1aff7a;
  color: #021006;
  font-family: "Press Start 2P", monospace;
  font-size: 12px;
  padding: 8px 14px;
  cursor: pointer;
}
.lb-save button:hover { background: #d9ff66; border-color: #d9ff66; }
.lb-save button:disabled { opacity: 0.5; cursor: not-allowed; }
.lb-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  font-family: "Press Start 2P", monospace;
  font-size: 10px;
  color: #8effb3;
  margin-bottom: 10px;
}
.lb-sort {
  background: transparent;
  border: 1px solid #1aff7a55;
  color: #8effb3;
  font-family: "Press Start 2P", monospace;
  font-size: 10px;
  padding: 4px 8px;
  cursor: pointer;
}
.lb-sort.active {
  background: #1aff7a;
  color: #021006;
  border-color: #1aff7a;
}
.lb-badge {
  margin-left: auto;
  font-family: "Press Start 2P", monospace;
  font-size: 9px;
  padding: 3px 6px;
  border: 1px solid #1aff7a;
  color: #1aff7a;
  letter-spacing: 1px;
}
.lb-badge.local {
  border-color: #ffbb55;
  color: #ffbb55;
}
#leaderboardList {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid #1aff7a33;
  background: rgba(0,0,0,0.35);
}
#leaderboardList li {
  display: grid;
  grid-template-columns: 28px 1fr 88px 88px;
  gap: 8px;
  padding: 6px 10px;
  font-size: 18px;
  border-bottom: 1px dashed #1aff7a22;
  align-items: center;
}
#gameover.viewonly { background: #02060a; }
#gameover.viewonly #gameoverTitle { color: #ffd966; text-shadow: 0 0 12px #ffd96688; }
#gameover.viewonly .panel { border-color: #ffd966; box-shadow: 0 0 40px #ffd96666; }
#gameover.viewonly #finalStats,
#gameover.viewonly .lb-save,
#gameover.viewonly #playAgain { display: none; }
#closeLb {
  width: 100%;
  background: transparent;
  border: 2px solid #ffd966;
  color: #ffd966;
  font-family: "Press Start 2P", monospace;
  font-size: 14px;
  padding: 10px;
  cursor: pointer;
  letter-spacing: 1px;
}
#closeLb:hover { background: #ffd966; color: #2a1a06; }
#leaderboardList li:nth-child(odd) { background: rgba(26,255,122,0.04); }
#leaderboardList .rank { color: #ffbb55; font-family: "Press Start 2P", monospace; font-size: 10px; }
#leaderboardList .nm   { color: #d8ffe6; text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#leaderboardList .lb-tag {
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  color: #8effb3aa;
  margin-left: 6px;
  letter-spacing: 0.5px;
}
#leaderboardList .dr   { color: #1aff7a; text-align: right; }
#leaderboardList .tm   { color: #ffd966; text-align: right; }
#leaderboardList .me   { background: rgba(255, 217, 102, 0.12); }
#leaderboardList .empty { display: block; padding: 16px; text-align: center; color: #6fc28a; font-size: 18px; }
.gameover-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
#playAgain, #changeMode {
  width: 100%;
  background: transparent;
  border: 2px solid #1aff7a;
  color: #1aff7a;
  font-family: "Press Start 2P", monospace;
  font-size: 13px;
  padding: 10px;
  cursor: pointer;
  letter-spacing: 1px;
}
#playAgain:hover { background: #1aff7a; color: #021006; }
#changeMode {
  border-color: #ffd966;
  color: #ffd966;
}
#changeMode:hover { background: #ffd966; color: #2a1a06; }

/* ---- on-screen touch pad (lives at the bottom of the viewport on mobile) ---- */
#touchPad {
  display: none;
  position: fixed;
  left: 0; right: 0;
  bottom: env(safe-area-inset-bottom, 0);
  height: 90px;
  padding: 0 16px;
  align-items: center;
  justify-content: space-between;
  z-index: 50;
  background: linear-gradient(to top, rgba(0,0,0,0.5), rgba(0,0,0,0));
  pointer-events: none;
}
#touchPad button {
  pointer-events: auto;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 2px solid #1aff7a;
  background: rgba(5, 15, 8, 0.55);
  color: #1aff7a;
  font-size: 22px;
  font-family: "Press Start 2P", monospace;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  backdrop-filter: blur(2px);
  box-shadow: 0 0 16px #1aff7a44;
  transition: transform .06s, background .06s;
}
#touchPad button:active,
#touchPad button.pressed {
  background: #1aff7a;
  color: #021006;
  transform: scale(0.92);
  box-shadow: 0 0 24px #1aff7a;
}
/* Two left-side buttons grouped, jump on the right */
#tcLeft  { order: 0; }
#tcRight { order: 1; margin-right: auto; margin-left: 12px; }
#tcJump  { order: 2; }

/* === MOBILE LAYOUT === */
@media (pointer: coarse), (max-width: 820px) {
  body {
    display: block;
    padding: 0;
    overflow: hidden;
  }
  /* When the boot screen is showing, allow body to scroll so the
     full title card + pickers + buttons + credits are reachable on
     short landscape phones. During gameplay #boot is hidden and
     overflow: hidden kicks back in. */
  body:has(#boot:not([hidden])) { overflow: auto; }
  #touchPad { display: flex; }

  /* #game position/size is driven by JS (sizeGame) — keep CSS minimal
     so it doesn't fight the JS-applied inline styles. */
  #game {
    position: fixed;
    max-width: none;
    max-height: none;
  }

  /* HUD: anchored to the viewport with z-index above the dialog so the
     timer is ALWAYS visible (even while reading the scenario). */
  #hud {
    position: fixed;
    top: env(safe-area-inset-top, 8px);
    left: 8px;
    right: 8px;
    font-size: 13px;
    padding: 0;
    z-index: 80;
    opacity: 0.92;
  }
  #timerWrap {
    width: 36vw;
    max-width: 240px;
    height: 22px;
    background: rgba(0, 0, 0, 0.45);
    border-color: rgba(26, 255, 122, 0.8);
  }
  #timerBar { opacity: 0.85; }
  #timerText { font-size: 14px; }
  #hudStats { flex-direction: column; gap: 3px; font-size: 12px; }
  #roundText { font-size: 12px; }

  /* Dialog: fixed bottom sheet that lives in the VIEWPORT, not inside
     #game — so its size is independent of the canvas. Capped at 90% of
     screen height with scroll, and z-indexed above the touch pad. */
  #dialog {
    position: fixed;
    left: 0;
    right: 0;
    /* leave the top strip free so the HUD/timer is visible above */
    top: 44px;
    bottom: calc(env(safe-area-inset-bottom, 0) + 4px);
    z-index: 60;
    pointer-events: none;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    padding: 0 8px;
  }
  #dialog .panel {
    pointer-events: auto;
    max-height: 100%;
    overflow-y: auto;
    padding: 14px 16px;
    width: 100%;
    max-width: 680px;
    -webkit-overflow-scrolling: touch;
  }
  .scenario { font-size: 16px; line-height: 1.25; margin-bottom: 10px; }
  .question { font-size: 16px; line-height: 1.25; padding-top: 8px; margin-bottom: 10px; }
  .choice { font-size: 15px; padding: 12px 14px; min-height: 56px; line-height: 1.2; }
  .choices { gap: 10px; }
  #loading { font-size: 14px; margin-top: 8px; }

  /* On phone landscape (short, wide) stack the A/B options so they're
     readable instead of two narrow columns. */
  @media (orientation: landscape) and (max-height: 480px) {
    .choices { grid-template-columns: 1fr; }
    .choice { min-height: 48px; padding: 10px 12px; }
    .scenario { font-size: 14px; margin-bottom: 6px; }
    .question { font-size: 14px; margin-bottom: 6px; padding-top: 6px; }
  }

  /* While the dialog or result modal is up, hide the touch pad so it
     can't sit on top of the question text or the choice buttons. */
  body.modal-open #touchPad { display: none; }

  /* Result + gameover panels: fit the screen, scroll if needed */
  #result, #gameover {
    align-items: flex-start;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 0;
  }
  #result .panel,
  #gameover .panel {
    width: calc(100vw - 24px);
    max-width: 520px;
    padding: 16px;
    margin: auto;
  }
  .gameover-title { font-size: 18px; }
  #finalStats { font-size: 16px; }
  #leaderboardList li { grid-template-columns: 22px 1fr 64px 64px; font-size: 14px; gap: 6px; padding: 5px 8px; }
  #leaderboardList { max-height: 38vh; }
  .lb-save input, .lb-save button { font-size: 11px; padding: 8px; }
  .lb-controls { flex-wrap: wrap; row-gap: 6px; }
  .lb-badge { margin-left: 0; }

  /* Short landscape phones (~iPhone in landscape, ≤480px tall):
     trim every section so PLAY AGAIN is visible without scrolling.
     The leaderboard list itself stays scrollable (≈3 rows). */
  @media (orientation: landscape) and (max-height: 480px) {
    #result .panel,
    #gameover .panel { padding: 10px 12px; }
    .gameover-title { font-size: 14px; margin-bottom: 4px; }
    #finalStats { font-size: 12px; margin-bottom: 6px; line-height: 1.2; }
    .lb-save { margin-bottom: 6px; }
    .lb-save input, .lb-save button { font-size: 10px; padding: 6px 8px; }
    .lb-controls { font-size: 9px; margin-bottom: 6px; }
    .lb-sort { padding: 3px 6px; font-size: 9px; }
    #leaderboardList { max-height: 86px; margin: 0 0 8px; }
    #leaderboardList li { font-size: 12px; padding: 4px 8px; grid-template-columns: 20px 1fr 56px 56px; }
    #playAgain, #closeLb { font-size: 11px; padding: 7px; }
  }

  /* Boot screen */
  #boot { padding: 14px; width: 100%; }
  .crt { padding: 18px 14px; }
  .logo { font-size: 8px; }
  #boot h1 { font-size: 18px; }
  #boot h2 { font-size: 17px; }
  #boot .warn { font-size: 16px; max-width: 100%; }
  #startBtn, #lbBtn { font-size: 11px; padding: 12px 14px; }
  .hint { font-size: 13px; }

  /* Landscape phones (short, wide) — compact every line of the boot
     screen so the whole card fits without scrolling. */
  @media (orientation: landscape) and (max-height: 500px) {
    #boot { padding: 8px; min-height: 100vh; }
    .crt { padding: 10px 14px; }
    .logo { font-size: 6px; line-height: 1; margin: 0 0 6px; }
    #boot h1 { font-size: 14px; margin: 6px 0 2px; }
    #boot h2 { font-size: 14px; margin: 0 0 6px; }
    #boot .warn { font-size: 13px; margin: 0 0 8px; line-height: 1.2; }
    .mobile-tip { font-size: 10px; padding: 6px 10px; margin: 6px 0; gap: 8px; }
    .mobile-tip .rot-icon { font-size: 16px; }
    .boot-pickers { gap: 8px; margin: 6px 0; }
    .picker { gap: 2px; }
    .picker-label { font-size: 7px; }
    .picker select { min-width: 130px; font-size: 14px; padding: 4px 6px; }
    .boot-buttons { gap: 8px; }
    #startBtn, #lbBtn { font-size: 10px; padding: 8px 10px; }
    .hint { font-size: 11px; margin-top: 8px; }
    .creator { margin-top: 6px; font-size: 12px; }
  }
}

/* ---- creator footer ---- */
.creator {
  margin-top: 16px;
  color: #6fc28a;
  font-size: 14px;
  font-family: "VT323", monospace;
  opacity: 0.8;
}
.creator a {
  color: #1aff7a;
  text-decoration: none;
  border-bottom: 1px dashed #1aff7a55;
}
.creator a:hover { color: #d9ff66; border-bottom-color: #d9ff66; }

/* ---- "Rotate to landscape" overlay (portrait phones only) ---- */
#rotateHint {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #02060a;
  color: #1aff7a;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  gap: 14px;
}
#rotateHint .rotate-icon {
  font-size: 92px;
  line-height: 1;
  color: #1aff7a;
  text-shadow: 0 0 24px #1aff7a;
  animation: rotateNudge 2.4s ease-in-out infinite;
  transform-origin: center;
}
@keyframes rotateNudge {
  0%, 60%, 100% { transform: rotate(0deg); }
  70% { transform: rotate(-90deg); }
  90% { transform: rotate(-90deg); }
}
#rotateHint h2 {
  font-family: "Press Start 2P", monospace;
  font-size: 16px;
  margin: 8px 0;
  text-shadow: 0 0 8px #1aff7a;
}
#rotateHint p {
  color: #8effb3;
  font-size: 18px;
  max-width: 320px;
  margin: 0;
}
#playAnyway {
  margin-top: 18px;
  background: transparent;
  border: 2px solid #ffd966;
  color: #ffd966;
  font-family: "Press Start 2P", monospace;
  font-size: 11px;
  padding: 12px 14px;
  cursor: pointer;
}
#playAnyway:active { background: #ffd966; color: #2a1a06; }

@media (orientation: portrait) and (max-width: 820px) {
  #rotateHint:not(.dismissed) { display: flex; }
}

/* Hide letterboxed scrollbars and lock the page on mobile */
html, body { overscroll-behavior: none; }

/* ============== NEW SPRINT: pickers, streak, lifelines, filters ============== */

/* ---- Boot screen theme/difficulty pickers ---- */
.boot-pickers {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 14px auto 16px;
}
.picker {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.picker-label {
  font-family: "Press Start 2P", monospace;
  font-size: 9px;
  color: #8effb3;
  letter-spacing: 1px;
}
.picker select {
  background: #021006;
  border: 2px solid #1aff7a;
  color: #d8ffe6;
  font-family: "VT323", monospace;
  font-size: 18px;
  padding: 6px 10px;
  cursor: pointer;
  min-width: 200px;
}
.picker select:focus {
  outline: none;
  box-shadow: 0 0 0 2px #1aff7a55;
}

/* ---- HUD: streak badge, boss banner, lifelines, mute ---- */
#streakBadge {
  background: rgba(0, 0, 0, 0.55);
  border: 2px solid #ff9933;
  color: #ffcc66;
  padding: 4px 10px;
  font-family: "Press Start 2P", monospace;
  font-size: 11px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-shadow: 0 0 8px #ff9933;
  animation: streakPulse 0.9s ease-in-out infinite;
}
@keyframes streakPulse {
  0%, 100% { box-shadow: 0 0 0 #ff993300; }
  50%      { box-shadow: 0 0 16px #ff993399; }
}
#streakBadge[hidden] { display: none; }

#bossBanner {
  background: linear-gradient(90deg, #ff3355, #ff8833);
  color: #fff;
  font-family: "Press Start 2P", monospace;
  font-size: 13px;
  padding: 6px 14px;
  border: 2px solid #fff;
  letter-spacing: 2px;
  text-shadow: 0 0 8px #000;
  animation: bossThrob 0.6s ease-in-out infinite;
}
#bossBanner[hidden] { display: none; }
@keyframes bossThrob {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.06); }
}

#lifelines {
  display: flex;
  gap: 6px;
  pointer-events: auto;
}
.lifeline {
  width: 38px;
  height: 38px;
  background: rgba(0, 0, 0, 0.55);
  border: 2px solid #1aff7a;
  color: #1aff7a;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .1s, background .1s, opacity .15s;
  border-radius: 4px;
  -webkit-tap-highlight-color: transparent;
}
.lifeline:hover:not(:disabled) { background: #1aff7a; color: #021006; }
.lifeline:active:not(:disabled) { transform: scale(0.92); }
/* Fully consumed (.used) — dimmed AND no wiggle */
.lifeline.used {
  opacity: 0.32;
  cursor: not-allowed;
  filter: grayscale(0.7);
  border-color: #444;
  color: #666;
  background: transparent;
  animation: none !important;
}
/* Temporarily disabled (still unused, e.g. during walking/typewriter) —
   slightly faded but still wiggles so players notice them. */
.lifeline:disabled:not(.used) {
  cursor: default;
  opacity: 0.78;
}

/* Low-key wiggle so players notice the lifelines. The "interesting"
   part of the keyframe lives in the last ~5% so the button sits still
   most of the time, then shakes briefly. Staggered per button. */
@keyframes lifelineWiggle {
  0%, 94%, 100% { transform: rotate(0deg);  }
  95%           { transform: rotate(-12deg); }
  96%           { transform: rotate(10deg);  }
  97%           { transform: rotate(-7deg);  }
  98%           { transform: rotate(4deg);   }
}
.lifeline:not(.used) {
  animation: lifelineWiggle 11s ease-in-out infinite;
}
#llInspect { animation-delay: 0s !important; }
#llSenior  { animation-delay: 3.6s !important; }
#llRecrawl { animation-delay: 7.2s !important; }

#hudMeta {
  display: flex;
  align-items: center;
  gap: 8px;
}
#muteBtn {
  background: rgba(0, 0, 0, 0.55);
  border: 2px solid #1aff7a;
  color: #1aff7a;
  font-size: 14px;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  border-radius: 4px;
  -webkit-tap-highlight-color: transparent;
}
#muteBtn:active { transform: scale(0.92); }
#muteBtn.muted { color: #ff5577; border-color: #ff5577; }

/* ---- Dialog: hint box + 3-option Nightmare layout ---- */
.hint-box {
  background: rgba(255, 217, 102, 0.12);
  border-left: 3px solid #ffd966;
  color: #ffd966;
  padding: 8px 12px;
  margin-bottom: 12px;
  font-size: 17px;
  line-height: 1.25;
}
.hint-box[hidden] { display: none; }

/* "FEATURING: <name>" badge on cameo scenarios — sits above the
   scenario text in the dialog so the player knows whose level they
   walked into. */
.cameo-badge {
  display: inline-block;
  background: linear-gradient(90deg, #ffd966, #ff8833);
  color: #2a1a06;
  font-family: "Press Start 2P", monospace;
  font-size: 11px;
  letter-spacing: 1px;
  padding: 5px 10px;
  margin-bottom: 10px;
  border: 1px solid #ffd96655;
  text-shadow: 0 0 4px #ffe49a55;
}
.cameo-badge[hidden] { display: none; }
.choice.eliminated {
  opacity: 0.35;
  text-decoration: line-through;
  pointer-events: none;
  border-color: #555;
  color: #888;
}
/* When optionC is shown (Nightmare), stack all three full-width */
.choices.three-options { grid-template-columns: 1fr; }
.choice[hidden] { display: none; }

/* ---- Leaderboard filters (theme + difficulty) ---- */
.lb-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  font-family: "Press Start 2P", monospace;
  font-size: 9px;
  color: #8effb3;
}
.lb-filter-label { letter-spacing: 1px; }
.lb-filter-select {
  background: #021006;
  border: 1px solid #1aff7a55;
  color: #d8ffe6;
  font-family: "VT323", monospace;
  font-size: 15px;
  padding: 3px 6px;
  cursor: pointer;
}
.lb-filter-count {
  margin-left: auto;
  color: #ffd966;
  font-size: 9px;
  letter-spacing: 0.5px;
}

/* Boss-round bordering on a leaderboard row (when entry.boss = true) */
#leaderboardList li.boss-row { background: rgba(255, 51, 85, 0.08); border-left: 3px solid #ff3355; }

/* ---- Toast (Quick Crawl etc.) ---- */
#toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -150%);
  background: rgba(5, 15, 8, 0.95);
  border: 2px solid #ffd966;
  color: #ffd966;
  font-family: "Press Start 2P", monospace;
  font-size: 18px;
  padding: 14px 22px;
  letter-spacing: 1px;
  text-shadow: 0 0 8px #ffd966;
  pointer-events: none;
  opacity: 0;
  z-index: 90;
  transition: opacity .25s, transform .25s;
}
#toast.visible {
  opacity: 1;
  transform: translate(-50%, -50%);
}
#toast.win  { border-color: #1aff7a; color: #1aff7a; text-shadow: 0 0 8px #1aff7a; }
#toast.warn { border-color: #ff3355; color: #ff6677; text-shadow: 0 0 8px #ff3355; }

/* ---- Mobile overrides for the new HUD pieces ---- */
@media (pointer: coarse), (max-width: 820px) {
  /* HUD stays a single row but everything shrinks */
  #hud {
    top: env(safe-area-inset-top, 6px);
    gap: 6px;
  }
  #streakBadge { font-size: 9px; padding: 3px 6px; }
  #bossBanner { font-size: 10px; padding: 4px 8px; letter-spacing: 1px; }
  .lifeline { width: 32px; height: 32px; font-size: 14px; }
  #lifelines { gap: 4px; }
  #muteBtn { width: 26px; height: 26px; font-size: 12px; }
  #hudMeta { gap: 5px; }

  /* Pickers: narrower on small screens */
  .picker select { min-width: 160px; font-size: 16px; }
  .boot-pickers { gap: 10px; margin: 10px auto; }
  .picker-label { font-size: 8px; }

  /* Leaderboard filter row: compact */
  .lb-filters { font-size: 8px; gap: 4px; margin-bottom: 6px; }
  .lb-filter-select { font-size: 13px; padding: 2px 4px; }
  .lb-filter-count { font-size: 8px; }

  /* Toast: smaller on phone */
  #toast { font-size: 14px; padding: 10px 16px; }
}

/* On really short landscape phones, shrink the lifelines to a tiny
   row instead of hiding them — players still need to be able to use
   their jokers. */
@media (orientation: landscape) and (max-height: 380px) {
  .lifeline { width: 26px; height: 26px; font-size: 11px; }
  #lifelines { gap: 3px; }
  #bossBanner { font-size: 9px; padding: 3px 6px; }
  /* Pull HUD a touch tighter so timer + lifelines + stats all share
     the strip cleanly. */
  #hud { gap: 4px; font-size: 10px; }
  #timerWrap { width: 28vw; max-width: 180px; height: 18px; }
  #timerText { font-size: 11px; }
  #hudStats { font-size: 10px; }
  #roundText { font-size: 10px; }
  #muteBtn { width: 22px; height: 22px; font-size: 10px; }
}
