:root {
  --bg: #101018;
  --panel: #3c4a6e;
  --panel-hi: #6a7ca8;
  --panel-lo: #1e2640;
  --text: #f4f0d8;
  --accent: #f8d030;
  --msg-bg: #1a1a6e;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "VT323", ui-monospace, Menlo, Consolas, monospace;
  font-size: 22px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-block: 16px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
#game { width: 100%; max-width: 960px; user-select: none; -webkit-user-select: none; }
#stage { position: relative; max-width: 100%; width: 100%; aspect-ratio: 2 / 1; border: 4px solid var(--panel-lo); }
#scene {
  width: 100%; height: 100%; display: block;
  image-rendering: pixelated; image-rendering: crisp-edges;
  cursor: crosshair; touch-action: manipulation;
}
#msg {
  position: absolute; left: 6%; right: 6%; top: 6%;
  background: var(--msg-bg);
  border: 3px solid #fff; outline: 3px solid #000;
  padding: 8px 14px; line-height: 1.15;
  box-shadow: 6px 6px 0 rgba(0,0,0,.5);
  cursor: pointer;
}
#msg .who { color: var(--accent); }
#msg .more { float: right; opacity: .7; font-size: .8em; }
#overlay {
  position: absolute; inset: 0;
  background: rgba(8, 8, 32, .92);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 4%;
}
#overlay[hidden], #msg[hidden] { display: none; }
#overlay h1 { color: var(--accent); font-weight: normal; font-size: clamp(30px, 6vw, 56px); margin: 0 0 .2em; text-shadow: 3px 3px 0 #b02020; }
#overlay h2 { font-weight: normal; font-size: clamp(20px, 3vw, 28px); margin: 0 0 .6em; color: #a8c8ff; }
#overlay .verse { font-size: clamp(17px, 2.4vw, 24px); line-height: 1.2; margin: 0 0 1em; color: #e8e0c0; font-style: italic; }
#overlay button { font: inherit; }
#status {
  min-height: 1.4em; padding: 2px 8px; text-align: center;
  background: var(--panel-lo); color: var(--accent);
}
#ui {
  display: flex; gap: 8px; padding: 8px; background: var(--panel);
  border: 4px solid; border-color: var(--panel-hi) var(--panel-lo) var(--panel-lo) var(--panel-hi);
  flex-wrap: wrap;
}
#verbs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; flex: 2 1 300px; }
#inv { display: flex; gap: 6px; flex: 1 1 200px; flex-wrap: wrap; align-content: flex-start; min-height: 44px; background: var(--panel-lo); padding: 4px; }
.btn, #meta button {
  font: inherit; color: var(--text); background: var(--panel);
  border: 3px solid; border-color: var(--panel-hi) var(--panel-lo) var(--panel-lo) var(--panel-hi);
  padding: 4px 6px; cursor: pointer;
}
.btn:active, .btn.on { border-color: var(--panel-lo) var(--panel-hi) var(--panel-hi) var(--panel-lo); background: #2c3858; color: var(--accent); }
.item {
  width: 44px; height: 36px; padding: 0; background: #2a3354;
  border: 2px solid #55628a; cursor: pointer;
}
.item img { width: 32px; height: 32px; image-rendering: pixelated; display: block; margin: auto; }
.item.on { border-color: var(--accent); background: #4a4020; }
#meta { display: flex; justify-content: space-between; align-items: center; padding: 6px 2px; font-size: 18px; opacity: .8; }
#meta button { font-size: 18px; padding: 2px 8px; }
.meta-btns { display: flex; gap: 6px; }
.big { font-size: 26px; padding: 6px 18px; margin: 4px; }
@media (max-width: 560px) {
  body { font-size: 19px; }
  #msg { font-size: 16px; top: 3%; padding: 4px 8px; }
  #verbs { grid-template-columns: repeat(5, 1fr); }
  .btn { padding: 6px 2px; }
}

#choices {
  position: absolute; left: 4%; right: 4%; bottom: 4%;
  display: flex; flex-direction: column; gap: 4px;
  background: var(--msg-bg); border: 3px solid #fff; outline: 3px solid #000; padding: 6px;
}
#choices[hidden] { display: none; }
.choice {
  font: inherit; text-align: left; color: var(--text); background: transparent;
  border: 0; padding: 2px 6px; cursor: pointer; line-height: 1.1;
}
.choice:hover, .choice:focus-visible { color: var(--accent); background: rgba(255,255,255,.08); outline: none; }
@media (max-width: 560px) { #choices { font-size: 15px; padding: 3px; gap: 1px; } }
