* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #05060a; color: #e8ecf5;
  font-family: "Consolas", "Courier New", monospace; }
body { display: flex; align-items: center; justify-content: center; }
#wrap { position: relative; width: min(100vw, 160vh); aspect-ratio: 8 / 5; container-type: inline-size; user-select: none; }
#game { width: 100%; height: 100%; display: block; image-rendering: pixelated; background: #000; cursor: crosshair; }
#screen { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center;
  justify-content: safe center; gap: 1.2cqw; padding: 2cqw 5cqw; text-align: center; overflow-y: auto;
  font-size: 1.7cqw; line-height: 1.45; background: rgba(6, 8, 16, 0.9); }
#screen.show { display: flex; }
#screen.light { background: rgba(6, 8, 16, 0.68); }
h1 { font-size: 6cqw; letter-spacing: 0.4cqw; color: #ffd23e; text-shadow: 0.35cqw 0.35cqw 0 #a1121f; line-height: 1.05; }
h2 { font-size: 3.6cqw; color: #ffd23e; text-shadow: 0.25cqw 0.25cqw 0 #a1121f; }
h3 { font-size: 2cqw; color: #7fd6ff; font-weight: normal; }
p { max-width: 70cqw; }
.dim { color: #8d96ad; font-size: 1.35cqw; }
.red { color: #ff6b6b; }
.row { display: flex; flex-wrap: wrap; gap: 1cqw; justify-content: center; }
button { font: inherit; color: #fff; background: #1c2542; border: 0.2cqw solid #54669f; padding: 0.6cqw 1.8cqw; cursor: pointer; }
button:hover, button:focus-visible { background: #a1121f; border-color: #ffd23e; outline: none; }
button.sel { background: #3a4a86; border-color: #ffd23e; }
button.primary { background: #a1121f; border-color: #ffd23e; font-size: 2.1cqw; padding: 0.8cqw 3cqw; }
button.floor { width: 20cqw; text-align: left; font-size: 1.4cqw; }
button:disabled { opacity: 0.35; cursor: default; background: #1c2542; border-color: #54669f; }
table { border-collapse: collapse; text-align: left; }
td { padding: 0.15cqw 1.4cqw; }
td:first-child { color: #ffd23e; text-align: right; }
.talismans { display: flex; gap: 2.5cqw; justify-content: center; }
.talismans span { font-weight: bold; }

/* ---------------- phones and tablets ---------------- */
#touch { display: none; }
.rotate-hint { display: none; }
body.touch { position: fixed; inset: 0; touch-action: none; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
body.touch #wrap { width: min(100vw, 160vh); width: min(100vw, 160dvh); container-type: normal; position: static; }
body.touch.playing #touch { display: block; position: fixed; inset: 0; z-index: 5; }
#stickZone, #lookZone { position: absolute; bottom: 0; height: 100%; touch-action: none; }
#stickZone { left: 0; width: 42%; }
#lookZone { right: 0; width: 58%; }
#stickBase { position: absolute; left: calc(84px + env(safe-area-inset-left)); top: calc(100% - 96px);
  width: 116px; height: 116px; margin: -58px 0 0 -58px; border-radius: 50%; pointer-events: none;
  border: 2px solid rgba(255,255,255,0.4); background: rgba(20,28,60,0.28); }
#stickBase.held { border-color: #ffd23e; }
#stickBase.run { box-shadow: 0 0 0 6px rgba(255,210,62,0.35); }
#knob { position: absolute; left: 32px; top: 32px; width: 48px; height: 48px; border-radius: 50%; background: rgba(255,255,255,0.45); }
#touch button { position: absolute; width: 58px; height: 58px; padding: 0; border-radius: 50%; touch-action: none;
  font: bold 13px Consolas, monospace; background: rgba(28,37,66,0.55); border: 2px solid rgba(255,255,255,0.45); }
#touch #fire { right: calc(18px + env(safe-area-inset-right)); bottom: calc(80px + env(safe-area-inset-bottom));
  width: 90px; height: 90px; font-size: 17px; background: rgba(161,18,31,0.6); }
#touch #fire.held { background: rgba(255,80,60,0.85); border-color: #ffd23e; }
#touch #use { right: calc(122px + env(safe-area-inset-right)); bottom: calc(78px + env(safe-area-inset-bottom)); }
#touch #gun { right: calc(34px + env(safe-area-inset-right)); bottom: calc(188px + env(safe-area-inset-bottom)); }
.tbar { position: absolute; left: calc(8px + env(safe-area-inset-left)); top: calc(8px + env(safe-area-inset-top)); display: flex; flex-direction: column; gap: 8px; }
#touch .tbar button { position: static; width: 46px; height: 46px; }

/* Menus use the whole screen with readable text. */
body.touch #screen { position: fixed; z-index: 10; justify-content: safe center; touch-action: pan-y; overscroll-behavior: contain;
  font-size: clamp(12px, 3.6vmin, 20px); gap: 0.6em; line-height: 1.35;
  padding: calc(10px + env(safe-area-inset-top)) calc(14px + env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) calc(14px + env(safe-area-inset-left)); }
body.touch #screen > * { flex-shrink: 0; }
body.touch h1 { font-size: 2.6em; letter-spacing: 0.05em; text-shadow: 2px 2px 0 #a1121f; }
body.touch h2 { font-size: 1.7em; text-shadow: 2px 2px 0 #a1121f; }
body.touch h3 { font-size: 1.1em; }
body.touch p { max-width: 42em; }
body.touch .dim { font-size: 0.85em; }
body.touch .row { gap: 0.6em; }
body.touch button { border-width: 2px; }
body.touch #screen button { padding: 0.55em 1.1em; min-height: 40px; }
body.touch button.primary { font-size: 1.15em; }
body.touch button.floor { width: 17em; max-width: 100%; font-size: 0.95em; }
body.touch table td { padding: 1px 8px; }
body.touch .talismans { flex-wrap: wrap; gap: 0.4em 1.2em; }
body.touch #portraits canvas { width: 18vmin !important; height: 18vmin !important; }

/* Held upright: the view sits on top and the controls go underneath. */
@media (orientation: portrait) {
  body.touch { align-items: flex-start; }
  body.touch #wrap { margin-top: calc(60px + env(safe-area-inset-top)); }
  body.touch .tbar { flex-direction: row; }
  body.touch .rotate-hint { display: block; color: #7fd6ff; }
}
