:root{
  --void: #04040a;
  --deep: #0a0a18;
  --panel: #12111f;
  --line: #2a2840;
  --ink: #f5f3ff;
  --ink-dim: #9895b4;
  --light: #fff7d6;
  --gold: #fde68a;
  --teal: #2dd4bf;
  --orange: #fb923c;
  --accent: #fde68a;
  --accent-deep: #c9a227;
  --dark: #ef4444;
}

*, *::before, *::after{ box-sizing: border-box; margin: 0; padding: 0; }

html, body{ height: 100%; }
body{
  background: var(--void);
  color: var(--ink);
  font-family: "Space Mono", ui-monospace, Consolas, monospace;
  overflow: hidden; overscroll-behavior: none; touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* The sky warms with each chapter: the universe filling with light */
.sky{
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  transition: background 1.4s ease;
  background:
    radial-gradient(1px 1px at 12% 18%, #fff5 50%, transparent 51%),
    radial-gradient(1px 1px at 72% 12%, #fff4 50%, transparent 51%),
    radial-gradient(1px 1px at 33% 82%, #fff4 50%, transparent 51%),
    radial-gradient(ellipse 70% 55% at 50% 45%, #10101e, var(--void));
}
.sky{ transition: opacity 1.4s ease; }
body.night .sky{ background:
    radial-gradient(1px 1px at 72% 12%, #fff3 50%, transparent 51%),
    radial-gradient(ellipse 50% 40% at 90% 5%, #4a0d1455, transparent 70%),
    radial-gradient(ellipse 70% 55% at 50% 45%, #0e0a12, var(--void)); }

.app{
  position: relative; z-index: 1;
  height: 100vh; height: 100dvh;
  max-width: 1120px; margin: 0 auto;
  display: flex; flex-direction: column;
  padding: max(10px, env(safe-area-inset-top)) 16px max(12px, env(safe-area-inset-bottom));
  gap: 10px;
}

/* ---- Top bar ---- */
.topbar{ display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.home-link{
  color: var(--ink-dim); text-decoration: none; font-size: 13px; justify-self: start;
  padding: 6px 8px; margin-left: -8px; border-radius: 8px;
}
.home-link:hover{ color: var(--ink); background: #ffffff0d; }
.brand{
  font-family: Orbitron, sans-serif; font-weight: 900; font-size: 26px; letter-spacing: .3em;
  padding-left: .3em;
  background: linear-gradient(90deg, var(--teal), var(--light) 45%, var(--gold) 60%, var(--orange));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 12px #fde68a44);
}
.top-actions{ justify-self: end; display: flex; gap: 8px; }
.icon-btn{
  width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid var(--line); background: #ffffff08; color: var(--ink-dim); cursor: pointer;
  display: grid; place-items: center;
}
.icon-btn:hover{ color: var(--ink); border-color: #4a4668; }
.icon-btn svg{ width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn svg .spk{ fill: currentColor; stroke: none; }
.icon-btn .mute{ display: none; }
.icon-btn.muted .mute{ display: inline; }
.icon-btn.muted .wave{ display: none; }

/* ---- HUD ---- */
.hud{
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 14px;
  background: linear-gradient(180deg, #17152acc, #0d0c1acc);
}
.hud-room{ display: flex; flex-direction: column; min-width: 0; flex: 1; }
.hud-title{ font-family: Orbitron, sans-serif; font-weight: 700; font-size: 17px; letter-spacing: .06em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-sub{ color: var(--ink-dim); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.portraits{ display: flex; gap: 8px; }
.portrait{
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 1px;
  width: 62px; padding: 5px 4px 4px; border-radius: 12px; cursor: pointer; font: inherit;
  border: 1px solid var(--line); background: #ffffff06; color: var(--ink-dim);
}
.portrait svg{ width: 24px; height: 24px; }
.portrait.k0 svg path{ fill: #fde68a; } .portrait.k1 svg path{ fill: #2dd4bf; } .portrait.k2 svg path{ fill: #fb923c; }
.portrait .key{ position: absolute; top: 3px; left: 6px; font-size: 10px; color: var(--ink-dim); }
.portrait .tag{ font-style: normal; font-size: 9px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink); white-space: nowrap; }
.portrait .tag.dim{ color: var(--ink-dim); }
.portrait .tag.rec{ color: #fdba74; }
.portrait.active{ color: var(--ink); background: #ffffff10; }
.portrait.k0.active{ border-color: #fde68a; box-shadow: 0 0 14px #fde68a33; }
.portrait.k1.active{ border-color: #2dd4bf; box-shadow: 0 0 14px #2dd4bf33; }
.portrait.k2.active{ border-color: #fb923c; box-shadow: 0 0 14px #fb923c33; }
.portrait.dead{ opacity: .35; }
.hud-right{ display: flex; align-items: center; gap: 8px; flex: 1; justify-content: flex-end; }
.hud-spark{ font-size: 22px; color: #4a4668; }
.hud-spark.got{ color: var(--light); text-shadow: 0 0 10px #fde68a; }
.icon-btn.small{ width: 34px; height: 34px; }
.icon-btn.small svg{ width: 18px; height: 18px; }

/* ---- Board ---- */
.board-wrap{ flex: 1; min-height: 0; display: grid; place-items: center; position: relative; }
#board{ display: block; touch-action: none; border-radius: 14px; outline: none; box-shadow: 0 10px 40px #0008; }
#board:focus-visible{ box-shadow: 0 0 0 2px #fde68a66; }
.toast{
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 3;
  padding: 7px 14px; border-radius: 999px; font-size: 12px; white-space: nowrap; pointer-events: none;
  border: 1px solid var(--line); background: #0b0a16e6; color: var(--ink);
  animation: toast 2.4s ease forwards;
}
.toast.good{ border-color: var(--teal); color: #ccfbf1; }
.toast.bad{ border-color: #7f1d1d; color: #fecaca; }
@keyframes toast{ 0%{ opacity: 0; transform: translate(-50%, -8px); } 10%, 80%{ opacity: 1; transform: translate(-50%, 0); } 100%{ opacity: 0; } }

.tip{
  min-height: 2.6em; text-align: center; color: var(--ink-dim); font-size: 13px; line-height: 1.35;
  padding: 0 8px;
}
.tip b{ color: var(--ink); font-weight: 700; }
.tip .c-t{ color: var(--teal); } .tip .c-o{ color: var(--orange); } .tip .c-g{ color: var(--gold); } .tip .c-r{ color: #f87171; }

/* ---- Keys and touch pad ---- */
.keys{ text-align: center; color: var(--ink-dim); font-size: 11px; }
.keys kbd{ margin: 0 1px; }
.pad{ display: none; justify-content: space-between; align-items: center; gap: 12px; padding-bottom: 4px; }
.pad-group{ display: flex; gap: 10px; align-items: center; }
.pad-btn{
  width: 64px; height: 64px; border-radius: 50%; font: inherit; font-weight: 700; font-size: 14px;
  border: 1px solid var(--line); background: #ffffff0c; color: var(--ink); touch-action: none; user-select: none; -webkit-user-select: none;
}
.pad-btn.small{ width: 54px; height: 54px; font-size: 10px; color: var(--ink-dim); }
.pad-btn.jump{ border-color: #7a6a2a; color: var(--gold); width: 72px; height: 72px; }
.pad-btn.power{ border-color: #2f5a55; color: var(--teal); }
.pad-btn.on{ background: #ffffff26; transform: scale(.95); }
@media (pointer: coarse){
  .pad{ display: flex; }
  .keys{ display: none; }
}

/* ---- Overlays ---- */
.overlay{
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center;
  padding: 16px; background: #030308cc; backdrop-filter: blur(6px);
  animation: fade .2s ease-out;
}
.overlay[hidden]{ display: none; }
@keyframes fade{ from{ opacity: 0; } }
.panel{
  position: relative; width: 100%; max-width: 380px; max-height: 100%; overflow-y: auto;
  padding: 26px 22px 22px; border-radius: 20px; text-align: center;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #1a1830, #0d0c1a);
  box-shadow: 0 30px 80px #000a, inset 0 1px 0 #ffffff12;
  animation: rise .28s cubic-bezier(.2,.9,.3,1.2);
}
.panel-wide{ max-width: 560px; text-align: left; }
.panel-xwide{ max-width: 760px; text-align: left; }
.panel-story{ max-width: 500px; text-align: left; }
@keyframes rise{ from{ transform: translateY(14px) scale(.97); opacity: 0; } }
.panel h2{ font-family: Orbitron, sans-serif; font-weight: 900; font-size: 22px; letter-spacing: .08em; }
.panel-sub{ color: var(--ink-dim); font-size: 13px; margin-top: 4px; }
.panel-foot{ margin-top: 18px; text-align: center; color: var(--ink-dim); font-size: 12px; }
.close{
  position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid var(--line); background: #ffffff08; color: var(--ink-dim); font-size: 22px; line-height: 1; cursor: pointer;
}
.close:hover{ color: var(--ink); }
.link-btn{ font: inherit; font-size: 12px; color: var(--gold); background: none; border: none; cursor: pointer; text-decoration: underline; }

.eyebrow{ font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--accent); margin-bottom: 4px; }
.story-art{ display: grid; place-items: center; margin: -6px 0 10px; }
.story-art svg{ width: 120px; height: 120px; }
.story-art:empty{ display: none; }
.story-text{ margin-top: 12px; }
.story-text p{ font-size: 14px; line-height: 1.7; color: #e9e5f2; animation: fade .5s; }
.story-text p + p{ margin-top: 10px; }
.story-text .dark{ color: #fca5a5; }
.story-text a{ color: var(--gold); }

.howto{ margin: 14px 0 0 20px; display: flex; flex-direction: column; gap: 10px; font-size: 13px; line-height: 1.55; color: #e9e5f2; }
.howto b{ color: var(--ink); }
kbd{ font: inherit; font-size: 11px; padding: 1px 5px; border-radius: 5px; border: 1px solid var(--line); background: #ffffff0a; color: var(--ink); }

.win-line{ font-size: 15px; }
.win-line b{ font-family: Orbitron, sans-serif; }
.win-note{ color: var(--ink-dim); font-size: 12px; margin-top: 6px; min-height: 1em; }
.panel-actions{ display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }

.btn{
  font: inherit; font-weight: 700; font-size: 14px; letter-spacing: .06em; cursor: pointer;
  padding: 12px 16px; border-radius: 12px; border: 1px solid #fde68a88; text-align: center; text-decoration: none;
  color: #1c1405; background: linear-gradient(180deg, #fff3c4, #f5cf5a);
  box-shadow: 0 0 22px #fde68a44;
}
.btn:hover{ filter: brightness(1.06); }
.btn-ghost{ color: var(--ink); background: #ffffff08; border-color: var(--line); box-shadow: none; }
.btn-ghost:hover{ background: #ffffff12; }

/* ---- Rooms ---- */
.chapter{ margin-top: 16px; }
.chapter-head{ margin-bottom: 8px; }
.chapter-name{ font-family: Orbitron, sans-serif; font-weight: 700; font-size: 14px; letter-spacing: .06em; }
.chapter-blurb{ color: var(--ink-dim); font-size: 12px; }
.room-grid{ display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.room-btn{
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 8px; text-align: left;
  padding: 9px 10px; border-radius: 12px; cursor: pointer; font: inherit;
  border: 1px solid var(--line); background: #ffffff07; color: var(--ink);
}
.room-btn .rn{ grid-row: span 2; font-family: Orbitron, sans-serif; font-weight: 700; font-size: 16px; align-self: center; min-width: 22px; color: var(--ink-dim); }
.room-btn .rt{ font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-btn .rs{ font-size: 11px; color: var(--gold); min-height: 1.2em; }
.room-btn:hover:not(:disabled){ border-color: #6a6490; background: #ffffff10; }
.room-btn.done{ background: #fde68a0a; }
.room-btn.done .rn{ color: var(--gold); }
.room-btn.current{ border-color: var(--gold); }
.room-btn:disabled{ opacity: .35; cursor: default; }
.chapter-dark{ padding: 12px; border-radius: 16px; border: 1px solid #4a1d24; background: radial-gradient(circle at 90% 0%, #3a0d1488, #07060b 70%); }
.chapter-dark .chapter-name{ color: #fecaca; }
.win-kids svg{ width: 120px; height: 50px; margin-bottom: 6px; }
.howto .c-g{ color: var(--gold); font-weight: 700; } .howto .c-t{ color: var(--teal); font-weight: 700; } .howto .c-o{ color: var(--orange); font-weight: 700; }

/* ---- Achievements (same badges as the other Stargames) ---- */
.ach-list{ margin-top: 12px; }
.ach-grid{ display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 620px){ .ach-grid{ grid-template-columns: 1fr; } }
.ach-card{ display: flex; gap: 12px; align-items: flex-start; padding: 10px; background: #0e0d1a; border: 1px solid var(--line); border-radius: 12px; }
.ach-card.tier-1.done{ border-color: rgba(227,164,100,.6); }
.ach-card.tier-2.done{ border-color: rgba(226,232,240,.6); }
.ach-card.tier-3.done{ border-color: rgba(250,204,21,.7); }
.ach-card.tier-4.done{ border-color: rgba(196,181,253,.85); box-shadow: 0 0 12px rgba(167,139,250,.25); }
.ach-card.tier-5{ grid-column: 1 / -1; background: #000; border-color: rgba(255,255,255,.6); }
.ach-icon{ flex: 0 0 64px; width: 64px; height: 64px; }
.ach-icon svg{ width: 100%; height: 100%; display: block; }
.ach-card.tier-5 .ach-icon{ flex-basis: 96px; width: 96px; height: 96px; }
.ach-card.locked .ach-icon{ filter: grayscale(1) brightness(.6); }
.ach-body{ flex: 1; min-width: 0; }
.ach-tier{ font-size: 9px; letter-spacing: .18em; text-transform: uppercase; color: var(--ink-dim); }
.ach-card.tier-1.done .ach-tier{ color: #e3a464; }
.ach-card.tier-2.done .ach-tier{ color: #e2e8f0; }
.ach-card.tier-3.done .ach-tier{ color: #facc15; }
.ach-card.tier-4.done .ach-tier{ color: #c4b5fd; }
.ach-card.tier-5.done .ach-tier{ color: #fff; }
.ach-name{ font-size: 13px; font-weight: 700; color: var(--ink); margin: 2px 0 3px; }
.ach-card.locked .ach-name{ color: var(--ink-dim); }
.ach-req{ font-size: 11px; color: var(--ink-dim); line-height: 1.4; }
.ach-bar{ height: 5px; background: #06060c; border: 1px solid var(--line); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.ach-bar i{ display: block; height: 100%; background: var(--accent-deep); }
.ach-card.done .ach-bar i{ background: #a6ff66; }
.ach-progress{ font-size: 10px; color: var(--ink-dim); margin-top: 3px; font-variant-numeric: tabular-nums; }
.ach-toast{
  position: fixed; left: 50%; top: 14px; z-index: 30; transform: translate(-50%, -30px); opacity: 0;
  display: flex; gap: 10px; align-items: center; padding: 8px 14px 8px 8px; min-width: 260px;
  background: rgba(10,10,20,.96); border: 1px solid var(--line); border-radius: 12px; pointer-events: none;
  box-shadow: 0 8px 22px rgba(0,0,0,.5); transition: transform .35s ease, opacity .35s ease; text-align: left;
}
.ach-toast.show{ transform: translate(-50%, 0); opacity: 1; }
.ach-toast[hidden]{ display: none; }
.ach-toast.tier-1{ border-color: #e3a464; } .ach-toast.tier-2{ border-color: #e2e8f0; }
.ach-toast.tier-3{ border-color: #facc15; } .ach-toast.tier-4{ border-color: #c4b5fd; }
.ach-toast.tier-5{ border-color: #fff; background: #000; }
.ach-toast-icon{ width: 48px; height: 48px; flex: 0 0 48px; }
.ach-toast-icon svg{ width: 100%; height: 100%; display: block; }
.ach-toast-label{ font-size: 9px; letter-spacing: .16em; text-transform: uppercase; color: var(--accent); }
.ach-toast-name{ font-size: 13px; font-weight: 700; color: var(--ink); }
.ach-toast-reward{ font-size: 11px; color: var(--ink-dim); }


/* ---- Main menu ---- */
.hide-sm{ display: inline; } .show-sm{ display: none; }
.show-touch{ display: none; }
@media (pointer: coarse){ .hide-touch{ display: none !important; } .show-touch{ display: inline; } }
.menu{
  position: fixed; inset: 0; z-index: 9; overflow: hidden; background: var(--void);
  animation: fade .35s ease-out;
}
.menu[hidden]{ display: none; }
.menu-bg{ position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.menu-shade{
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, #04040aee 0%, #04040acc 28%, #04040a55 52%, transparent 75%), linear-gradient(0deg, #04040a99, transparent 30%);
}
.pill{
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px 7px 8px; border-radius: 999px;
  border: 1px solid #ffffff1c; background: #0a0a16b8; color: var(--ink-dim); text-decoration: none; font-size: 12px;
  backdrop-filter: blur(6px);
}
.pill:hover{ color: var(--ink); border-color: #ffffff3a; }
.pill-logo{ width: 22px; height: 22px; display: grid; place-items: center; border-radius: 6px; background: linear-gradient(135deg, #2dd4bf, #a78bfa); color: #04040a; font-size: 12px; font-weight: 900; }
.menu-home{ position: absolute; left: max(22px, env(safe-area-inset-left)); top: max(18px, env(safe-area-inset-top)); z-index: 2; }
.menu-actions{ position: absolute; right: max(22px, env(safe-area-inset-right)); top: max(18px, env(safe-area-inset-top)); z-index: 2; display: flex; gap: 10px; }
.round-btn{
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  border: 1px solid #ffffff1c; background: #0a0a16b8; color: var(--ink-dim); backdrop-filter: blur(6px);
}
.round-btn[hidden]{ display: none; }
.round-btn:hover{ color: var(--ink); border-color: #ffffff3a; }
.round-btn svg{ width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.round-btn svg .spk{ fill: currentColor; stroke: none; }
.round-btn .mute{ display: none; } .round-btn.muted .mute{ display: inline; } .round-btn.muted .wave{ display: none; }
.menu-main{
  position: absolute; z-index: 1; left: max(56px, 6vw); top: 50%; transform: translateY(-50%);
  width: min(440px, calc(100vw - 32px)); max-height: 100%; overflow-y: auto; padding: 70px 0 50px;
  scrollbar-width: none;
}
.menu-main::-webkit-scrollbar{ display: none; }
.menu-eyebrow{ font-size: 11px; letter-spacing: .24em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.menu-title{
  font-family: Orbitron, sans-serif; font-weight: 900; font-size: min(56px, calc((100vw - 36px) / 8.2)); line-height: 1.05; letter-spacing: .06em; white-space: nowrap; margin: 10px 0 8px;
  color: #fde68a; text-shadow: 0 0 34px #fde68a55, 0 3px 0 #b8860b; 
  background: linear-gradient(180deg, #fff7d6 10%, #fde68a 55%, #e0a93a); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 0 #8a5d10aa) drop-shadow(0 0 22px #fde68a44);
}
.menu-tag{ color: #bdb9d8; font-size: 15px; margin-bottom: 22px; }
.menu-primary{
  width: 100%; display: flex; align-items: center; gap: 14px; padding: 12px 16px 12px 12px; border-radius: 16px; cursor: pointer; text-align: left; font: inherit;
  border: 1px solid #fff3c4aa; color: #1c1405;
  background: linear-gradient(180deg, #ffeaa0, #f6d567);
  box-shadow: 0 0 34px #fde68a66, inset 0 1px 0 #fff9;
  transition: transform .12s, box-shadow .12s;
}
.menu-primary:hover, .menu-primary:focus-visible{ transform: translateY(-1px); box-shadow: 0 0 46px #fde68a99, inset 0 1px 0 #fff9; outline: none; }
.play-ico{ flex: 0 0 44px; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: #8a6a1c55; }
.play-ico svg{ width: 22px; height: 22px; fill: #3a2a06; margin-left: 2px; }
.mi-text{ display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 2px; }
.mi-text b{ font-family: Orbitron, sans-serif; font-size: 17px; letter-spacing: .04em; }
.mi-text i{ font-style: normal; font-size: 12px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-primary kbd{ border-color: #3a2a0666; background: #ffffff55; color: #3a2a06; font-size: 10px; letter-spacing: .1em; padding: 3px 8px; border-radius: 6px; }
.menu-list{ margin-top: 12px; display: flex; flex-direction: column; border-top: 1px solid #ffffff12; }
.menu-item{
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 8px; cursor: pointer; text-align: left; font: inherit; color: var(--ink);
  background: transparent; border: none; border-bottom: 1px solid #ffffff12; border-radius: 0;
}
.menu-item[hidden]{ display: none; }
.menu-item .mi-text b{ font-family: "Space Mono", monospace; font-size: 15px; letter-spacing: 0; }
.menu-item .mi-text i{ color: var(--ink-dim); opacity: 1; }
.menu-item .chev{ color: var(--ink-dim); font-size: 22px; line-height: 1; transition: transform .12s, color .12s; }
.menu-item:hover, .menu-item:focus-visible{ background: linear-gradient(90deg, #ffffff0d, transparent); outline: none; }
.menu-item:hover .chev, .menu-item:focus-visible .chev{ transform: translateX(3px); color: var(--gold); }
.menu-keys{
  position: absolute; z-index: 1; right: max(26px, 3vw); bottom: 56px; padding: 12px 14px 10px; border-radius: 14px;
  border: 1px solid #ffffff18; background: #0a0a16c8; backdrop-filter: blur(8px);
}
.mk-title{ font-size: 9px; letter-spacing: .2em; color: var(--ink-dim); margin-bottom: 8px; }
.mk-row{ display: flex; gap: 10px; }
.mk-row span{ display: flex; flex-direction: column; align-items: center; gap: 5px; }
.mk-row span:first-child{ flex-direction: row; flex-wrap: wrap; justify-content: center; max-width: 76px; }
.mk-row span:first-child i{ flex-basis: 100%; text-align: center; }
.mk-row kbd{ min-width: 34px; text-align: center; padding: 6px 8px; border-radius: 7px; font-size: 11px; background: #ffffff0c; border-color: #ffffff22; }
.mk-row i{ font-style: normal; font-size: 9px; color: var(--ink-dim); }
.menu-foot{
  position: absolute; z-index: 1; left: max(56px, 6vw); bottom: max(18px, env(safe-area-inset-bottom)); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: #7a7696;
}
.foot-link{ font: inherit; letter-spacing: inherit; text-transform: inherit; background: none; border: none; color: var(--gold); cursor: pointer; padding: 6px 2px; }
.foot-link:hover{ text-decoration: underline; }

/* ---- Hero runs ---- */
.panel-heroes{ max-width: 760px; }
.back{ position: absolute; top: 14px; left: 18px; font: inherit; font-size: 12px; color: var(--gold); background: none; border: none; cursor: pointer; padding: 6px 2px; }
.back[hidden]{ display: none; }
.panel-heroes .back:not([hidden]) ~ .eyebrow{ margin-top: 24px; }
.hero-cards{ margin-top: 16px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.hero-card{
  display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 18px 14px 16px; text-align: center; cursor: pointer; font: inherit; color: var(--ink);
  border-radius: 16px; border: 1px solid var(--line); background: linear-gradient(180deg, #17152a, #0d0c1a);
}
.hero-card:hover:not(:disabled){ transform: translateY(-2px); }
.hero-card.k0:hover:not(:disabled){ border-color: #fde68a; box-shadow: 0 0 24px #fde68a2a; }
.hero-card.k1:hover:not(:disabled){ border-color: #2dd4bf; box-shadow: 0 0 24px #2dd4bf2a; }
.hero-card.k2:hover:not(:disabled){ border-color: #fb923c; box-shadow: 0 0 24px #fb923c2a; }
.hero-card:disabled{ cursor: default; opacity: .62; }
.hc-art{ width: 72px; height: 72px; display: grid; place-items: center; border-radius: 50%; background: radial-gradient(circle, #ffffff10, transparent 70%); }
.hc-art svg{ width: 44px; height: 44px; }
.k0 .hc-art svg path{ fill: #fde68a; } .k1 .hc-art svg path{ fill: #2dd4bf; } .k2 .hc-art svg path{ fill: #fb923c; }
.hero-card.locked .hc-art svg{ filter: grayscale(1) brightness(.7); }
.hc-body{ display: flex; flex-direction: column; align-items: center; gap: 5px; width: 100%; }
.hc-name{ font-family: Orbitron, sans-serif; font-size: 15px; letter-spacing: .05em; }
.hc-power{ font-size: 10px; letter-spacing: .16em; text-transform: uppercase; }
.k0 .hc-power{ color: #fde68a; } .k1 .hc-power{ color: #2dd4bf; } .k2 .hc-power{ color: #fb923c; }
.hc-line{ font-size: 12px; line-height: 1.45; color: var(--ink-dim); }
.hc-bar{ width: 100%; height: 5px; border-radius: 3px; background: #06060c; border: 1px solid var(--line); overflow: hidden; margin-top: 6px; }
.hc-bar i{ display: block; height: 100%; background: var(--accent-deep); }
.k1 .hc-bar i{ background: #14a090; } .k2 .hc-bar i{ background: #d97316; }
.hc-prog{ font-size: 11px; color: var(--ink-dim); }
.hc-lock{ display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 11px; line-height: 1.4; color: #c9a227; margin-top: 4px; }
.lock{ width: 15px; height: 15px; flex: 0 0 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.hero-grid{ margin-top: 16px; }
.hero-grid.k0 .room-btn.done .rn{ color: #fde68a; } .hero-grid.k1 .room-btn.done .rn{ color: #2dd4bf; } .hero-grid.k2 .room-btn.done .rn{ color: #fb923c; }
.solo [data-pad="switch"]{ display: none; }
@media (max-width: 640px){
  .hero-cards{ grid-template-columns: 1fr; }
  .hero-card{ flex-direction: row; text-align: left; align-items: center; padding: 12px; gap: 12px; }
  .hc-art{ flex: 0 0 56px; width: 56px; height: 56px; } .hc-art svg{ width: 34px; height: 34px; }
  .hc-body{ align-items: flex-start; }
  .hc-lock{ justify-content: flex-start; text-align: left; }
  .room-grid{ grid-template-columns: repeat(2, 1fr); }
}

/* ---- Menu on phones ---- */
@media (max-width: 860px){
  .menu-shade{ background: linear-gradient(180deg, #04040acc 0%, #04040a99 45%, #04040acc 100%); }
  .menu-main{ left: 50%; transform: translate(-50%, -50%); width: min(430px, calc(100vw - 36px)); padding: 64px 0 56px; }
  .menu-keys{ display: none; }
  .menu-foot{ left: 0; right: 0; text-align: center; }
  .hide-sm{ display: none; } .show-sm{ display: inline; }
}
@media (max-height: 560px){
  .menu-main{ top: 0; transform: none; display: grid; grid-template-columns: 1fr 1fr; column-gap: 24px; align-items: center; height: 100%; padding: 56px 0 34px; width: auto; left: max(24px, env(safe-area-inset-left)); right: max(24px, env(safe-area-inset-right)); }
  .menu-main > .menu-eyebrow, .menu-main > .menu-title, .menu-main > .menu-tag, .menu-main > .menu-primary{ grid-column: 1; }
  .menu-main > .menu-list{ grid-column: 2; grid-row: 1 / span 4; margin-top: 0; align-self: center; }
  .menu-title{ font-size: clamp(34px, 9vh, 54px); margin: 4px 0; }
  .menu-tag{ margin-bottom: 10px; font-size: 13px; }
  .menu-item{ padding: 8px 8px; } .menu-item .mi-text i{ display: none; }
  .menu-primary{ padding: 8px 12px 8px 8px; } .play-ico{ flex-basis: 36px; width: 36px; height: 36px; }
  .menu-shade{ background: linear-gradient(90deg, #04040acc, #04040a77); }
  .menu-foot{ bottom: 6px; }
  .menu-home, .menu-actions{ top: max(8px, env(safe-area-inset-top)); }
  .round-btn{ width: 36px; height: 36px; }
}
@media (max-width: 420px){
  .menu-home{ left: 12px; } .menu-actions{ right: 12px; gap: 6px; }
  .round-btn{ width: 38px; height: 38px; }
  .pill{ padding: 5px 12px 5px 6px; }
  .menu-tag{ font-size: 13px; }
}
@media (prefers-reduced-motion: reduce){ .menu, .menu-primary{ animation: none; transition: none; } }


/* ---- Hero Run triangle ---- */
.tri{ position: relative; width: 100%; height: min(86vw, 420px); margin: 14px auto 0; max-width: 520px; }
.tri-lines{ position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.tri-lines line{ stroke: #3a3660; stroke-width: 2; stroke-dasharray: 5 6; vector-effect: non-scaling-stroke; }
.tri-lines line.lit{ stroke: #fde68a; stroke-dasharray: none; filter: drop-shadow(0 0 4px #fde68a88); }
.tri-node{
  position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none; cursor: pointer; font: inherit; color: var(--ink); padding: 0; -webkit-tap-highlight-color: transparent;
}
.tn-art{ position: relative; display: flex; align-items: center; justify-content: center; gap: 2px; border-radius: 50%; background: radial-gradient(circle at 50% 35%, #26224a, #0d0c1a); border: 2px solid var(--line); transition: transform .12s, box-shadow .12s; }
.tri-node.hero .tn-art{ width: 72px; height: 72px; }
.tri-node.duo .tn-art{ width: 62px; height: 62px; border-radius: 18px; transform: rotate(0); }
.tri-node:hover .tn-art, .tri-node:focus-visible .tn-art{ transform: scale(1.08); }
.tri-node:focus-visible{ outline: none; }
.tri-node.k0 .tn-art{ border-color: #fde68a; box-shadow: 0 0 18px #fde68a33; }
.tri-node.k1 .tn-art{ border-color: #2dd4bf; box-shadow: 0 0 18px #2dd4bf33; }
.tri-node.k2 .tn-art{ border-color: #fb923c; box-shadow: 0 0 18px #fb923c33; }
.tri-node.d01 .tn-art{ border-color: transparent; background: linear-gradient(#0d0c1a, #0d0c1a) padding-box, linear-gradient(135deg, #fde68a, #2dd4bf) border-box; box-shadow: 0 0 16px #8be5b522; }
.tri-node.d12 .tn-art{ border-color: transparent; background: linear-gradient(#0d0c1a, #0d0c1a) padding-box, linear-gradient(135deg, #2dd4bf, #fb923c) border-box; box-shadow: 0 0 16px #a8bf7922; }
.tri-node.d20 .tn-art{ border-color: transparent; background: linear-gradient(#0d0c1a, #0d0c1a) padding-box, linear-gradient(135deg, #fb923c, #fde68a) border-box; box-shadow: 0 0 16px #fbb86a22; }
.tri-node.locked .tn-art{ filter: grayscale(1) brightness(.6); box-shadow: none; }
.tri-node.locked .tn-art svg:not(.lock){ opacity: .45; }
.tn-art .lock{ position: absolute; width: 22px; height: 22px; color: #e9e5f2; stroke-width: 2.2; }
.tn-name, .tn-prog{ text-shadow: 0 0 3px #15132a, 0 0 5px #15132a, 0 0 8px #15132a; }
.tn-name{ font-family: Orbitron, sans-serif; font-size: 11px; font-weight: 700; letter-spacing: .05em; white-space: nowrap; }
.tri-node.duo .tn-name{ font-size: 9px; letter-spacing: .14em; color: var(--ink-dim); text-transform: uppercase; }
.tn-prog{ font-size: 10px; color: var(--ink-dim); min-height: 1.2em; }
.tri-node.complete .tn-prog{ color: var(--gold); }
.tri-node.complete .tn-art::after{ content: "✦"; position: absolute; top: -6px; right: -4px; font-size: 14px; color: #fff7d6; text-shadow: 0 0 8px #fde68a; }
.tri-info{ margin: 10px 0 0; min-height: 4.6em; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: #0d0c1a; color: var(--ink-dim); font-size: 12px; line-height: 1.55; text-align: center; transition: border-color .2s; }
.tri-info b{ color: var(--ink); font-family: Orbitron, sans-serif; }
.tri-info.flash{ border-color: #fde68a; }
.ti-power{ color: var(--gold); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; margin-left: 4px; }
.ti-prog{ color: var(--gold); margin-left: 4px; }
.ti-lock{ color: #e0b53a; display: inline-flex; gap: 6px; align-items: flex-start; justify-content: center; text-align: left; }
.hero-grid.duo .room-btn.done .rn{ color: #f0abfc; }
@media (max-width: 420px){
  .tri-node.hero .tn-art{ width: 60px; height: 60px; } .tri-node.duo .tn-art{ width: 52px; height: 52px; border-radius: 15px; }
  .tri-node.hero .tn-art svg{ width: 32px; height: 32px; } .tri-node.duo .tn-art svg{ width: 20px; height: 20px; }
  .tn-name{ font-size: 10px; }
}

@media (max-width: 720px){
  .app{ padding-left: 10px; padding-right: 10px; gap: 6px; }
  .brand{ font-size: 18px; letter-spacing: .2em; padding-left: .2em; }
  .home-link span{ display: none; }
  .icon-btn{ width: 36px; height: 36px; }
  .top-actions{ gap: 6px; }
  .hud{ padding: 6px 8px; gap: 8px; }
  .hud-title{ font-size: 14px; }
  .portrait{ width: 46px; }
  .portrait .tag{ display: none; }
  .tip{ font-size: 12px; min-height: 0; }
}
@media (max-width: 380px){
  .pad, .pad-group{ gap: 6px; }
  .pad-btn{ width: 54px; height: 54px; font-size: 13px; }
  .pad-btn.small{ width: 46px; height: 46px; font-size: 9px; }
  .pad-btn.jump{ width: 62px; height: 62px; }
}
@media (max-height: 560px){
  .app{ gap: 4px; padding-top: max(4px, env(safe-area-inset-top)); padding-bottom: max(4px, env(safe-area-inset-bottom)); }
  .tip, .keys{ display: none; }
  .hud-sub{ display: none; }
  .brand{ font-size: 15px; }
  .icon-btn{ width: 30px; height: 30px; }
  .icon-btn svg{ width: 17px; height: 17px; }
  .hud{ padding: 3px 8px; }
  .portrait{ padding: 2px 4px; }
  .portrait svg{ width: 18px; height: 18px; }
  .pad-btn{ width: 52px; height: 52px; }
  .pad-btn.jump{ width: 58px; height: 58px; }
}
/* landscape phones: the touch buttons float over the bottom corners so the room can fill the screen */
@media (pointer: coarse) and (orientation: landscape){
  .pad{ position: fixed; left: max(8px, env(safe-area-inset-left)); right: max(8px, env(safe-area-inset-right)); bottom: max(6px, env(safe-area-inset-bottom)); z-index: 5; pointer-events: none; }
  .pad-group{ pointer-events: auto; }
  .pad-btn{ background: #0b0a16a6; backdrop-filter: blur(2px); }
}
@media (prefers-reduced-motion: reduce){
  .panel, .overlay, .toast{ animation: none; }
}
