/* Dark, readable, keyboard-first */
:root {
  --bg: #0f0f12;
  --panel: #17171b;
  --text: #e9eaee;
  --muted: #9aa1ad;
  --accent: #8bd0ff;
  --danger: #ff6b6b;
  --success: #5de3a9;
  --focus: #ffd166;
  --border: #26262c;
  --shadow: rgba(0,0,0,0.4);
  font-synthesis-weight: none;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial, sans-serif;
}

.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; gap: 1rem;
}
.site-footer { border-top: 1px solid var(--border); border-bottom: none; box-shadow: 0 -2px 8px var(--shadow); }

h1 { margin: 0; font-size: 1.25rem; }
.subtitle { color: var(--muted); font-weight: 400; margin-left: 0.25rem; }
.container { max-width: 980px; margin: 0 auto; padding: 1rem; }
.pane { display: none; }
.pane.active { display: block; }

.start-form, .choices, .hud, .foot-actions, .results-actions, .share {
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 1rem; margin-bottom: 1rem;
}
.hud { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; align-items: start; }
.hud .inv ul, .hud .trust ul { list-style: none; padding: 0; margin: 0.25rem 0 0; }
.hud .clock, .hud .room { font-weight: 700; }
.meter progress { width: 100%; height: 1rem; }

.prose { padding: 1rem; background: var(--panel); border: 1px solid var(--border); border-radius: 16px; min-height: 160px; }
.choices { display: grid; grid-template-columns: 1fr; gap: 0.5rem; }
@media (min-width: 640px) { .choices { grid-template-columns: 1fr 1fr; } }

button, .ghost, .primary, input, select {
  font: inherit; color: inherit;
}
button, .ghost, .primary {
  background: #1e1e24; border: 1px solid var(--border); padding: 0.7rem 1rem; border-radius: 10px; cursor: pointer;
}
button:hover { border-color: var(--accent); }
button:focus { outline: 2px solid var(--focus); outline-offset: 2px; }
button.primary { background: var(--accent); color: #091019; border-color: var(--accent); }
button.ghost { background: transparent; }

.choice-btn { text-align: left; }
.choice-btn .meta { display: block; color: var(--muted); font-size: 0.85rem; }

label { display: inline-block; margin-bottom: 0.25rem; }
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; }

.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }

.diary { white-space: pre-wrap; background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 1rem; min-height: 220px; }

.top-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.location-toggle { border: 1px dashed var(--border); padding: 0.5rem 0.75rem; border-radius: 10px; }

.site-footer { text-align: center; color: var(--muted); }

.trust-row{ margin-top:6px; opacity:0.85; font-size:0.9rem; }
.trust{ padding:2px 6px; border:1px solid #444; border-radius:6px; margin-right:6px; }
.seed-tag{ margin-left:8px; font-size:0.85rem; opacity:0.75; }

/* Tells Aide + Threat Clock */
.choice { position: relative; }
.choice .choice-text { padding-right: 1.25rem; display: inline-block; }
.hint-dot, .roll-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-left: 6px; vertical-align: middle;
}
.hint-dot { background: #5ec4a9; box-shadow: 0 0 6px rgba(94,196,169,.6); }
.roll-dot { background: #e0a84a; box-shadow: 0 0 6px rgba(224,168,74,.6); }
.hour-icon {
  display: none; margin-left: 10px; opacity: .85; font-size: 0.95rem;
  padding: 0 6px; border: 1px solid #444; border-radius: 6px;
}


/* Threat Clock blink (respects reduced motion) */
@keyframes mm-pulse { 
  0% { box-shadow: 0 0 0 0 rgba(224,168,74,.45); } 
  70% { box-shadow: 0 0 0 8px rgba(224,168,74,0); } 
  100% { box-shadow: 0 0 0 0 rgba(224,168,74,0); } 
}
.hour-icon.blink { animation: mm-pulse 1.2s infinite; }
@media (prefers-reduced-motion: reduce){
  .hour-icon.blink { animation: none; }
}

/* Ultra-rare glyph */
.rare-glyph{
  display:inline-block; margin-left:6px; font-size:0.9rem; line-height:1; 
  opacity:0.9; filter: drop-shadow(0 0 4px rgba(179,139,250,.4));
}


/* Settings modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: none; align-items: center; justify-content: center; z-index: 999; }
.modal[hidden] { display: none; }
.modal:not([hidden]) { display: flex; }
.modal-content { background: var(--panel); color: var(--text); padding: 1rem; border: 1px solid var(--border); border-radius: 10px; width: 540px; max-width: 92vw; box-shadow: 0 10px 30px var(--shadow); }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: .5rem; }
.field label { font-weight: 600; display: block; margin-bottom: .25rem; }
.field small { color: var(--muted); display: block; margin-top: .25rem; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg-btn { background: transparent; border: none; padding: .4rem .6rem; color: var(--text); cursor: pointer; }
.seg-btn.active { background: rgba(255,255,255,.06); }
.modal-actions { margin-top: 1rem; display: flex; gap: .5rem; justify-content: flex-end; }

/* High contrast theme */
:root.hc {
  --bg: #000; --panel: #0a0a0a; --text: #ffffff; --muted: #d0d0d0; --accent: #8bd0ff;
  --danger: #ff6b6b; --success: #4af1b5; --focus: #ffdd66; --border: #3a3a3a; --shadow: rgba(0,0,0,0.7);
}

/* Reduce motion class overrides */
body.no-anim * { animation: none !important; transition: none !important; }

/* Dev Validator panel */
.dev-panel{
  position: fixed; right: 12px; bottom: 12px; width: min(720px, 90vw);
  max-height: 70vh; overflow: auto; background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 40px var(--shadow);
  z-index: 1000; padding: 10px;
}
.dev-panel[hidden]{ display:none; }
.dev-head{ display:flex; align-items:center; justify-content:space-between; margin-bottom:.5rem; }
.dev-body .summary{ margin-bottom:.5rem; opacity:.85; }
.dev-body .issues{ list-style: decimal; padding-left: 1.1rem; margin: 0 0 .5rem 0; }
.dev-body .issues li{ margin: .2rem 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9rem; }
.dev-body .issues li .id{ color: var(--accent); }
.dev-body .issues li .type{ opacity: .8; }
.dev-body .issues li.ok{ color: var(--success); }
.dev-body .issues li.err{ color: var(--danger); }
.dev-body .issues li.warn{ color: #e0a84a; }
.dev-panel .actions{ display:flex; gap:.5rem; justify-content:flex-end; }


/* Diary preview */
.diary-preview{ background: #0d0f12; color: var(--text); border: 1px solid var(--border);
  padding: .75rem; border-radius: 8px; max-height: 40vh; overflow: auto; white-space: pre-wrap; }


/* Share card preview */
.card-preview{
  margin-top: .75rem; border: 1px solid var(--border); border-radius: 10px; padding: .5rem;
  background: #0b0d10;
}
.card-preview img{ max-width: 100%; height: auto; display:block; margin: 0 auto; }


/* Achievements */
.achievements-box { margin-bottom: .75rem; }
.ach-list { list-style: none; padding: 0; margin: .25rem 0 0 0; display: grid; grid-template-columns: 1fr; gap: .35rem; }
.ach { display: flex; align-items: center; gap: .5rem; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: .45rem .6rem; }
.ach .ico { font-size: 1rem; width: 1.4rem; text-align: center; }
.ach .meta { display: flex; flex-direction: column; }
.ach .title { font-weight: 600; line-height: 1.2; }
.ach .desc { font-size: .9rem; opacity: .8; }
.ach.locked { opacity: .55; filter: grayscale(0.5); }


/* Ghost pips */
.pips { display:flex; gap:0.4rem; align-items:center; margin-top: 0.25rem; }
.pips [role="list"] { display:flex; gap:0.35rem; }
.pip { width: 10px; height: 10px; border-radius: 50%; display:inline-block; background: var(--accent); box-shadow: 0 0 0 1px rgba(0,0,0,0.25); }
.pip.placated { background: transparent; border: 1px dashed var(--accent); box-shadow:none; }
.pip.banished { background: transparent; border: 1px solid var(--accent); border-radius: 2px; position: relative; }
.pip.banished::after { content: ''; position: absolute; left: 1px; right: 1px; top: 50%; height: 1px; background: var(--accent); transform: rotate(45deg); }
.pip[aria-label] { outline: none; } /* tooltip via title, keyboard focus handled at container level */


/* == Map overlay == */
#map-wrap { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: none; align-items: center; justify-content: center; padding: 2rem; z-index: 50; }
#map-wrap:not([hidden]) { display: flex; }
#map-wrap .map-inner { background: var(--bg, #111); color: var(--fg, #eee); padding: 1rem; border-radius: 12px; max-width: 960px; width: 90vw; max-height: 90vh; overflow: auto; box-shadow: 0 8px 40px rgba(0,0,0,0.5); }
#map-content svg { width: 100%; height: auto; }
#map-wrap .close { float: right; margin-bottom: 0.5rem; }
#map-content [data-room].current-room, #map-content .current-room { stroke: currentColor; stroke-width: 3; filter: drop-shadow(0 0 6px currentColor); }
#map-content [data-room].adjacent-room, #map-content .adjacent-room { opacity: 0.8; }

/* Map overlay */
.map-overlay{ position:fixed; inset:0; background:rgba(0,0,0,0.84); z-index:9999; display:flex; flex-direction:column; }
.map-overlay[hidden]{ display:none; }
.map-overlay .map-ui{ display:flex; align-items:center; justify-content:space-between; padding:8px 12px; }
.map-overlay .legend{ font-size:12px; opacity:0.85; }
.map-overlay .map-wrap{ flex:1; display:flex; align-items:center; justify-content:center; padding:8px; }
.map-overlay object{ width: min(92vw, 1100px); height: min(86vh, 900px); border:1px solid rgba(255,255,255,0.1); border-radius:8px; background:#111; }
#map-close{ background:#222; color:#eee; border:1px solid #444; border-radius:6px; padding:4px 8px; cursor:pointer; }

/* Rescuer on-call pip */
.pips .pip.rescuer{ box-shadow:0 0 0 1px rgba(255,255,255,0.25) inset; background:#1b3a56; }
body.hc .pips .pip.rescuer{ background:#0a7; }

/* Rescuer variants (subtle hues) */
.pips .pip.rescuer.priest_hale{ background:#2a2e55; }
.pips .pip.rescuer.medium_rose{ background:#3b2e4a; }
.pips .pip.rescuer.caretaker_abel{ background:#1b3a56; }
.pips .pip.rescuer.trespasser_kid{ background:#294738; }
body.hc .pips .pip.rescuer{ outline:2px solid #fff; }

/* Map legend — rescuer pip doc */
.legend .rescuer-legend{ margin-top:6px; display:flex; align-items:center; gap:8px; font-size:12px; opacity:0.9; }
.legend .rescuer-legend .pip.rescuer{ width:10px; height:10px; border-radius:50%; display:inline-block; }

/* Results share bar */
.sharebar{ display:flex; gap:8px; flex-wrap:wrap; margin-top:8px; }
.sharebar button{ background:#222; color:#eee; border:1px solid #444; border-radius:6px; padding:6px 10px; cursor:pointer; }

/* Map tweak*/
.current-room  { filter: drop-shadow(0 0 6px #9cf); }
.adjacent-room { filter: drop-shadow(0 0 4px #6f6); opacity: 0.9; }

/* Locked choices*/
.choice-btn.locked::before { content: "🔒 "; }
.choice-btn.owned { opacity: .6; cursor: not-allowed; }
