:root { --bg: #0b0605; --ink: #f0e6d0; --red: #d8341e; --gold: #ffc846; --panel: #3a0d06; --edge: #f0b04a; color-scheme: dark; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); overflow: hidden;
  font-family: "Courier New", monospace; -webkit-user-select: none; user-select: none; touch-action: none; }
#stage { position: fixed; inset: 0; display: grid; place-items: center; }
#screen { display: block; width: min(100vw, calc(100vh * 384 / 216)); height: auto; aspect-ratio: 384 / 216;
  image-rendering: pixelated; image-rendering: crisp-edges; background: #000; cursor: crosshair; }
button { font: inherit; font-weight: bold; letter-spacing: .04em; }
#fs { position: fixed; top: 8px; right: 8px; z-index: 5; width: 34px; height: 34px; border: 1px solid #6b3a1c;
  background: rgba(20, 8, 4, .6); color: var(--gold); font-size: 18px; border-radius: 4px; cursor: pointer; opacity: .55; }
#fs:hover { opacity: 1; }
body[data-state="play"]:not([data-menu="1"]) #fs { display: none; }
#endui { position: fixed; left: 50%; bottom: 4vh; transform: translateX(-50%); display: flex; gap: 10px; flex-wrap: wrap;
  justify-content: center; z-index: 6; width: min(96vw, 720px); }
#endui[hidden] { display: none; }
#endui button { padding: 10px 16px; border: 2px solid var(--edge); background: var(--panel); color: var(--gold); cursor: pointer;
  box-shadow: 0 2px 0 #000; }
#endui button:hover { background: #5a160a; }
#toast { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); background: var(--panel); border: 2px solid var(--edge);
  color: var(--gold); padding: 8px 14px; z-index: 7; }
#toast[hidden] { display: none; }
#touch { display: none; }
body.has-touch[data-state="play"]:not([data-menu="1"]) #touch { display: block; }
#touch .stick { position: fixed; left: max(14px, env(safe-area-inset-left)); bottom: calc(15vh + 6px); width: 132px; height: 132px; border-radius: 50%;
  border: 2px solid rgba(255, 200, 70, .35); background: rgba(40, 10, 4, .25); z-index: 4; touch-action: none; }
#touch .knob { position: absolute; left: 41px; top: 41px; width: 46px; height: 46px; border-radius: 50%;
  background: rgba(255, 200, 70, .45); border: 2px solid rgba(255, 220, 140, .7); }
#touch .look { position: fixed; left: 40vw; right: 0; top: 0; bottom: 0; z-index: 3; touch-action: none; }
#touch button { position: fixed; z-index: 4; border: 2px solid rgba(255, 200, 70, .55); background: rgba(58, 13, 6, .55);
  color: var(--gold); border-radius: 50%; touch-action: none; font-size: 12px; }
#touch button.on { background: rgba(216, 52, 30, .75); }
#touch .fire { right: max(18px, env(safe-area-inset-right)); bottom: calc(15vh + 10px); width: 86px; height: 86px; font-size: 15px; }
#touch .use { right: calc(max(18px, env(safe-area-inset-right)) + 96px); bottom: calc(15vh + 8px); width: 58px; height: 58px; }
#touch .next { right: calc(max(18px, env(safe-area-inset-right)) + 14px); bottom: calc(15vh + 108px); width: 54px; height: 54px; }
#touch .map { right: max(10px, env(safe-area-inset-right)); top: 22px; width: 50px; height: 34px; border-radius: 8px; }
#touch .menu { right: calc(max(10px, env(safe-area-inset-right)) + 58px); top: 22px; width: 56px; height: 34px; border-radius: 8px; }
#rotate { display: none; }
@media (orientation: portrait) and (max-width: 820px) {
  body.has-touch #rotate { display: grid; place-items: center; position: fixed; inset: 0; z-index: 9; background: rgba(11, 6, 5, .94);
    text-align: center; color: var(--gold); font-size: 20px; padding: 24px; }
  body.has-touch #rotate small { color: var(--ink); font-size: 14px; }
}
#keep { position: fixed; inset: 0; z-index: 8; display: grid; place-items: center; background: rgba(11, 6, 5, .88); padding: 16px; }
#keep[hidden] { display: none; }
.keep-card { display: grid; gap: 10px; justify-items: center; max-width: min(92vw, 900px); }
#keep-img { max-width: 100%; max-height: 70vh; image-rendering: pixelated; border: 2px solid var(--edge); }
#keep-hint { margin: 0; color: var(--ink); }
#keep-text { width: min(92vw, 620px); background: var(--panel); color: var(--gold); border: 1px solid var(--edge); padding: 8px; font: inherit; }
#keep-close { padding: 8px 16px; border: 2px solid var(--edge); background: var(--panel); color: var(--gold); cursor: pointer; }
button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
