/* SECONDHAND — instrument-panel look. You are reading a place, not seeing it.
 *
 * [hidden] guard first, and non-negotiable: this project has now shipped the
 * "display:flex beats hidden" bug three times across three games. Any rule that
 * sets display must be unable to defeat the attribute.
 */
[hidden] { display: none !important; }

:root {
  --bg: #07090c;
  --ink: #cfe3f2;
  --dim: #5c7285;
  --line: #22303d;
  --me: #7ee8ff;
  --hot: #ff4d5e;
  --good: #2bd9a3;
  --warm: #ffb020;
  /* Overridden natively on Android. env() in a WebView only ever reports a
   * display cutout — never the status or navigation bar — so these exist so the
   * native layer can hand us the real insets. See CLAUDE.md, "Android". */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--ink);
  font: 500 15px/1.4 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: .04em;
  overscroll-behavior: none;
  user-select: none; -webkit-user-select: none;
}

.screen {
  position: fixed; inset: 0;
  padding: calc(var(--safe-t) + 20px) 20px calc(var(--safe-b) + 20px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px;
}

h1 { font-size: clamp(30px, 11vw, 52px); margin: 0; letter-spacing: .14em; font-weight: 700; }
h1 span { color: var(--me); }
h2 { font-size: 26px; margin: 0; letter-spacing: .18em; }
.tag { color: var(--dim); text-align: center; margin: 0 0 10px; line-height: 1.7; }
.hint { color: var(--dim); text-align: center; font-size: 13px; margin: 0; max-width: 30ch; }
.label { color: var(--dim); font-size: 12px; letter-spacing: .3em; margin: 0; }
.code { font-size: 40px; letter-spacing: .3em; margin: 0; color: var(--me); }
.err { color: var(--hot); text-align: center; font-size: 13px; margin: 0; }
.row { display: flex; gap: 10px; width: 100%; max-width: 340px; }

input {
  flex: 1; min-width: 0;
  background: #0d1116; border: 1px solid var(--line); color: var(--ink);
  padding: 14px; border-radius: 10px; font: inherit; text-align: center;
  letter-spacing: .2em; text-transform: uppercase;
}
input::placeholder { color: #3c4b59; letter-spacing: .2em; }
input:focus { outline: none; border-color: var(--me); }

.btn {
  background: #0d1116; border: 1px solid var(--line); color: var(--ink);
  padding: 14px 18px; border-radius: 10px; font: inherit; letter-spacing: .16em;
  cursor: pointer; white-space: nowrap;
}
.btn.primary { border-color: var(--me); color: var(--me); }
.btn.ghost { border-color: transparent; color: var(--dim); }
.btn:active { transform: translateY(1px); }
#lobby .row:first-of-type .btn { flex: 1; }

#seats { list-style: none; padding: 0; margin: 0; width: 100%; max-width: 340px; }
#seats li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px;
}
#seats li.ready { border-color: var(--good); color: var(--good); }
#seats .who { display: flex; align-items: center; gap: 10px; }
#seats .dot { width: 10px; height: 10px; border-radius: 50%; }

/* ── run ─────────────────────────────────────────────────────────────── */
.screen.run { justify-content: flex-start; gap: 10px; padding: calc(var(--safe-t) + 8px) 10px calc(var(--safe-b) + 8px); }

#hud {
  display: flex; justify-content: space-between; width: 100%;
  color: var(--dim); font-size: 13px; letter-spacing: .18em; flex: 0 0 auto;
}
#hud.urgent #clock { color: var(--hot); }

#panel, #talk {
  width: 100%; border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; flex: 0 0 auto; background: #0a0e13;
}
.panel-head { color: var(--dim); font-size: 11px; letter-spacing: .28em; }
.panel-head b { color: var(--ink); font-weight: 700; }

.heard {
  font-size: clamp(24px, 8vw, 40px); font-weight: 700; letter-spacing: .12em;
  color: var(--me); min-height: 1.2em; line-height: 1.2;
}
.heard.stale { color: #2f4453; }

.lamps { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.lamp {
  font-size: 10px; letter-spacing: .16em; padding: 4px 7px;
  border: 1px solid var(--line); border-radius: 6px; color: #2f4453;
}
.lamp.on { color: var(--bg); }
#lamp-bump.on  { background: var(--warm); border-color: var(--warm); }
#lamp-plate.on { background: var(--warm); border-color: var(--warm); }
#lamp-exit.on  { background: var(--good); border-color: var(--good); }
#lamp-down.on  { background: var(--hot);  border-color: var(--hot); }

#view {
  flex: 1 1 auto; width: 100%; min-height: 0;
  border: 1px solid var(--line); border-radius: 12px; touch-action: none; display: block;
}

.tokens { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 8px; }
.tokens button {
  background: #0d1116; border: 1px solid var(--line); color: var(--ink);
  padding: 12px 2px; border-radius: 8px; font: inherit; font-size: 12px;
  letter-spacing: .06em; cursor: pointer;
}
.tokens button:active { background: var(--me); color: var(--bg); border-color: var(--me); }
.tokens button.hot { border-color: var(--hot); color: var(--hot); }

@media (min-width: 700px) and (orientation: landscape) {
  .tokens { grid-template-columns: repeat(6, 1fr); }
}

.run-hint {
  flex: 0 0 auto; max-width: none; text-align: center; font-size: 12px;
  color: var(--warm); border: 1px dashed rgba(255, 176, 32, .35);
  border-radius: 10px; padding: 8px 10px; line-height: 1.5;
}
