:root {
  --bg: #080606;
  --amber: #ffba46;
  --text: #e6dcc8;
  --muted: #aa9678;
  --panel: rgba(0, 0, 0, 0.85);
  --font: Consolas, Menlo, "DejaVu Sans Mono", "Roboto Mono", "Courier New", monospace;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: var(--font); overflow: hidden; user-select: none; -webkit-user-select: none;
  touch-action: none; -webkit-tap-highlight-color: transparent;
}
#film { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
#stage { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }
#screen { display: block; background: #000; image-rendering: pixelated; }

.hud {
  position: fixed; top: max(8px, env(safe-area-inset-top)); z-index: 2;
  color: var(--amber); font-weight: bold; font-size: clamp(11px, 1.6vw, 20px);
  text-shadow: 0 0 4px #000, 0 0 8px #000; white-space: pre; pointer-events: none;
}
#hud-left { left: max(10px, env(safe-area-inset-left)); }
#hud-right { right: max(10px, env(safe-area-inset-right)); display: flex; gap: 10px; align-items: center; }
#hud-right-text.hurry { color: #ff5a5a; }
#perf { top: auto; bottom: 4px; left: 8px; font-size: 10px; color: #554a3a; font-weight: normal; }
#gear {
  pointer-events: auto; font-size: clamp(20px, 3vw, 30px); line-height: 1; padding: 4px 8px;
  background: rgba(0, 0, 0, 0.5); color: var(--amber); border: 1px solid #5a4020; border-radius: 8px;
}

#overlay {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 3;
  width: min(92vw, 760px); padding: 18px 22px; text-align: center;
  background: rgba(0, 0, 0, 0.78); border: 1px solid #3c2819; border-radius: 10px;
}
#overlay[hidden] { display: none; }
#overlay h1 { color: var(--amber); margin: 0 0 8px; font-size: clamp(24px, 5vw, 52px); }
#overlay p { margin: 6px 0; font-size: clamp(13px, 2vw, 20px); }
#overlay .big { color: #fff; font-size: clamp(18px, 3vw, 28px); }
#overlay .small { font-size: clamp(11px, 1.5vw, 15px); color: var(--muted); }
button.start {
  margin: 12px 0 6px; font: bold clamp(16px, 2.6vw, 24px) var(--font); color: #000;
  background: var(--amber); border: 0; border-radius: 10px; padding: 12px 28px; cursor: pointer;
}

.popup {
  position: fixed; z-index: 4; transform: translate(-50%, -50%); pointer-events: none;
  font-weight: bold; font-size: clamp(14px, 2vw, 22px); text-shadow: 0 0 4px #000; white-space: nowrap;
  animation: rise 0.9s ease-out forwards;
}
.popup.catch { color: #78ffeb; }
.popup.oops { color: #ff5a5a; }
@keyframes rise { to { transform: translate(-50%, -260%); opacity: 0; } }

#settings { position: fixed; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.35); }
#settings[hidden] { display: none; }
.panel {
  width: min(94vw, 560px); max-height: 92vh; overflow-y: auto; touch-action: pan-y;
  background: var(--panel); border: 1px solid #5a4020; border-radius: 10px; padding: 10px 14px;
}
.panel-head { display: flex; justify-content: space-between; align-items: center; color: var(--amber); margin-bottom: 6px; }
.panel-head button {
  margin-left: 6px; font: 14px var(--font); padding: 6px 12px; color: var(--amber);
  background: #1a1208; border: 1px solid #5a4020; border-radius: 6px;
}
.row { display: grid; grid-template-columns: 11em 1fr 3.5em; gap: 10px; align-items: center; padding: 5px 0; font-size: 14px; }
.row input[type="checkbox"], .row select { justify-self: start; }
.row input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--amber); }
.row select { font: 14px var(--font); padding: 4px; background: #1a1208; color: var(--text); border: 1px solid #5a4020; }
.row input[type="range"] { width: 100%; accent-color: var(--amber); }
.row output { color: var(--muted); text-align: right; }

#rotate { display: none; }
@media (orientation: portrait) and (max-width: 700px) {
  #rotate {
    display: flex; position: fixed; inset: auto 0 0 0; z-index: 6; justify-content: center;
    padding: 14px; background: rgba(0, 0, 0, 0.85); color: var(--amber); font-weight: bold;
  }
}
