:root {
  color-scheme: dark;
  --ink: #0d0a07;
  --night: #14100c;
  --stone: #33291e;
  --parchment: #dac99d;
  --muted: #998b70;
  --gold: #d9aa4f;
  --bright-gold: #f0d486;
  --red: #6d2e26;
  --green: #637a52;
  --cyan: #7bb9b7;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  color: var(--parchment);
  font-family: Georgia, "Times New Roman", serif;
  background: #080604;
}
button, input { font: inherit; }
button { cursor: pointer; }
#game-shell { height: 100vh; display: grid; grid-template-rows: 76px minmax(0, 1fr) 46px; }

.marquee {
  display: flex; align-items: center; gap: 13px;
  padding: 8px clamp(12px, 2.5vw, 32px);
  border-bottom: 4px ridge #705837;
  background:
    linear-gradient(90deg, transparent 0 49%, #6e58332e 50%, transparent 51%) 0 0 / 70px 100%,
    linear-gradient(#292117, #110e0a);
  box-shadow: 0 5px 24px #000c; z-index: 4;
}
.brand-mark {
  width: 51px; height: 51px; display: grid; place-items: center; flex: 0 0 auto;
  color: #211609; font-size: 31px; font-weight: 900;
  background: radial-gradient(circle at 35% 28%, #f5df98, #a36b2d 67%, #57381b);
  border: 4px double #e6c477; border-radius: 50%; text-shadow: 0 1px #fff7;
  box-shadow: inset 0 0 13px #3f210f, 0 0 15px #000;
}
.eyebrow { margin: 0; color: #b49a69; font: 700 10px/1.2 system-ui, sans-serif; letter-spacing: .17em; text-transform: uppercase; }
h1 { margin: 1px 0 0; color: #efd58e; font-size: clamp(25px, 3vw, 35px); line-height: .92; text-shadow: 2px 2px #4d271c; }
.campaign-meter { width: min(330px, 32vw); margin-left: auto; }
.meter-copy { display: flex; justify-content: space-between; align-items: baseline; color: #a99b7c; font: 10px system-ui, sans-serif; text-transform: uppercase; letter-spacing: .08em; }
.meter-copy strong { color: #e8c978; font-size: 12px; }
.meter-track { height: 7px; margin-top: 5px; padding: 1px; background: #080604; border: 1px solid #665034; box-shadow: inset 0 1px 3px #000; }
.meter-track i { width: 0; height: 100%; display: block; background: linear-gradient(90deg, #6e3024, #d9aa4f); box-shadow: 0 0 8px #c8933b; transition: width .5s; }
.status-cluster { display: flex; align-items: center; gap: 7px; color: #ad9c7b; font: 11px system-ui, sans-serif; }
.classic-switch { padding: 5px 8px; color: #d4b66f; border: 1px solid #5e472b; background: #1b140d; text-decoration: none; font: 9px system-ui, sans-serif; letter-spacing: .08em; text-transform: uppercase; }
.classic-switch:hover { color: #f3d993; border-color: #a47b3f; }
.death-switch { color: #d69a88; border-color: #69342d; }
.network-dot { width: 7px; height: 7px; background: #655b49; border-radius: 50%; }
.network-dot.online { background: #78b673; box-shadow: 0 0 7px #78b673; }
.seal-button { width: 31px; height: 31px; margin-left: 6px; color: #cba65c; background: #231b12; border: 1px solid #725735; border-radius: 50%; }

.viewport-frame { position: relative; min-height: 0; background: #000; overflow: hidden; }
#viewport { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
#crosshair { position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; border: 1px solid #ffe7a19c; transform: translate(-50%, -50%) rotate(45deg); box-shadow: 0 0 7px #000; }
.location-plaque { position: absolute; top: 13px; left: 50%; min-width: 210px; padding: 8px 28px 6px; text-align: center; transform: translateX(-50%); background: linear-gradient(90deg, transparent, #120e09e8 12% 88%, transparent); text-shadow: 1px 2px #000; }
.location-plaque span { display: block; color: #efd69a; font-size: 17px; }
.location-plaque small { color: #9c8a67; font: 9px system-ui, sans-serif; letter-spacing: .28em; }
.prompt { position: absolute; left: 50%; bottom: 25px; transform: translateX(-50%); padding: 9px 17px; white-space: nowrap; color: #fff1bd; background: #120d08e8; border: 1px solid #cf9f4d; box-shadow: 0 4px 22px #000; font-size: 14px; }
kbd { min-width: 1.6em; display: inline-block; margin: 0 1px; padding: 2px 5px; text-align: center; color: #f6dfa1; background: #33281b; border: 1px solid #806641; border-bottom-width: 2px; border-radius: 3px; font: 10px system-ui, sans-serif; }
.toast { position: absolute; top: 70px; left: 50%; width: min(520px, 86vw); padding: 12px 20px; transform: translateX(-50%); text-align: center; color: #ead7a8; background: #18100de8; border: 1px solid #7b5b35; box-shadow: 0 8px 28px #000; }
.whisper { position: absolute; left: 50%; bottom: 13%; width: min(620px, 85vw); transform: translateX(-50%); color: #c9c4b6a8; text-align: center; font-size: clamp(15px, 2vw, 21px); font-style: italic; letter-spacing: .04em; text-shadow: 0 2px 8px #000, 0 0 20px #8ea3a044; animation: whisperIn 5s ease both; pointer-events: none; }
@keyframes whisperIn { 0% { opacity: 0; filter: blur(4px); } 18%, 68% { opacity: .82; filter: blur(0); } 100% { opacity: 0; filter: blur(3px); } }
.location-plaque.disturbed small { color: #9db4ae; animation: compassTremor .12s steps(2) infinite; }
@keyframes compassTremor { 50% { transform: translateX(1px); opacity: .65; } }

.map-reveal { position: absolute; inset: 0; display: grid; place-items: center; background: #050301c7; backdrop-filter: blur(2px); z-index: 3; }
.map-reveal[hidden] { display: none; }
.map-reveal::before { content: ""; position: absolute; width: min(74vh, 74vw); aspect-ratio: 1; background: radial-gradient(circle, #d09a3a1d, transparent 68%); animation: flamePulse .7s infinite alternate; }
@keyframes flamePulse { to { transform: scale(1.08); opacity: .6; } }
#minimap { width: min(68vh, 68vw); height: min(68vh, 68vw); border: 5px ridge #9e763c; background: #100c08; box-shadow: 0 10px 60px #000, 0 0 50px #b8752638; image-rendering: pixelated; z-index: 1; }
.map-heading { position: absolute; top: 24px; display: flex; gap: 15px; align-items: center; z-index: 2; color: #e7cb87; text-transform: uppercase; letter-spacing: .12em; font-size: 12px; }
.map-heading strong { width: 28px; height: 28px; display: grid; place-items: center; color: #1b1007; background: #d8aa4e; border-radius: 50%; font-family: system-ui, sans-serif; }

.command-bar { display: flex; align-items: center; gap: 19px; padding: 7px 17px; background: #110e0a; border-top: 4px ridge #705837; font: 11px system-ui, sans-serif; z-index: 4; }
.torch-button { margin-left: auto; padding: 5px 10px; color: #e5cc90; background: #261b11; border: 1px solid #735735; }
.torch-button b { filter: drop-shadow(0 0 5px #e08327); }
.torch-button em { display: inline-grid; width: 20px; height: 20px; margin-left: 6px; place-items: center; color: #1b1107; background: #d7aa52; border-radius: 50%; font-style: normal; font-weight: 800; }
.torch-button:disabled { opacity: .45; cursor: not-allowed; }
.ambience-button { padding: 5px 8px; color: #8f856f; background: transparent; border: 1px solid #493a28; font-size: 10px; }
.ambience-button[aria-pressed="true"] { color: #b8c9bf; border-color: #52665f; box-shadow: inset 0 0 12px #49635a33; }
.party { min-width: 100px; padding-left: 14px; border-left: 1px solid #51412a; }
.party span { display: block; }
.party-label { color: #82745d; font-size: 8px; text-transform: uppercase; letter-spacing: .12em; }

.mobile-controls { display: none; position: absolute; inset: auto 10px 10px; grid-template-columns: repeat(5, 46px); justify-content: center; gap: 7px; z-index: 2; }
.mobile-controls button { width: 46px; height: 46px; color: #f4d88f; background: #211810dd; border: 2px ridge #9e783f; border-radius: 50%; }
.mobile-controls .interact-control { background: #5d3520e8; }

dialog { color: var(--parchment); }
dialog::backdrop { background: #050301df; backdrop-filter: blur(4px); }
.stone-dialog {
  width: min(720px, calc(100vw - 30px)); max-height: min(84vh, 760px); overflow: auto;
  padding: clamp(24px, 5vw, 46px); border: 8px ridge #80663e;
  background: linear-gradient(135deg, #382f23, #1a150f 72%);
  box-shadow: 0 20px 90px #000, inset 0 0 65px #0006;
}
.stone-dialog h2, .encounter-copy h2 { margin: 8px 32px 18px 0; color: #f0d792; font-size: clamp(30px, 6vw, 51px); font-weight: normal; line-height: 1; }
.stone-dialog p { line-height: 1.65; }
.dialog-close { position: absolute; top: 10px; right: 14px; color: #cbb78d; background: none; border: 0; font-size: 31px; z-index: 4; }
.runes { padding: 28px; text-align: center; color: var(--gold); font-size: 26px; animation: flamePulse 1.2s infinite alternate; }
.dialog-actions { margin-top: 26px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }
.dialog-actions a { color: #efc96f; }
.dialog-actions button, form button { padding: 10px 14px; color: #f2ddb0; background: #3c2b1e; border: 2px ridge #a17e48; }
.compact-dialog { width: min(480px, calc(100vw - 30px)); }
form { display: grid; gap: 14px; }
form label { display: grid; gap: 6px; font: 11px system-ui, sans-serif; text-transform: uppercase; letter-spacing: .08em; }
input { width: 100%; padding: 10px; color: #f5e3b8; background: #110d09; border: 1px solid #82683f; }
input[type="color"] { height: 43px; padding: 3px; }
.fine-print { color: #9d9075; font-size: 12px; }

.encounter-dialog, .challenge-dialog { width: min(980px, calc(100vw - 26px)); height: min(82vh, 740px); padding: 0; overflow: hidden; border: 7px ridge #80643b; background: #16110c; box-shadow: 0 24px 100px #000; }
.encounter-dialog[open], .challenge-dialog[open] { display: grid; grid-template-columns: minmax(260px, 43%) 1fr; }
.character-stage, .question-keeper { position: relative; min-height: 0; overflow: hidden; background: #050403; }
.character-stage::after, .question-keeper::after { content: ""; position: absolute; inset: 0; box-shadow: inset -30px 0 45px #16110c, inset 0 0 30px #000; pointer-events: none; }
.character-stage img, .question-keeper img { width: 100%; height: 100%; object-fit: cover; object-position: center top; }
.encounter-copy, .challenge-copy { position: relative; min-width: 0; overflow-y: auto; padding: clamp(25px, 5vw, 53px); background: radial-gradient(circle at 30% 15%, #3c3022, #17110c 72%); }
.character-speech { font-size: clamp(17px, 2vw, 22px); line-height: 1.65; }

.challenge-dialog[open] { grid-template-columns: 31% 1fr; }
.question-keeper img { object-position: 47% top; }
.question-meta { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; font: 700 10px system-ui, sans-serif; letter-spacing: .1em; text-transform: uppercase; }
.question-meta span { padding: 5px 8px; color: #d7bf88; border: 1px solid #59462d; }
.question-meta strong { margin-left: auto; color: #edc66a; }
.timer { height: 4px; margin: 13px 0 21px; background: #090705; }
.timer i { width: 100%; height: 100%; display: block; background: linear-gradient(90deg, #743027, #e1b452); transition: width .2s linear; }
.challenge-copy h2 { margin: 0 0 22px; color: #eee0bd; font-size: clamp(22px, 3vw, 34px); font-weight: normal; line-height: 1.28; }
.question-answers { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.question-answers button { min-height: 58px; padding: 10px 13px; color: #d9c8a4; background: linear-gradient(#38291e, #251a13); border: 2px ridge #775b39; text-align: left; }
.question-answers button:hover { color: #ffeab8; border-color: #bd8b47; }
.question-answers button.correct { color: #ecffdc; background: #2e492d; border-color: #8cb679; }
.question-answers button.wrong { color: #ffdbcf; background: #572c26; border-color: #b76e62; }
.question-answers button:disabled { cursor: default; }
.research-drawer { max-height: 240px; margin-top: 15px; padding: 15px; overflow-y: auto; background: #0e1a1ce8; border-left: 3px solid #659a98; }
.research-drawer h3 { margin: 4px 0 7px; color: #a9d5d2; }
.research-drawer p { margin: 0 0 8px; color: #b7c4bd; font: 13px/1.55 system-ui, sans-serif; }
.research-drawer a { color: #86c8c3; font-size: 12px; }
.challenge-tools { display: flex; gap: 9px; margin-top: 15px; }
.challenge-tools button { padding: 8px 10px; color: #c8b993; background: #251c14; border: 1px solid #6b5435; font-size: 12px; }
.challenge-tools .quiet-button { color: #9b8f77; background: transparent; border-color: transparent; }
.question-result { min-height: 44px; color: #e8c979; line-height: 1.5; }

@media (max-width: 760px) {
  #game-shell { grid-template-rows: 64px minmax(0, 1fr) 40px; }
  .brand-mark { width: 42px; height: 42px; font-size: 25px; }
  .campaign-meter { margin-left: auto; width: 35vw; }
  .meter-copy span, #network-label, .command-bar > span, .title-lockup .eyebrow, .classic-switch { display: none; }
  .status-cluster { margin-left: 0; }
  .mobile-controls { display: grid; }
  .prompt { bottom: 70px; }
  .party { display: none; }
  .torch-button { margin: auto; }
  .ambience-button { display: none; }
  .encounter-dialog[open], .challenge-dialog[open] { height: min(90vh, 820px); display: block; overflow-y: auto; }
  .character-stage, .question-keeper { height: 34vh; min-height: 220px; }
  .character-stage::after, .question-keeper::after { box-shadow: inset 0 -35px 40px #16110c, inset 0 0 25px #000; }
  .encounter-copy, .challenge-copy { overflow: visible; }
  .question-answers { grid-template-columns: 1fr; }
}
