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

/* This is a fixed, single-screen app layout — nothing should scroll the page
   itself. Panels (guided-login card, terminal, macros, etc.) manage their own
   internal scroll. Without this, mobile browsers can rubber-band the whole
   page when any element is a hair taller than the viewport, and the address
   bar collapsing/expanding during that bounce reads as content "snapping
   back" mid-scroll. */
html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

/* ── Design tokens ─────────────────────────────────────────────────────── */
:root {
  --bg-deep:      #0e1823;
  --bg-panel:     #15232f;
  --bg-surface:   #1e3044;
  --border:       #2f4759;
  --border-light: #4d7299;
  --text-primary: #e9e2d3;
  --text-muted:   #8ea4b8;
  --text-dim:     #c0b8a8;
  --accent-blue:  #4d7299;
  --accent-gold:  #b8942a;
  --accent-gold-bright: #e3b737;
  --accent-gold-light:  #eedda0;
  --accent-green: #57a05a;
  --accent-cyan:  #4d9aaa;
  --accent-red:   #c04444;
  --accent-yellow:#c8a84a;
  --accent-magenta:#8866aa;
  --selection:    #2f4759;
  --cursor:       #d9c9a3;
  --shadow:       rgba(0, 0, 0, 0.3);
  --shadow-heavy: rgba(0, 0, 0, 0.5);
  --glow-gold:    rgba(184, 148, 42, 0.4);
  --transition:   0.2s ease;
}

html, body {
  height: 100%;
  background: var(--bg-deep);
  cursor: url('/play/sounds/cursor_pointer.png'), auto;
  color: var(--text-primary);
  font-family: 'Consolas', 'Menlo', 'Courier New', monospace;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: filter 3s;
}
/* Text inputs keep the native I-beam, not the custom fantasy cursor */
input[type="text"], input[type="search"], input:not([type]), textarea { cursor: text; }

body.sleeping { filter: brightness(0.15); }
body.cv-protanopia { filter: url(#cv-protanopia); }
body.cv-deuteranopia { filter: url(#cv-deuteranopia); }
body.cv-tritanopia { filter: url(#cv-tritanopia); }
body.cv-highcontrast { filter: contrast(1.4) saturate(1.3); }
body.cv-grayscale { filter: grayscale(1) contrast(1.2); }
body.sleeping.cv-protanopia { filter: brightness(0.15) url(#cv-protanopia); }
body.sleeping.cv-deuteranopia { filter: brightness(0.15) url(#cv-deuteranopia); }
body.sleeping.cv-tritanopia { filter: brightness(0.15) url(#cv-tritanopia); }
body.sleeping.cv-highcontrast { filter: brightness(0.15) contrast(1.4) saturate(1.3); }
body.sleeping.cv-grayscale { filter: brightness(0.15) grayscale(1) contrast(1.2); }

/* ── Combat mode ────────────────────────────────────────────────────────── */

body.combat #terminal-wrap {
  box-shadow: inset 0 0 40px rgba(180, 40, 20, 0.15);
  animation: combat-pulse 2s ease-in-out infinite;
}
body.combat #cmd-input { border-color: #8a3030; }
body.combat #cmd-input:focus { border-color: #c04444; }
body.combat .dir-btn { border-color: #5a2020; color: #c09080; }
body.combat .dir-btn:hover { background: #8a3030; }
body.combat .exits-known .dir-btn.exit-avail { border-color: #c04444; }
body.combat #inputbar { border-color: #5a2020; }
body.combat { filter: contrast(1.08) saturate(1.15); }

@keyframes combat-pulse {
  0%, 100% { box-shadow: inset 0 0 40px rgba(180, 40, 20, 0.12); }
  50% { box-shadow: inset 0 0 50px rgba(180, 40, 20, 0.22); }
}

body.combat.light #cmd-input { border-color: #c07060; }
body.combat.light .dir-btn { border-color: #c09080; color: #8a4030; }
body.combat.light .exits-known .dir-btn.exit-avail { border-color: #c04444; }

/* ── Death screen ──────────────────────────────────────────────────────── */

#death-screen {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0);
}

#death-screen.active {
  animation: death-bg 8s ease-out forwards;
}

#death-screen.active #death-text {
  animation: death-text-fade 8s ease-out forwards;
}

#death-text {
  font-family: 'Aniron', serif;
  font-size: 1.8rem;
  background: linear-gradient(180deg, #b87316 0%, #e3b737 30%, #eedda0 50%, #e3b737 70%, #b87316 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 20px rgba(184, 115, 22, 0.4));
  opacity: 0;
}

@keyframes death-bg {
  0%   { background: rgba(0,0,0,0); }
  40%  { background: rgba(0,0,0,0.6); }
  100% { background: rgba(0,0,0,0.95); }
}

@keyframes death-text-fade {
  0%, 50% { opacity: 0; }
  70%     { opacity: 1; }
  100%    { opacity: 0.8; }
}

/* ── Snow particles ─────────────────────────────────────────────────────── */
/* Canvas now (see client.js); JS drives opacity via the .active class same as
   before, drawing itself is done in snowFrame() rather than a CSS keyframe. */

#snow-container {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 3;
  overflow: hidden;
  opacity: 0;
  transition: opacity 3s;
}
#snow-container.active { opacity: 1; }

@keyframes underwater-wave {
  0%, 100% { transform: skewX(0deg) translateX(0); }
  25%  { transform: skewX(0.3deg) translateX(1px); }
  50%  { transform: skewX(-0.15deg) translateX(-0.5px); }
  75%  { transform: skewX(-0.3deg) translateX(-1px); }
}
#terminal-wrap.underwater { animation: underwater-wave 4s ease-in-out infinite; }

@keyframes screen-shake {
  0%   { transform: translate(0, 0); }
  15%  { transform: translate(calc(-1px * var(--shake)), calc(1px * var(--shake))); }
  30%  { transform: translate(calc(2px * var(--shake)), calc(-1px * var(--shake))); }
  45%  { transform: translate(calc(-1px * var(--shake)), calc(-2px * var(--shake))); }
  60%  { transform: translate(calc(2px * var(--shake)), calc(1px * var(--shake))); }
  75%  { transform: translate(calc(-1px * var(--shake)), calc(0px * var(--shake))); }
  100% { transform: translate(0, 0); }
}

@font-face {
  font-family: 'Aniron';
  src: url('/play/sounds/aniron.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}
@font-face {
  font-family: 'Aniron Mono';
  src: url('/play/sounds/aniron_mono.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}
@font-face {
  font-family: 'Ringbearer Mono';
  src: url('/play/sounds/ringbearer_mono.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}
@font-face {
  font-family: 'OpenDyslexic Mono';
  src: url('/play/sounds/opendyslexic_mono.otf') format('opentype');
  font-weight: normal;
  font-style: normal;
}
@font-face {
  font-family: 'Tengwar';
  src: url('/play/sounds/tengwar_mapped.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

/* ── Splash overlay ────────────────────────────────────────────────────── */

#splash-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 200;
  background: rgba(5, 5, 10, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 1.5s;
}
#splash-overlay.hidden { opacity: 0; pointer-events: none; }

/* ── Login clouds ──────────────────────────────────────────────────────── */

.login-cloud {
  position: absolute;
  background: rgba(200, 200, 220, 0.25);
  border-radius: 50%;
  filter: blur(30px);
  animation: cloud-drift linear infinite;
  z-index: 1;
}
@keyframes cloud-drift {
  0%   { transform: translateX(-120%); }
  100% { transform: translateX(calc(100vw + 120%)); }
}

.login-mist {
  position: absolute;
  bottom: 0;
  border-radius: 50%;
  background: rgba(180, 185, 200, 0.35);
  filter: blur(35px);
  animation: mist-rise ease-in-out infinite;
  z-index: 1;
}

@keyframes mist-rise {
  0%   { transform: translateY(20px) scale(1); opacity: 0; }
  20%  { opacity: 0.6; }
  60%  { opacity: 0.3; }
  100% { transform: translateY(-200px) scale(1.8); opacity: 0; }
}

#splash-content { text-align: center; animation: splash-fade-in 2s ease-out; }
@keyframes splash-fade-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

#splash-title {
  font-family: 'Aniron', serif;
  font-size: 2.8rem;
  font-weight: normal;
  letter-spacing: 0.15em;
  font-variant: small-caps;
  background: linear-gradient(180deg, #b87316 0%, #e3b737 30%, #eedda0 50%, #e3b737 70%, #b87316 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 20px rgba(184, 115, 22, 0.4)) drop-shadow(0 0 40px rgba(227, 183, 55, 0.15));
  margin-bottom: 1.2rem;
  position: relative;
}

#splash-sub {
  font-family: 'Aniron', serif;
  font-size: 0.7rem;
  color: #eedda0;
  letter-spacing: 0.1em;
  animation: splash-pulse 2.5s ease-in-out infinite;
}

@keyframes splash-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ── Login backdrop ────────────────────────────────────────────────────── */

#login-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 0;
  overflow: hidden;
  background: #050508;
  transition: opacity 3s;
}
#login-backdrop.hidden { opacity: 0; pointer-events: none; }
#login-backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, .58), rgba(0, 0, 0, .28) 9%, rgba(0, 0, 0, .08) 22%, transparent 38%),
    linear-gradient(90deg, rgba(0, 0, 0, .35), transparent 22%, transparent 78%, rgba(0, 0, 0, .35));
}

.lb-slide {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  animation: kb-fade 120s infinite;
}

#lb-s1 {
  background-image: url("/play/bg_minas.png");
  animation-delay: 0s;
  animation-name: kb-fade, kb-pan1;
}
#lb-s2 {
  background-image: url("/play/bg_mountains.png");
  animation-delay: 15s;
  animation-name: kb-fade, kb-pan2;
}
#lb-s3 {
  background-image: url("/play/bg_falls.png");
  animation-delay: 30s;
  animation-name: kb-fade, kb-pan3;
}
#lb-s4 {
  background-image: url("/play/bg_gondor_map.png");
  animation-delay: 45s;
  animation-name: kb-fade, kb-pan1;
}
#lb-s5 {
  background-image: url("/play/bg_argonath.png");
  animation-delay: 60s;
  animation-name: kb-fade, kb-pan2;
}
#lb-s6 {
  background-image: url("/play/bg_whitetree.png");
  animation-delay: 75s;
  animation-name: kb-fade, kb-pan3;
}
#lb-s7 {
  background-image: url("/play/bg_osgiliath_map.png");
  animation-delay: 90s;
  animation-name: kb-fade, kb-pan1;
}
#lb-s8 {
  background-image: url("/play/bg_ithilien.png");
  animation-delay: 105s;
  animation-name: kb-fade, kb-pan2;
}

@keyframes kb-fade {
  0%    { opacity: 0; }
  2%    { opacity: 1; }
  10.5% { opacity: 1; }
  12.5% { opacity: 0; }
  100%  { opacity: 0; }
}

@keyframes kb-pan1 {
  0%   { transform: scale(1.1) translate(5%, 2%); }
  33%  { transform: scale(1.1) translate(-5%, -2%); }
  100% { transform: scale(1.1) translate(5%, 2%); }
}
@keyframes kb-pan2 {
  0%   { transform: scale(1.02) translate(-1%, 0%); }
  33%  { transform: scale(1.05) translate(1%, 0%); }
  100% { transform: scale(1.02) translate(-1%, 0%); }
}
@keyframes kb-pan3 {
  0%   { transform: scale(1.02) translate(1%, 0%); }
  33%  { transform: scale(1.05) translate(-1%, 0%); }
  100% { transform: scale(1.02) translate(1%, 0%); }
}

/* ── Main menu ─────────────────────────────────────────────────────────── */

#main-menu {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 90;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(5, 6, 12, 0.5);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
body.menu-active #main-menu { display: flex; animation: panel-fade-in 0.7s ease-out; }
body.menu-active #topbar,
body.menu-active #terminal-wrap,
body.menu-active #statusbar,
body.menu-active #inputbar,
body.menu-active #fire-flicker,
body.menu-active #action-bar { opacity: 0; pointer-events: none; visibility: hidden; }
body.menu-active { background: transparent; }

#menu-content { text-align: center; animation: splash-fade-in 1s ease-out; }

#menu-title {
  font-family: 'Aniron', serif;
  font-size: 2.6rem;
  letter-spacing: 0.13em;
  font-variant: small-caps;
  background: linear-gradient(180deg, #b87316 0%, #e3b737 32%, #eedda0 50%, #e3b737 68%, #b87316 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 18px rgba(184, 115, 22, 0.4)) drop-shadow(0 0 40px rgba(227, 183, 55, 0.12));
  margin-bottom: 0.4rem;
}
#menu-sub {
  font-family: 'Aniron', serif;
  font-size: 0.65rem;
  color: #c9b888;
  letter-spacing: 0.12em;
  opacity: 0.7;
  margin-bottom: 2.2rem;
}
#menu-buttons { display: flex; flex-direction: column; gap: 0.75rem; align-items: center; }

.menu-btn {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  font-family: 'Aniron', serif;
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  min-width: 300px;
  padding: 0.7rem 1.6rem;
  background:
    linear-gradient(180deg, rgba(35, 47, 58, 0.72), rgba(12, 18, 27, 0.72)),
    rgba(20, 30, 42, 0.55);
  border: 1px solid rgba(184, 148, 42, 0.4);
  border-radius: 6px;
  color: #eedda0;
  transition: background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease, color 0.25s ease, transform 0.15s ease;
}
.menu-btn::before {
  content: "";
  position: absolute;
  inset: -120% -35%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 18% 35%, rgba(255, 219, 103, 0.42), transparent 28%),
    radial-gradient(ellipse at 76% 62%, rgba(184, 94, 22, 0.36), transparent 32%),
    radial-gradient(ellipse at 48% 48%, rgba(255, 246, 190, 0.22), transparent 25%),
    linear-gradient(115deg, transparent 18%, rgba(184, 148, 42, 0.16) 43%, rgba(255, 246, 190, 0.24) 50%, rgba(184, 94, 22, 0.18) 57%, transparent 82%);
  background-size: 160% 160%, 180% 180%, 145% 145%, 220% 100%;
  filter: blur(1px);
  transform: translate3d(-8%, 0, 0) rotate(0deg) scale(1.05);
  opacity: 0.36;
  animation: menu-molten-gold 6s ease-in-out infinite alternate;
}
.menu-btn::after {
  content: "";
  position: absolute;
  inset: -55% -80%;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(
    115deg,
    transparent 0%,
    transparent 38%,
    rgba(184, 148, 42, 0.10) 44%,
    rgba(255, 246, 190, 0.58) 50%,
    rgba(184, 148, 42, 0.16) 56%,
    transparent 62%,
    transparent 100%
  );
  mix-blend-mode: screen;
  opacity: 0;
  transform: translateX(-72%) skewX(-12deg);
}
.menu-btn:hover {
  background:
    linear-gradient(180deg, rgba(52, 42, 20, 0.52), rgba(16, 19, 24, 0.78)),
    rgba(184, 148, 42, 0.14);
  border-color: rgba(184, 148, 42, 0.85);
  box-shadow:
    0 0 20px rgba(184, 148, 42, 0.22),
    inset 0 0 18px rgba(238, 221, 160, 0.08);
  color: #fff;
}
.menu-btn:hover::before {
  opacity: 0.78;
  animation-duration: 3.2s;
}
.menu-btn:hover::after,
.menu-btn:focus-visible::after {
  opacity: 1;
  animation: menu-gold-shine 1.1s ease-out forwards;
}
.menu-btn:active { transform: translateY(1px); }
.menu-btn:focus { outline: none; }
.menu-btn:focus-visible {
  outline: none;
  border-color: rgba(184, 148, 42, 0.85);
  box-shadow: 0 0 20px rgba(184, 148, 42, 0.3);
}

@keyframes menu-molten-gold {
  0% {
    background-position: 0% 45%, 82% 56%, 45% 52%, 0% 50%;
    transform: translate3d(-8%, 0, 0) rotate(-1deg) scale(1.05);
  }
  50% {
    background-position: 24% 52%, 58% 46%, 52% 42%, 50% 50%;
    transform: translate3d(4%, -2%, 0) rotate(1deg) scale(1.11);
  }
  100% {
    background-position: 42% 38%, 34% 64%, 60% 56%, 100% 50%;
    transform: translate3d(9%, 1%, 0) rotate(-0.5deg) scale(1.07);
  }
}

@keyframes menu-gold-shine {
  0% { transform: translateX(-72%) skewX(-12deg); }
  100% { transform: translateX(72%) skewX(-12deg); }
}

.menu-btn-ghost {
  min-width: 200px;
  padding: 0.45rem 1rem;
  margin-top: 0.6rem;
  font-size: 0.85rem;
  border-color: rgba(140, 164, 184, 0.25);
  color: rgba(200, 200, 210, 0.55);
}
.menu-btn-ghost::before { opacity: 0.16; }
.menu-btn-ghost::after { opacity: 0; }
.menu-btn-ghost:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(140, 164, 184, 0.5);
  box-shadow: none;
  color: #d8d8e0;
}
.menu-btn-ghost:hover::before { opacity: 0.28; }

@media (prefers-reduced-motion: reduce) {
  .menu-btn::before,
  .menu-btn:hover::before {
    animation: none;
    opacity: 0.24;
  }
  .menu-btn:hover::after,
  .menu-btn:focus-visible::after {
    animation: none;
    opacity: 0;
  }
}

@media (max-width: 600px) {
  #menu-title { font-size: 1.9rem; }
  .menu-btn { min-width: 260px; font-size: 0.95rem; }
}

body.login-screen #topbar { background: rgba(21, 35, 47, 0.4); }
body.login-screen #terminal-wrap { opacity: 0.55; }
body.login-screen #inputbar { background: rgba(14, 24, 35, 0.4); }
body.login-screen { background: transparent; }
body.splash-active #topbar,
body.splash-active #terminal-wrap,
body.splash-active #statusbar,
body.splash-active #inputbar,
body.splash-active #fire-flicker,
body.splash-active #action-bar { opacity: 0; pointer-events: none; }
body.splash-active { background: transparent; }

/* ── Micro-interactions ────────────────────────────────────────────────── */

#settings-panel, #macro-panel, #help-panel, #color-editor, #alias-panel, #command-palette {
  animation: panel-fade-in 0.2s ease-out;
}
@keyframes panel-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes panel-fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

#minimap-wrap.visible { animation: minimap-appear 0.5s ease-out; }
@keyframes minimap-appear {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 0.85; transform: translateY(0); }
}
@keyframes minimap-disappear {
  from { opacity: 0.85; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-8px); }
}

/* ── Tooltips ──────────────────────────────────────────────────────────── */

.soi-tooltip {
  position: fixed;
  background: rgba(15, 22, 30, 0.95);
  border: 1px solid rgba(184, 148, 42, 0.3);
  border-radius: 5px;
  color: var(--text-primary);
  font-size: .75rem;
  padding: .4rem .6rem;
  max-width: 240px;
  pointer-events: none;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.2s;
  box-shadow: 0 2px 10px var(--shadow-heavy);
  line-height: 1.4;
}
.soi-tooltip.visible { opacity: 1; }
.soi-tooltip .tt-label {
  color: var(--accent-gold-bright);
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: .2rem;
}

/* ── Display Modes ─────────────────────────────────────────────────────── */

/* Manuscript — warm literary styling */
body[data-text-mode="manuscript"] #topbar { background: #2a2118; border-color: #4a3a28; }
body[data-text-mode="manuscript"] #statusbar { background: #241e15; border-color: #3a2e20; }
body[data-text-mode="manuscript"] #inputbar { background: #2a2118; border-color: #4a3a28; }
body[data-text-mode="manuscript"] #terminal-wrap { padding: 1rem 2rem .5rem; }
body[data-text-mode="manuscript"] #cmd-input { background: #1a1610; border-color: #4a3a28; }
body[data-text-mode="manuscript"] .status-tag { background: #2a2118; border-color: #4a3a28; color: #c8b898; }
body[data-text-mode="manuscript"] .tb-btn { background: #2a2118; border-color: #4a3a28; color: #c8b898; }
body[data-text-mode="manuscript"] .dir-btn { background: #2a2118; border-color: #4a3a28; color: #c8b898; }
body[data-text-mode="manuscript"] #conn-label { color: #a89878; }
body[data-text-mode="manuscript"] .vital-track { border-color: #4a3a28; background: #1a1610; }
body[data-text-mode="manuscript"] .vital-fill { border-radius: 1px; }

/* Travel Journal — exploration emphasis */
body[data-text-mode="travel-journal"] #minimap-wrap { display: block !important; width: 260px; height: 260px; opacity: 1; }
body[data-text-mode="travel-journal"] #minimap { width: 260px; height: 260px; }
body[data-text-mode="travel-journal"] #statusbar { background: #152218; border-color: #2a4a30; }
body[data-text-mode="travel-journal"] #topbar { background: #152218; border-color: #2a4a30; }
body[data-text-mode="travel-journal"] #inputbar { background: #152218; border-color: #2a4a30; }
body[data-text-mode="travel-journal"] .status-tag { background: #1a2e1e; border-color: #2a4a30; color: #8ac090; }
body[data-text-mode="travel-journal"] .tb-btn { background: #1a2e1e; border-color: #2a4a30; color: #8ac090; }
body[data-text-mode="travel-journal"] .dir-btn { border-color: #2a4a30; color: #8ac090; }
body[data-text-mode="travel-journal"] .exits-known .dir-btn.exit-avail { border-color: #4a8a50; color: #a0d8a8; background: rgba(40,100,50,0.2); }
body[data-text-mode="travel-journal"] .vital-track { border-color: #2a4a30; }
body[data-text-mode="travel-journal"] #cmd-input { border-color: #2a4a30; }
body[data-text-mode="travel-journal"] #conn-label { color: #6a9a70; }

/* Combat Focus — combat readability */
body[data-text-mode="combat-focus"] #statusbar { background: #1f1518; border-color: #4a2530; border-bottom-width: 2px; }
body[data-text-mode="combat-focus"] #topbar { background: #1f1518; border-color: #4a2530; }
body[data-text-mode="combat-focus"] #inputbar { background: #1f1518; border-color: #4a2530; }
body[data-text-mode="combat-focus"] .vital-track { border-color: #4a2530; height: 10px; }
body[data-text-mode="combat-focus"] .vital-name { font-size: .8rem; color: #c08888; }
body[data-text-mode="combat-focus"] .status-tag { background: #2a1520; border-color: #4a2530; color: #c8a0a0; }
body[data-text-mode="combat-focus"] .tb-btn { background: #2a1520; border-color: #4a2530; color: #c8a0a0; }
body[data-text-mode="combat-focus"] .dir-btn { border-color: #4a2530; color: #c8a0a0; }
body[data-text-mode="combat-focus"] #cmd-input { border-color: #4a2530; }
body[data-text-mode="combat-focus"] #conn-label { color: #9a6a6a; }
body[data-text-mode="combat-focus"] #target-info.visible { border: 1px solid #6a3040; border-radius: 4px; padding: 0 .4rem; background: rgba(100,30,40,0.15); }

/* Builder Dense — compact staff layout */
body[data-text-mode="builder-dense"] #terminal-wrap { padding: .2rem .4rem .1rem; }
body[data-text-mode="builder-dense"] #topbar { height: 32px; padding: 0 .5rem; }
body[data-text-mode="builder-dense"] #statusbar { min-height: 22px; padding: .15rem .5rem; font-size: .7rem; gap: .4rem; }
body[data-text-mode="builder-dense"] .status-tag { font-size: .6rem; padding: .05rem .3rem; }
body[data-text-mode="builder-dense"] .vital-track { width: 50px; height: 5px; }
body[data-text-mode="builder-dense"] .vital-name { font-size: .6rem; }
body[data-text-mode="builder-dense"] #inputbar { padding: .2rem .4rem; }
body[data-text-mode="builder-dense"] .tb-btn { font-size: .7rem; padding: .15rem .4rem; }
body[data-text-mode="builder-dense"] #mood-overlay,
body[data-text-mode="builder-dense"] #fire-flicker,
body[data-text-mode="builder-dense"] #rain-canvas,
body[data-text-mode="builder-dense"] #snow-container,
body[data-text-mode="builder-dense"] #fireflies { display: none; }

/* Display mode scrollbars */
body[data-text-mode="manuscript"] ::-webkit-scrollbar-thumb,
body[data-text-mode="manuscript"] .xterm-viewport::-webkit-scrollbar-thumb {
  background-image: linear-gradient(180deg, #4a3a20, #2a2015, #4a3a20);
  border-color: rgba(160, 120, 60, 0.3);
  box-shadow: inset 2px 2px 4px 0 rgba(255, 230, 180, 0.15);
}
body[data-text-mode="travel-journal"] ::-webkit-scrollbar-thumb,
body[data-text-mode="travel-journal"] .xterm-viewport::-webkit-scrollbar-thumb {
  background-image: linear-gradient(180deg, #1a3a1a, #0e2510, #1a3a1a);
  border-color: rgba(60, 140, 60, 0.25);
  box-shadow: inset 2px 2px 4px 0 rgba(180, 255, 180, 0.1);
}
body[data-text-mode="combat-focus"] ::-webkit-scrollbar-thumb,
body[data-text-mode="combat-focus"] .xterm-viewport::-webkit-scrollbar-thumb {
  background-image: linear-gradient(180deg, #3a1a1a, #251010, #3a1a1a);
  border-color: rgba(160, 50, 50, 0.25);
  box-shadow: inset 2px 2px 4px 0 rgba(255, 180, 180, 0.1);
}
body[data-text-mode="builder-dense"] ::-webkit-scrollbar-thumb,
body[data-text-mode="builder-dense"] .xterm-viewport::-webkit-scrollbar-thumb {
  background-image: linear-gradient(180deg, #2a2a30, #1a1a20, #2a2a30);
  border-color: rgba(100, 100, 120, 0.25);
  box-shadow: inset 2px 2px 4px 0 rgba(200, 200, 220, 0.08);
}

/* ── Race themes ──────────────────────────────────────────────────────── */

/* Login screen — thin gold frame around window */
body.login-screen::after {
  content: "";
  position: fixed;
  top: 12px; left: 12px; right: 12px; bottom: 12px;
  border: 1px solid rgba(184, 148, 42, 0.5);
  box-shadow: inset 0 0 0 1px rgba(184, 148, 42, 0.15), 0 0 0 1px rgba(184, 148, 42, 0.15);
  pointer-events: none;
  z-index: 99;
}
body.login-screen::before {
  content: "";
  position: fixed;
  top: 18px; left: 18px; right: 18px; bottom: 18px;
  border: 1px solid rgba(184, 148, 42, 0.3);
  pointer-events: none;
  z-index: 99;
}
body.login-screen .gondor-corner {
  position: fixed;
  width: 30px; height: 30px;
  border-color: rgba(184, 148, 42, 0.6);
  border-style: solid;
  border-width: 0;
  pointer-events: none;
  z-index: 100;
}
.gondor-corner.tl { top: 8px; left: 8px; border-top-width: 2px; border-left-width: 2px; }
.gondor-corner.tr { top: 8px; right: 8px; border-top-width: 2px; border-right-width: 2px; }
.gondor-corner.bl { bottom: 8px; left: 8px; border-bottom-width: 2px; border-left-width: 2px; }
.gondor-corner.br { bottom: 8px; right: 8px; border-bottom-width: 2px; border-right-width: 2px; }

.gondor-diamond {
  position: fixed;
  width: 8px; height: 8px;
  background: rgba(184, 148, 42, 0.5);
  transform: rotate(45deg);
  pointer-events: none;
  z-index: 100;
  display: none;
}
body.login-screen .gondor-diamond { display: block; }
.gondor-diamond.top { top: 9px; left: 50%; margin-left: -4px; }
.gondor-diamond.bottom { bottom: 9px; left: 50%; margin-left: -4px; }
.gondor-diamond.left { left: 9px; top: 50%; margin-top: -4px; }
.gondor-diamond.right { right: 9px; top: 50%; margin-top: -4px; }

/* Gondorian — gold ornamental frame around terminal */
body.race-gondor #terminal-wrap {
  border: 1px solid rgba(184, 148, 42, 0.5);
  box-shadow: inset 0 0 0 1px rgba(184, 148, 42, 0.15), 0 0 0 1px rgba(184, 148, 42, 0.15), 0 0 8px rgba(184, 148, 42, 0.1);
  position: relative;
}
body.race-gondor #terminal-wrap::after {
  content: "";
  position: absolute;
  top: 5px; left: 5px; right: 5px; bottom: 5px;
  border: 1px solid rgba(184, 148, 42, 0.3);
  pointer-events: none;
  z-index: 9;
}
body.race-gondor #terminal-wrap::before {
  content: "";
  position: absolute;
  top: -5px; left: 50%; margin-left: -4px;
  width: 8px; height: 8px;
  background: rgba(184, 148, 42, 0.5);
  transform: rotate(45deg);
  pointer-events: none;
  z-index: 9;
}

/* ── Topbar ─────────────────────────────────────────────────────────────── */

#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  height: 44px;
  padding: 0 1rem;
  gap: 1rem;
}

#brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  min-width: 0;
}

#banner-img {
  height: 30px;
  width: auto;
  display: block;
}

#brand-text {
  font-family: 'Aniron', serif;
  color: var(--cursor);
  font-size: .85rem;
  font-weight: normal;
  letter-spacing: .06em;
  white-space: nowrap;
  display: none; /* shown only when banner fails */
}

#sound-controls {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-left: auto;
}

#sound-toggle-label {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: .25rem;
  user-select: none;
}

#sound-toggle { display: none; }

#sound-icon { font-size: 1rem; opacity: .85; }

#sound-volume {
  -webkit-appearance: none;
  appearance: none;
  width: 80px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}
#sound-volume::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent-blue);
  cursor: pointer;
}
#sound-volume::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent-blue);
  border: none;
  cursor: pointer;
}

#conn-status {
  display: flex;
  align-items: center;
  gap: .45rem;
  white-space: nowrap;
  font-size: .78rem;
  color: var(--text-muted);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background-color .3s;
}
.dot-connecting { background: #d9a030; }
.dot-connected  { background: #57b057; }
.dot-disconnected { background: #c04040; }

/* ── Terminal ───────────────────────────────────────────────────────────── */

#terminal-wrap {
  flex: 1;
  min-height: 0;
  padding: .5rem .75rem .25rem;
  overflow: hidden;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.4), inset 0 0 1px rgba(0,0,0,0.6);
  border-top: 1px solid rgba(255,255,255,0.03);
}

/* Styled scrollbar — carved gold */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: #0a0e14; border-left: 1px solid rgba(184, 148, 42, 0.08); }
::-webkit-scrollbar-thumb {
  background-image: linear-gradient(180deg, #4a3a1a, #2a2010, #4a3a1a);
  border-radius: 100px;
  border: 1px solid rgba(184, 148, 42, 0.25);
  box-shadow: inset 2px 2px 4px 0 rgba(255, 240, 200, 0.12);
}
::-webkit-scrollbar-thumb:hover {
  background-image: linear-gradient(180deg, #5a4a25, #3a3018, #5a4a25);
  border-color: rgba(184, 148, 42, 0.5);
  box-shadow: inset 2px 2px 4px 0 rgba(255, 240, 200, 0.2);
}
.xterm-viewport::-webkit-scrollbar { width: 10px; }
.xterm-viewport::-webkit-scrollbar-track { background: #0a0e14; border-left: 1px solid rgba(184, 148, 42, 0.08); }
.xterm-viewport::-webkit-scrollbar-thumb {
  background-image: linear-gradient(180deg, #4a3a1a, #2a2010, #4a3a1a);
  border-radius: 100px;
  border: 1px solid rgba(184, 148, 42, 0.25);
  box-shadow: inset 2px 2px 4px 0 rgba(255, 240, 200, 0.12);
}
.xterm-viewport::-webkit-scrollbar-thumb:hover {
  background-image: linear-gradient(180deg, #5a4a25, #3a3018, #5a4a25);
  border-color: rgba(184, 148, 42, 0.5);
  box-shadow: inset 2px 2px 4px 0 rgba(255, 240, 200, 0.2);
}

#terminal {
  width: 100%;
  height: 100%;
}

/* Override xterm.js default background to match our bg */
.xterm { background: #0e1823 !important; }
.xterm-viewport { background: #0e1823 !important; }
.xterm-screen  { background: #0e1823 !important; }

/* ── Input bar ──────────────────────────────────────────────────────────── */

#inputbar {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: var(--bg-panel);
  border-top: 1px solid #2f4759;
  flex-shrink: 0;
  padding: .45rem .75rem;
}

#input-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .3rem;
  min-width: 0;
}

#input-actions {
  display: flex;
  gap: .35rem;
}

#cmd-input {
  flex: 1;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: .95rem;
  outline: none;
  padding: .55rem .75rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}
#cmd-input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px rgba(77, 114, 153, 0.15), 0 0 12px rgba(184, 148, 42, 0.08);
}
#cmd-input::placeholder { color: #3a4a5a; }

#send-btn {
  background: var(--accent-blue);
  border: none;
  border-radius: 4px;
  color: #fff;
  cursor: pointer;
  font-size: .82rem;
  font-family: inherit;
  padding: .4rem .9rem;
  transition: background .15s;
  white-space: nowrap;
}
#send-btn:hover { background: #6f93b8; }
#send-btn:active { background: #3a5a7a; }

/* ── Compass rose ──────────────────────────────────────────────────────── */

#compass-wrap {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  align-items: stretch;
}

#compass {
  display: grid;
  grid-template-columns: repeat(3, 28px);
  grid-template-rows: repeat(3, 28px);
  gap: 2px;
}

#compass-ud {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
#compass-ud .dir-btn {
  flex: 1;
  width: 22px;
  font-size: .55rem;
}
#compass-ud .dir-btn:nth-child(3),
#compass-ud .dir-btn:nth-child(4) {
  font-size: .48rem;
}

.dir-diag { font-size: .5rem; }

.dir-btn {
  background: var(--bg-surface);
  border: 1px solid rgba(47, 71, 89, 0.5);
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: .6rem;
  font-weight: 600;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  user-select: none;
}
.dir-btn:hover { background: #4d7299; color: #fff; cursor: url('/play/sounds/cursor_default.png'), pointer; }
.dir-btn:active { background: #3a5a7a; }
.dir-center { font-size: .8rem; }

/* ── Light theme ───────────────────────────────────────────────────────── */

body.light {
  background: #f0ede6;
  color: #2a2a2a;
}
body.light #topbar,
body.light #inputbar {
  background: #ddd8cc;
  border-color: #b8b0a0;
}
body.light #cmd-input {
  background: #f7f5f0;
  border-color: #b8b0a0;
  color: #2a2a2a;
}
body.light #cmd-input::placeholder { color: #998f80; }
body.light .dir-btn {
  background: #e0dbd0;
  border-color: #b8b0a0;
  color: #555;
}
body.light .dir-btn:hover { background: #4d7299; color: #fff; cursor: url('/play/sounds/cursor_default.png'), pointer; }
body.light .tb-btn {
  background: #ccc7ba;
  color: #444;
}
body.light .tb-btn:hover { background: #4d7299; color: #fff; }
body.light .dot-connecting { background: #c8a020; }
body.light .dot-connected { background: #3a8a3a; }
body.light #conn-status { color: #666; }
body.light #brand-text { color: #5a4a30; }
body.light #scroll-bottom { background: #6a8ab0; }
body.light .xterm { background: #f0ede6 !important; }
body.light .xterm-viewport { background: #f0ede6 !important; }
body.light .xterm-screen { background: #f0ede6 !important; }
body.light #autocomplete { background: #e8e4da; border-color: #b8b0a0; }
body.light #autocomplete .ac-item { color: #333; border-color: #ccc7ba; }
body.light #alias-panel div[style*="fixed"] > div { background: #e8e4da !important; border-color: #b8b0a0 !important; color: #333 !important; }

/* ── Font controls ──────────────────────────────────────────────────────── */

#font-controls {
  display: flex;
  align-items: center;
  gap: .25rem;
}

.tb-btn {
  background: rgba(47, 71, 89, 0.5);
  border: 1px solid rgba(47, 71, 89, 0.4);
  border-radius: 4px;
  color: var(--text-dim);
  cursor: pointer;
  font-family: inherit;
  font-size: .72rem;
  padding: .25rem .5rem;
  transition: all var(--transition);
  white-space: nowrap;
}
.tb-btn:hover { background: var(--accent-blue); color: #fff; border-color: var(--accent-blue); cursor: url('/play/sounds/cursor_default.png'), pointer; }
.tb-btn:active { background: #3a5a7a; }

#send-btn {
  background: var(--accent-blue);
  border: 1px solid var(--accent-blue);
  border-radius: 4px;
  color: #fff;
  font-weight: 600;
  transition: all var(--transition);
}
#send-btn:hover { background: #5a82a9; }

/* ── Scroll-to-bottom ──────────────────────────────────────────────────── */

#terminal-wrap { position: relative; }

#scroll-bottom {
  display: none;
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent-blue);
  border: none;
  border-radius: 16px;
  color: #fff;
  cursor: pointer;
  font-family: inherit;
  font-size: .75rem;
  padding: .3rem 1rem;
  opacity: .9;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
  transition: opacity .15s;
  animation: scroll-pulse 1.5s ease-in-out infinite;
}
#scroll-bottom:hover { opacity: 1; }

@keyframes scroll-pulse {
  0%, 100% { box-shadow: 0 2px 8px rgba(0,0,0,.4); }
  50% { box-shadow: 0 2px 12px rgba(77,114,153,.6); }
}

/* ── Mobile ─────────────────────────────────────────────────────────────── */

@media (max-width: 600px) {
  #topbar {
    padding: 0 .4rem;
    gap: .3rem;
    height: 38px;
    flex-wrap: nowrap;
  }
  #banner-img { height: 22px; }
  #brand-text { font-size: .75rem; }
  #sound-volume { width: 40px; }
  #conn-label { display: none; }
  .tb-btn { padding: .2rem .35rem; font-size: .65rem; }

  #terminal-wrap { padding: .15rem .25rem 0; }

  #inputbar {
    flex-direction: row;
    align-items: center;
    padding: .4rem;
    gap: .4rem;
    padding-bottom: calc(.4rem + env(safe-area-inset-bottom, 0px));
  }

  #compass-wrap { order: 0; align-self: center; }
  #input-col { order: 1; flex: 1; min-width: 0; }
  #input-actions { flex-wrap: wrap; }

  #compass {
    grid-template-columns: repeat(3, 30px);
    grid-template-rows: repeat(3, 26px);
  }
  #compass-ud .dir-btn { width: 22px; }
  .dir-btn { font-size: .7rem; }
  .dir-center { font-size: .9rem; }

  #cmd-input {
    font-size: 16px;
    padding: .5rem .6rem;
    border-radius: 6px;
  }
  #send-btn {
    padding: .5rem .8rem;
    font-size: .85rem;
    border-radius: 6px;
    min-height: 40px;
  }

  #scroll-bottom { bottom: 8px; font-size: .7rem; padding: .25rem .8rem; }
}

@media (max-width: 380px) {
  #font-controls { display: none; }
  #sound-volume { display: none; }
}

/* ── Status bar ────────────────────────────────────────────────────────── */

#statusbar {
  display: none;
  align-items: center;
  gap: .75rem;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  padding: .3rem 1rem;
  min-height: 28px;
  font-size: .75rem;
  flex-wrap: wrap;
}
#statusbar.visible { display: flex; animation: slide-down 0.3s ease-out; }
@keyframes slide-down { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

#vitals {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.vital-group {
  display: flex;
  align-items: center;
  gap: .35rem;
}

.vital-name {
  color: var(--text-muted);
  font-size: .7rem;
  font-weight: 600;
  min-width: 1.4em;
}

.vital-track {
  width: 72px;
  height: 7px;
  background: var(--bg-deep);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.vital-fill {
  height: 100%;
  border-radius: 2px;
  transition: width .5s ease-out, background .5s ease-out;
  width: 0;
}

.target-fill { background: #c04444; }

.vital-text {
  color: var(--text-muted);
  font-size: .68rem;
  min-width: 3.5em;
}

#status-tags {
  display: flex;
  align-items: center;
  gap: .3rem;
  flex-wrap: wrap;
}

.status-tag {
  background: rgba(30, 48, 68, 0.4);
  border: 1px solid rgba(47, 71, 89, 0.5);
  border-radius: 3px;
  color: rgba(142, 164, 184, 0.7);
  font-size: .65rem;
  padding: .1rem .5rem;
  white-space: nowrap;
  transition: var(--transition);
}

#wound-info {
  display: none;
  align-items: center;
  gap: .3rem;
  flex-wrap: wrap;
}
#wound-info.visible { display: flex; }

.wound-tag {
  border-radius: 3px;
  font-size: .65rem;
  padding: .1rem .4rem;
  white-space: nowrap;
}
.wound-minor    { background: #2a3a20; border: 1px solid #4a6a30; color: #7bc87e; }
.wound-moderate { background: #3a3520; border: 1px solid #6a5a20; color: #e9c96a; }
.wound-severe   { background: #3a2020; border: 1px solid #6a3030; color: #e06666; }

#hands-info {
  display: none;
  align-items: center;
  gap: .3rem;
  flex-wrap: wrap;
}
#hands-info.visible { display: flex; }

.hand-tag {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  border-radius: 3px;
  font-size: .65rem;
  padding: .1rem .45rem;
  white-space: nowrap;
  transition: var(--transition);
}
.hand-tag .hand-side {
  font-size: .55rem;
  opacity: .65;
  font-weight: 600;
}
.hand-drawn {
  background: #241d0c;
  border: 1px solid #7a5a1a;
  color: #e3b737;
}
.hand-carried {
  background: rgba(30, 48, 68, 0.4);
  border: 1px solid rgba(47, 71, 89, 0.5);
  color: rgba(192, 168, 120, 0.85);
}

#target-info { display: none; }
#target-info.visible { display: flex; }

/* ── Exit highlighting ─────────────────────────────────────────────────── */

/* ── Mood overlay ──────────────────────────────────────────────────────── */

#mood-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 5;
  transition: background-color 4s ease;
  background-color: transparent;
}

/* ── HP vignette ───────────────────────────────────────────────────────── */

#hp-vignette {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 2;
  box-shadow: inset 0 0 100px 20px rgba(150, 0, 0, 0.6);
  opacity: 0;
  z-index: 6;
}

@keyframes hp-throb {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.15; }
}

@keyframes hp-throb-crit {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 0.25; }
}

/* ── Storm flash ───────────────────────────────────────────────────────── */

#storm-flash {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 7;
  background: rgba(200, 215, 255, 1);
  opacity: 0;
}

/* ── Knockout overlay ──────────────────────────────────────────────────── */

#knockout-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 8;
  background: #000;
  opacity: 0;
  transition: opacity 2s;
}

/* ── Mini-map ──────────────────────────────────────────────────────────── */

#minimap-wrap {
  position: absolute;
  top: 8px;
  right: 36px;
  z-index: 9;
  opacity: 0.85;
  transition: opacity var(--transition);
  display: none;
  background: rgba(10, 16, 22, 0.92);
  border: 1px solid rgba(47, 71, 89, 0.4);
  border-radius: 6px;
  padding: 4px 4px 0;
  box-shadow: 0 2px 12px var(--shadow-heavy);
}
#minimap-wrap.visible { display: block; }
#minimap-wrap:hover { opacity: 1; }
#minimap-title {
  font-size: .6rem;
  color: rgba(142, 164, 184, 0.5);
  text-align: center;
  padding: 2px 0;
  letter-spacing: .05em;
  text-transform: uppercase;
}
#minimap {
  width: 200px;
  height: 200px;
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: crosshair;
}

body.light #minimap { background: rgba(220, 215, 205, 0.9); border-color: #b8b0a0; }

@media (max-width: 600px) {
  #minimap { width: 140px; height: 140px; }
  #minimap-wrap { top: 4px; right: 4px; }
}

/* ── Fireflies ─────────────────────────────────────────────────────────── */

#fireflies {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 3;
  overflow: hidden;
  opacity: 0;
  transition: opacity 4s;
}
#fireflies.active { opacity: 1; }

.firefly {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #ccdd66;
  box-shadow: 0 0 6px 2px rgba(180, 220, 80, 0.5);
}

@keyframes firefly-a {
  0%, 100% { opacity: 0; transform: translate(0, 0); }
  15% { opacity: 0.8; }
  40% { opacity: 0.2; transform: translate(25px, -15px); }
  60% { opacity: 0.7; transform: translate(-10px, -30px); }
  85% { opacity: 0.3; transform: translate(15px, 10px); }
}
@keyframes firefly-b {
  0%, 100% { opacity: 0; transform: translate(0, 0); }
  20% { opacity: 0.6; transform: translate(-20px, 10px); }
  50% { opacity: 0.9; transform: translate(10px, -25px); }
  75% { opacity: 0.2; transform: translate(-15px, -5px); }
}
@keyframes firefly-c {
  0%, 100% { opacity: 0; transform: translate(0, 0); }
  10% { opacity: 0.5; transform: translate(15px, 20px); }
  45% { opacity: 0.8; transform: translate(-25px, -10px); }
  70% { opacity: 0.3; transform: translate(5px, -20px); }
  90% { opacity: 0.7; }
}

/* ── Rain canvas ───────────────────────────────────────────────────────── */

#tp-badge {
  margin-left: 0.6rem;
  padding: 0.1rem 0.4rem;
  border: 1px solid #c04444;
  border-radius: 3px;
  background: rgba(192, 68, 68, 0.18);
  color: #e08c8c;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  vertical-align: middle;
}

#rain-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 4;
  opacity: 0;
  transition: opacity 3s;
}

/* Embers rise from the bottom of the terminal, above the weather layers.
   Positioned in JS to match the terminal canvas rect, same as #rain-canvas. */
/* Frost sits above every weather layer; drawn only when the level changes,
   never per frame. Positioned in JS to match the terminal canvas rect. */
#frost-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 7;
  opacity: 0;
  transition: opacity 1.2s ease; /* the shader eases the growth itself */
}

#ember-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 6;
  opacity: 0;
  transition: opacity 1.6s;
}

/* Same stacking slot as frost (drawn after it in the DOM, so it layers on
   top): fog is the outermost atmosphere, sitting in front of the ice on
   the glass. Stays below #knockout-overlay (z-index 8) on purpose -- a
   blackout should always win over ambient haze. */
#fog-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 7;
  opacity: 0;
  transition: opacity 4s ease;   /* fog rolls in slowly, not a fade-cut */
  filter: blur(1.5px);   /* softens the noise field so it reads as atmospheric haze, not static */
}

/* Splashes sit just above the rain layer; positioned in JS to match the
   terminal canvas rect, same as #rain-canvas. */
#splash-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 5;
  opacity: 0;
  transition: opacity 1.2s;
}

/* ── UI Tour (new-player walkthrough) ──────────────────────────────────── */

#tour-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 300;
  animation: panel-fade-in 0.3s ease-out;
}
.tour-dim {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.65);
}
.tour-spotlight {
  position: fixed;
  border-radius: 8px;
  box-shadow: 0 0 0 4000px rgba(0, 0, 0, 0.65), 0 0 20px rgba(184, 148, 42, 0.4);
  border: 1px solid rgba(184, 148, 42, 0.5);
  background: transparent;
  z-index: 301;
  transition: all 0.4s ease;
}
.tour-card {
  position: fixed;
  z-index: 302;
  background: #1a2a3a;
  border: 1px solid rgba(184, 148, 42, 0.4);
  border-radius: 8px;
  padding: 1rem 1.2rem;
  width: 310px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  animation: panel-fade-in 0.3s ease-out;
}
.tour-step-num {
  font-size: .65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .4rem;
}
.tour-title {
  font-family: 'Aniron', serif;
  font-size: .9rem;
  color: var(--accent-gold-light);
  margin-bottom: .4rem;
}
.tour-text {
  font-size: .82rem;
  color: var(--text-dim);
  line-height: 1.5;
  margin-bottom: 1rem;
}
.tour-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.tour-nav-right {
  display: flex;
  gap: .4rem;
}
.tour-btn {
  padding: .35rem .8rem;
  border-radius: 4px;
  border: 1px solid rgba(184, 148, 42, 0.4);
  background: rgba(20, 30, 42, 0.5);
  color: #eedda0;
  font-family: inherit;
  font-size: .78rem;
  transition: var(--transition);
}
.tour-btn:hover {
  border-color: rgba(184, 148, 42, 0.8);
  background: rgba(184, 148, 42, 0.12);
}
.tour-btn-primary {
  background: rgba(184, 148, 42, 0.2);
  border-color: rgba(184, 148, 42, 0.6);
}
.tour-btn-primary:hover {
  background: rgba(184, 148, 42, 0.3);
  border-color: rgba(184, 148, 42, 0.9);
}
.tour-btn-ghost {
  border-color: rgba(140, 164, 184, 0.25);
  color: rgba(200, 200, 210, 0.55);
}
.tour-btn-ghost:hover {
  border-color: rgba(140, 164, 184, 0.5);
  color: #d8d8e0;
  background: rgba(255, 255, 255, 0.05);
}

@media (max-width: 600px) {
  .tour-card { width: 260px; padding: .8rem 1rem; }
  .tour-title { font-size: .8rem; }
  .tour-text { font-size: .75rem; }
}

/* ── Action bar ───────────────────────────────────────────────────────── */

#action-bar {
  flex-shrink: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  overflow: hidden;
  transition: var(--transition);
}
#action-bar.visible { display: flex; }

#action-bar-toggle {
  background: none; border: none;
  color: var(--text-muted); font-size: .6rem;
  padding: 2px 24px; line-height: 1;
  opacity: 0.5;
  transition: var(--transition);
}
#action-bar-toggle:hover { opacity: 1; color: var(--accent-gold-bright); }
#action-bar:not(.collapsed) #action-bar-toggle { transform: rotate(180deg); }

#action-bar-tray {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
  padding: 5px 10px 7px;
  max-height: 200px;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
}
#action-bar.collapsed #action-bar-tray {
  max-height: 0;
  padding-top: 0; padding-bottom: 0;
  opacity: 0;
}

.ab-group {
  display: flex;
  gap: 4px;
  padding-right: 8px;
  border-right: 1px solid rgba(47, 71, 89, 0.5);
}
.ab-group:last-child { border-right: none; padding-right: 0; }

.ab-btn {
  padding: 4px 11px;
  border-radius: 4px;
  border: 1px solid rgba(184, 148, 42, 0.3);
  background: rgba(20, 30, 42, 0.5);
  color: #eedda0;
  font-size: .78rem;
  font-family: inherit;
  letter-spacing: 0.02em;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  white-space: nowrap;
}
.ab-btn:hover {
  border-color: rgba(184, 148, 42, 0.8);
  background: rgba(184, 148, 42, 0.12);
  box-shadow: 0 0 12px rgba(184, 148, 42, 0.15);
}
.ab-btn:active { transform: translateY(1px); }

.ab-btn-combat {
  border-color: rgba(192, 68, 68, 0.4);
  background: rgba(192, 68, 68, 0.08);
  color: #e06666;
}
.ab-btn-combat:hover {
  border-color: rgba(192, 68, 68, 0.8);
  background: rgba(192, 68, 68, 0.15);
  box-shadow: 0 0 12px rgba(192, 68, 68, 0.15);
}

@media (max-width: 600px) {
  #action-bar-tray { padding: 4px 6px 6px; gap: 3px; }
  .ab-btn { font-size: .7rem; padding: 3px 8px; }
  .ab-group { padding-right: 6px; gap: 3px; }
}

/* ── Guided login overlay ─────────────────────────────────────────────── */

#guided-login {
  position: absolute;
  top: calc(50% - 18px);
  right: clamp(2.25rem, 4.75vw, 5.5rem);
  transform: translateY(-50%);
  width: min(380px, calc(100vw - 2rem));
  z-index: 35;
  pointer-events: auto;
  transition: opacity .25s ease, transform .25s ease;
}
#guided-login::before {
  content: "";
  position: absolute;
  top: -28px;
  bottom: -28px;
  left: -22px;
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(218, 190, 118, .32) 18%, rgba(218, 190, 118, .42) 50%, rgba(218, 190, 118, .22) 82%, transparent);
  box-shadow: 0 0 18px rgba(184, 148, 42, .18);
  pointer-events: none;
}
#guided-login.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-48%);
}
.gl-card {
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  max-height: calc(100vh - 6rem);
  padding: 1.1rem;
  border: 1px solid rgba(218, 190, 118, .48);
  border-radius: 14px;
  background:
    radial-gradient(circle at 18% 0%, rgba(218, 190, 118, .12), transparent 32%),
    linear-gradient(145deg, rgba(5, 8, 12, .98), rgba(11, 18, 25, .96));
  box-shadow:
    0 28px 90px rgba(0, 0, 0, .78),
    inset 0 0 0 1px rgba(255, 255, 255, .04),
    0 0 42px rgba(184, 148, 42, .18);
  backdrop-filter: blur(16px) brightness(.55);
  animation: gl-arrive .35s ease-out;
}
.gl-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(115deg, transparent 0%, rgba(255, 255, 255, .045) 42%, transparent 58%),
    linear-gradient(rgba(0, 0, 0, .32), rgba(0, 0, 0, .32)),
    repeating-linear-gradient(90deg, rgba(255,255,255,.018) 0 1px, transparent 1px 26px);
  opacity: .75;
  pointer-events: none;
}
@keyframes gl-arrive {
  from { opacity: 0; transform: translateY(8px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.gl-kicker {
  position: relative;
  color: rgba(218, 190, 118, .74);
  font-size: .65rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  margin-bottom: .35rem;
}
.gl-title {
  position: relative;
  font-family: 'Aniron', serif;
  font-size: 1.05rem;
  color: #f0dfaa;
  letter-spacing: .04em;
  margin-bottom: .4rem;
}
.gl-copy {
  position: relative;
  color: rgba(232, 236, 232, .84);
  font-size: .82rem;
  line-height: 1.45;
  margin-bottom: .85rem;
}
.gl-form {
  position: relative;
  display: grid;
  gap: .55rem;
}
.gl-field {
  display: grid;
  gap: .25rem;
}
.gl-label {
  color: rgba(220, 226, 226, .65);
  font-size: .68rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.gl-input {
  width: 100%;
  padding: .68rem .78rem;
  border: 1px solid rgba(218, 190, 118, .44);
  border-radius: 8px;
  background: rgba(0, 0, 0, .72);
  color: #f3ebd3;
  font: inherit;
  outline: none;
  box-shadow: inset 0 0 18px rgba(0, 0, 0, .45);
}
.gl-input:focus {
  border-color: rgba(238, 211, 143, .74);
  box-shadow: 0 0 0 2px rgba(184, 148, 42, .14), inset 0 0 18px rgba(0, 0, 0, .22);
}
.gl-textarea {
  min-height: 9rem;
  resize: vertical;
  line-height: 1.45;
  font-family: inherit;
}
.gl-actions,
.gl-menu {
  position: relative;
  display: flex;
  gap: .45rem;
  flex-wrap: wrap;
}
.gl-actions-footer {
  margin-top: .65rem;
}
.gl-menu {
  margin-top: .85rem;
  padding-top: .8rem;
  border-top: 1px solid rgba(184, 148, 42, .18);
}
.gl-menu-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.gl-menu-grid .gl-btn {
  width: 100%;
}
.gl-btn {
  border: 1px solid rgba(218, 190, 118, .46);
  border-radius: 8px;
  padding: .55rem .75rem;
  background: rgba(25, 20, 8, .82);
  color: #eedda0;
  font: inherit;
  font-size: .78rem;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .15s;
}
.gl-btn:disabled {
  opacity: .48;
  cursor: default;
  transform: none;
}
.gl-btn:hover {
  background: rgba(184, 148, 42, .22);
  border-color: rgba(238, 211, 143, .68);
  transform: translateY(-1px);
}
.gl-btn-primary {
  background: linear-gradient(135deg, rgba(184, 148, 42, .36), rgba(94, 72, 24, .32));
  border-color: rgba(238, 211, 143, .62);
}
.gl-btn-ghost {
  color: rgba(232, 236, 232, .72);
  border-color: rgba(160, 178, 190, .32);
  background: rgba(0, 0, 0, .38);
}
.gl-status {
  position: relative;
  margin-top: .65rem;
  min-height: 1rem;
  color: rgba(220, 226, 226, .58);
  font-size: .72rem;
}
.gl-waiting {
  position: relative;
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .75rem .8rem;
  border: 1px solid rgba(218, 190, 118, .2);
  border-radius: 8px;
  background: rgba(0, 0, 0, .28);
  color: rgba(232, 236, 232, .78);
  font-size: .78rem;
}
.gl-spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(218, 190, 118, .22);
  border-top-color: rgba(238, 221, 160, .85);
  animation: gl-spin .9s linear infinite;
}
@keyframes gl-spin {
  to { transform: rotate(360deg); }
}
.gl-terminal-note {
  position: relative;
  margin-top: .8rem;
  color: rgba(238, 221, 160, .48);
  font-size: .68rem;
}
body.guided-login-active #terminal-wrap {
  box-shadow: none;
}
body.login-screen.guided-login-active #terminal-wrap {
  opacity: 1;
  background: transparent;
  border-top-color: transparent;
}
body.login-screen.guided-login-active #terminal-wrap::before {
  content: "";
  position: absolute;
  top: 4%;
  left: 0;
  bottom: 8%;
  width: min(980px, 72vw);
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 34% 42%, rgba(0, 0, 0, .78), rgba(0, 0, 0, .52) 48%, transparent 82%),
    linear-gradient(90deg, rgba(0, 0, 0, .62), rgba(0, 0, 0, .34) 60%, transparent 100%);
  mask-image: linear-gradient(180deg, transparent, #000 6%, #000 92%, transparent);
}
body.login-screen.guided-login-active #terminal,
body.login-screen.guided-login-active .xterm,
body.login-screen.guided-login-active .xterm-viewport,
body.login-screen.guided-login-active .xterm-screen {
  background: transparent !important;
}
body.login-screen.guided-login-active #terminal {
  position: relative;
  z-index: 2;
}
body.login-screen.guided-login-active .xterm-rows {
  text-shadow: 0 1px 2px rgba(0, 0, 0, .95), 0 0 7px rgba(0, 0, 0, .85);
}
body.guided-login-active #terminal,
body.guided-login-active #minimap-wrap,
body.guided-login-active #rain-canvas,
body.guided-login-active #snow-container,
body.guided-login-active #fireflies {
  opacity: .78;
}
body.guided-login-active #guided-login {
  opacity: 1;
}
body.guided-login-active #cmd-input {
  opacity: .75;
}
@media (max-width: 800px) {
  /* Bottom sheet. Two things make this reliable on iOS Safari, which the
     earlier attempts missed:
     1) The SCROLL lives on #guided-login (the fixed element) itself, not on
        its .gl-card child. iOS won't touch-scroll a child of a fixed element,
        but it will scroll the fixed element directly.
     2) No backdrop-filter on the scrolling element (blur can't re-composite
        mid-scroll on iOS → elastic snap-back). The card bg is ~98% opaque, so
        it looks the same.
     Plus the menu buttons go 2-column and compact so the common account menu
     fits with no scroll needed at all. */
  #guided-login {
    position: fixed;
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    width: auto;
    transform: none;
    z-index: 60;
    max-height: 88dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 0 .5rem calc(.5rem + env(safe-area-inset-bottom, 0px));
  }
  #guided-login::before { display: none; }
  #guided-login.hidden { transform: translateY(14px); }
  .gl-card {
    max-height: none;
    overflow: visible;
    padding: .85rem;
    backdrop-filter: none;
    background: linear-gradient(145deg, #060a0f, #0d151d);
  }
  .gl-title { font-size: .9rem; }
  .gl-copy { font-size: .75rem; }
  .gl-menu-grid { grid-template-columns: 1fr; }
  .gl-menu {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .35rem;
  }
  .gl-menu .gl-btn { padding: .5rem .55rem; font-size: .8rem; }
}

/* ── Fire flicker bar ──────────────────────────────────────────────────── */

#fire-flicker {
  height: 2px;
  flex-shrink: 0;
  opacity: 0;
  background: #c87830;
  box-shadow: 0 -3px 15px 3px rgba(200, 120, 30, 0.4),
              0 -1px 6px rgba(220, 100, 20, 0.3);
  transition: opacity 2s;
}

/* ── Exit highlighting ─────────────────────────────────────────────────── */

.exits-known .dir-btn:not(.dir-center) {
  opacity: .25;
  border-color: transparent;
}
.exits-known .dir-btn.exit-avail {
  opacity: 1;
  border-color: #4d7299;
  color: var(--text-dim);
  animation: exit-fade-in 0.4s ease-out;
}
@keyframes exit-fade-in { from { opacity: 0.25; } to { opacity: 1; } }

/* ── Active toolbar button ─────────────────────────────────────────────── */

.tb-active { background: #4d7299 !important; color: #fff !important; }

/* ── Settings panel (sidebar nav layout) ───────────────────────────────── */

#settings-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.6); z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
#settings-box {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 640px; max-width: 92vw; height: 540px; max-height: 88vh;
  color: var(--text-primary); font-family: inherit;
  display: flex; flex-direction: column;
  box-shadow: 0 8px 32px var(--shadow-heavy);
  overflow: hidden;
}
#settings-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: .9rem 1.1rem;
  border-bottom: 1px solid var(--border);
}
#settings-header b { font-size: 1rem; }
#settings-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 1.2rem; line-height: 1;
}
#settings-close:hover { color: var(--text-primary); }
#settings-body { display: flex; min-height: 0; flex: 1; }
#settings-nav {
  flex-shrink: 0; width: 180px;
  border-right: 1px solid var(--border);
  padding: .5rem 0;
  overflow-y: auto; overflow-x: hidden;
  background: rgba(0,0,0,0.15);
}
.settings-cat {
  padding: .5rem 1rem;
  font-size: .8rem; color: var(--text-muted);
  border-left: 2px solid transparent;
  transition: var(--transition);
  white-space: nowrap;
}
.settings-cat:hover { color: var(--text-primary); background: rgba(255,255,255,0.03); }
.settings-cat.active {
  color: var(--accent-gold-light);
  border-left-color: var(--accent-gold);
  background: rgba(184,148,42,0.08);
}
#settings-content {
  flex: 1; min-width: 0; padding: .6rem 1.1rem;
  overflow-y: auto; overflow-x: hidden;
}
.settings-btn-sm {
  background: var(--accent-blue); border: none; border-radius: 4px;
  color: #fff; padding: .2rem .6rem; font-size: .75rem; font-family: inherit;
}
.settings-btn-sm:hover { background: #5a82a9; }
.settings-select {
  background: var(--bg-deep); border: 1px solid var(--border);
  border-radius: 4px; color: var(--text-primary);
  padding: .2rem .4rem; font-family: inherit; font-size: .75rem;
  max-width: 230px;
}

#settings-preview {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding: .55rem .9rem .8rem;
  background: rgba(0,0,0,0.15);
}
#settings-preview-label {
  font-size: .62rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); margin-bottom: .4rem;
}
#settings-preview-text {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .5rem .7rem;
  line-height: 1.4;
  max-height: 150px; overflow-y: auto;
  white-space: pre-wrap; word-break: break-word;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .35rem 0;
  border-bottom: 1px solid var(--border);
  font-size: .82rem;
  color: var(--text-dim);
}
.settings-row:last-child { border-bottom: none; }
.settings-label { flex: 1; }
.settings-switch { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.settings-switch input { opacity: 0; width: 0; height: 0; }
.settings-slider {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-surface); border-radius: 10px; cursor: pointer;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}
.settings-slider::before {
  content: ""; position: absolute; left: 2px; top: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #6a7a8a;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.3s ease, box-shadow 0.3s ease;
}
.settings-switch input:checked + .settings-slider {
  background: var(--accent-blue);
  box-shadow: 0 0 8px rgba(77, 114, 153, 0.3);
}
.settings-switch input:checked + .settings-slider::before {
  transform: translateX(16px);
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
.settings-slider:hover { background: rgba(47, 71, 89, 0.8); }
.settings-switch input:checked + .settings-slider:hover { background: #5a8ab0; }
.settings-heading {
  font-size: .7rem; color: #4d7299; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em;
  padding: .5rem 0 .2rem; margin-top: .2rem;
}

/* ── Status bar — light theme ──────────────────────────────────────────── */

body.light #statusbar           { background: #ddd8cc; border-color: #b8b0a0; }
body.light .vital-track         { background: #c8c0b0; border-color: #b8b0a0; }
body.light .vital-name,
body.light .vital-text          { color: #666; }
body.light .status-tag          { background: #e0dbd0; border-color: #b8b0a0; color: #555; }
body.light .wound-minor         { background: #d8e8d0; border-color: #a0c890; color: #3a7a3a; }
body.light .wound-moderate      { background: #e8e0c8; border-color: #c8b870; color: #8a7020; }
body.light .wound-severe        { background: #e8d0d0; border-color: #c89090; color: #b03030; }
body.light .exits-known .dir-btn.exit-avail { border-color: #4d7299; }

/* ── Status bar — mobile ───────────────────────────────────────────────── */

@media (max-width: 600px) {
  #statusbar { padding: .25rem .4rem; gap: .4rem; }
  .vital-track { width: 56px; }
  #target-info .vital-name { max-width: 60px; overflow: hidden; text-overflow: ellipsis; }
  #minimap-wrap { display: none !important; }
}

/* ── Unified clickable cursor ──────────────────────────────────────────────
   Custom cursor on the BASE state of every clickable (not just :hover) so
   there's no native-pointer flicker on mouseover, and so the Send button
   (which had no hover rule) is consistent. !important so it also overrides
   the inline `cursor:pointer` on dynamically-built panel buttons and selects. */
button, select, #sound-toggle-label, .dir-btn, .tb-btn, .settings-slider,
.palette-item, .ac-item, input[type="range"], input[type="checkbox"], input[type="color"],
#send-btn, #scroll-bottom {
  cursor: url('/play/sounds/cursor_default.png'), pointer !important;
}

/* Custom Cursor toggled off — fall back to native cursors everywhere */
body.no-custom-cursor * { cursor: auto !important; }
body.no-custom-cursor button, body.no-custom-cursor select, body.no-custom-cursor #sound-toggle-label,
body.no-custom-cursor .dir-btn, body.no-custom-cursor .tb-btn, body.no-custom-cursor .settings-slider,
body.no-custom-cursor .settings-cat, body.no-custom-cursor .palette-item, body.no-custom-cursor .ac-item,
body.no-custom-cursor .menu-btn, body.no-custom-cursor #send-btn, body.no-custom-cursor #scroll-bottom,
body.no-custom-cursor #mode-select, body.no-custom-cursor input[type="range"],
body.no-custom-cursor input[type="checkbox"], body.no-custom-cursor input[type="color"] { cursor: pointer !important; }
body.no-custom-cursor input[type="text"], body.no-custom-cursor input[type="search"],
body.no-custom-cursor input:not([type]), body.no-custom-cursor textarea { cursor: text !important; }

/* ── Guided chargen: progress bar, skill picker, picks counter ─────────── */

.gl-progress {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin: .1rem 0 .55rem;
}
.gl-progress-track {
  flex: 1;
  height: 4px;
  background: rgba(184, 148, 42, .16);
  border-radius: 2px;
  overflow: hidden;
}
.gl-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #b87316, #e3b737, #eedda0);
  border-radius: 2px;
  transition: width .5s ease;
}
.gl-progress-label {
  color: rgba(238, 221, 160, .72);
  font-size: .62rem;
  letter-spacing: .08em;
  white-space: nowrap;
}

.gl-picks {
  font-family: 'Aniron', serif;
  color: #e3b737;
  font-size: .78rem;
  letter-spacing: .06em;
  margin-bottom: .45rem;
}

.gl-skill-group {
  color: rgba(238, 221, 160, .55);
  font-size: .64rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  margin: .45rem 0 .25rem;
}
.gl-skill-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .28rem;
  max-height: 11rem;
  overflow-y: auto;
  padding-right: .2rem;
}
.gl-skill-btn {
  font-size: .7rem;
  padding: .22rem .55rem;
}

.gl-skill-btn.gl-skill-picked {
  background: linear-gradient(180deg, rgba(227, 183, 55, .92), rgba(184, 115, 22, .92));
  border-color: #eedda0;
  color: #1a1408;
  font-weight: bold;
  box-shadow: 0 0 10px rgba(227, 183, 55, .35);
}
.gl-skill-btn.gl-skill-picked:hover {
  background: linear-gradient(180deg, rgba(238, 221, 160, .95), rgba(184, 115, 22, .95));
  color: #1a1408;
}

/* ── Guided chargen: race lore parchment + review recap card ───────────── */

.gl-lore-heading {
  font-family: 'Aniron', serif;
  font-size: 1rem;
  letter-spacing: .06em;
  color: #eedda0;
  text-shadow: 0 0 12px rgba(227, 183, 55, .35);
  margin-bottom: .4rem;
}

.gl-lore {
  position: relative;
  white-space: pre-wrap;
  max-height: 16rem;
  overflow-y: auto;
  padding: 1.1rem 1.2rem 1rem;
  margin-bottom: .7rem;
  background:
    radial-gradient(ellipse at 15% 8%, rgba(120, 90, 40, .16), transparent 45%),
    radial-gradient(ellipse at 85% 92%, rgba(120, 90, 40, .14), transparent 45%),
    linear-gradient(165deg, #ebdcb8 0%, #e2cfa2 45%, #d9c495 100%);
  border: 1px solid #8a6a3a;
  border-radius: 2px;
  box-shadow:
    0 0 0 4px rgba(184, 148, 42, .18),
    0 3px 14px rgba(0, 0, 0, .45),
    inset 0 0 40px rgba(120, 85, 30, .18);
  color: #3a2a14;
  font-family: 'Aniron', 'Georgia', serif;
  font-size: .82rem;
  line-height: 1.65;
  text-shadow: 0 1px 0 rgba(255, 248, 225, .4);
}
.gl-lore::first-letter {
  float: left;
  font-family: 'Aniron', serif;
  font-size: 2.6em;
  line-height: .78;
  padding: .04em .1em 0 .02em;
  color: #7a3d10;
  text-shadow: none;
}

.gl-recap {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  margin-bottom: .7rem;
  padding: .7rem .85rem;
  background: rgba(184, 148, 42, .06);
  border: 1px solid rgba(184, 148, 42, .28);
  border-radius: 4px;
}
.gl-recap-row { display: flex; gap: .6rem; font-size: .78rem; }
.gl-recap-label {
  min-width: 5.2rem;
  color: rgba(238, 221, 160, .55);
  font-size: .66rem;
  letter-spacing: .09em;
  text-transform: uppercase;
  padding-top: .12rem;
}
.gl-recap-value { color: #e9e2d3; flex: 1; }
.gl-recap-value.gl-recap-missing { color: #c08484; font-style: italic; }

/* ── Credits: cinema roll ─────────────────────────────────────────────────── */

#credits-panel {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #000;
  opacity: 0;
  transition: opacity 1.1s ease;
  color: var(--text-primary);
  font-family: inherit;
  overflow: hidden;
}
#credits-panel.cc-lit { opacity: 1; }

.cc-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  /* Text emerges and dissolves at the edges instead of hard-clipping. */
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 14%, #000 86%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 14%, #000 86%, transparent 100%);
}

.cc-content {
  position: absolute;
  top: 0;
  left: 50%;
  width: min(620px, 88vw);
  margin-left: calc(min(620px, 88vw) / -2);
  text-align: center;
  will-change: transform;
  padding-bottom: 4rem;
}

.cc-title {
  font-family: 'Aniron', serif;
  font-size: clamp(1.8rem, 5vw, 3rem);
  letter-spacing: 0.13em;
  font-variant: small-caps;
  line-height: 1.2;
  margin-bottom: 3.5rem;
  background: linear-gradient(180deg, #b87316 0%, #e3b737 32%, #eedda0 50%, #e3b737 68%, #b87316 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 22px rgba(184, 115, 22, 0.35));
}

/* ── Sections, centred for the roll ── */

.credits-section + .credits-section { margin-top: 2.6rem; }

.credits-section-title {
  font-family: 'Aniron', serif;
  color: var(--accent-gold-bright);
  font-size: 1.15rem;
  font-weight: 400;
  font-variant: small-caps;
  letter-spacing: 0.16em;
  margin-bottom: 0.9rem;
  text-shadow: 0 0 18px rgba(184, 148, 42, 0.35);
}

.credits-row {
  display: block;
  padding: 0.28rem 0;
}
.credits-name {
  display: block;
  color: var(--text-primary);
  font-size: 0.98rem;
  letter-spacing: 0.02em;
}
.credits-role {
  display: block;
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-top: 0.05rem;
}

.credits-group + .credits-group { margin-top: 1.1rem; }
.credits-group-label {
  color: var(--text-primary);
  font-size: 0.92rem;
  margin-bottom: 0.2rem;
}
.credits-group-people {
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.7;
}

/* One name per line — keeps long names from breaking across a separator. */
.credits-person {
  color: var(--text-muted);
  font-size: 0.86rem;
  line-height: 1.85;
}

/* The 140-name roll — three columns so it reads as a block, not a mile of list. */
.credits-roll {
  column-count: 3;
  column-gap: 1.5rem;
  text-align: center;
}
.credits-roll .credits-person {
  /* Keep a name that wraps to two lines from splitting across columns. */
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  page-break-inside: avoid;
  font-size: 0.79rem;
  line-height: 1.7;
}

.credits-note {
  color: var(--text-dim);
  font-size: 0.86rem;
  line-height: 1.7;
  margin-top: 0.5rem;
}
.credits-note + .credits-note { margin-top: 0.4rem; }
.credits-roll + .credits-note,
.credits-note + .credits-roll { margin-top: 0.7rem; }

.cc-disclaimer {
  color: var(--text-muted);
  font-size: 0.74rem;
  line-height: 1.75;
  margin-top: 3.2rem;
  padding-top: 1.4rem;
  border-top: 1px solid rgba(47, 71, 89, 0.6);
}

.cc-end {
  font-family: 'Aniron', serif;
  color: var(--accent-gold);
  font-size: 1.25rem;
  font-variant: small-caps;
  letter-spacing: 0.14em;
  margin-top: 3.5rem;
  text-shadow: 0 0 20px rgba(184, 148, 42, 0.3);
}

/* ── Chrome ── */

.cc-close {
  position: absolute;
  top: 0.9rem;
  right: 1.1rem;
  z-index: 2;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity var(--transition), color var(--transition);
}
.cc-close:hover { opacity: 1; color: var(--accent-gold-bright); }

.cc-hint {
  position: absolute;
  bottom: 1.1rem;
  left: 0;
  right: 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.68rem;
  letter-spacing: 0.09em;
  opacity: 0.62;
  transition: opacity 1.6s ease;
  pointer-events: none;
}
.cc-hint.cc-hint-dim { opacity: 0.12; }

/* ── Reduced motion: no crawl, plain scrollable list ── */

#credits-panel.cc-static .cc-viewport {
  overflow-y: auto;
  -webkit-mask-image: none;
  mask-image: none;
  padding: 3rem 1rem;
}
#credits-panel.cc-static .cc-content {
  position: relative;
  top: auto;
  transform: none !important;
}

@media (max-width: 600px) {
  .cc-content { width: 92vw; margin-left: -46vw; }
  .credits-section + .credits-section { margin-top: 2.1rem; }
  .credits-section-title { font-size: 1rem; }
  /* Three columns is unreadable at phone width — drop to two. */
  .credits-roll { column-count: 2; column-gap: 0.9rem; }
  .credits-roll .credits-person { font-size: 0.74rem; }
}
