:root {
  --ink: #efe6d2;
  --dim: #b9ad94;
  --gold: #d9b867;
  --blood: #b3262e;
  --panel: rgba(12, 9, 7, 0.72);
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, 'Times New Roman', serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: #050406; color: var(--ink); font-family: var(--serif); overflow: hidden; }
#view { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; cursor: crosshair; }

#vignette {
  position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 48%, transparent 45%, rgba(0, 0, 0, 0.55) 100%);
}
body.can-take #vignette { animation: breathe 3.2s ease-in-out infinite; }
@keyframes breathe { 50% { background: radial-gradient(ellipse at 50% 48%, transparent 38%, rgba(0, 0, 0, 0.7) 100%); } }

#crosshair {
  position: fixed; left: 50%; top: 50%; width: 5px; height: 5px; margin: -2.5px 0 0 -2.5px;
  border-radius: 50%; background: rgba(239, 230, 210, 0.45); pointer-events: none; opacity: 0; transition: opacity 0.3s, transform 0.2s;
}
body.playing #crosshair { opacity: 1; }
#crosshair.on { background: var(--gold); transform: scale(1.5); }

#target {
  position: fixed; left: calc(50% + max(34px, 13vw)); top: calc(50% + 5vh); pointer-events: none;
  opacity: 0; transition: opacity 0.2s; text-shadow: 0 1px 3px #000, 0 0 12px #000;
}
#target.show { opacity: 1; }
#target-name { font-style: italic; color: var(--gold); font-size: 17px; margin-bottom: 4px; }
#actions { list-style: none; margin: 0; padding: 0; font-size: 16px; }
#actions li { padding: 2px 0; color: var(--dim); }
#actions li.sel { color: var(--ink); }
#actions li.sel::before { content: '▸ '; color: var(--gold); margin-left: -1.1em; }
kbd {
  display: inline-block; min-width: 1.4em; margin-right: 0.5em; padding: 0 0.3em; border: 1px solid rgba(217, 184, 103, 0.5);
  border-radius: 3px; font: 12px/1.5 ui-monospace, Menlo, monospace; color: var(--gold); text-align: center; background: rgba(0, 0, 0, 0.35);
}

#held { position: fixed; left: 24px; bottom: 22px; font-size: 15px; color: var(--dim); opacity: 0; transition: opacity 0.3s; text-shadow: 0 1px 3px #000; }
#held.show { opacity: 1; }
#held span { color: var(--ink); font-style: italic; margin-right: 0.8em; }
#held kbd { margin-left: 0; }

.caption {
  position: fixed; left: 50%; bottom: 11vh; transform: translateX(-50%); width: min(880px, 86vw);
  text-align: center; font-size: clamp(18px, 2.1vw, 25px); line-height: 1.45; font-style: italic;
  text-shadow: 0 1px 4px #000, 0 0 22px rgba(0, 0, 0, 0.9); opacity: 0; transition: opacity 0.6s; pointer-events: none;
}
.caption.show { opacity: 1; }
.caption.canon { font-style: normal; }
.caption small { display: block; font-size: 12px; font-style: normal; color: var(--dim); letter-spacing: 0.08em; margin-top: 6px; }
#said {
  position: fixed; left: 50%; top: 14vh; transform: translateX(-50%); width: min(760px, 84vw); text-align: center;
  font-size: clamp(19px, 2.2vw, 26px); color: #fff4dc; opacity: 0; transition: opacity 0.5s; pointer-events: none; text-shadow: 0 1px 4px #000, 0 0 18px #000;
}
#said.show { opacity: 1; }

#prompt {
  position: fixed; left: 50%; top: 18vh; transform: translateX(-50%); text-align: center; pointer-events: none;
  font-size: clamp(20px, 2.3vw, 28px); letter-spacing: 0.02em; opacity: 0; transition: opacity 1.2s; text-shadow: 0 1px 4px #000, 0 0 24px #000;
}
#prompt.show { opacity: 1; }
#prompt small { display: block; font-size: 14px; color: var(--gold); margin-top: 8px; letter-spacing: 0.1em; text-transform: uppercase; }
#hint {
  position: fixed; left: 50%; top: 22px; transform: translateX(-50%); font-size: 14px; color: var(--dim); opacity: 0; transition: opacity 0.8s;
  background: var(--panel); padding: 8px 14px; border-radius: 4px; pointer-events: none; white-space: nowrap; max-width: 96vw; overflow: hidden; text-overflow: ellipsis;
}
#hint.show { opacity: 1; }

#bargain {
  position: fixed; left: 50%; bottom: 5vh; transform: translateX(-50%); width: min(820px, 92vw); display: none; flex-direction: column; gap: 8px;
}
#bargain.show { display: flex; }
#bargain .opt {
  font: inherit; font-size: clamp(16px, 1.6vw, 19px); text-align: left; color: var(--dim); background: var(--panel); border: 1px solid rgba(217, 184, 103, 0.18);
  border-radius: 4px; padding: 10px 14px; cursor: pointer; transition: color 0.2s, border-color 0.2s;
}
#bargain .opt.sel, #bargain .opt:hover { color: var(--ink); border-color: rgba(217, 184, 103, 0.7); }
#bargain .opt.leave { font-style: italic; }

/* Begin again, at any moment of play (the mouse must be free: Esc) */
#restart { position: fixed; right: 18px; top: 18px; display: none; text-align: right; }
body.playing #restart { display: block; }
#restart-open { font-size: 14px; padding: 5px 13px; background: var(--panel); opacity: 0.55; transition: opacity 0.2s; }
#restart-open:hover, #restart-open:focus-visible { opacity: 1; }
#restart-ask { background: var(--panel); border: 1px solid rgba(217, 184, 103, 0.3); border-radius: 4px; padding: 12px 14px; }
#restart-ask p { margin: 0 0 10px; font-style: italic; text-align: center; }
#restart-ask button { font-size: 15px; padding: 6px 16px; }

#page { position: fixed; inset: 0; display: none; place-items: center; background: rgba(0, 0, 0, 0.55); pointer-events: none; }
#page.show { display: grid; }
#page img { width: min(900px, 88vw); box-shadow: 0 20px 60px #000; border-radius: 2px; }

#fade { position: fixed; inset: 0; background: #000; opacity: 1; pointer-events: none; transition: opacity 1s linear; }

#title, #ending { position: fixed; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 16px; }
#title.show, #ending.show { display: flex; }
#title { background: radial-gradient(ellipse at 50% 40%, #1a120c 0%, #050406 70%); z-index: 5; }
#title h1 { font-weight: normal; font-size: clamp(40px, 7vw, 84px); margin: 0.1em 0 0.25em; letter-spacing: 0.02em; white-space: nowrap; }
#title .kicker { color: var(--gold); letter-spacing: 0.16em; text-transform: uppercase; font-size: 13px; margin: 0; }
#title .lede { font-style: italic; font-size: clamp(17px, 2vw, 22px); color: var(--dim); margin: 0 0 1.6em; }
.small { font-size: 13px; color: var(--dim); }
.buttons { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
button {
  font: inherit; font-size: 18px; color: #1a120c; background: var(--gold); border: 0; border-radius: 3px; padding: 10px 26px; cursor: pointer;
}
button:disabled { opacity: 0.4; cursor: wait; }
button.secondary { background: transparent; color: var(--gold); border: 1px solid rgba(217, 184, 103, 0.6); }
button:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

#ending { z-index: 4; pointer-events: none; }
#end-card { pointer-events: auto; }
#end-lines { width: min(880px, 88vw); }
#end-lines p {
  font-size: clamp(19px, 2.2vw, 27px); line-height: 1.5; opacity: 0; transform: translateY(6px); transition: opacity 1.1s, transform 1.1s;
  text-shadow: 0 1px 5px #000, 0 0 26px #000;
}
#end-lines p.show { opacity: 1; transform: none; }
#end-lines small { display: block; font-size: 12px; color: var(--dim); margin-top: 10px; letter-spacing: 0.08em; }
#end-card { display: none; flex-direction: column; align-items: center; max-width: 92vw; }
#end-card.show { display: flex; }
#end-card h2 { font-weight: normal; font-size: clamp(36px, 5vw, 60px); margin: 0; }
#end-card .sub { color: var(--gold); font-style: italic; margin: 0.3em 0 1.4em; }
.found { list-style: none; padding: 0; margin: 0.4em 0 1em; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; max-width: 720px; }
.found li { font-size: 13px; padding: 4px 9px; border: 1px solid rgba(217, 184, 103, 0.25); border-radius: 3px; color: #6a604e; min-width: 2.2em; }
.found li.got { color: var(--ink); border-color: rgba(217, 184, 103, 0.7); }
.count { font-size: 13px; color: var(--dim); margin: 0; letter-spacing: 0.06em; }
.end-hint { font-style: italic; color: var(--dim); max-width: 560px; margin: 0 0 1.4em; }

#debug {
  position: fixed; left: 8px; top: 8px; margin: 0; font: 11px/1.35 ui-monospace, Menlo, monospace; color: #9fe; background: rgba(0, 0, 0, 0.6); padding: 6px 8px; pointer-events: none; z-index: 9; max-width: 70vw; white-space: pre-wrap;
}

@media (max-width: 700px) {
  #target { left: 50%; top: calc(50% + 18px); transform: translateX(-50%); text-align: center; }
  #actions li.sel::before { content: ''; margin: 0; }
}

body.bargaining .caption { bottom: auto; top: 26vh; }
body.bargaining #said { top: 8vh; }
body.facing #crosshair { opacity: 0; }
