:root {
  color-scheme: dark;
  --bg: #0d100f;
  --surface: #171c1a;
  --surface-2: #202724;
  --line: #3d4742;
  --text: #f1f3ed;
  --muted: #aab2ac;
  --amber: #f4b942;
  --teal: #53c7ba;
  --red: #e7685d;
  --green: #7dc77a;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { min-height: 100vh; letter-spacing: 0; }
button, input, select { font: inherit; letter-spacing: 0; }
button { touch-action: manipulation; }

.scene {
  position: fixed;
  inset: 0 0 auto;
  height: 300px;
  background: #0d100f url("/assets/bunker-control-room.png") center 42% / cover no-repeat;
  opacity: .48;
  pointer-events: none;
}
.scene::after { content: ""; position: absolute; inset: 0; background: rgba(13, 16, 15, .44); }
.app-shell { position: relative; min-height: 100vh; max-width: 860px; margin: 0 auto; padding-bottom: calc(78px + var(--safe-bottom)); }
.topbar { height: 72px; display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-bottom: 1px solid rgba(255,255,255,.13); }
.brand-mark { width: 42px; height: 42px; display: block; object-fit: cover; border: 1px solid var(--amber); }
.brand-copy { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.brand-copy strong { font: 700 20px/1.1 Georgia, serif; }
.brand-copy span { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.connection { margin-left: auto; display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; text-transform: uppercase; }
.connection span { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 3px rgba(244,185,66,.16); }
.connection.online span { background: var(--green); box-shadow: 0 0 0 3px rgba(125,199,122,.16); }
.connection.offline span { background: var(--red); }

main { padding: 150px 16px 20px; }
.system-state { max-width: 520px; padding: 24px 0; }
.system-state h1 { margin: 18px 0 8px; font: 700 30px/1.1 Georgia, serif; }
.system-state p { margin: 0; color: var(--muted); line-height: 1.5; }
.loader { width: 38px; height: 38px; border: 3px solid var(--line); border-top-color: var(--amber); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.game-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; padding-bottom: 18px; }
.eyebrow { margin: 0 0 6px; color: var(--amber); font-size: 11px; font-weight: 800; text-transform: uppercase; }
h1, h2, h3, p { overflow-wrap: anywhere; }
.game-head h1 { margin: 0; font: 700 30px/1.1 Georgia, serif; }
.game-head .meta { color: var(--muted); font-size: 13px; margin: 7px 0 0; }
.timer { min-width: 96px; padding: 10px 12px; background: rgba(13,16,15,.74); border: 1px solid var(--line); text-align: center; }
.timer span { display: block; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.timer strong { display: block; margin-top: 3px; color: var(--amber); font: 700 22px/1 monospace; }

.content-band { margin: 0 -16px; padding: 22px 16px; background: var(--bg); border-top: 1px solid var(--line); }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-title h2 { margin: 0; font-size: 17px; }
.section-title span { color: var(--muted); font-size: 12px; }
.bunker-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.bunker-item { min-height: 82px; padding: 13px; background: var(--surface); }
.bunker-item.wide { grid-column: 1 / -1; }
.bunker-item small { display: block; color: var(--teal); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.bunker-item strong { display: block; margin-top: 7px; font-size: 14px; line-height: 1.35; }
.bunker-item ul { margin: 7px 0 0; padding-left: 18px; color: var(--text); font-size: 13px; line-height: 1.45; }

.players { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
.player { min-height: 74px; display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 10px; padding: 11px; background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--teal); }
.player.eliminated { opacity: .55; border-left-color: var(--red); }
.player-number { width: 34px; height: 34px; display: grid; place-items: center; background: var(--surface-2); color: var(--amber); font-weight: 800; }
.player-name { min-width: 0; font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-state { margin-top: 4px; color: var(--muted); font-size: 11px; }
.host-badge { padding: 4px 6px; color: var(--amber); border: 1px solid rgba(244,185,66,.45); font-size: 9px; font-weight: 800; text-transform: uppercase; }

.vote-panel { border-left: 3px solid var(--amber); background: var(--surface); padding: 15px; }
.vote-panel h2 { margin: 0 0 4px; font-size: 17px; }
.vote-panel > p { margin: 0 0 14px; color: var(--muted); font-size: 12px; }
.vote-options { display: grid; gap: 7px; }
.vote-option { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 8px 11px; background: var(--surface-2); border: 1px solid var(--line); color: var(--text); text-align: left; }
.vote-option.selected { border-color: var(--amber); color: var(--amber); }
.vote-option:disabled { opacity: .55; }

.character-sheet { background: rgba(13,16,15,.88); border: 1px solid var(--line); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 16px; border-bottom: 1px solid var(--line); }
.sheet-head h1 { margin: 0; font: 700 25px/1.1 Georgia, serif; }
.sheet-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); }
.trait { min-height: 100px; padding: 15px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.trait:nth-child(even) { border-right: 0; }
.trait small { display: block; color: var(--teal); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.trait strong { display: block; margin-top: 9px; font-size: 14px; line-height: 1.4; }
.action-cards { padding: 15px; }
.action-cards small { color: var(--amber); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.action-cards p { margin: 9px 0 0; padding: 10px; background: var(--surface-2); font-size: 13px; }

.control-list { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); }
.control-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; padding: 14px; background: var(--surface); }
.control-row strong { display: block; font-size: 14px; }
.control-row p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.control-row select, .control-row input { width: 108px; min-height: 40px; padding: 8px; color: var(--text); background: var(--surface-2); border: 1px solid var(--line); }
.button { min-height: 42px; padding: 9px 14px; background: var(--amber); border: 1px solid var(--amber); color: #17120a; font-weight: 800; cursor: pointer; }
.button.secondary { background: transparent; color: var(--text); border-color: var(--line); }
.button.danger { background: transparent; color: var(--red); border-color: var(--red); }
.button:disabled { opacity: .45; cursor: default; }
.wide-button { width: 100%; margin-top: 10px; }
.events { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.events li { display: grid; grid-template-columns: 74px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.events time { color: var(--muted); }

.tabs { position: fixed; z-index: 5; bottom: 0; left: 50%; transform: translateX(-50%); width: min(860px,100%); height: calc(64px + var(--safe-bottom)); padding: 5px 8px var(--safe-bottom); display: grid; grid-template-columns: repeat(3,1fr); background: #121715; border-top: 1px solid var(--line); }
.tabs[hidden] { display: none; }
.tabs button { min-width: 0; background: transparent; border: 0; color: var(--muted); font-size: 11px; font-weight: 700; }
.tabs button.active { color: var(--amber); }
.tab-icon { display: block; margin-bottom: 3px; font-size: 18px; }
.toast { position: fixed; z-index: 10; left: 50%; bottom: calc(78px + var(--safe-bottom)); width: min(440px, calc(100% - 24px)); transform: translate(-50%, 20px); padding: 12px 14px; background: #f1f3ed; color: #171c1a; border-left: 4px solid var(--green); opacity: 0; pointer-events: none; transition: .2s ease; font-size: 13px; font-weight: 700; }
.toast.show { opacity: 1; transform: translate(-50%,0); }
.toast.error { border-left-color: var(--red); }
.empty { padding: 24px 0; color: var(--muted); line-height: 1.5; }

@media (max-width: 520px) {
  main { padding-top: 125px; }
  .scene { height: 260px; }
  .players { grid-template-columns: 1fr; }
  .game-head h1 { font-size: 26px; }
  .sheet-grid { grid-template-columns: 1fr; }
  .trait { border-right: 0; }
  .control-row { grid-template-columns: 1fr; }
  .control-row .button, .control-row select, .control-row input { width: 100%; }
}

@media (min-width: 760px) {
  main { padding-left: 28px; padding-right: 28px; }
  .content-band { margin-left: -28px; margin-right: -28px; padding-left: 28px; padding-right: 28px; }
}
