:root {
  --bg: #0B0F14;
  --panel: #121820;
  --panel-line: #1E2733;
  --text: #D8E1E8;
  --muted: #7C8A99;
  --ok: #3ECF8E;
  --warn: #E8B339;
  --bad: #E2554B;
  --accent: #5AC8E8;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font-family: var(--sans); display: flex; flex-direction: column; align-items: center;
  position: relative;
}
#backdrop {
  position: fixed; inset: 0; z-index: -1; background-color: var(--bg);
  background-repeat: no-repeat; background-size: cover; background-position: center bottom;
  opacity: 0.55; transition: opacity 0.8s ease, background-image 0.8s ease;
}
#backdrop::before {
  content: ""; position: absolute; inset: 0; transition: background 0.8s ease; pointer-events: none;
}
#backdrop.mood-arcane::before { background: radial-gradient(circle at 50% 30%, rgba(90,200,232,0.16), transparent 65%); }
#backdrop.mood-calm::before { background: radial-gradient(circle at 50% 20%, rgba(240,192,96,0.12), transparent 65%); }
#backdrop.mood-tension::before { background: radial-gradient(circle at 50% 10%, rgba(232,179,57,0.10), transparent 60%); }
#backdrop.mood-danger { opacity: 0.7; }
#backdrop.mood-danger::before {
  background: radial-gradient(circle at 50% 15%, rgba(226,85,75,0.24), transparent 65%);
  animation: dangerPulse 2.5s ease-in-out infinite;
}
@keyframes dangerPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
#backdrop.mood-somber::before { background: radial-gradient(circle at 50% 80%, rgba(124,138,153,0.14), transparent 65%); }
.hero {
  min-height: 100vh; background: var(--bg);
  justify-content: flex-start;
  text-align: center; gap: 28px; padding: 110px 20px 40px;
}
.hero-title {
  font-family: "Space Grotesk", var(--sans);
  font-size: clamp(36px, 8vw, 64px); font-weight: 700; margin: 0; letter-spacing: -0.02em; color: var(--text);
}
.hero-title::after {
  content: ""; display: block; width: 64px; height: 3px; background: var(--accent);
  margin: 18px auto 0; border-radius: 2px;
}
.hero-intro {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap;
  gap: 20px; max-width: 560px; text-align: left;
}
@media (max-width: 480px) {
  .hero-intro { flex-direction: column; text-align: center; }
}
.headshot {
  width: 120px; height: 120px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
  border: 2px solid var(--panel-line); background: var(--panel);
}
.hero-intro p { font-size: 16px; line-height: 1.6; color: var(--muted); margin: 0; max-width: 340px; }
.start-link {
  font-size: clamp(28px, 5vw, 40px); font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--accent); text-decoration: underline; text-underline-offset: 6px;
}
.start-link:hover { filter: brightness(1.15); }

.page-layer {
  display: none; opacity: 0; width: 100%;
  flex-direction: column; align-items: center;
  transition: opacity 0.5s ease;
}
.page-layer.visible { display: flex; }
.page-layer.fade-in { opacity: 1; }

.game-layer { padding: 24px 16px 60px; }

/* Only the game shows the illustrated backdrop; every other page is flat. */
.bio-layer, .interests-layer { background: var(--bg); }

.static-page {
  width: 100%; max-width: 720px; min-height: 100vh;
  display: flex; flex-direction: column; align-items: center;
  text-align: center; gap: 24px; padding: 110px 20px 40px;
}
.placeholder-card {
  background: #0B0F14; border: 1px solid var(--panel-line); border-radius: 8px;
  padding: 24px; max-width: 480px; color: var(--muted); font-size: 15px;
}
.credits-card {
  max-width: 640px; text-align: left; line-height: 1.6;
}
.credits-card h2 {
  color: var(--text); font-size: 15px; margin: 22px 0 6px;
}
.credits-card h2:first-child { margin-top: 0; }
.credits-card code {
  font-family: var(--mono); font-size: 13px; color: var(--text);
  background: var(--panel); padding: 1px 5px; border-radius: 4px;
}
.credits-card a { color: var(--accent); }
.credits-card ul { margin: 6px 0; padding-left: 20px; }
.back-link {
  color: var(--accent); text-decoration: underline; text-underline-offset: 4px; font-size: 14px;
}

.menu-btn {
  position: fixed; top: 20px; right: 20px; z-index: 40;
  background: none; border: none; cursor: pointer; padding: 6px;
  display: flex; flex-direction: column; justify-content: center; gap: 5px;
  width: 32px; height: 32px;
}
.menu-btn span { display: block; width: 100%; height: 2px; background: var(--text); border-radius: 1px; }
.menu-btn:hover span { background: var(--accent); }
.menu-btn:focus-visible { outline: none; }
.menu-btn:focus-visible span { background: var(--accent); }
.menu-dropdown {
  position: fixed; top: 60px; right: 20px; z-index: 40;
  background: var(--panel); border: 1px solid var(--panel-line); border-radius: 8px;
  padding: 6px; display: flex; flex-direction: column; min-width: 160px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.menu-dropdown[hidden] { display: none; }
.menu-item {
  background: none; border: none; color: var(--text); text-align: left;
  padding: 10px 12px; font-size: 14px; font-family: var(--sans); cursor: pointer; border-radius: 6px;
}
.menu-item:hover, .menu-item:focus-visible { background: rgba(90,200,232,0.12); color: var(--accent); outline: none; }

.console {
  position: relative;
  width: 100%; max-width: 720px; background: var(--panel); border: 1px solid var(--panel-line);
  border-radius: 10px; overflow: hidden; box-shadow: 0 0 0 1px rgba(255,255,255,0.02), 0 20px 60px rgba(0,0,0,0.5);
}
.hud {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  /* Right padding reserves room for the fixed-position hamburger (top:20px;
     right:20px; 32px wide) so it doesn't crowd/overlap the mute button. The
     console is edge-to-edge (minus .game-layer's 16px padding) on any
     viewport narrower than ~752px (720px max-width + 16px*2), so this has to
     apply well before a typical "mobile" breakpoint, not just under 480px. */
  padding: 12px 56px 12px 18px; border-bottom: 1px solid var(--panel-line); font-family: var(--mono);
  font-size: 12px; color: var(--muted); flex-wrap: wrap;
}
.hud b { color: var(--text); font-weight: 600; }
.hud .stat { display: flex; align-items: center; gap: 6px; }
.hud-metrics { display: flex; align-items: center; gap: 16px; }
.company-icon { font-size: 1.7em; line-height: 1; }

/* Below ~480px, company/class/LVL + the mute button no longer fit on one
   line alongside the XP/HP bars too - wrapping used to split unevenly
   (HP and the mute button both getting pushed down together). Force XP/HP
   onto their own second row instead, and keep the mute button up on row 1
   next to the hamburger by ordering it ahead of that forced row break. */
@media (max-width: 480px) {
  .mute-wrap { order: 4; }
  #devBackBtn { order: 5; }
  .hud-metrics { order: 10; flex-basis: 100%; }
}
.bar { width: 60px; height: 6px; background: #0B0F14; border-radius: 3px; overflow: hidden; border: 1px solid var(--panel-line); }
.bar > i { display: block; height: 100%; background: var(--accent); transition: width .4s ease; }
.bar.hp > i { background: var(--ok); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.status-dot.alarm { background: var(--bad); box-shadow: 0 0 8px var(--bad); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

.body { padding: 28px 24px; }
.eyebrow { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); margin: 0 0 10px; }
h1 { font-size: 22px; margin: 0 0 14px; line-height: 1.3; }
p.narrative { font-size: 15px; line-height: 1.65; color: var(--text); margin: 0 0 20px; }
.muted { color: var(--muted); font-size: 13px; }

input[type=text] {
  width: 100%; padding: 11px 12px; background: #0B0F14; border: 1px solid var(--panel-line);
  border-radius: 6px; color: var(--text); font-family: var(--sans); font-size: 14px; margin-bottom: 18px;
}
input[type=text]:focus { outline: 1px solid var(--accent); border-color: var(--accent); }

.class-grid { display: grid; grid-template-columns: 1fr; gap: 10px; margin-bottom: 20px; }
@media (min-width: 560px) { .class-grid { grid-template-columns: 1fr 1fr 1fr; } }
.class-card {
  background: #0B0F14; border: 1px solid var(--panel-line); border-radius: 8px; padding: 14px;
  cursor: pointer; text-align: left; color: var(--text); font-family: var(--sans);
}
.class-card:hover, .class-card:focus-visible { border-color: var(--accent); }
.class-card:focus-visible { outline: none; box-shadow: 0 0 0 2px rgba(90,200,232,0.35); }
.class-card .sprite { width: 36px; height: 36px; object-fit: contain; display: block; }
.class-card .title { font-weight: 600; margin: 6px 0 4px; font-size: 14px; }
.sprite-inline { width: 1.3em; height: 1.3em; object-fit: contain; vertical-align: middle; }

.party-tagline { margin-bottom: 10px; }
.party-card {
  background: #0B0F14; border: 1px solid var(--panel-line); border-radius: 8px; padding: 14px;
  text-align: left; color: var(--text); font-family: var(--sans);
}
.party-card .sprite { width: 36px; height: 36px; object-fit: contain; display: block; }
.party-card .title { font-weight: 600; margin: 6px 0 4px; font-size: 14px; }
.party-card .tagline { font-size: 12px; color: var(--muted); line-height: 1.4; }

.choices { display: flex; flex-direction: column; gap: 8px; margin-bottom: 6px; }
.choice {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: #0B0F14; border: 1px solid var(--panel-line); border-radius: 8px;
  padding: 12px 14px; cursor: pointer; text-align: left; color: var(--text); font-size: 14px; font-family: var(--sans);
  width: 100%;
}
.choice:hover, .choice:focus-visible { border-color: var(--accent); }
.choice:focus-visible { outline: none; box-shadow: 0 0 0 2px rgba(90,200,232,0.35); }
.choice .hint-line { display: none; font-size: 11.5px; color: var(--muted); margin-top: 4px; font-family: var(--mono); }
.choices.hints-on .hint-line { display: block; }
.choice .letter { font-family: var(--mono); color: var(--muted); font-size: 12px; flex-shrink: 0; }

.hint-toggle {
  display: inline-flex; align-items: center; gap: 6px; background: none; border: 1px solid var(--panel-line);
  color: var(--muted); border-radius: 20px; padding: 4px 10px 4px 8px; font-size: 11px; cursor: pointer;
  font-family: var(--mono); margin-bottom: 14px;
}
.hint-toggle:hover, .hint-toggle:focus-visible { border-color: var(--accent); color: var(--accent); }
.hint-toggle:focus-visible { outline: none; box-shadow: 0 0 0 2px rgba(90,200,232,0.35); }
.hint-toggle .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--panel-line); display: flex; align-items: center; justify-content: center; font-size: 10px; }

.resolution {
  border-left: 3px solid var(--panel-line); padding: 12px 14px; margin: 14px 0 20px; border-radius: 0 6px 6px 0; font-size: 14px; line-height: 1.6;
}
.resolution.full_success { border-color: var(--ok); background: rgba(62,207,142,0.08); }
.resolution.partial_success { border-color: var(--warn); background: rgba(232,179,57,0.08); }
.resolution.fail { border-color: var(--bad); background: rgba(226,85,75,0.08); }
.company-evolved-icon { font-size: 1.6em; vertical-align: middle; margin-right: 2px; }
.resolution .tag { font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; display: block; margin-bottom: 6px; }
.resolution.full_success .tag { color: var(--ok); }
.resolution.partial_success .tag { color: var(--warn); }
.resolution.fail .tag { color: var(--bad); }

button.primary {
  background: var(--accent); color: #08111A; border: none; border-radius: 6px; padding: 11px 20px;
  font-size: 14px; font-weight: 600; cursor: pointer; font-family: var(--sans);
}
button.primary:hover { filter: brightness(1.08); }
button.primary:focus-visible { outline: none; box-shadow: 0 0 0 2px rgba(90,200,232,0.5); }
button.primary:disabled { opacity: .4; cursor: not-allowed; filter: none; }
button.ghost {
  background: none; border: 1px solid var(--panel-line); color: var(--text); border-radius: 6px;
  padding: 10px 18px; font-size: 13px; cursor: pointer; font-family: var(--sans);
}

.shake { animation: shake .4s; }
@keyframes shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }
.flash-green { animation: flashGreen .6s; }
@keyframes flashGreen { 0% { box-shadow: inset 0 0 0 999px rgba(62,207,142,0); } 30% { box-shadow: inset 0 0 0 999px rgba(62,207,142,0.18); } 100% { box-shadow: inset 0 0 0 999px rgba(62,207,142,0); } }
.console.boss-alarm { animation: alarmBorder 1s infinite; }
@keyframes alarmBorder { 0%,100% { border-color: var(--panel-line); } 50% { border-color: var(--bad); } }

.scene-flash { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.scene-flash-portal {
  background: radial-gradient(circle at 50% 45%, rgba(143,224,255,0.9), rgba(90,200,232,0.25) 40%, transparent 70%);
  animation: portalFlash 0.9s ease-out forwards;
}
@keyframes portalFlash {
  0% { opacity: 0; transform: scale(0.3); }
  30% { opacity: 1; transform: scale(1.1); }
  100% { opacity: 0; transform: scale(1.6); }
}
.scene-flash-boss {
  background: radial-gradient(circle at 50% 20%, rgba(226,85,75,0.55), transparent 70%);
  animation: bossFlash 0.8s ease-out forwards;
}
@keyframes bossFlash {
  0% { opacity: 0; }
  20% { opacity: 1; }
  100% { opacity: 0; }
}
.scene-flash-victory {
  background: radial-gradient(circle at 50% 40%, rgba(240,192,96,0.9), rgba(240,192,96,0.2) 45%, transparent 75%);
  animation: victoryFlash 1.1s ease-out forwards;
}
@keyframes victoryFlash {
  0% { opacity: 0; transform: scale(0.5); }
  35% { opacity: 1; transform: scale(1.15); }
  100% { opacity: 0; transform: scale(1.5); }
}
.console.boss-shake { animation: bossShake 0.6s ease-in-out; }
@keyframes bossShake {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-8px, 4px); }
  20% { transform: translate(7px, -3px); }
  30% { transform: translate(-6px, 3px); }
  40% { transform: translate(6px, -4px); }
  50% { transform: translate(-4px, 2px); }
  60% { transform: translate(4px, -2px); }
  70% { transform: translate(-2px, 1px); }
  80% { transform: translate(2px, -1px); }
  90% { transform: translate(-1px, 0); }
}
.boss-enter { animation: bossEnter 0.7s cubic-bezier(.34,1.56,.64,1) both; }
@keyframes bossEnter {
  0% { opacity: 0; transform: scale(0.4) translateY(-40px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-overlay {
  position: fixed; inset: 0; z-index: 20; background: rgba(8,17,26,0.82);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal {
  background: var(--panel); border: 1px solid var(--accent); border-radius: 10px;
  padding: 24px; width: min(420px, 100%); max-height: 85vh; overflow-y: auto;
  box-shadow: 0 0 40px rgba(90,200,232,0.25);
}
.modal h1 { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 19px; }

.captcha-widget { display: flex; flex-direction: column; align-items: center; gap: 10px; }

/* Positioned relative to .mute-wrap (not .console) so it always tracks the
   mute button's actual flex position - it used to be pinned to a fixed
   offset from the console's corner, which pointed at the wrong button once
   the dev Back button (?debug=1) appeared and pushed mute button left. */
.mute-wrap { position: relative; display: inline-flex; }
.toast {
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 15;
  display: flex; align-items: flex-start; gap: 8px;
  /* Explicit width, not max-width on an auto width: .mute-wrap (the
     containing block) is only as wide as the mute button itself, and an
     absolutely-positioned box with only "right" set shrink-to-fits against
     its containing block's width when width is auto - against a ~40px
     containing block that collapses the toast down to a tall, one-word-per-line column. */
  width: 240px; max-width: calc(100vw - 40px);
  background: var(--panel); border: 1px solid var(--accent); border-radius: 8px;
  padding: 10px 12px; font-size: 12px; line-height: 1.5; color: var(--text);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4); opacity: 1; transition: opacity 0.5s ease;
}
.toast::before {
  content: ""; position: absolute; top: -6px; right: 10px; width: 10px; height: 10px;
  background: var(--panel); border-left: 1px solid var(--accent); border-top: 1px solid var(--accent);
  transform: rotate(45deg);
}
.toast.toast-hidden { opacity: 0; pointer-events: none; }
.toast-close {
  background: none; border: none; color: var(--muted); cursor: pointer; font-size: 15px;
  line-height: 1; padding: 0; margin-left: auto; flex-shrink: 0;
}
.toast-close:hover { color: var(--text); }

.footer-note { max-width: 720px; margin-top: 16px; font-size: 11.5px; color: var(--muted); font-family: var(--mono); line-height: 1.6; text-align: center; }
