:root {
  --bg: #08090c;
  --panel: rgba(10, 12, 16, 0.86);
  --text: #e6e8ec;
  --muted: #9aa1ad;
  --ok: #6fdc8c;
  --bad: #ff6b5e;
  --pending: #e8c15a;
  --line: rgba(255, 255, 255, 0.12);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow: hidden;
}

#canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
}

#hud-color { position: fixed; inset: 0; z-index: 1; pointer-events: none; }
#game-hud { position: fixed; inset: 0; z-index: 2; pointer-events: none; color: #f7f3e8;
  text-shadow: 0 2px 6px #000, 0 0 2px #000; }
#game-hud p { position: absolute; margin: 0; padding: 10px 16px; max-width: min(440px, 80vw);
  background: rgba(9, 11, 15, .65); border-left: 3px solid #c9b48a; }
#game-hud p[hidden] { display: none; }
#hud-objective { top: 28px; right: 28px; font-size: 17px; }
#hud-objective::before { content: 'Objective'; display: block; color: #c9b48a; font-size: 11px;
  letter-spacing: .12em; text-transform: uppercase; }
#hud-tip { top: 100px; left: 4px; font-size: 15px; color: #ffe8a0; }
#hud-print { bottom: 60px; right: 20px; font-size: 15px; text-align: right; }
#hud-inventory { top: 20px; right: 20px; font-size: 15px; white-space: pre-line; text-align: right; }

.game-menu[hidden] { display: none; }
.game-menu { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center;
  background: #000; }
.game-menu-frame { width: min(100vw, 133.333vh); aspect-ratio: 4 / 3;
  position: relative; background-color: #12151a; background-position: center;
  background-repeat: no-repeat; background-size: 100% 100%; container-type: inline-size; }
.game-menu-content { position: absolute; left: 11%; top: 54%; width: 35%;
  max-height: 38%; overflow-y: auto; color: #d4d5d4; text-align: center; }
#game-menu-heading { margin: 0 0 3cqw; font: bold 2.3cqw/1.1 Arial, sans-serif;
  text-shadow: 1px 2px 3px #000; }
#game-menu-items { display: grid; gap: .3cqw; }
#game-menu-items button { width: 100%; padding: .1cqw .3cqw; border: 0; background: transparent;
  color: #c8c9c9; font: bold 2.3cqw/1.1 Arial, sans-serif; text-shadow: 1px 2px 3px #000;
  cursor: pointer; }
#game-menu-items button:hover, #game-menu-items button:focus-visible { color: #f4f4f2;
  text-shadow: 0 0 6px #d6e0eb, 1px 2px 3px #000; outline: none; }
#game-menu-items button:disabled { color: #707578; cursor: default; }
#game-menu-message { margin: 1cqw 0 0; min-height: 1em; font: 1.8cqw/1.2 Arial, sans-serif; }
#game-menu-tip { position: absolute; bottom: 1.2%; left: 1.6%; right: 1.6%; margin: 0;
  color: #ddd; font: 1.5cqw/1.2 Arial, sans-serif; text-shadow: 1px 2px 3px #000; }
.menu-active #panel { display: none; }

#panel {
  position: fixed;
  z-index: 3;
  top: 16px;
  left: 16px;
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 16px 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

h1 { margin: 0 0 6px; font-size: 16px; }
h1 span { color: var(--muted); font-weight: normal; }

.note { margin: 0 0 12px; color: var(--muted); font-size: 12px; }

dl {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 4px 12px;
  margin: 0 0 14px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
dt { color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; }
dd[data-state="ok"] { color: var(--ok); }
dd[data-state="bad"] { color: var(--bad); }
dd[data-state="pending"] { color: var(--pending); }

.picker {
  display: inline-block;
  padding: 6px 12px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}
.picker:hover { border-color: var(--muted); }
.picker input { display: none; }

.controls { display: grid; gap: 7px; margin: 4px 0 14px; }
.controls label { color: var(--muted); }
.controls select, .controls button {
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #1a1d24;
  color: var(--text);
  font: inherit;
}
.controls button { cursor: pointer; }
.controls button:hover:not(:disabled) { border-color: var(--muted); }
.controls button:disabled, .controls select:disabled { opacity: 0.5; cursor: default; }
.sound-buttons { display: flex; gap: 7px; }
.sound-buttons button { flex: 1; }

.save-controls { border-top: 1px solid var(--line); padding-top: 10px; margin-bottom: 14px; }
.save-controls h2 { font-size: 14px; margin: 0 0 8px; }
.save-controls label { color: var(--muted); margin-right: 8px; }
.save-controls select, .save-controls button {
  padding: 6px 8px; border: 1px solid var(--line); border-radius: 5px;
  background: #1a1d24; color: var(--text); font: inherit;
}
.save-buttons { display: flex; gap: 7px; margin: 8px 0; }
.save-buttons button { flex: 1; cursor: pointer; }
.save-buttons button:disabled { opacity: 0.5; cursor: default; }
#save-status[data-state="bad"] { color: var(--bad); }
#save-status[data-state="ok"] { color: var(--ok); }

.game-over[hidden] { display: none; }
.game-over {
  position: fixed; inset: 0; z-index: 5; display: grid; place-items: center;
  padding: 20px; background: rgba(4, 5, 8, 0.82);
}
.game-over-card {
  width: min(440px, 100%); padding: 24px; background: #15181f;
  border: 1px solid var(--bad); border-radius: 10px;
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.55);
}
.game-over-card h2 { margin: 0 0 8px; color: var(--bad); font-size: 24px; }
.game-over-card p { margin: 0 0 18px; }
.game-over-card label { display: block; margin: 14px 0 5px; color: var(--muted); }
.game-over-card button, .game-over-card select {
  width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 5px;
  background: #252a33; color: var(--text); font: inherit;
}
.game-over-card button { cursor: pointer; }
.game-over-card button:disabled { opacity: 0.5; cursor: default; }
#game-over-message { margin: 12px 0 0; color: var(--bad); min-height: 1.4em; }

#extensions {
  list-style: none;
  margin: 0;
  padding: 0;
  columns: 2;
  font-size: 12px;
  color: var(--muted);
}

.novel-view[hidden] { display: none; }
.novel-view { position: fixed; z-index: 30; inset: 0; display: flex; flex-direction: column;
  background: #08090c; color: #f5f1e9; }
.novel-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: .65rem;
  padding: .7rem 1rem; background: #1c1d21; }
.novel-toolbar label { display: flex; gap: .35rem; align-items: center; }
.novel-toolbar select { max-width: 11rem; }
.novel-toolbar button, .novel-toolbar select { font: inherit; }
.novel-toolbar #novel-close { margin-left: auto; }
.novel-stage { flex: 1; min-height: 0; display: grid; place-items: center; overflow: auto; }
.novel-stage img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; }
#novel-status { margin: 0; padding: .5rem 1rem; background: #1c1d21; font-size: .9rem; }
