:root {
  color-scheme: dark;
  --ink: #12151c;
  --cream: #f4ead6;
  --orange: #ff7a1a;
  --teal: #43f0c8;
  --glass: rgba(18, 21, 28, 0.72);
  --label: "SF Pro Rounded", ui-rounded, "Nunito", system-ui, sans-serif;
  --digit: ui-monospace, "SF Mono", Menlo, monospace;
  --spring: cubic-bezier(0.2, 1.4, 0.4, 1);
  --move: 200ms;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ink);
  color: var(--cream);
  font: 16px/1.4 var(--label);
  overflow: hidden;
  touch-action: auto;
}

[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 2px;
}

#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#wayup {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  z-index: 12;
  color: var(--cream);
  background: var(--ink);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 16px;
  border: 2px solid var(--cream);
  font-weight: 700;
}

body:has(#aeParentNav) #wayup { display: none; }
body.photo #wayup { display: none; }

.bezel {
  position: relative;
  background: var(--glass);
  color: var(--cream);
  border: 2px solid var(--cream);
  border-radius: 16px;
  backdrop-filter: blur(10px);
  box-shadow: inset 0 1px 0 rgba(244, 234, 214, 0.35);
}

.bezel::before {
  content: '';
  position: absolute;
  inset: 5px;
  pointer-events: none;
  background:
    radial-gradient(circle at 0 0, #f4ead6 1.6px, transparent 1.8px),
    radial-gradient(circle at 100% 0, #f4ead6 1.6px, transparent 1.8px),
    radial-gradient(circle at 0 100%, #f4ead6 1.6px, transparent 1.8px),
    radial-gradient(circle at 100% 100%, #f4ead6 1.6px, transparent 1.8px);
}

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 8;
}

#hudPlates {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-16px);
  transition: opacity var(--move) var(--spring), transform var(--move) var(--spring);
}

body.hud-in #hudPlates {
  opacity: 1;
  transform: none;
}

#compass {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: 50%;
  width: min(340px, 46vw);
  height: 46px;
  transform: translateX(-50%);
  overflow: hidden;
  pointer-events: none;
}

#compassTrack {
  position: absolute;
  inset: 0;
}

.cardinal, .mark {
  position: absolute;
  top: 6px;
  transform: translateX(-50%);
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--cream);
  white-space: nowrap;
}

.mark {
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: 92px;
  color: var(--teal);
  font-weight: 700;
  font-size: 13px;
  text-shadow: 0 0 8px rgba(67, 240, 200, 0.45);
}
.mark i {
  font-style: normal;
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  line-height: 16px;
  margin: 0;
  text-align: center;
  border-radius: 4px;
  background: #16343c;
  box-shadow: 0 0 0 1px #43f0c8;
}
.mark b {
  font-weight: 700;
  min-width: 0;
  max-width: 74px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#phase {
  position: absolute;
  top: 64px;
  left: 50%;
  right: auto;
  bottom: auto;
  transform: translateX(-50%);
  margin: 0;
  font-family: var(--digit);
  font-size: 11px;
  color: var(--teal);
  background: rgba(18, 21, 28, 0.88);
  border-radius: 999px;
  padding: 2px 8px;
  text-shadow: 0 0 8px rgba(67, 240, 200, 0.45);
  pointer-events: none;
}

#compassPip {
  position: absolute;
  top: 4px;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 8px var(--orange);
}

#compassTick {
  position: absolute;
  left: 50%;
  top: 2px;
  z-index: 2;
  width: 0;
  height: 0;
  margin-left: -6px;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 9px solid #ff7a1a;
  pointer-events: none;
}

#topbar {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 108px;
  transform: none;
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
  padding: 4px 10px 4px 4px;
  pointer-events: auto;
  white-space: nowrap;
  width: max-content;
  max-width: calc(100vw - 280px);
}

#wordmark {
  background: #12151c;
  color: #f4ead6;
  border-radius: 14px;
  padding: 4px 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.1;
  cursor: pointer;
  min-width: 64px;
  text-align: center;
}

body.arriving #wordmark {
  animation: stamp 220ms var(--spring);
}

@keyframes stamp {
  0% { transform: scale(1.35); }
  100% { transform: none; }
}

.chip, #count, #phase, #wordmark { white-space: nowrap; flex: 0 0 auto; }

.chip, #count {
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.15;
  max-height: 34px;
}

.chip {
  background: #ff7a1a;
  color: #12151c;
}

#count {
  font-family: var(--digit);
  color: #43f0c8;
  background: #12151c;
  text-shadow: 0 0 8px rgba(67, 240, 200, 0.45);
  height: 22px;
  line-height: 22px;
  overflow: hidden;
}

#count.flap { animation: flap 200ms var(--spring); }

@keyframes flap {
  0% { transform: translateY(-60%); }
  100% { transform: none; }
}

#radar {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  width: 148px;
  height: 148px;
  border-radius: 50%;
  overflow: hidden;
  pointer-events: none;
}

#minimap {
  position: absolute;
  inset: 0;
  width: 148px;
  height: 148px;
  border-radius: 50%;
  border: 0;
  background: #12151c;
  pointer-events: none;
}

#sweep {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 78%, rgba(67, 240, 200, 0.55) 100%);
  opacity: 0;
  pointer-events: none;
}

#sweep.on { opacity: 1; animation: spin 900ms linear; }

@keyframes spin { to { transform: rotate(360deg); } }

#ahead {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #f4ead6;
  text-shadow: 0 1px 2px #12151c;
  pointer-events: none;
}

#scanMeter {
  position: absolute;
  left: max(16px, env(safe-area-inset-left));
  bottom: 78px;
  width: 72px;
  height: 72px;
  pointer-events: none;
}

#scanMeter svg { width: 100%; height: 100%; transform: rotate(-90deg); }
#scanMeter .track { fill: none; stroke: rgba(244, 234, 214, 0.25); stroke-width: 6; }
#scanMeter .arc {
  fill: none;
  stroke: #43f0c8;
  stroke-width: 6;
  stroke-linecap: round;
  filter: drop-shadow(0 0 4px rgba(67, 240, 200, 0.8));
}
#scanMeter.pulse .arc { animation: pulse 200ms var(--spring); }
#scanWord {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  color: #43f0c8;
}

@keyframes pulse {
  50% { stroke-width: 9; }
}

#keyHints {
  position: fixed;
  z-index: 9;
  left: max(16px, env(safe-area-inset-left));
  bottom: max(16px, env(safe-area-inset-bottom));
  max-width: calc(100vw - 140px);
  margin: 0;
  color: #f4ead6;
  font-weight: 700;
  pointer-events: none;
  transition: opacity var(--move) var(--spring);
}

body:not(.hud-in) #keyHints { opacity: 0; }
body.paused #keyHints { z-index: 28; opacity: 1; }
#keyHints.gone { opacity: 0; }
body.paused #keyHints.gone { opacity: 1; }

.keycap {
  display: inline-block;
  min-width: 1.4em;
  padding: 1px 6px;
  margin: 0 2px;
  border-radius: 8px;
  border: 2px solid #f4ead6;
  background: #12151c;
  color: #f4ead6;
  font-family: var(--digit);
  font-weight: 800;
  text-align: center;
}

#freeMouse {
  position: absolute;
  left: 50%;
  bottom: max(28px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  margin: 0;
  padding: 8px 14px;
  border-radius: 16px;
  border: 2px solid #f4ead6;
  background: rgba(18, 21, 28, 0.72);
  backdrop-filter: blur(10px);
  color: #f4ead6;
  font-weight: 800;
  white-space: nowrap;
}

#freeMouse.tiny {
  left: max(16px, env(safe-area-inset-left));
  bottom: max(64px, env(safe-area-inset-bottom));
  transform: none;
  width: 64px;
  height: 64px;
  min-width: 64px;
  min-height: 64px;
  padding: 0;
  overflow: hidden;
  font-size: 0;
}

#freeMouse.tiny::after {
  content: 'Esc';
  font-size: 13px;
  font-family: var(--digit);
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

#exploreBlock {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
}

#clickExplore {
  margin: 0;
  padding: 12px 18px;
  border-radius: 16px;
  border: 2px solid #f4ead6;
  background: rgba(18, 21, 28, 0.72);
  backdrop-filter: blur(10px);
  color: #f4ead6;
  font-size: 28px;
  font-weight: 800;
}

#lookHint, #walkHint {
  margin: 8px 0 0;
  color: #f4ead6;
  font-weight: 800;
}

#menuKey {
  position: fixed;
  z-index: 20;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  min-width: 64px;
  min-height: 64px;
  padding: 8px 16px;
  border-radius: 16px;
  border: 2px solid #f4ead6;
  background: #ff7a1a;
  color: #12151c;
  font: inherit;
  font-weight: 800;
  pointer-events: auto;
}

#prompt, #toast {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(18, 21, 28, 0.72);
  color: #f4ead6;
  border: 2px solid #f4ead6;
  border-radius: 16px;
  padding: 10px 14px;
  margin: 0;
  max-width: min(440px, 86vw);
  backdrop-filter: blur(10px);
}

#prompt { bottom: max(88px, calc(env(safe-area-inset-bottom) + 72px)); }
#toast { top: max(72px, calc(env(safe-area-inset-top) + 56px)); }

#touch {
  position: fixed;
  inset: auto 0 0 0;
  height: 46vh;
  z-index: 14;
  pointer-events: none;
}

#stick {
  position: absolute;
  left: max(18px, env(safe-area-inset-left));
  bottom: max(18px, env(safe-area-inset-bottom));
  width: 128px;
  height: 128px;
  min-width: 64px;
  min-height: 64px;
  border-radius: 50%;
  background: rgba(18, 21, 28, 0.72);
  border: 2px solid #f4ead6;
  backdrop-filter: blur(10px);
  pointer-events: auto;
  touch-action: none;
}

#stickLabel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  color: #f4ead6;
  pointer-events: none;
}

#nub {
  position: absolute;
  left: 42px;
  top: 42px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #ff7a1a;
}

#touchActions {
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 72px 72px;
  gap: 8px;
  pointer-events: auto;
}

#touch button, #photoBar button, .sheet button, #adminPanel button, #pauseGames {
  min-width: 64px;
  min-height: 64px;
  border-radius: 16px;
  border: 2px solid #f4ead6;
  font: inherit;
  font-weight: 800;
  padding: 8px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

#photoBar button, .sheet button, #adminPanel button, #pauseGames {
  background: #ff7a1a;
  color: #12151c;
}

#pauseRoot > button,
#pauseGames {
  background: #12151c;
  color: #f4ead6;
}

#pause #pauseResume {
  background: #ff7a1a;
  color: #12151c;
}

#photoBar #photoSave {
  background: #ff7a1a;
  color: #12151c;
}

#photoBar #photoExit {
  background: #12151c;
  color: #f4ead6;
}

#touch button {
  background: #12151c;
  color: #f4ead6;
  white-space: nowrap;
}

#touch #btnGuns,
#touch #btnMissiles {
  display: none;
}

body.cr #touch #btnGuns,
body.cr #touch #btnMissiles {
  display: inline-flex;
}

#weaponRead {
  position: absolute;
  left: 50%;
  bottom: 18%;
  transform: translateX(-50%);
  margin: 0;
  padding: 8px 14px;
  border-radius: 999px;
  background: #12151c;
  color: #f4ead6;
  font-weight: 800;
}

#touch #btnJump {
  background: #ff7a1a;
  color: #12151c;
  min-width: 84px;
  min-height: 84px;
  grid-column: 1 / -1;
}

#pause button, #pauseGames, #help button, #confirm button {
  width: 100%;
  margin-top: 8px;
}

#pauseGames { box-sizing: border-box; }

#photoBar {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  align-items: center;
  z-index: 16;
}

#photoNote {
  margin: 0;
  color: #f4ead6;
  background: rgba(18, 21, 28, 0.72);
  border: 2px solid #f4ead6;
  border-radius: 16px;
  padding: 8px 12px;
  font-weight: 800;
}

#loader {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: #12151c;
  color: #f4ead6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

#loaderName {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin: 0;
  padding: 8px 18px;
  border: 2px solid #f4ead6;
  border-radius: 16px;
}

#loaderHint { margin: 0; color: #43f0c8; font-weight: 800; }

#bootBar {
  width: min(280px, 70vw);
  height: 14px;
  margin-top: 8px;
  border: 2px solid #f4ead6;
  border-radius: 16px;
  overflow: hidden;
  background: #12151c;
}

#bootFill {
  display: block;
  height: 100%;
  width: 35%;
  background: #43f0c8;
  animation: boot 1.6s var(--spring) infinite;
}

@keyframes boot {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(290%); }
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 24;
  background: rgba(18, 21, 28, 0.45);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.sheet {
  width: min(560px, 100%);
  color: #f4ead6;
  padding: 22px;
  max-height: min(80vh, 720px);
  overflow: auto;
}

.sheet h2 { margin: 0 0 8px; color: #f4ead6; }
.sheet ul { padding-left: 18px; }
.sheet .row, #adminPanel { display: flex; flex-direction: column; gap: 10px; }
.sheet label, .toggle, .range {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: #f4ead6;
  font-weight: 700;
}
.hint, .safe { margin: 4px 0 8px; color: #f4ead6; }
#adminPanel select, #adminSpeed, #setQuality, #setSens, #setSound { min-height: 44px; }
#setQuality, #adminJump, #adminQuality {
  background: #12151c;
  color: #f4ead6;
  border: 2px solid #f4ead6;
  border-radius: 12px;
  min-height: 44px;
}

.map-sheet {
  position: relative;
  width: min(720px, calc(100vw - 48px), calc(100vh - 48px));
  height: min(720px, calc(100vw - 48px), calc(100vh - 48px));
  max-height: none;
  padding: 16px;
  overflow: hidden;
  background: rgba(18, 21, 28, 0.72);
}

#mapHead {
  position: absolute;
  top: 22px;
  left: 22px;
  right: 22px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 6px 8px 6px 14px;
  pointer-events: none;
  background: rgba(18, 21, 28, 0.72);
  border: 2px solid #f4ead6;
  border-radius: 16px;
}

#mapTitle { margin: 0; font-size: 20px; }
#mapNorth {
  margin: 0;
  font-weight: 800;
  color: #43f0c8;
  text-shadow: 0 0 8px rgba(67, 240, 200, 0.45);
}

#mapClose {
  margin-left: auto;
  pointer-events: auto;
  min-width: 64px;
  min-height: 64px;
  width: auto;
}

#mapLegend {
  position: absolute;
  left: 28px;
  right: 28px;
  bottom: 28px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 0;
  padding: 8px 12px;
  list-style: none;
  pointer-events: none;
  background: rgba(18, 21, 28, 0.72);
  border: 2px solid #f4ead6;
  border-radius: 14px;
  color: #f4ead6;
  font-weight: 800;
  font-size: 14px;
}

#mapLegend .swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 6px;
  border-radius: 4px;
  vertical-align: -2px;
}

#mapLegend .you { background: #43f0c8; }
#mapLegend .water { background: #1e609c; }
#mapLegend .land { background: #3a8a3e; }
#mapLegend .path { background: #c49a5c; }
#mapLegend .next { background: #ff7a1a; }
#mapCanvas { width: 100%; height: 100%; border-radius: 12px; display: block; }

#coach {
  position: fixed;
  left: 50%;
  bottom: 36px;
  transform: translateX(-50%);
  z-index: 17;
  margin: 0;
  pointer-events: none;
  background: rgba(18, 21, 28, 0.72);
  color: #f4ead6;
  border: 2px solid #f4ead6;
  border-radius: 16px;
  padding: 8px 14px;
  font-weight: 800;
  white-space: nowrap;
  backdrop-filter: blur(10px);
}

#logCard {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  top: 38%;
  z-index: 18;
  width: min(360px, 86vw);
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: rgba(18, 21, 28, 0.72);
  color: #f4ead6;
  border: 2px solid #f4ead6;
  border-radius: 16px;
  padding: 14px 16px;
  pointer-events: none;
  backdrop-filter: blur(10px);
}

#logCard.slide { animation: slideIn 220ms var(--spring); }

@keyframes slideIn {
  from { transform: translateX(72%); opacity: 0; }
  to { transform: none; opacity: 1; }
}

#logIcon {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: 2px solid #43f0c8;
  color: #43f0c8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0;
  text-shadow: 0 0 8px rgba(67, 240, 200, 0.45);
}

#logKind {
  margin: 0;
  font-family: var(--digit);
  font-size: 12px;
  font-weight: 800;
  color: #43f0c8;
  letter-spacing: 0.06em;
}

#logVoice {
  margin: 2px 0 0;
  font-size: 13px;
  font-weight: 800;
  color: #ffb020;
}

#logCard h2 { margin: 0 0 4px; font-size: 18px; color: #f4ead6; }
#logCard p { margin: 0; }

#aeAetherPill {
  position: fixed !important;
  left: max(14px, env(safe-area-inset-left)) !important;
  right: auto !important;
  top: calc(50% - 22px) !important;
  bottom: auto !important;
  width: 56px !important;
  height: 44px !important;
  z-index: 70 !important;
}

#adminSoak, #autotestResult {
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: 50;
  max-width: 90vw;
  white-space: pre-wrap;
  background: #12151c;
  color: #43f0c8;
  padding: 8px;
}

body.photo #minimap,
body.photo #radar,
body.photo #compass,
body.photo #topbar,
body.photo #scanMeter,
body.photo #keyHints,
body.photo #freeMouse,
body.photo #exploreBlock,
body.photo #menuKey,
body.photo #questChip { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  #hudPlates { transform: none !important; }
}

@media (max-width: 720px) {
  #radar, #minimap { width: 96px; height: 96px; }
  #wordmark { display: inline-block; }
}

/* Phone overrides for this bar must stay below it. A later bottom plus a phone top stretches the box. */
#storyBar {
  position: fixed;
  left: 50%;
  right: auto;
  top: auto;
  bottom: max(78px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 15;
  width: min(560px, calc(100% - 32px));
  height: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: stretch;
  padding: 8px 12px;
  border-radius: 16px;
  background: #12151c;
  color: #f4ead6;
  border: 2px solid #f4ead6;
  pointer-events: none;
}

#storyRow {
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
}

#storyWho {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0.04em;
  color: #43f0c8;
}

#questChip {
  position: fixed;
  top: 78px;
  left: 50%;
  right: auto;
  bottom: auto;
  transform: translateX(-50%);
  z-index: 9;
  margin: 0;
  padding: 6px 12px;
  border-radius: 999px;
  background: #12151c;
  color: #f4ead6;
  border: 2px solid #ff7a1a;
  font-weight: 800;
  font-size: 15px;
  pointer-events: none;
  max-width: min(420px, calc(100% - 220px));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.story-cover #exploreBlock,
body.story-cover #btnFriends,
body.story-cover #menuKey,
body.story-cover #scanMeter {
  visibility: hidden !important;
  pointer-events: none !important;
}

body.story-card #keyHints,
body.story-card #touch {
  visibility: hidden !important;
  pointer-events: none !important;
}

body.plant-ready #scanMeter {
  visibility: visible !important;
  left: 12px;
  right: auto;
  top: auto;
  bottom: 188px;
  transform: none;
}

.story-hide {
  visibility: hidden !important;
  pointer-events: none !important;
}

@media (max-width: 430px) {
  #wayup {
    top: 8px;
    left: 8px;
    padding: 6px 10px;
    font-size: 14px;
  }
  #topbar {
    left: 86px;
    right: auto;
    transform: none;
    top: 8px;
    width: max-content;
    max-width: calc(100vw - 178px);
    white-space: nowrap;
  }
  #wordmark { min-width: 0; }
  #compass {
    left: 8px;
    top: 92px;
    transform: none;
    width: 210px;
    height: 36px;
  }
  #phase {
    font-size: 11px;
    line-height: 1.15;
    padding: 1px 6px;
    top: 98px;
    left: 224px;
    right: auto;
    bottom: auto;
    transform: none;
    width: max-content;
  }
  #storyBar {
    padding: 3px 8px;
    gap: 2px;
  }
  #storyBar #storyWho {
    font-size: 12px;
    line-height: 12px;
    max-height: 12px;
    overflow: hidden;
  }
  #storyBar #storyRow {
    flex-wrap: wrap;
    row-gap: 2px;
  }
  #storyBar #storyBeat {
    order: -1;
    flex: 1 0 100%;
    font-size: 13px;
    line-height: 13px;
    max-height: 52px;
    overflow: hidden;
  }
  #phase::before,
  #phase[data-night="1"]::before { content: none; }
  #radar {
    top: 52px;
    right: 8px;
    width: 76px;
    height: 76px;
  }
  #minimap {
    top: 0;
    right: 0;
    bottom: auto;
    left: auto;
    width: 76px;
    height: 76px;
  }
  #ahead { font-size: 12px; top: 2px; }
  #wordmark { font-size: 13px; padding: 2px 8px; }
  #topbar .chip { font-size: 12px; padding: 2px 6px; }
  #count { font-size: 12px; }
  #keyHints, #menuKey { display: none; }
  #scanMeter {
    left: 50%;
    right: auto;
    bottom: auto;
    top: 132px;
    width: 56px;
    height: 56px;
    transform: translateX(-50%);
  }
  #clickExplore { font-size: 22px; }
  #aeAetherPill {
    top: 136px !important;
    left: 8px !important;
    right: auto !important;
    bottom: auto !important;
    width: 48px !important;
    height: 44px !important;
  }
  #coach {
    top: 196px;
    bottom: auto;
    left: 64px;
    transform: none;
    max-width: 168px;
    white-space: normal;
    text-align: left;
  }
  #logCard {
    left: 8px;
    right: 8px;
    top: auto;
    bottom: 196px;
    transform: none;
    width: auto;
    max-height: 168px;
    overflow: auto;
  }
  .map-sheet {
    height: auto;
    max-height: calc(100vh - 16px);
    overflow: auto;
  }
  #mapCanvas { height: min(62vw, 46vh); }
  #mapHead { position: static; }
  #mapLegend { position: static; margin-top: 8px; }
  #charCards { grid-template-columns: 1fr; }
  #freeMouse { max-width: 92vw; white-space: normal; text-align: center; }
  #questChip {
    top: 46px;
    bottom: auto;
    left: 8px;
    right: auto;
    transform: none;
    width: calc(100vw - 108px);
    max-width: calc(100vw - 108px);
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    z-index: 12;
    font-size: 13px;
    line-height: 1.15;
    padding: 4px 8px;
  }
  #storyBar {
    top: 148px;
    bottom: auto;
    left: 8px;
    right: auto;
    transform: none;
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    height: auto;
    max-height: none;
    z-index: 18;
    padding: 3px 8px;
    gap: 2px;
  }
}

body.force-phone #topbar {
  left: 86px;
  right: auto;
  top: 8px;
  transform: none;
  white-space: nowrap;
  width: max-content;
  max-width: calc(100vw - 178px);
}
body.force-phone #compass {
  left: 8px;
  top: 92px;
  transform: none;
  width: 210px;
  height: 36px;
}
body.force-phone #radar {
  top: 52px;
  right: 8px;
  width: 76px;
  height: 76px;
}
body.force-phone #minimap {
  top: 0;
  right: 0;
  width: 76px;
  height: 76px;
}
body.force-phone #keyHints,
body.force-phone #menuKey { display: none; }
body.force-phone #wordmark { min-width: 0; font-size: 13px; padding: 2px 8px; }
body.force-phone #topbar .chip { font-size: 12px; padding: 2px 6px; }
body.force-phone #count { font-size: 12px; }
body.force-phone #phase {
  font-size: 11px;
  line-height: 1.15;
  padding: 1px 6px;
  top: 98px;
  left: 224px;
  right: auto;
  bottom: auto;
  transform: none;
  width: max-content;
}
body.force-phone #phase::before,
body.force-phone #phase[data-night="1"]::before { content: none; }
body.force-phone #ahead { font-size: 12px; }
body.force-phone #coach {
  top: 196px;
  bottom: auto;
  left: 64px;
  transform: none;
  max-width: 200px;
  white-space: normal;
  text-align: left;
}
body.force-phone #logCard {
  left: 8px;
  right: 8px;
  top: auto;
  bottom: 196px;
  transform: none;
  width: auto;
  max-height: 168px;
  overflow: auto;
}
body.force-phone #questChip {
  top: 46px;
  bottom: auto;
  left: 8px;
  right: auto;
  transform: none;
  width: calc(100vw - 108px);
  max-width: calc(100vw - 108px);
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  z-index: 12;
  font-size: 13px;
  line-height: 1.15;
  padding: 4px 8px;
}
body.force-phone #storyBar {
  top: 148px;
  bottom: auto;
  left: 8px;
  right: auto;
  transform: none;
  width: calc(100vw - 16px);
  max-width: calc(100vw - 16px);
  height: auto;
  max-height: none;
  z-index: 18;
  padding: 3px 8px;
  gap: 2px;
}
body.force-phone #storyBar #storyWho {
  font-size: 12px;
  line-height: 12px;
  max-height: 12px;
  overflow: hidden;
}
body.force-phone #storyBar #storyRow {
  flex-wrap: wrap;
  row-gap: 2px;
}
body.force-phone #storyBar #storyBeat {
  order: -1;
  flex: 1 0 100%;
  font-size: 13px;
  line-height: 13px;
  max-height: 52px;
  overflow: hidden;
}

#titleCharacters {
  pointer-events: auto;
  margin: 14px auto 0;
  min-width: 64px;
  min-height: 64px;
  padding: 8px 18px;
  border-radius: 16px;
  border: 2px solid #f4ead6;
  background: #12151c;
  color: #f4ead6;
  font: inherit;
  font-weight: 800;
}

#charStage {
  width: min(100%, 280px);
  max-width: 280px;
  height: 220px;
  margin: 0 auto 8px;
  border-radius: 16px;
  background: #243044;
  display: block;
}

#charAsk {
  margin: 0 0 8px;
  font-weight: 750;
  color: #f4ead6;
}

#charWho {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 800;
  color: #f4ead6;
}

.charTop {
  display: flex;
  align-items: center;
  gap: 8px;
}

.charSwatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #12151c;
  display: inline-block;
  flex: 0 0 auto;
}

.playing {
  margin-left: auto;
  font-size: 13px;
  font-weight: 800;
}

#charCards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.charCardWrap { display: flex; flex-direction: column; gap: 4px; }

#pauseCharactersSheet .charCard {
  min-height: 64px;
  background: #12151c;
  color: #f4ead6;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
}

#pauseCharactersSheet .charCard small {
  font-weight: 650;
  font-size: 13px;
  line-height: 1.25;
}

#pauseCharactersSheet .charCard[aria-pressed="true"] {
  background: #ff7a1a;
  color: #12151c;
}

#pauseCharactersSheet a[data-credit] {
  color: #f4ead6;
  font-size: 14px;
  font-weight: 750;
  line-height: 1.3;
}

#charactersBack {
  position: sticky;
  bottom: 0;
  z-index: 2;
  background: #12151c;
  color: #f4ead6;
}

#btnFriends {
  position: absolute;
  left: max(18px, env(safe-area-inset-left));
  bottom: calc(156px + env(safe-area-inset-bottom));
  width: 112px;
  min-height: 64px;
  pointer-events: auto;
  z-index: 2;
}

#pauseWorkshopSheet {
  max-height: min(70vh, 640px);
  overflow: auto;
}

#workshopLead {
  margin: 0 0 6px;
  font-weight: 800;
}

#workshopBody {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(8, auto);
  gap: 6px;
  max-width: 280px;
  margin: 12px auto;
}

#workshopBody [data-part] {
  min-height: 44px;
  border: 2px dashed #8a8175;
  border-radius: 12px;
  color: #c8bfb0;
  font-size: 13px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4px;
  white-space: pre-line;
  line-height: 1.15;
}

#workshopBody [data-part].in {
  border-style: solid;
  border-color: #43f0c8;
  background: #16343c;
  color: #f4ead6;
}

#workshopBody [data-slot="mind"] {
  border-radius: 50%;
  width: 72px;
  min-height: 72px;
  justify-self: center;
}

#workshopBack {
  position: sticky;
  bottom: 0;
  z-index: 2;
  background: #12151c;
  color: #f4ead6;
}

#workshopCount {
  font-weight: 800;
  margin: 0 0 4px;
}

#workshopHint {
  min-height: 2.6em;
  color: #f4ead6;
}

@media (max-width: 430px) {
  #workshopBody {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-width: 100%;
  }
  #workshopBody [data-part] {
    min-width: 0;
    overflow-wrap: normal;
    word-break: normal;
    font-size: 12px;
    line-height: 1.15;
  }
  #workshopBody [data-slot="mind"] {
    width: 64px;
    min-height: 64px;
  }
}

body.force-phone #workshopBody {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-width: 100%;
}

body.force-phone #workshopBody [data-part] {
  min-width: 0;
  overflow-wrap: normal;
  word-break: normal;
  font-size: 12px;
  line-height: 1.15;
}

body.force-phone #workshopBody [data-slot="mind"] {
  width: 64px;
  min-height: 64px;
}

#storyCount {
  margin: 0;
  min-width: 4.2em;
  font-weight: 800;
  color: #ff7a1a;
}

#sunDot, #moonDot {
  display: inline-block;
  width: 22px;
  height: 22px;
  margin-right: 6px;
  border-radius: 50%;
  vertical-align: middle;
}

#sunDot {
  background: #ffb020;
  box-shadow:
    0 0 8px #ffb020,
    0 -11px 0 -7px #ffb020,
    0 11px 0 -7px #ffb020,
    -11px 0 0 -7px #ffb020,
    11px 0 0 -7px #ffb020,
    -8px -8px 0 -7px #ffb020,
    8px -8px 0 -7px #ffb020,
    -8px 8px 0 -7px #ffb020,
    8px 8px 0 -7px #ffb020;
}

#moonDot {
  background: #d5deea;
  box-shadow: 0 0 8px #c5d0e0, inset -8px 0 0 -2px #12151c;
}

#storyBeat {
  margin: 0;
  flex: 1;
  font-weight: 750;
  line-height: 1.35;
}

#logMore {
  margin: 6px 0 0;
  font-weight: 800;
  color: #43f0c8;
}

#storySkip {
  pointer-events: auto;
  min-width: 64px;
  min-height: 64px;
  border-radius: 16px;
  border: 2px solid #f4ead6;
  background: #ff7a1a;
  color: #12151c;
  font: inherit;
  font-weight: 800;
}

/* SAVE SLOTS (2026-10-17). Fixed layout: six tiles of one size, a one-line note, and a delete question that
   covers the slot area in place. Nothing in this sheet changes size when it repaints. */
#titleSaves {
  pointer-events: auto;
  margin: 14px 0 0 8px;
  min-width: 64px;
  min-height: 64px;
  padding: 8px 18px;
  border-radius: 16px;
  border: 2px solid #f4ead6;
  background: #12151c;
  color: #f4ead6;
  font: inherit;
  font-weight: 800;
}
#savesNote {
  height: 1.4em;
  line-height: 1.4em;
  margin: 0 0 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#savesTop {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
#pause #savesTop button {
  margin-top: 0;
  height: 64px;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}
#savesTop small {
  font-size: 13px;
  font-weight: 650;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#pause #savesNew {
  background: #12151c;
  color: #f4ead6;
}
#slotArea {
  position: relative;
  margin-top: 8px;
}
#slotList {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: repeat(3, 92px);
  gap: 8px;
}
.slotTile {
  position: relative;
  min-width: 0;
  height: 92px;
}
#pause .slotTile button {
  margin-top: 0;
  box-sizing: border-box;
}
#pause .slotPick {
  width: 100%;
  height: 92px;
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto auto;
  grid-template-columns: minmax(0, 1fr);
  justify-content: stretch;
  justify-items: start;
  align-content: center;
  gap: 2px;
  text-align: left;
  padding: 6px 10px;
  position: relative;
  background: #12151c;
  color: #f4ead6;
  overflow: hidden;
}
.slotPick b,
.slotPick small {
  display: block;
  max-width: 100%;
  box-sizing: border-box;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.slotPick b { font-size: 17px; }
/* the last line leaves room bottom-right for Delete (or the Playing tag) */
.slotPick small {
  width: 100%;
  font-size: 13px;
  font-weight: 650;
}
.slotPick .slotWhen { padding-right: 74px; }
.slotTag {
  position: absolute;
  right: 12px;
  bottom: 14px;
  font-style: normal;
  font-size: 13px;
  font-weight: 800;
}
#pause .slotTile.active .slotPick {
  background: #ff7a1a;
  color: #12151c;
}
#pause .slotTile.empty .slotPick {
  border-style: dashed;
  color: #c8bfb0;
}
#pause .slotDel {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 68px;
  min-width: 68px;
  height: 44px;
  min-height: 44px;
  padding: 4px;
  font-size: 14px;
  background: #12151c;
  color: #ffb3a0;
  border-color: #ffb3a0;
  z-index: 1;
}
#pause .slotDel.off { visibility: hidden; }
#slotConfirm {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  text-align: center;
  background: #12151c;
  border: 2px solid #ff7a1a;
  border-radius: 16px;
}
#slotConfirm[hidden] { display: none; }
#slotConfirmText {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#slotConfirmMore { margin: 0; font-weight: 700; }
#slotConfirmRow {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
  max-width: 420px;
}
#pause #slotConfirmRow button { margin-top: 0; }
#pause #slotKeep { background: #ff7a1a; color: #12151c; }
#pause #slotDelete { background: #12151c; color: #ffb3a0; border-color: #ffb3a0; }
#pauseSavesSheet.busy #savesTop,
#pauseSavesSheet.busy #slotArea { opacity: 0.6; pointer-events: none; }
#pauseSavesSheet button:focus-visible { outline: 3px solid #7df9ff; outline-offset: 2px; }
#pause [data-aepad-focus] { outline: 3px solid #7df9ff !important; outline-offset: 2px !important; }
@media (max-width: 560px) {
  #slotList { grid-template-columns: 1fr; grid-template-rows: repeat(6, 80px); }
  .slotTile, #pause .slotPick { height: 80px; }
}

/* Controller play (2026-10-24): the browser won't lock the pointer for a pad press, so hide it over the game. */
body.pad-play #view { cursor: none; }

/* Polish: scrollable sheets, clear tactile feedback, and readable phone chrome. */
.overlay { touch-action: pan-y; padding: max(12px, env(safe-area-inset-top)) 16px max(12px, env(safe-area-inset-bottom)); }
.sheet { touch-action: pan-y; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.sheet:not(.map-sheet) { max-height: min(88dvh, 800px); }
#touch { touch-action: none; }
.sheet label { min-height: 48px; }
.sheet input[type="checkbox"] { width: 24px; height: 24px; flex-shrink: 0; accent-color: var(--orange); }
.sheet input[type="range"] { min-width: 0; width: 45%; touch-action: pan-y; }
button, #pauseGames, #wayup { -webkit-tap-highlight-color: transparent; }
button:not(:disabled):active, #pauseGames:active { filter: brightness(1.2); }
button:disabled { opacity: 0.55; cursor: default; }
#wayup { min-height: 44px; display: inline-flex; align-items: center; }
#loadGoal, #loadControls, #loadTip { margin: 6px 0 0; max-width: 420px; text-align: center; }
#loadGoal { margin-top: 20px; font-size: 20px; font-weight: 800; }
#loadControls, #loadTip { color: #d5deea; }
#loadTip { font-size: 14px; }
#loader { padding: 24px; text-align: center; overflow: auto; }
#loader { justify-content: safe center; }
#loader > * { flex-shrink: 0; }
@media (prefers-reduced-motion: reduce) {
  #bootFill { animation: none; }
}
#loadRecovery { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 14px; }
#loadRecovery button, #loadRecovery a { min-height: 48px; padding: 12px 16px; border-radius: 12px; font: inherit; font-weight: 800; }
#loadRetry { background: var(--orange); color: var(--ink); border: 2px solid var(--cream); }
#loadRecovery a { color: var(--cream); }
#loadExit { position: absolute; top: max(12px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left)); min-height: 44px; padding: 10px 14px; color: var(--cream); border: 2px solid var(--cream); border-radius: 16px; text-decoration: none; font-weight: 700; }
#photoBar { width: min(620px, calc(100% - 24px)); flex-wrap: wrap; justify-content: center; bottom: max(72px, env(safe-area-inset-bottom)); }
#photoNote { flex: 1 0 100%; text-align: center; }
body.photo #touchActions, body.photo #btnFriends { display: none; }
body.photo #photoBar { pointer-events: auto; }
body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after { animation: none !important; transition: none !important; }
body.reduce-motion #hudPlates { transform: none !important; }
@media (max-width: 560px) {
  .sheet { padding: 16px; }
  #mapHead { flex-wrap: wrap; gap: 6px; }
  #mapTitle { font-size: 18px; }
  #mapNorth { font-size: 14px; }
  #mapClose { min-width: 52px; min-height: 48px; }
  #photoBar { bottom: max(164px, env(safe-area-inset-bottom)); }
  #savesNote { height: auto; min-height: 2.8em; white-space: normal; overflow: visible; }
}

/* Controls → Controller buttons: fixed-size rows and a two-line status, so rebinding never moves the menu. */
#pauseControlsSheet .padHead { margin: 14px 0 4px; color: #f4ead6; font-size: 1.05em; }
#pauseControlsSheet .padStatus { min-height: 2.6em; line-height: 1.3em; margin: 2px 0 6px; overflow: hidden; }
#pauseControlsSheet .padBinds { display: flex; flex-direction: column; gap: 6px; }
#pauseControlsSheet .padRow { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 52px; font-weight: 700; }
#pause #pauseControlsSheet .padBind {
  flex: none; width: 200px; min-width: 200px; height: 48px; min-height: 48px; margin-top: 0; padding: 4px 10px;
  background: #12151c; color: #f4ead6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px;
}
#pause #pauseControlsSheet .padBind.listening { background: #7df9ff; color: #12151c; border-color: #7df9ff; }
@media (max-width: 420px) { #pause #pauseControlsSheet .padBind { width: 150px; min-width: 150px; font-size: 13px; } }

/* Site content-runway chip ("Trailblazers") is injected after #count inside
   #topbar; inline it widens the bar into the compass. Hang it under the bar. */
#topbar .crw-chip { position: absolute; left: 4px; top: calc(100% + 6px); margin: 0; }

/* Short landscape screens keep every touch action above the bottom edge. */
@media (orientation: landscape) and (max-height: 540px) {
  #touchActions { grid-template-columns: repeat(3, 64px); gap: 6px; }
  #touch button, #touch #btnJump { min-width: 44px; min-height: 48px; grid-column: auto; font-size: 14px; }
  #touch #btnFriends { min-height: 48px; bottom: 154px; }
  #photoBar { width: min(360px, calc(100% - 180px)); left: auto; right: 12px; transform: none; bottom: 72px; }
  #photoBar button { min-height: 48px; }
  #loader { gap: 4px; }
  #loaderName { font-size: 28px; }
  #loadGoal { margin-top: 8px; }
}

/* Round 4: reserve parent navigation and let labels grow at phone widths. */
.overlay {
  padding-top: max(72px, calc(env(safe-area-inset-top) + 60px));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}
.sheet:not(.map-sheet) {
  max-height: min(800px, calc(100dvh - max(72px, calc(env(safe-area-inset-top) + 60px)) - max(16px, env(safe-area-inset-bottom))));
}
.map-sheet {
  width: min(720px, calc(100vw - 32px), calc(100dvh - 88px));
  height: min(720px, calc(100vw - 32px), calc(100dvh - 88px));
  max-height: 100%;
}
#pauseControlsSheet .padRow {
  height: auto;
  min-height: 52px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  overflow-wrap: anywhere;
}
#pause #pauseControlsSheet .padBind {
  width: 100%; min-width: 44px; height: auto;
  white-space: normal; overflow: visible; overflow-wrap: anywhere;
}
#wordmark { position: relative; border: 0; font-family: inherit; font-size: inherit; }
/* Gate fix: 44px touch area without growing the HUD chip (chips stay <= 34px). */
#wordmark::after { content: ''; position: absolute; inset: -9px -4px; }
#topbar { flex-wrap: wrap; max-width: calc(100vw - 124px); }
@media (max-width: 430px) {
  #topbar { gap: 2px 6px; max-width: calc(100vw - 94px); padding: 2px 6px; }
  #wordmark { font-size: 13px; }
  #topbar #count { flex-basis: 100%; text-align: center; }
}

.previewTurns { display: flex; gap: 8px; }
#pause .previewTurns button { min-height: 44px; margin: 0; }

#walkHint, #lookHint {
  background: #12151c; border-radius: 8px; padding: 4px 8px;
}
#topbar { top: max(72px, calc(env(safe-area-inset-top) + 60px)); left: max(16px, env(safe-area-inset-left)); }
@media (max-width: 430px) {
  #topbar {
    top: max(8px, env(safe-area-inset-top)); left: max(86px, calc(env(safe-area-inset-left) + 78px));
    display: grid; grid-template-columns: auto auto; gap: 0 6px;
  }
  #wordmark { grid-row: 1 / 3; }
  #topbar .chip { font-size: 11px; }
  #topbar #count { grid-column: 2; }
  #questChip { top: max(66px, calc(env(safe-area-inset-top) + 58px)); }
  .map-sheet { height: auto; max-height: calc(100dvh - 88px); }
}
