/*
 * style.css — the 8-bit look.
 *
 * The whole page re-themes itself as you climb: game.js sets
 * <body data-tier="0..6">, and each tier below swaps the colour variables.
 */

/* ---------- colour themes, one per zone of the building ---------- */
body[data-tier="0"] { /* Condemned Lobby: grimy CRT */
  --bg: #14100c; --page-text: #cdb894; --panel: #2e2620; --panel-hi: #40352b; --panel-lo: #1f1a15;
  --ink: #0a0806; --text: #cdb894; --muted: #8a7658; --accent: #b8893a; --on-accent: #140f08;
  --good: #8aa65a; --close: #c9a24a; --bad: #c4583c; --led: #d08a2a;
  --input-bg: #1a1511; --input-text: #e0cfa8; --scan: 0.28;
}
body[data-tier="1"] { /* Walk-up Offices: beige paperwork */
  --bg: #2a2d30; --page-text: #e8e2cc; --panel: #d6cba8; --panel-hi: #ece3c6; --panel-lo: #b9ad88;
  --ink: #1c1b17; --text: #2a2820; --muted: #6b634c; --accent: #3d6d99; --on-accent: #f4f0e2;
  --good: #6fb86a; --close: #e0b04a; --bad: #c4503a; --led: #ffb43a;
  --input-bg: #f4efdc; --input-text: #1c1b17; --scan: 0.16;
}
body[data-tier="2"] { /* Grand Hotel: burgundy and brass */
  --bg: #1c0a0f; --page-text: #f5e4c3; --panel: #5e1823; --panel-hi: #7c2533; --panel-lo: #3e0f17;
  --ink: #100406; --text: #f5e4c3; --muted: #d0a47e; --accent: #e2b448; --on-accent: #2a1405;
  --good: #a8d66e; --close: #f0c860; --bad: #ff8270; --led: #ffd877;
  --input-bg: #2a0a10; --input-text: #fff0d6; --scan: 0.1;
}
body[data-tier="3"] { /* Sky Tower: glass and chrome */
  --bg: #0b1824; --page-text: #e8f3ff; --panel: #1e3a56; --panel-hi: #2d5679; --panel-lo: #13283d;
  --ink: #06101a; --text: #e8f3ff; --muted: #93b6d4; --accent: #5fd0ff; --on-accent: #04202e;
  --good: #7ef0a6; --close: #ffe07a; --bad: #ff8a8a; --led: #5fd0ff;
  --input-bg: #0d1f30; --input-text: #ffffff; --scan: 0.06;
}
body[data-tier="4"] { /* Penthouse Suites: velvet and gold */
  --bg: #0c0612; --page-text: #fdf2ff; --panel: #28163a; --panel-hi: #3d2256; --panel-lo: #170c22;
  --ink: #050208; --text: #fdf2ff; --muted: #c4a8da; --accent: #ffd34d; --on-accent: #2a1a00;
  --good: #92f2b4; --close: #ffe48a; --bad: #ff7fa6; --led: #ffd34d;
  --input-bg: #1a0d26; --input-text: #ffffff; --scan: 0.04;
}
body[data-tier="5"] { /* Orbital Deck: neon in space */
  --bg: #000005; --page-text: #eafcff; --panel: #07071a; --panel-hi: #151540; --panel-lo: #020210;
  --ink: #00e5ff; --text: #eafcff; --muted: #86b0d0; --accent: #ff3ad0; --on-accent: #140010;
  --good: #5bffa6; --close: #ffe07a; --bad: #ff5a85; --led: #ff3ad0;
  --input-bg: #03031a; --input-text: #eafcff; --scan: 0.02;
  background-image:
    radial-gradient(1px 1px at 20% 30%, #fff, transparent),
    radial-gradient(1px 1px at 70% 80%, #00f0ff, transparent),
    radial-gradient(1px 1px at 40% 60%, #fff, transparent),
    radial-gradient(1px 1px at 90% 20%, #ff3ad0, transparent);
  background-size: 200px 200px;
}

body[data-tier="6"] { /* Spirit Realm: violet sky, aurora and moonlight */
  --bg: #0f0820; --page-text: #f4f0ff; --panel: #1e1238; --panel-hi: #2e1d52; --panel-lo: #140b28;
  --ink: #cdb8ff; --text: #f4f0ff; --muted: #a89ad0; --accent: #7affd4; --on-accent: #120a24;
  --good: #9affc8; --close: #ffe08a; --bad: #ff8ab0; --led: #b8fff0;
  --input-bg: #140b28; --input-text: #ffffff; --scan: 0;
  background-image:
    radial-gradient(60% 40% at 20% 20%, rgba(63, 207, 159, 0.18), transparent),
    radial-gradient(50% 40% at 80% 30%, rgba(224, 122, 200, 0.16), transparent);
  background-attachment: fixed;
}

/* ---------- basics ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: 'Press Start 2P', 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.8;
  background-color: var(--bg);
  color: var(--page-text);
  transition: background-color 0.8s, color 0.8s;
}
/* CRT scanlines: heavy in the old lobby, almost gone in space */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, var(--scan)) 0 1px, transparent 1px 3px);
  z-index: 10;
}
p { margin: 0 0 12px; }
a { color: var(--accent); }
[hidden] { display: none !important; }
.small { font-size: 9px; }
.muted { color: var(--muted); }

.app {
  max-width: 1040px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 100vh;
}

/* A chunky pixel box: dark outline plus light/dark bevels */
.box {
  background: var(--panel);
  color: var(--text);
  border: 4px solid var(--ink);
  box-shadow: inset 4px 4px 0 var(--panel-hi), inset -4px -4px 0 var(--panel-lo), 6px 6px 0 rgba(0, 0, 0, 0.4);
  padding: 20px;
  transition: background-color 0.8s, color 0.8s;
}

/* ---------- header ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.logo {
  margin: 0;
  font-size: 30px;
  letter-spacing: 4px;
  color: var(--accent);
  text-shadow: 4px 4px 0 var(--ink);
}
body[data-tier="0"] .logo .flicker { animation: neon-fail 5s steps(1) infinite; }
body[data-tier="5"] .logo { text-shadow: 0 0 8px var(--accent), 4px 4px 0 #2a0030; }
/* The pixel triangle standing in for the "A". The font draws each capital
   7 pixels tall on an 8-pixel grid, one pixel above the baseline, so a 7x7
   shape at 0.875em, raised by one font pixel (0.125em), lines up exactly. */
.logo-arrow {
  display: inline-block;
  width: 0.875em;
  height: 0.875em;
  margin-right: 0.125em;
  vertical-align: 0.125em;
  fill: currentColor;
  filter: drop-shadow(4px 4px 0 var(--ink));
}
body[data-tier="5"] .logo-arrow { filter: drop-shadow(0 0 8px var(--accent)) drop-shadow(4px 4px 0 #2a0030); }
body[data-tier="6"] .logo { text-shadow: 0 0 10px var(--accent), 4px 4px 0 #2a1450; }
body[data-tier="6"] .logo-arrow { filter: drop-shadow(0 0 10px var(--accent)) drop-shadow(4px 4px 0 #2a1450); }

.indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 128px;
  justify-content: center;
  padding: 8px 14px;
  background: #000;
  border: 4px solid var(--ink);
  box-shadow: inset 0 0 0 2px #222;
}
.indicator .num { font-size: 26px; color: var(--led); text-shadow: 0 0 6px var(--led); min-width: 3ch; text-align: center; }
.indicator .arrow { color: var(--led); font-size: 14px; opacity: 0.25; }
.indicator.moving .arrow { opacity: 1; animation: blink 0.4s steps(2) infinite; }
body[data-tier="0"] .indicator .num { animation: flicker 3s steps(1) infinite; }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(240px, 360px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.scene-wrap { position: relative; }
#scene {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 144 / 192;
  image-rendering: pixelated;   /* keep the pixels crisp when scaled up */
  image-rendering: crisp-edges;
  border: 4px solid var(--ink);
  background: #000;
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.4);
}
.tier-name {
  margin-top: 10px;
  text-align: center;
  font-size: 10px;
  color: var(--accent);
}
.scene-fx { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }

.banner {
  position: absolute;
  left: 50%;
  top: 8%;
  max-width: 92%;
  padding: 8px 10px;
  transform: translateX(-50%);
  background: var(--accent);
  color: var(--on-accent);
  border: 4px solid var(--ink);
  font-size: 9px;
  text-align: center;
  animation: banner 2.8s steps(14) forwards;
}
.float-pts {
  position: absolute;
  left: 50%;
  top: 52%;
  transform: translateX(-50%);
  font-size: 18px;
  color: var(--good);
  text-shadow: 3px 3px 0 #000;
  animation: float-up 1.2s steps(12) forwards;
}

/* ---------- title screen ---------- */
.tagline { font-size: 14px; color: var(--accent); }
.points-table { list-style: none; margin: 0 0 14px; padding: 0; font-size: 10px; }
.points-table li { display: flex; gap: 8px; padding: 2px 0; }
.points-table li span:first-child { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; }
.points-table li span:first-child::after { content: ' ........................................'; color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  font: inherit;
  font-size: 12px;
  text-transform: uppercase;
  padding: 12px 16px;
  cursor: pointer;
  color: var(--on-accent);
  background: var(--accent);
  border: 4px solid var(--ink);
  box-shadow: inset -4px -4px 0 rgba(0, 0, 0, 0.25), inset 4px 4px 0 rgba(255, 255, 255, 0.25);
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: translateY(2px); box-shadow: inset 4px 4px 0 rgba(0, 0, 0, 0.25); }
.btn:disabled { opacity: 0.5; cursor: wait; }
.btn:focus-visible, .guess-input:focus-visible, a:focus-visible { outline: 4px solid var(--good); outline-offset: 2px; }
.btn-big { font-size: 14px; padding: 14px 22px; }
.btn-small { font-size: 9px; padding: 8px 10px; }
.btn-ghost { background: transparent; color: inherit; box-shadow: none; border-width: 3px; }

/* ---------- a round ---------- */
.round-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.strikes { display: flex; gap: 6px; }
.strikes i { width: 14px; height: 14px; background: var(--panel-lo); border: 3px solid var(--ink); }
.strikes i.on { background: var(--bad); box-shadow: 0 0 8px var(--bad); }

.timer-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.timer { flex: 1; height: 18px; background: var(--panel-lo); border: 4px solid var(--ink); }
.timer-fill { height: 100%; width: 100%; background: var(--accent); transition: width 0.1s linear; }
.timer.low .timer-fill { background: var(--bad); animation: blink 0.5s steps(2) infinite; }
.timer-text { min-width: 3ch; text-align: right; }

.guess-form { display: flex; gap: 8px; margin-bottom: 10px; }
.guess-input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 14px;
  padding: 12px;
  color: var(--input-text);
  background: var(--input-bg);
  border: 4px solid var(--ink);
  border-radius: 0;
  outline: none;
}
.guess-input:disabled { opacity: 0.6; }
.shake { animation: shake 0.3s steps(6); }

.feedback { min-height: 3.6em; font-size: 10px; margin-bottom: 8px; }
.feedback.good { color: var(--good); }
.feedback.warn { color: var(--close); }
.feedback.bad { color: var(--bad); }
.feedback.info { color: var(--muted); }

.board { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.row { display: grid; grid-template-columns: 112px 1fr; gap: 8px; align-items: start; }
.row-label { font-size: 8px; color: var(--muted); padding-top: 8px; }
.tiles { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.tile .ans { overflow-wrap: anywhere; }
.tile {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 92px;
  padding: 5px 8px;
  font-size: 9px;
  background: var(--panel-lo);
  border: 3px solid var(--ink);
}
.tile .pts { font-size: 7px; opacity: 0.85; white-space: nowrap; }
.tile .q { letter-spacing: 2px; opacity: 0.7; }
.tile.found { background: var(--good); color: #0b0b0b; }
.tile.close { background: var(--close); color: #0b0b0b; }
.tile.wrong { background: var(--bad); color: #0b0b0b; }
.tile.missed { opacity: 0.6; border-style: dashed; }
.tile.pop { animation: flip 0.4s steps(4); }

.round-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- summary ---------- */
.summary-head { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.sum-art { width: 96px; height: 96px; border: 4px solid var(--ink); image-rendering: pixelated; flex-shrink: 0; }
.sum-title { font-size: 14px; color: var(--accent); margin-bottom: 6px; }
.sum-artist { margin-bottom: 6px; }
.sum-floors { font-size: 9px; color: var(--good); margin: 0; }

/* ---------- final ---------- */
.final-floor { font-size: 28px; color: var(--accent); margin: 6px 0; text-shadow: 3px 3px 0 var(--ink); }
.final-tier { font-size: 14px; color: var(--good); }
.final-rounds { padding-left: 22px; font-size: 9px; }
.final-rounds li { margin-bottom: 6px; }
.final-rounds .fr-pts { color: var(--good); margin-left: 8px; white-space: nowrap; }
.final-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.share-text { width: 100%; margin-top: 12px; font: inherit; font-size: 10px; padding: 8px; }

/* ---------- footer ---------- */
.footer { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: auto; font-size: 9px; }
.ctl { display: flex; align-items: center; gap: 8px; }
.ctl input { accent-color: var(--accent); }
.credit-line { margin: 0 0 0 auto; }

/* ---------- small screens: stack the building on top ---------- */
@media (max-width: 760px) {
  .app { padding: 10px; gap: 10px; }
  .logo { font-size: 20px; letter-spacing: 2px; }
  .indicator { min-width: 96px; padding: 6px 10px; }
  .indicator .num { font-size: 18px; }
  .layout { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  #scene { width: auto; height: 30vh; margin: 0 auto; }
  .box { padding: 14px; }
  .row { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .row-label { padding-top: 0; }
  .credit-line { margin-left: 0; }
}

/* ---------- animations (steps() keeps them choppy, like old games) ---------- */
@keyframes blink { 50% { opacity: 0.2; } }
@keyframes flicker { 0%, 92%, 96% { opacity: 1; } 94%, 98% { opacity: 0.3; } }
@keyframes neon-fail { 0% { opacity: 1; } 70% { opacity: 0.15; } 72% { opacity: 1; } 75% { opacity: 0.15; } 76%, 100% { opacity: 1; } }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes flip { 0% { transform: scaleY(0.1); } 100% { transform: scaleY(1); } }
@keyframes float-up { 0% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; transform: translate(-50%, -60px); } }
@keyframes banner { 0% { opacity: 0; } 10%, 85% { opacity: 1; } 100% { opacity: 0; } }
.blink { animation: blink 1s steps(2) infinite; }

@media (prefers-reduced-motion: reduce) {
  *, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}

/* ---------- daily / unlimited buttons ---------- */
.mode-buttons { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin: 16px 0 12px; }
.mode-note { margin: 0 0 10px; }
.mode-buttons .btn-ghost { font-size: 11px; }
.error-line { color: var(--bad); }
.error-line:empty { display: none; }
.final-mode { font-size: 10px; color: var(--accent); margin-bottom: 4px; }
.final-actions { align-items: center; }

/* ---------- the UPBEAT logo is a link back to the lobby ---------- */
.logo-link { color: inherit; text-decoration: none; display: inline-block; }
.logo-link:hover { filter: brightness(1.2); transform: translateY(-2px); }
.logo-link:active { transform: translateY(1px); }

/* ---------- the lobby picture behind the title screen ---------- */
body { position: relative; }
.app { position: relative; z-index: 1; }
.lobby-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 0;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s;
}
.lobby-bg canvas { display: block; image-rendering: pixelated; image-rendering: crisp-edges; }
body.in-lobby .lobby-bg { opacity: 1; }
body.in-lobby #scene { visibility: hidden; }  /* the lobby's own elevator stands here instead */
body.in-lobby .tier-name { visibility: hidden; }
body.in-lobby .indicator { visibility: hidden; } /* the floor display is only for rides */ /* the sign above the lobby's elevator names it instead */
body.in-lobby .footer,
body.in-lobby .logo-link { background: rgba(0, 0, 0, 0.72); padding: 4px 10px; }
body.in-lobby .footer { padding: 8px 12px; }
.lobby-line { color: var(--accent); }

/* ---------- "leave this ride?" box ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.7);
}
.modal-box { max-width: 460px; }
