/* Mallory Mansion — Hardened 2025 Version (Parity-Safe) */

/* == Core Layout & Typography == */
:root {
  --bg: #0f0f12;
  --surface: #17171b;
  --panel: var(--surface);
  --text: #e9eaee;
  --muted: #9aa1ad;
  --accent: #8bd0ff;
  --danger: #ff6b6b;
  --success: #5de3a9;
  --focus: #ffd166;
  --border: #26262c;
  --shadow: rgba(0, 0, 0, 0.4);
  --hue-rotate: 0deg;
  font-synthesis-weight: none;
}

html.theme-hc {
  --bg: #000;
  --surface: #000;
  --panel: var(--surface);
  --text: #fff;
  --muted: #ccc;
  --accent: #0ff;
  --border: #fff;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.6 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu,
    Cantarell, Noto Sans, Arial, sans-serif;
  transition: filter 0.6s ease;
  filter: hue-rotate(var(--hue-rotate));
}

body.plain-text {
  filter: none !important;
}
body.plain-text hr,
body.plain-text .decorative {
  display: none !important;
}

html.text-lg {
  font-size: 1.24em;
}

body.font-dyslexia {
  font-family: 'OpenDyslexic', 'Atkinson Hyperlegible', Arial, sans-serif;
}

body.no-tell-icons .choice-tells,
body.no-tell-icons .motif-hint {
  display: none;
}

/* Dynamic backgrounds by time phase */
body.phase-whispering {
  background: radial-gradient(at top, #1a1d2a, #0f0f12);
}
body.phase-haunting {
  background: radial-gradient(at top, #000000, #0a0a0c);
}
body.phase-haunting::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% -20%, rgba(255,255,255,0.05), transparent);
  opacity: 0;
  animation: midnight-flash 15s infinite;
}
body.phase-ferality {
  background: radial-gradient(at bottom, #240000, #0f0f12);
}
body.phase-ferality::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(at bottom, rgba(120,0,0,0.15), transparent);
  opacity: 0;
  animation: crimson-creep 60s forwards;
}
body.phase-survival {
  background: radial-gradient(at bottom, #2e0000, #0f0f12);
}

@keyframes midnight-flash {
  0%,97%,100% { opacity:0; }
  98% { opacity:1; }
  99% { opacity:0; }
}
@keyframes crimson-creep {
  from { opacity:0; }
  to { opacity:1; }
}

@media (prefers-reduced-motion: reduce) {
  body.phase-haunting::before,
  body.phase-ferality::before { animation: none; opacity: 0; }
}
.reduce-motion.phase-haunting::before,
.reduce-motion.phase-ferality::before { animation: none; opacity: 0; }

/* Critical health blur effect */
#pane-game {
  transition: filter 0.4s ease;
}
#pane-game.health-critical {
  filter: blur(2px);
}
@media (prefers-reduced-motion: reduce) {
  #pane-game { transition: none; }
}
.reduce-motion #pane-game {
  transition: none;
}

.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 1rem;
}

.site-header,
.site-footer {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 8px var(--shadow);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-footer {
  border-top: 1px solid var(--border);
  border-bottom: none;
  box-shadow: 0 -2px 8px var(--shadow);
  text-align: center;
  color: var(--muted);
}

h1 {
  margin: 0;
  font-size: 1.25rem;
}

.subtitle {
  color: var(--muted);
  font-weight: 400;
  margin-left: 0.25rem;
}

/* == Buttons & Inputs == */
button,
.primary,
.ghost,
input,
select {
  font: inherit;
  color: inherit;
}

button,
.primary,
.ghost {
  background: #1e1e24;
  border: 1px solid var(--border);
  padding: 0.7rem 1rem;
  border-radius: 10px;
  cursor: pointer;
  text-align: center;
}

button:hover,
.primary:hover,
.ghost:hover {
  border-color: var(--accent);
}

button:disabled,
.ghost:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button:focus-visible,
.primary:focus-visible,
.ghost:focus-visible,
.choice-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

button.primary {
  background: var(--accent);
  color: #091019;
  border-color: var(--accent);
}

button.ghost {
  background: transparent;
}

#btn-start-game {
  font-size: 1.25rem;
  padding: 1rem 1.5rem;
  min-height: 48px;
}

@media (max-width: 640px) {
  #btn-start-game {
    display: block;
    width: 100%;
  }
}

.choice-btn {
  position: relative;
  text-align: left;
  width: 100%;
  opacity: 0;
  animation: choice-fade 0.3s ease-out forwards;
}

.choice-btn.locked {
  opacity: 0.6;
}

.choice-btn.locked::before {
  content: "🔒 ";
}

.choice-btn.owned {
  opacity: 0.6;
  cursor: not-allowed;
}

.reduce-motion .choice-btn { animation: none; opacity: 1; }

@keyframes choice-fade {
  from { opacity:0; transform: translateY(4px); }
  to { opacity:1; transform: translateY(0); }
}

label {
  display: inline-block;
  margin-bottom: 0.25rem;
}

.location-toggle {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.location-toggle label {
  margin: 0;
}

input[type="text"] {
  background: #121216;
  border: 1px solid var(--border);
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  width: 100%;
}

.seed-wrap {
  display: inline-flex;
  align-items: center;
}

.seed-wrap input {
  width: 8.5rem;
}

/* == Main UI Panels == */
.pane {
  display: none;
}
.pane.active {
  display: block;
}

.start-form,
.choices,
.hud,
.foot-actions,
.hotkey-footer,
.results-actions,
.share {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.prose {
  padding: 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  min-height: 160px;
}

.choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 8px;
}

.choices ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.hotkey-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.hotkey-footer .key-tip {
  display: inline-flex;
  align-items: center;
}

.hotkey-footer kbd {
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 0.25rem;
  margin-right: 0.25rem;
}

@media (max-width: 480px) {
  .hotkey-footer { display: none; }
}

/* === Diary & Death pane === */
.diary {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1rem;
  min-height: 220px;
}

.diary h2 {
  margin-top: 0;
}

.diary h3 {
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.25rem;
}

.diary ul {
  padding-left: 1.25rem;
  margin: 0.5rem 0;
}

.diary hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1rem 0;
}

.diary .epitaph {
  font-style: italic;
  color: var(--muted);
  text-align: center;
}

#pane-death {
  position: relative;
  overflow-y: auto;
}

#pane-results {
  overflow-y: auto;
}

#pane-death::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
    ellipse at center,
    rgba(0, 0, 0, 0) 35%,
    rgba(0, 0, 0, 0.65) 80%
  );
  z-index: 0;
}

#pane-death .prose,
#pane-death h2,
#pane-death .actions {
  position: relative;
  z-index: 1;
}

.death-figure {
  margin: 1rem 0;
}

.death-figure img {
  display: block;
  max-width: 70%;     /* up from 40% */
  max-height: 55vh;   /* up from 30vh */
  height: auto;
  margin: 0 auto;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 1s;
}


.death-figure img.fade-in {
  opacity: 1;
}

.new-lore {
  margin-top: 1rem;
}

/* == Game HUD & Components == */
.hud {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-areas:
    "top top top"
    "left mid right"
    "bottom bottom bottom";
  column-gap: 1rem;
  row-gap: 0.5rem;
  align-items: start;
}

.hud-top { grid-area: top; display: flex; justify-content: center; }
.hud-left { grid-area: left; }
.hud-mid { grid-area: mid; position: relative; }
.hud-right { grid-area: right; }
.hud-bottom { grid-area: bottom; display: flex; justify-content: center; }

.hud .inv ul,
.hud .trust ul,
.hud .states ul,
.hud .quests ul {
  list-style: none;
  padding: 0;
  margin: 0.25rem 0 0;
}

.hud .inv {
  margin-bottom: 0.5rem;
}

#states li.status-flash {
  animation: statusFlash 0.5s ease-out;
}

@keyframes statusFlash {
  from { background: rgba(255,255,255,0.2); }
  to   { background: transparent; }
}

#quest-log {
  margin: 0.25rem 0 0;
  padding: 0;
}

#quest-log li {
  list-style: none;
  padding: 0.25rem 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

#quest-log li:first-child {
  border-top: none;
}

#quest-log .quest-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

#quest-log .quest-stage {
  font-size: 0.75rem;
  color: var(--muted);
}

#quest-log .quest-status {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: inline-block;
  margin-top: 0.125rem;
  transition: all 0.2s ease;
}

#quest-log .quest-status.status-active { color: var(--accent); }
#quest-log .quest-status.status-available { color: var(--muted); }
#quest-log .quest-status.status-completed { color: var(--success); }
#quest-log .quest-status.status-failed { color: var(--danger); }
#quest-log .quest-status.status-reminder { color: var(--muted); }

/* Enhanced quest status styling for better accessibility */
#quest-log .quest-status.status-active {
  background: rgba(139, 208, 255, 0.1);
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid rgba(139, 208, 255, 0.3);
}

#quest-log .quest-status.status-completed {
  background: rgba(93, 227, 169, 0.1);
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid rgba(93, 227, 169, 0.3);
}

#quest-log .quest-status.status-failed {
  background: rgba(255, 107, 107, 0.1);
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid rgba(255, 107, 107, 0.3);
}

/* Subtle pulse for active quests in HUD */
#quest-log .quest-status.status-active {
  animation: quest-status-pulse 3s ease-in-out infinite;
}

@keyframes quest-status-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.8; }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  #quest-log .quest-status {
    border: 1px solid currentColor;
    background: rgba(255, 255, 255, 0.05);
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  #quest-log .quest-status.status-active {
    animation: none;
  }
}

#quest-log .quest-empty {
  color: var(--muted);
  font-size: 0.8rem;
  padding: 0.25rem 0;
  border-top: none;
}

#quest-log li.quest-flash {
  animation: statusFlash 0.6s ease-out;
}

/* Mobile-specific quest log enhancements */
@media (max-width: 640px) {
  #quest-log {
    margin: 0.5rem 0 0;
    padding: 0;
  }

  #quest-log li {
    padding: 0.5rem 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }

  #quest-log li:first-child {
    border-top: none;
  }

  #quest-log .quest-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
  }

  #quest-log .quest-stage {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.125rem;
  }

  #quest-log .quest-status {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    display: inline-block;
    margin-top: 0.25rem;
    transition: all 0.2s ease;
    padding: 3px 8px;
    border-radius: 4px;
    min-height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Enhanced mobile status styling with better contrast */
  #quest-log .quest-status.status-active {
    color: var(--accent);
    background: rgba(139, 208, 255, 0.15);
    border: 1px solid rgba(139, 208, 255, 0.4);
    font-weight: 600;
  }

  #quest-log .quest-status.status-completed {
    color: var(--success);
    background: rgba(93, 227, 169, 0.15);
    border: 1px solid rgba(93, 227, 169, 0.4);
    font-weight: 600;
  }

  #quest-log .quest-status.status-failed {
    color: var(--danger);
    background: rgba(255, 107, 107, 0.15);
    border: 1px solid rgba(255, 107, 107, 0.4);
    font-weight: 600;
  }

  #quest-log .quest-status.status-available {
    color: var(--muted);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
  }

  #quest-log .quest-status.status-reminder {
    color: var(--muted);
    background: rgba(203, 213, 245, 0.1);
    border: 1px solid rgba(203, 213, 245, 0.3);
  }

  /* Larger touch targets for mobile */
  #quest-log li {
    min-height: 44px;
    padding: 0.75rem 0;
  }

  /* Better spacing for mobile HUD */
  .hud .quests {
    margin-top: 0.75rem;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 6px;
  }
}

@media (max-width: 480px) {
  /* Extra small screens - further optimize */
  #quest-log .quest-title {
    font-size: 0.85rem;
  }

  #quest-log .quest-stage {
    font-size: 0.75rem;
  }

  #quest-log .quest-status {
    font-size: 0.65rem;
    padding: 2px 6px;
    min-height: 20px;
  }

  #quest-log li {
    padding: 0.5rem 0;
  }
}

.hud .clock,
.hud .room {
  font-weight: 700;
}

.hud .clock {
  background: #1b1b1f;
  border: 1px solid #2a2a33;
  border-radius: 6px;
  padding: 0.125rem 0.5rem;
  font-variant-numeric: tabular-nums;
  font-family: "Courier New", monospace;
  letter-spacing: 0.03em;
  justify-self: start;
  width: fit-content;

}

.top-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

[data-action="menu-open"] {
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.top-stats {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  padding: 0.25rem 0.5rem;
  flex-wrap: wrap;
}

.top-stats .stat {
  background: #1b1b1f;
  border: 1px solid #2a2a33;
  border-radius: 10px;
  padding: 0.25rem 0.5rem;
  font-size: 0.9rem;
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
}

.top-stats .label {
  opacity: 0.6;
  font-size: 0.8rem;
  margin-right: 0.25rem;
}

.top-stats .divider {
  opacity: 0.6;
  margin: 0 0.25rem;
}

.dev-only {
  display: none;
}


.journal {
  margin: 0.5rem 0 0 0;
  max-height: 0;
  overflow: hidden;
  border: none;
  border-radius: 8px;
  padding: 0;
  background: #101014;
  transition: max-height 0.3s ease;
}

.journal.open {
  max-height: 140px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid #2a2a33;
  padding: 0.5rem;
}

.journal ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.journal li {
  font-size: 0.9rem;
  line-height: 1.25;
  padding: 0.15rem 0;
  color: #cfd3dc;
}

.journal li.new-entry .entry-text {
  display: inline-block;
  overflow: hidden;
  white-space: nowrap;
  animation: journal-type 1s steps(var(--chars)) forwards;
}

@keyframes journal-type {
  from { width: 0; }
  to { width: calc(var(--chars) * 1ch); }
}

#pane-start {
  position: relative;
  overflow-x: hidden;
  overflow-y: auto;
}
#pane-start::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255,255,255,0.05), transparent),
              linear-gradient(90deg, rgba(255,255,255,0.03), rgba(0,0,0,0.03));
  background-size: 200% 200%;
  animation: fog-drift 60s linear infinite;
  pointer-events: none;
}
#pane-start::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(255,220,150,0.1), transparent 70%);
  animation: candle-flicker 3s infinite alternate;
  pointer-events: none;
}
@keyframes fog-drift {
  from { background-position: 0 0; }
  to { background-position: 200% 0; }
}
@keyframes candle-flicker {
  from { opacity: 0.2; }
  to { opacity: 0.4; }
}

.main-menu {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  z-index: 1;
}

#start-heading {
  margin-left: 0.5rem;
}

.main-menu #btn-main-new {
  font-size: 1.25rem;
  font-weight: 700;
  padding: 1rem 1.5rem;
}

/* Highlight the guided tutorial as a distinct option */
.main-menu .tutorial-entry {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border: 1px dashed var(--accent);
  border-radius: 0.5rem;
  margin-bottom: 1.25rem; /* create a larger gap below */
}

.main-menu .tutorial-entry button {
  font-size: 0.875rem;
  font-weight: 600;
}

.main-menu .tutorial-entry small {
  margin-top: 0.25rem;
}

.main-menu #btn-main-journal,
.main-menu #btn-main-achievements,
.main-menu #btn-main-settings {
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
}

@media (prefers-reduced-motion: reduce){
  .journal li.new-entry .entry-text { animation: none; width: auto; }
}

.journal .t {
  opacity: 0.6;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  margin-right: 0.5rem;
}

.trust-row {
  margin-top: 0.375rem;
  opacity: 0.85;
  font-size: 0.9rem;
}

.trust {
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-right: 0.375rem;
}

.trust .npc-link {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0;
  font: inherit;
  text-decoration: underline;
}

#npc-modal img {
  max-width: 60%;
  height: auto;
  display: block;
  margin: 0 auto 1rem;
}

#survived-modal img {
  max-width: 60%;
  height: auto;
  display: block;
  margin: 0 auto 1rem;
}

.states {
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-right: 0.375rem;
}

.seed-tag {
  margin-left: 0.5rem;
  font-size: 0.85rem;
  opacity: 0.75;
}

.meta-chip {
  background: #1b1b1f;
  border: 1px solid #2a2a33;
  border-radius: 10px;
  padding: 0.25rem 0.5rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.meta-chip.lore {
  color: var(--focus);
  border-color: var(--focus);
}

#seed-chip {
  cursor: pointer;
  user-select: all;
}

/* Who chip used in tells */
.who-chip { margin-right: .5rem; font-weight: 600; }

/* -- Omen Meter -- */
.meter progress {
  width: 100%;
  height: 1rem;
}

#omen.low {
  accent-color: var(--success);
}
#omen.mid {
  accent-color: var(--focus);
}
#omen.high {
  accent-color: var(--danger);
}

/* -- Escape Meter -- */
#escape-meter {
  margin-left: 8px;
  vertical-align: middle;
}
#escape-meter .meter {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
#escape-meter .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3b3f46;
  opacity: 0.55;
}
#escape-meter .dot.filled {
  background: #8bdc65;
  opacity: 1;
}
html.theme-hc #escape-meter .dot {
  background: transparent;
  outline: 1px solid #fff;
  opacity: 1;
}
html.theme-hc #escape-meter .dot.filled {
  background: #fff;
}

#escape-meter-tip {
  position: fixed; /* Use fixed for tooltips over scrollable content */
  z-index: 99999;
  min-width: 220px;
  max-width: 280px;
  background: rgba(17, 17, 23, 0.96);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  padding: 10px 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-2px);
  transition: opacity 0.12s ease, transform 0.12s ease;
  font: 13px/1.3 system-ui, sans-serif;
}

#status-tip {
  position: fixed;
  z-index: 99999;
  max-width: 260px;
  background: rgba(17,17,23,0.96);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  padding: 8px 10px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-2px);
  transition: opacity 0.12s ease, transform 0.12s ease;
  font: 13px/1.3 system-ui, sans-serif;
}
#escape-meter-tip .tip-head {
  font-weight: 600;
  margin-bottom: 6px;
}
#escape-meter-tip .tip-rows .row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 2px 0;
}
#escape-meter-tip .val.pos {
  color: var(--success);
}
#escape-meter-tip .val.neg {
  color: var(--danger);
}

/* -- Choice Hints & Meta -- */
.choice-btn .motif-hint {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 6px;
  font-size: 12px;
  line-height: 1;
  border-radius: 999px;
  border: 1px solid #3b3f46;
  background: linear-gradient(#16181d, #0f1115);
  color: #cfd3da;
  vertical-align: middle;
  transform: translateY(-1px);
  opacity: 0.95;
}
.choice-btn.has-hint {
  box-shadow: 0 0 0 0 rgba(123, 217, 122, 0);
  transition: box-shadow 0.18s ease;
}
.choice-btn.has-hint:hover {
  box-shadow: 0 0 0 3px rgba(123, 217, 122, 0.18);
}
.choice-btn .meta {
  margin-left: 8px;
  font-size: 12px;
  color: var(--muted);
}

/* -- Multi-tell Pips -- */
.choice-tells { display: inline-flex; gap: 4px; margin-left: .5rem; vertical-align: middle; }
.tell-pip { width: .6rem; height: .6rem; border-radius: 50%; outline: 2px solid transparent; }
.tell-pip[data-type="red"]  { background: currentColor; }
.tell-pip[data-type="gold"] { background: currentColor; }
.tell-pip[data-type="blue"] { background: currentColor; }

.tell-pip.tell-pulse,
.motif-hint.tell-pulse {
  animation: tell-pulse 0.4s ease-in-out;
}

@keyframes tell-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.4); }
  100% { transform: scale(1); }
}

/* High Contrast mode hook */
.theme-hc .tell-pip { outline-color: currentColor; background: transparent; }
.theme-hc .tell-pip::after { content: ""; display:block; width:100%; height:100%; border: 2px solid currentColor; border-radius:inherit; }

/* Colorblind-safe tells */
body.cb-tells .tell-pip {
  background: transparent;
  border: 1px solid currentColor;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.55rem;
  line-height: 0.55rem;
}
body.cb-tells .tell-pip[data-type="red"]::after { content: "!"; }
body.cb-tells .tell-pip[data-type="gold"]::after { content: "★"; }
body.cb-tells .tell-pip[data-type="blue"]::after { content: "●"; }

.choice-btn {
    align-items: flex-start;
}

.choice-label-line {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.risk-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}
.chip {
    font-size: 0.8em;
    padding: 0.2rem 0.5rem;
    border-radius: 1rem;
    background-color: #333;
    color: #eee;
    white-space: nowrap;
}
.chip.time { background-color: #3a5a75; }
.chip.omen { background-color: #753a3a; }
.chip.omen-none { background-color: #4f4f4f; }

#num-omen.omen-rise { color:#ff6b6b; animation:omen-rise 0.8s ease-out; }
#num-omen.omen-fall { color:#72d28b; animation:omen-fall 0.8s ease-out; }
@keyframes omen-rise { 0%,100%{ text-shadow:0 0 0 rgba(255,107,107,0); } 50%{ text-shadow:0 0 6px rgba(255,107,107,0.9); } }
@keyframes omen-fall { 0%,100%{ text-shadow:0 0 0 rgba(114,210,139,0); } 50%{ text-shadow:0 0 6px rgba(114,210,139,0.9); } }
.chip.attack-low { background-color: #3a754b; }
.chip.attack-med { background-color: #756a3a; }
.chip.attack-high { background-color: #753a3a; }
.chip.attack-none { background-color: #4f4f4f; }
.chip.need { background-color: #6c4f8a; }


/* == Modals & Overlays == */
/* -- Generic Modal -- */
.modal {

        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.6);
        display: none; /* hidden by default */
        align-items: center;
        justify-content: center;
        padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);

        z-index: 999;
        opacity: 0;
        transition: opacity 0.15s ease-out;
        overflow: hidden;
        height: 100vh;
}
@supports (height: 100dvh){
        .modal { height: 100dvh; }
}
.modal.is-open {
        display: flex;
        opacity: 1;
}
.modal-content {
        background: var(--panel);
        padding: 1.25rem;
        border: 1px solid var(--border);
                border-radius: 12px;
                max-width: 92vw;
                box-shadow: 0 10px 30px var(--shadow);
                        transform: scale(0.95);
                        transition: transform 0.15s ease-out;
                    }
                    .modal.is-open .modal-content {
                        transform: scale(1);
                      }
                      .modal-content {
                        position: relative;
                        max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 2rem);
                        overflow-y: auto;
}
.close-button {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
}
.close-button:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
  border-color: var(--border);
}
/* Prevent a stuck `modal-open` class from permanently disabling page scroll.
  The app normally toggles this class while a modal is visible. In some
  dev/preview situations the class can be left on; allow scrolling by
  falling back to auto overflow while preserving the visual layout. This
  is intentionally conservative and reversible. */
body.modal-open { position: static; width: auto; overflow: auto; }
.modal-actions {
	margin-top: 1.5rem;
	display: flex;
	gap: 0.5rem;
	justify-content: flex-end;
}
.settings-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
        margin-top: 0.5rem;
}
@media (max-width: 600px){
        .settings-grid { grid-template-columns: 1fr; }
}
#settings-modal .modal-content {
        max-height: 90vh;
        overflow-y: auto;
}
#seed-modal .modal-content {
        max-width: 20rem;
}
.field {
        border: 1px solid var(--border);
        border-radius: 8px;
        padding: 0.75rem;
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
}
.field label {
        font-weight: 600;
        display: block;
        margin-bottom: 0.25rem;
}
.field small {
        color: var(--muted);
        display: block;
        margin-top: 0.25rem;
}
.check-wrap {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        margin: 0.25rem 0;
}
.range-wrap {
        display: flex;
        align-items: center;
        gap: 0.5rem;
}

/* Segmented control */
.seg {
        display: inline-flex;
        border: 1px solid var(--border);
        border-radius: 8px;
        overflow: hidden;
}
.seg input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.seg-btn {
  background: transparent;
  border: none;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  flex: 1;

  /* keep label + Recommended pill aligned & non-wrapping */
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  white-space: nowrap;
}
.seg input[type="radio"]:checked + .seg-btn {
  background: rgba(255, 255, 255, 0.06);
}

/* === “Recommended” pill for segmented buttons === */
.recommended-tag {
  display: inline-block;
  font-size: 0.65em;
  color: var(--accent);
  opacity: 1;
  font-weight: 600;
  text-transform: uppercase;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(139, 208, 255, 0.12);
  border: 1px solid var(--border);
}

/* === Onboarding modal === */
#onboarding-modal .modal-content {
  max-width: 600px;
}

#onboarding-modal h4 {
  color: var(--accent);
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

#onboarding-modal hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1rem 0;
}

#onboarding-modal .modal-body {
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 1rem;
  margin-right: -1rem;
}

#onboarding-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#onboarding-modal .modal-header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#onboarding-modal .modal-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

/* -- Map Overlay -- */
#map-wrap {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.8);
	display: none; /* hidden by default */
	flex-direction: column;
	z-index: 50;
	padding: 1rem;
	opacity: 0;
	transition: opacity 0.15s ease-out;
}
#map-wrap.is-open {
	display: flex;
	opacity: 1;
}
#map-wrap .map-inner {
        background: var(--bg);
        color: var(--text);
        padding: 1rem;
        border-radius: 12px;
        max-width: 960px;
        width: 100%;
        max-height: calc(100vh - 4rem);
        overflow: auto;
        box-shadow: 0 8px 40px var(--shadow);
        margin: 2rem auto;
  position: relative;
}
#map-wrap .map-hud {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
        margin-bottom: 0.5rem;
}
#map-wrap .map-hud h3 {
        margin: 0;
        font-size: 0.9rem;
}
#map-wrap .map-hud #map-quick {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
}
#map-wrap .map-hud .quick-move {
        padding: 0.25rem 0.5rem;
        font-size: 0.85rem;
        border: 1px solid var(--border);
        border-radius: 4px;
        background: var(--panel);
}
#map-content svg {
	width: 100%;
	height: auto;
	display: block;
}
#map-content .current-room {
	filter: drop-shadow(0 0 6px var(--accent));
}
#map-content .adjacent-room {
	filter: drop-shadow(0 0 4px var(--success));
	opacity: 0.9;
}

/* Map legend */
#map-content .map-legend {
  display: inline-flex;
  gap: 1rem;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  margin-top: 0.5rem;
  font-size: 0.9rem;
  box-shadow: 0 2px 6px var(--shadow);
}
#map-content .map-legend .legend-dot { 
  display: inline-block; 
  width: 10px; height: 10px; border-radius: 50%;
}
#map-content .map-legend .legend-dot.current { box-shadow: 0 0 6px var(--accent); background: var(--accent); }
#map-content .map-legend .legend-dot.adjacent { box-shadow: 0 0 4px var(--success); background: var(--success); }
#map-content .map-legend .legend-dot.visited { background: var(--muted); }
#map-content .map-legend .legend-dot.warded { background: var(--accent); }
#map-content .map-legend .legend-dot.danger3 { background: #ff7f7f; }
#map-content .map-legend .spacer { width: 1px; height: 12px; background: var(--border); display:inline-block; margin: 0 0.25rem; }

/* Map affordances */
.map-current rect {
        outline: 3px solid currentColor;
        box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.28);
}
.map-unvisited {
        opacity: 0.45;
        filter: saturate(0.6) contrast(0.95);
}

#map-content .safe-room-flag {
  pointer-events: none;
  font-size: 24px;
}
#map-content .visited-check,
#map-content .warded-star {
  pointer-events: none;
  font-size: 16px;
}
#map-content .warded-star { fill: var(--accent); }
#map-content [data-room].danger-1 rect { fill: #ffd37f; }
#map-content [data-room].danger-2 rect { fill: #ffae7f; }
#map-content [data-room].danger-3 rect { fill: #ff7f7f; }
/* Screen flash for tells */
body.flash-red::after,
body.flash-blue::after,
body.flash-gold::after {
        content:"";
        position:fixed;
        inset:0;
        pointer-events:none;
        animation:screen-flash 0.35s ease-out forwards;
}
body.flash-red::after { background:rgba(255,0,0,0.25); }
body.flash-blue::after { background:rgba(0,136,255,0.25); }
body.flash-gold::after { background:rgba(245,197,83,0.25); }

@keyframes screen-flash {
        from { opacity:1; }
        to { opacity:0; }
}
/* == Themes & Utilities == */
.muted {
  color: var(--muted);
}
.hidden {
  display: none !important;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* -- Reduced Motion -- */
body.reduce-motion * {
  animation-name: none !important;
  animation-duration: 0s !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0s !important;
}
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

html.theme-hc .choice-btn:focus-visible {
  outline-color: #fff;
}
html.theme-hc #escape-meter-tip {
  background: #000;
  border-color: #fff;
  box-shadow: none;
}
html.theme-hc .choice-btn.has-hint:hover {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35);
}

/* == Developer Tools == */
#dev-overlay {
  position: fixed;
  right: 12px;
  top: 12px;
  z-index: 9999;
  width: 340px;
  background: rgba(10, 10, 14, 0.96);
  border: 1px solid #2a2a2f;
  border-radius: 10px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.6);
  font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #e5e7eb;
  padding: 8px 10px;
}
#dev-overlay[hidden] {
  display: none;
}
#dev-overlay .hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
#dev-overlay .badge {
  font-weight: 700;
  font-size: 11px;
  color: #fff;
  background: var(--danger);
  padding: 2px 6px;
  border-radius: 6px;
}
#dev-overlay #dev-close {
  background: transparent;
  border: 1px solid #3a3a3f;
  color: #aaa;
  border-radius: 6px;
  padding: 2px 6px;
  cursor: pointer;
}
#dev-overlay .grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
}
#dev-overlay .k {
  color: var(--muted);
}
#dev-overlay .v {
  font-weight: 600;
}
#dev-overlay .v.full {
  grid-column: 1 / -1;
}
#dev-overlay ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 4px;
}
#dev-overlay li {
  display: flex;
  align-items: center;
  gap: 6px;
}
#dev-overlay li code {
  background: #0b0b10;
  border: 1px solid #2b2b33;
  padding: 1px 4px;
  border-radius: 4px;
  color: var(--accent);
}
#dev-overlay .pct {
  margin-left: auto;
  color: var(--accent);
}
#dev-overlay .mitigated {
  color: var(--success);
}
#dev-overlay .unmitigated {
  color: var(--focus);
}
#dev-overlay .cd {
  color: var(--muted);
  font-style: italic;
}

#dev-omen-big {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 9998;
  font-size: 4rem;
  font-weight: 700;
  color: var(--accent);
  pointer-events: none;
}
#dev-omen-big[hidden] {
  display: none;
}

@media (prefers-reduced-motion: reduce){
 * { animation: none !important; transition: none !important; }
}
/* Choice keycaps (1–9) */
#choices button {
  display: block;
  width: 100%;
  text-align: left;
}

.choice { display:flex; align-items:flex-start; justify-content:space-between; gap:.5rem; }
.choice-text { flex:1; min-width:0; }
.risk-pill {
  flex:0 0 auto;
  font-weight:600;
  border:1px solid var(--muted);
  border-radius:999px;
  padding:.125rem .5rem;
  white-space:nowrap;
  font-size:.75rem;
}
.risk-pill.risk-low { background:#1b5e20; border-color:#1b5e20; color:#fff; }
.risk-pill.risk-medium { background:#fff; color:#000; }
.risk-pill.risk-high { background:#b71c1c; border-color:#b71c1c; color:#fff; }
.choice-meta .risk-pill {
  font-size: inherit;
  padding: 0 .25rem;
}
.sr-only { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(1px,1px,1px,1px); white-space:nowrap; }
.visually-hidden { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(1px,1px,1px,1px); white-space:nowrap; }
.choice.is-disabled, .choice-card.is-disabled { opacity:.65; cursor:not-allowed; }
.choice-req { margin-top:.25rem; font-size:.875rem; opacity:.9; }

/* WHAT: Subtle styling for the pager card so it reads as navigation, not content. */
.choice.is-pager .meta { opacity:.9; }
.choice-btn.is-pager .choice-label-line { letter-spacing:.2px; }

/* WHAT: Make inline lore hints readable and visually distinct. */
.tell-inline { display:block; font-style:italic; margin-bottom:.25rem; opacity:.95; }
.tell-inline--gold { color:#f5c553; } /* same hue as existing lore color */

#presence-chip.badge{margin:.25rem 0 .5rem;padding:.15rem .6rem;border:1px solid var(--border);border-radius:999px;opacity:.9;min-height:1.5rem}
.tell{ font-style:italic; margin:.25rem 0 .5rem; }
.tell--ambient{ color:#7fb7ff; animation: whisper-flicker 0.8s ease-in-out; }
.tell--menace { color:#ff6b6b; animation: menace-pulse 1.2s ease-in-out, ghost-shake 0.4s ease-in-out; }
.tell--lore   { color:#f5c553; animation: lore-glow 3s ease-in-out infinite alternate; }
.tell--boon   { color:#72d28b; } /* green */
body.cb-tells .tell--menace::before { content:"⚠ "; }
body.cb-tells .tell--lore::before { content:"★ "; }
body.cb-tells .tell--ambient::before { content:"● "; }
.escalation{opacity:.9;margin:.25rem 0;color:var(--danger);font-style:italic;font-weight:600}

.legend-dot { display:inline-block; width:10px; height:10px; border-radius:50%; margin-right:0.25rem; }
.legend-dot.ambient { background:#7fb7ff; }
.legend-dot.menace  { background:#ff6b6b; }
.legend-dot.lore    { background:#f5c553; }

@keyframes whisper-flicker {
  0%,100% { opacity:1; filter:none; }
  50% { opacity:0.8; filter:blur(1px); }
}
@keyframes menace-pulse {
  0%,100% { opacity:1; }
  50% { opacity:0.85; text-shadow:0 0 4px #ff6b6b; }
}
@keyframes ghost-shake {
  0%,100% { transform:translateX(0); }
  20% { transform:translateX(-1px); }
  40% { transform:translateX(1px); }
  60% { transform:translateX(-1px); }
  80% { transform:translateX(1px); }
}
@keyframes lore-glow {
  0%,100% { text-shadow:0 0 2px #f5c553; }
  50% { text-shadow:0 0 6px #f5c553; }
}

@media (prefers-reduced-motion: reduce){
  .tell--ambient,
  .tell--menace,
  .tell--lore { animation: none; }
}

.badge{display:inline-block;font-size:.8rem;padding:.1rem .5rem;border:1px solid var(--border);border-radius:6px;opacity:.85}
.badge.coming-soon{background:var(--accent);color:var(--surface)}

#run-goals{display:flex;gap:.5rem;margin:.25rem .5rem .5rem;flex-wrap:wrap}
#run-goals .goal{font-size:.85rem;padding:.15rem .5rem;border:1px solid var(--border);border-radius:999px;opacity:.9}
#run-goals .goal.done{opacity:.55;text-decoration:line-through}

.daily-modifier-badge {
  display: flex;
  gap: .5rem;
  margin: .25rem .5rem .5rem;
  font-size: .85rem;
  padding: .15rem .5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  opacity: .9;
  background: var(--panel);
  max-width: fit-content;
}

.content-offline-badge {
  background-color: var(--danger);
  color: white;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: bold;
  border-radius: 12px;
  margin-left: 1rem;
  vertical-align: middle;
}

/* Hint Overlay */
#hint-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10000;
  display: none;
}

.hint-box {
  position: absolute;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 1rem;
  color: var(--text);
  max-width: 300px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.hint-box p {
  margin: 0 0 1rem;
}

.warning-ribbon {
  background: #b96100;
  color: white;
  text-align: center;
  padding: 0.5rem;
  font-weight: bold;
}

/* Stats Page */
#pane-stats .modal-content {
  max-width: 800px;
  width: 90vw;
}

.stats-container {
  display: grid;
  gap: 2rem;
}

.stats-summary {
  display: flex;
  gap: 1rem;
  justify-content: space-around;
  background: rgba(255,255,255,0.05);
  padding: 1rem;
  border-radius: 8px;
}

.stat-box {
  text-align: center;
}

.stat-box .value {
  font-size: 2rem;
  font-weight: bold;
}

.stat-box .label {
  font-size: 0.9rem;
  color: var(--muted);
}

.run-history .table-wrap {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.run-history table {
  width: 100%;
  border-collapse: collapse;
}

.run-history th, .run-history td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.run-history th {
  background: rgba(255,255,255,0.1);
  position: sticky;
  top: 0;
}

.death-histogram .histogram-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.death-histogram .chart-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.histo-bar {
  display: grid;
  grid-template-columns: 120px 1fr 40px;
  gap: 1rem;
  align-items: center;
}

.histo-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
  font-size: 0.9rem;
}

.histo-value-wrap {
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
  height: 20px;
}

.histo-value {
  background-color: var(--accent);
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s;
}

.histo-count {
  font-weight: bold;
}

/* Log Book Page */
#pane-logbook .modal-content {
  max-width: 800px;
  width: 90vw;
}

.logbook-container {
  max-height: 60vh;
  overflow-y: auto;
}

.logbook-entries {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.logbook-entry {
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
  padding: 1rem;
  border-left: 4px solid var(--accent);
}

.logbook-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.logbook-entry-outcome {
  font-weight: bold;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
}

.logbook-entry-outcome.survival {
  background: var(--success);
  color: white;
}

.logbook-entry-outcome.death {
  background: var(--danger);
  color: white;
}

.logbook-entry-outcome.dawn {
  background: var(--focus);
  color: white;
}

.logbook-entry-notes {
  white-space: pre-wrap;
  line-height: 1.4;
}

.logbook-empty {
  text-align: center;
  color: var(--muted);
  padding: 2rem;
  font-style: italic;
}

/* Ghost Activity Bar */
#ghost-pips {
  display: flex;
  width: 100%;
  height: 8px;
  gap: 2px;
}
#ghost-pips .pip {
  flex: 1;
  background: var(--success);
}
#ghost-pips .pip.mid {
  background: var(--focus);
}
#ghost-pips .pip.high {
  background: var(--danger);
}

/* Threat Clock Bar */
.threat-bar {
  width: 100%;
  height: 8px;
  background-color: var(--border);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  cursor: help;
}

.threat-bar-fill {
  height: 100%;
  background-color: hsl(var(--hue, 120deg),100%,50%);
  border-radius: 4px;
  width: 0%; /* updated by JS */
  transition: width 0.5s ease-in-out, background-color 0.5s ease-in-out;
}

.threat-bar-fill.post-midnight {
  background: linear-gradient(90deg, var(--accent), var(--danger));
  animation: pulse-red 2s ease-in-out infinite;
}

@keyframes pulse-red {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.4);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(255, 107, 107, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 107, 107, 0);
  }
}

.threat-bar-ticks {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.threat-bar-ticks .tick {
  position: absolute;
  top: 0;
  width: 2px;
  height: 100%;
  background-color: var(--bg);
  cursor: help;
}

body[data-missing-threat-bar]::before {
  content: 'Missing threat bar';
  position: fixed;
  top: 0;
  left: 0;
  background: #c00;
  color: #fff;
  padding: 2px 4px;
  font-size: 12px;
  z-index: 10000;
}

/* Health Bar */
.health-bar {
  width: 100%;
  height: 0.75rem;
  background-color: var(--border);
  border-radius: 0.375rem;
  position: relative;
  overflow: visible;
  cursor: help;
}

.health-bar::before {
  content: '\2764\FE0F'; /* ❤️ */
  position: absolute;
  left: -1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.75rem;
  pointer-events: none;
  z-index: 1;
}

#health-bar-fill {
  position: relative;
  height: 100%;
  background-color: var(--danger);
  border-radius: 0.375rem;
  width: calc(var(--pct, 0) * 1%);
  transition: width 0.5s ease-in-out;
  z-index: 0;
}

body[data-missing-health-bar]::before {
  content: 'Missing health bar';
  position: fixed;
  top: 0;
  left: 0;
  background: #c00;
  color: #fff;
  padding: 2px 4px;
  font-size: 12px;
  z-index: 10000;
}

/* Achievements Grid */
.ach-percent-wrap {
  margin-top: 0.5rem;
}
.ach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 0.5rem; /* for scrollbar */
}

/* Boon picker grid */
.boon-grid {
  display: grid;
  gap: 12px;
}

.boon-grid button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

html.theme-hc .boon-grid button:focus-visible {
  outline: 2px solid #000;
}
.ach-tile {
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.ach-tile:not(.unlocked) {
  opacity: 0.5;
}
.ach-icon {
  font-size: 2rem;
  line-height: 1;
}
.ach-text strong {
  display: block;
}
.ach-text small {
  color: var(--muted);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Custom highlight for seed loading */
.highlight-link-load {
  outline: 1px solid var(--accent);
  box-shadow: 0 0 4px var(--accent);
  transition: outline .3s ease, box-shadow .3s ease;
}

/* Mallory Mansion — Diary print styles */
@media print {
  body {
    font-family: "Georgia", "Times New Roman", serif;
    color: #000;
    background: #fff !important;
    margin: 0;
    padding: 0;
  }
  header, nav, .hud, .controls, .settings, #seed-chip, footer, button, .meta-chip {
    display: none !important;
  }
  #diary, .diary {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 1.5cm;
    line-height: 1.4;
    font-size: 12pt;
  }
  #diary h1, #diary h2, #diary h3 {
    page-break-before: always;
    font-family: "Georgia", "Times New Roman", serif;
    font-weight: bold;
  }
  p, blockquote, li {
    page-break-inside: avoid;
  }
  img {
    max-width: 100% !important;
    height: auto !important;
    page-break-inside: avoid;
  }
}

.time-bar {
  position: relative;
  width: 100%;
  height: 8px;
  background: #222;
  border-radius: 4px;
  margin: 1rem 0;
  overflow: visible;

  padding-bottom: 0.75rem;
}

.time-bar-segment {
  position: absolute;
  height: 100%;
  top: 0;
}

.time-bar-midnight {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: #8e44ad;
  transform: translateX(-1px);
  z-index: 1;
}

.time-bar-marker {
  position: absolute;
  bottom: -0.6rem;
  font-size: 0.75rem;
  transform: translateX(-50%);
  color: var(--muted);
  white-space: nowrap;
  z-index: 2;
}

.time-bar-marker.overtime {
  color: var(--danger);
}
#choices button .k {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
  min-width: 1.5rem;
  height: 1.5rem;
  border: 1px solid #444;
  border-radius: 0.25rem;
  margin-right: 0.5rem;
  font-size: 0.8rem;
  opacity: 0.8;
}
/* === Mobile tweaks === */
@media (max-width: 640px) {
  :root {
    --pad: 0.75rem;
  }
  .site-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  .site-header .top-actions {
    width: 100%;
    justify-content: space-between;
  }
  .site-header #top-stats {
    width: 100%;
  }
  header.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--panel);
  }
  .pane {
    padding: var(--pad);
  }
  #prose {
    font-size: 1.06rem;
    line-height: 1.55;
  }
  #choices button {
    min-height: 3.25rem;
    padding: 0.75rem 0.9rem;
    margin-bottom: 0.5rem;
    -webkit-tap-highlight-color: transparent;
  }
  .journal {
    max-height: 34vh;
  }
  .hud {
    grid-template-columns: 1fr;
    grid-template-areas:
      "top"
      "left"
      "mid"
      "right"
      "bottom";
  }

  .stats { display:grid; grid-template-columns: repeat(3, auto); gap:.35rem .6rem; }

  .badge, .chip { padding:.25rem .5rem; }

  #panel-objectives {
    display: none;
  }

  .hud-right,
  .hud-right .panel,
  .hud-right .tab-panel {
    width: 100%;
  }

  .foot-actions {
    padding-bottom: calc(env(safe-area-inset-bottom) + 8px);
  }

  .top-stats .divider {
    display: none;
  }
}

.prose-hint {
  background: rgba(139, 208, 255, 0.08);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  padding: 0.75rem;
  margin: 1rem 0;
  color: var(--text);
  font-style: italic;
  opacity: 0.95;
}
.prose-hint::before {
  content: "Clue: ";
  font-weight: bold;
  color: var(--accent);
}

/* Hide controls on narrow screens */
@media (max-width: 640px){
  #btn-help, .site-header h1 { display: none; }
}

/* Bottom-sheet modal */
.menu-modal {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(2px);
        display: none; /* hidden by default */
        z-index: 1000;
        opacity: 0;
        transition: opacity 0.18s ease;
        height: 100vh;
}

@supports (height: 100dvh) {
  .menu-modal {
    height: 100dvh;
  }
}
.menu-modal.is-open {
        display: block;
        opacity: 1;
}
.menu-sheet{
  position: relative;
  left: 50%;
  top: 10%;
  bottom: 0%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 520px;
  background: var(--bg, #0b0b0d);
  border-top-left-radius: 16px; border-top-right-radius: 16px;
  box-shadow: 0 -10px 30px rgba(0,0,0,.35);
  padding: .75rem .75rem 1rem;
  z-index: 1001;
}
.menu-head{ display:flex; align-items:center; justify-content: space-between; padding: .25rem .25rem .5rem; }
.menu-list{ display:grid; grid-template-columns: 1fr; gap: .5rem; padding: .25rem; }

.menu-list button{
  font-size: 1.05rem;
  min-height: 3.25rem;
  justify-content: flex-start; text-align: left;
  border-radius: 12px;
}

/* Small motion guard */
@media (prefers-reduced-motion: no-preference) {
        .menu-sheet {
                transform: translate(-50%, 10%);
                transition: transform 0.18s ease, opacity 0.18s ease;
                opacity: 0;
        }
        .menu-modal.is-open .menu-sheet {
                transform: translate(-50%, 0);
                opacity: 1;
        }
}
/* Hide hamburger on desktop */
.hamburger {
  display: none;
  font-size: 1.4rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
}

/* Mobile breakpoint */
@media (max-width: 768px) {
  .site-header nav {
    display: none;
  }
  .hamburger {
    display: block;
  }
  #site-menu {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 2rem;
    z-index: 9999;
  }
  #site-menu a {
    font-size: 1.2rem;
    color: var(--text);
  }
}
/* Update-available toast */
.update-toast {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  z-index: 9999;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .65rem .9rem;
  border-radius: .5rem;
  background: #1a1a1f;
  color: #e9eaee;
  box-shadow: 0 4px 18px rgba(0,0,0,.45);
}
.update-toast button {
  appearance: none;
  border: 0;
  border-radius: .35rem;
  padding: .3rem .6rem;
  cursor: pointer;
  background: #fff;
  color: #111;
  font-weight: 600;
  line-height: 1;
}
@media (prefers-reduced-motion: reduce){
  .update-toast { transition: none !important; }
}

.split-button {
  position: relative;
  display: inline-flex;
}

.split-button .primary {
  border-radius: 0;
}

.split-button .primary:first-child {
  border-top-left-radius: 5px;
  border-bottom-left-radius: 5px;
}

.split-button #btn-share-more {
  border-top-right-radius: 5px;
  border-bottom-right-radius: 5px;
  border-left: 1px solid #222;
}

.split-button .dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background: #222;
  border: 1px solid #333;
  border-radius: 5px;
  padding: 0.5rem;
  display: none;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 10;
}

.split-button .dropdown-menu.show {
  display: flex;
}

.split-button .dropdown-menu button {
  width: 100%;
  text-align: left;
}

/* === Splash (moved from inline to CSS) === */
#splash {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: var(--muted);
  opacity: 1;
  transition: opacity .3s ease;
}
#splash.hidden {
  opacity: 0;
  pointer-events: none;
}

#activity-bar {
  display:flex;
  position:relative;
  width:100%;
  height:8px;
  margin:1rem 0;
  overflow:visible;
  padding-bottom:0.75rem;
}
#activity-bar .seg { height:8px; border-radius:2px; flex:0 0 auto }
#activity-bar .seg.low { background:#66b3ff }
#activity-bar .seg.med { background:#ffd45a }
#activity-bar .seg.high{ background:#ff9a3c }
#activity-bar .seg.crit{ background:#ff4d4d }
#activity-bar .seg.end { width:12px; height:10px; border:1px solid rgba(255,255,255,.2); flex:0 0 12px }
#activity-bar .seg.end.dead    { background:#111; }
#activity-bar .seg.end.escaped { background:#9be37f; }
#activity-bar .seg.end.dawn    { background:#c9c9ff; }
/* Fade overtime minutes to visually align with the time bar */
#activity-bar .seg.overtime { opacity: .4; }

.logo-wrapper {
  /* This container's width is set by the widest element inside it */
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 8px; /* <-- Add this line */
}

.site-logo-svg {
  color: white;
  height: 32px; 
  width: auto;
  vertical-align: text-bottom;
}

.site-sub-logo-svg {
  /* Ensures this SVG never grows wider than the container */
  max-width: 100%;
  color: grey;
  height: auto;
  width: 150px;
  vertical-align: text-bottom; 
}

/* Footer boot banner */
.boot-banner{
  display:inline-block;
  margin-left:.75rem;
  opacity:.85;
  color:#9aa;
  font:12px/1.3 monospace;
  white-space:pre;
}

/* Dawn choice helper text */
.choice-subtitle {
  font-size: .9rem;
  opacity: .8;
  margin-top: .25rem;
}

/* ── Choice group heading ───────────────────────────── */
.choice-group {
  margin: 12px 0 6px;
  opacity: .8;
  font-weight: 600;
  font-size: .9rem;
  border-top: 1px solid var(--dim);
  padding-top: 6px;
}
.choice-group:first-child {
  border-top: 0;
  padding-top: 0;
}

/* ── Beta touch-target bump (scoped) ───────────────── */
.choice-btn,
.modal-actions > button,
.inv-item .btn {
  min-height: 44px;            /* big enough for thumbs */
}
.choice-btn {
  padding: 10px 12px;
}

/* Don’t inflate tiny icon controls like the close “×” */
.close-button { min-height: initial; }

/* If you render subtitles inside buttons, keep them stacked nicely */
.choice-subtitle { display:block; font-size:.9rem; opacity:.8; margin-top:.25rem; }

/* --- Footer Social Icons Styling --- */

/* This targets the container for the social links */
.footer-socials {
  display: flex; /* Aligns icons in a row */
  align-items: center; /* Vertically centers the icons if needed */
  gap: 1rem;     /* Creates space between each icon. Adjust 1rem as you see fit. */
}

/* This targets the individual icon links */
.footer-socials a {
  text-decoration: none; /* **Removes the underline** from the links */
  color: #cccccc;        /* Sets the **default icon color** to light grey */
  transition: color 0.2s ease-in-out; /* Adds a smooth transition for the hover effect */
}

/* This changes the color when you mouse over an icon */
.footer-socials a:hover {
  color: #a972ff; /* Sets the **icon color on hover** to a nice purple */
}

/* Ensure keyboard users can see focus */
.footer-socials a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* --- General Footer Layout --- */

/* Optional: This helps align the copyright text and social icons on opposite sides */
.site-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%; /* Ensure footer spans the full width */
    padding: 1rem 2rem; /* Example padding */
    box-sizing: border-box;
}

@keyframes mm-unlock {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.unlock-anim {
  animation: mm-unlock 0.4s ease-out;
}
.reduce-motion .unlock-anim { animation: none; }

/* Threat pip HUD */
[data-hud="threat-pips-wrap"] {
  display: flex;
  gap: 4px;
}
[data-hud="threat-pips"] {
  display: flex;
  gap: 4px;
  --duration: 0.8s;
  --delay: 0s;
}
[data-hud="threat-pips"] .pip {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: hsl(var(--hue),100%,50%);
  animation: threat-pip var(--duration) ease-in-out var(--delay) infinite alternate;
  opacity: 0.3;
}
[data-hud="threat-pips"] .pip.is-lit {
  opacity: 1;
}
/* Alert: presence detected — rapid red flash */
[data-hud="threat-pips"].alert .pip {
  background: hsl(0,100%,50%);
  box-shadow: 0 0 6px rgba(255, 0, 0, 0.6), 0 0 12px rgba(255, 0, 0, 0.35);
}
@keyframes threat-pip {
  from { opacity: 1; transform: scale(1); }
  to { opacity: 0.3; transform: scale(0.5); }
}
/* Stronger pulse when alerting */
@keyframes threat-pip-alert {
  from { opacity: 1; transform: scale(1.1); }
  to { opacity: 0.35; transform: scale(0.75); }
}
/* Switch animation when alert flag is set */
[data-hud="threat-pips"].alert .pip {
  animation-name: threat-pip-alert;
}
@media (prefers-reduced-motion: reduce) {
  [data-hud="threat-pips"] .pip { animation: none; }
}
.reduce-motion [data-hud="threat-pips"] .pip { animation: none; }

.hud .quests {
  margin-top: 0.5rem;
}
