:root {
  --bg: #050505;
  --fg: #d8d2c4;
  --muted: #7d776b;
  --red: #b3261e;
  --red-hot: #ff3b2f;
  --panel: rgba(12, 11, 10, 0.92);
  --line: rgba(216, 210, 196, 0.16);
  --mono: "Courier New", ui-monospace, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font-family: var(--mono); overflow: hidden; user-select: none; }
canvas#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
button, input, select { font-family: var(--mono); }

.screen { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; z-index: 10; }
.screen.show { display: flex; }
.screen.overlay { background: rgba(0, 0, 0, 0.72); z-index: 30; }
.layer { position: fixed; inset: 0; pointer-events: none; display: none; z-index: 5; }
.layer.show { display: block; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.error { color: var(--red-hot); min-height: 1.2em; }

/* boot */
#boot { background: #000; flex-direction: column; gap: 10px; }
.boot-text { letter-spacing: 8px; font-size: 18px; }
.boot-sub { color: var(--muted); font-size: 12px; }
.dots::after { content: ''; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

/* menu */
#menu { background: radial-gradient(ellipse at 50% 40%, #16110d 0%, #050404 60%, #000 100%); }
.menu-bg { position: absolute; inset: 0; background: repeating-linear-gradient(0deg, rgba(255,255,255,0.025) 0 1px, transparent 1px 3px); pointer-events: none; animation: flick 6s infinite; }
@keyframes flick { 0%, 100% { opacity: 1; } 47% { opacity: 1; } 48% { opacity: 0.4; } 49% { opacity: 1; } 80% { opacity: 0.85; } }
.menu-inner { position: relative; text-align: center; width: min(520px, calc(100vw - 32px)); }
.title { white-space: nowrap; font-size: clamp(36px, 8vw, 92px); letter-spacing: 0.12em; margin: 0 0 6px; color: #e9e2d2; text-shadow: 0 0 18px rgba(255, 40, 30, 0.25); position: relative; }
.title::before, .title::after { content: attr(data-text); position: absolute; inset: 0; opacity: 0; }
.title::before { color: #ff2a1f; transform: translate(2px, 0); clip-path: inset(0 0 60% 0); animation: glitch 3.5s infinite; }
.title::after { color: #2ad4ff; transform: translate(-2px, 0); clip-path: inset(55% 0 0 0); animation: glitch 2.7s infinite reverse; }
@keyframes glitch { 0%, 92%, 100% { transform: translate(0, 0); opacity: 0; } 93% { transform: translate(3px, -1px); opacity: 0.6; } 95% { transform: translate(-3px, 1px); opacity: 0.6; } 97% { transform: translate(1px, 2px); opacity: 0.5; } }
.tagline { color: var(--muted); margin: 0 0 28px; font-size: 14px; }
.warn { color: var(--muted); font-size: 12px; margin-top: 22px; }
.menu-name { margin-bottom: 16px; }
.menu-name input, .join-row input { background: rgba(0,0,0,0.5); border: 1px solid var(--line); color: var(--fg); padding: 8px 10px; font-size: 15px; width: 180px; text-transform: none; }
.join-row input { width: 110px; text-transform: uppercase; letter-spacing: 3px; text-align: center; }
.menu-buttons { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.join-row { display: flex; gap: 8px; }

.btn { background: transparent; border: 1px solid rgba(216, 210, 196, 0.45); color: var(--fg); padding: 11px 26px; font-size: 15px; letter-spacing: 3px; cursor: pointer; min-width: 220px; transition: background 0.15s, color 0.15s, border-color 0.15s; }
.btn:hover:not(:disabled) { background: var(--fg); color: #000; }
.btn:disabled { opacity: 0.35; cursor: default; }
.btn.ghost { border-color: var(--line); color: var(--muted); }
.btn.ghost:hover { color: #000; }
.btn.small { min-width: 0; padding: 8px 16px; font-size: 13px; }
.btn.active { background: var(--red); border-color: var(--red); color: #fff; }

.panel { background: var(--panel); border: 1px solid var(--line); padding: 24px; max-height: calc(100vh - 32px); overflow: auto; }
.panel h2 { margin: 0 0 14px; letter-spacing: 6px; font-weight: normal; }
.panel h3 { margin: 18px 0 8px; font-size: 13px; letter-spacing: 3px; color: var(--muted); font-weight: normal; }
.small-panel { width: min(460px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.small-panel .btn { min-width: 0; }

/* lobby */
#lobby { background: radial-gradient(ellipse at 50% 30%, #120e0b 0%, #000 75%); }
.lobby-panel { width: min(980px, calc(100vw - 32px)); }
.lobby-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 10px; }
.room-code { color: var(--muted); letter-spacing: 3px; }
.room-code span { color: var(--fg); font-size: 22px; letter-spacing: 6px; user-select: text; }
.lobby-cols { display: flex; gap: 26px; flex-wrap: wrap; }
.lobby-col { flex: 1 1 240px; min-width: 0; }
.lobby-col.wide { flex: 2 1 420px; }
.player-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.player-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); }
.player-list .swatch { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.player-list .tag { margin-left: auto; font-size: 11px; color: var(--muted); letter-spacing: 2px; }
.player-list .tag.ready { color: #7fd17f; }
.map-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.map-card { border: 1px solid var(--line); padding: 12px; cursor: pointer; background: rgba(0,0,0,0.35); transition: border-color 0.15s; }
.map-card:hover { border-color: rgba(216,210,196,0.5); }
.map-card.sel { border-color: var(--red-hot); box-shadow: inset 0 0 0 1px var(--red-hot); }
.map-card.locked { cursor: default; }
.map-card h4 { margin: 0 0 6px; letter-spacing: 2px; font-weight: normal; }
.map-card p { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.45; }
.map-card .size { margin-top: 8px; font-size: 11px; color: var(--fg); letter-spacing: 2px; }
.settings-row { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 16px; }
.settings-row label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); letter-spacing: 2px; }
select { background: #0b0a09; color: var(--fg); border: 1px solid var(--line); padding: 7px 8px; font-size: 14px; }
.lobby-foot { display: flex; gap: 12px; align-items: center; margin-top: 22px; flex-wrap: wrap; }
.lobby-foot #lobbyHint { flex: 1; font-size: 12px; }
.mic-test { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }

.meter { width: 120px; height: 6px; background: rgba(255,255,255,0.08); overflow: hidden; }
.meter.wide { width: min(420px, 80vw); margin: 16px auto 8px; }
.meter > div { height: 100%; width: 0%; background: var(--fg); transition: width 0.08s linear; }

/* loading */
#loading { background: #000; }
.loading-inner { text-align: center; width: min(640px, calc(100vw - 32px)); }
.loading-title { font-size: 28px; letter-spacing: 8px; margin-bottom: 18px; }
.loading-story { color: var(--muted); line-height: 1.7; font-size: 14px; min-height: 5em; }

/* HUD */
#crosshair { position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px 0 0 -2px; border-radius: 50%; background: rgba(255,255,255,0.45); }
#prompt { position: absolute; left: 50%; top: calc(50% + 28px); transform: translateX(-50%); font-size: 14px; letter-spacing: 2px; text-shadow: 0 0 6px #000; white-space: nowrap; }
#prompt kbd { border: 1px solid rgba(255,255,255,0.5); padding: 1px 6px; margin-right: 6px; font-family: var(--mono); }
#clock { position: absolute; right: 22px; top: 18px; font-size: 22px; letter-spacing: 3px; text-shadow: 0 0 8px #000; }
#objective { position: absolute; left: 22px; top: 18px; font-size: 13px; color: var(--fg); max-width: 40vw; line-height: 1.6; text-shadow: 0 0 6px #000; }
#objective .done { color: var(--muted); text-decoration: line-through; }
#notices { position: absolute; left: 50%; top: 18%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.notice { font-size: 14px; letter-spacing: 3px; text-shadow: 0 0 8px #000; animation: noticeFade 4s forwards; text-align: center; }
.notice.bad { color: var(--red-hot); }
@keyframes noticeFade { 0% { opacity: 0; } 8% { opacity: 1; } 75% { opacity: 1; } 100% { opacity: 0; } }
#subtitle { position: absolute; left: 50%; bottom: 120px; transform: translateX(-50%); font-size: 14px; color: #bbb; font-style: italic; text-shadow: 0 0 6px #000; text-align: center; max-width: 70vw; }
#hudBottom { position: absolute; left: 22px; bottom: 22px; display: flex; flex-direction: column; gap: 6px; }
.stat { display: flex; align-items: center; gap: 10px; font-size: 11px; letter-spacing: 2px; color: var(--muted); }
.stat .lbl { width: 56px; }
#micBar { background: #7fd17f; }
#micBar.loud { background: var(--red-hot); }
#batBar.low { background: var(--red-hot); }
#inventory { position: absolute; right: 22px; bottom: 22px; display: flex; gap: 8px; }
.slot { width: 64px; height: 64px; border: 1px solid var(--line); background: rgba(0,0,0,0.35); display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 10px; letter-spacing: 1px; color: var(--muted); position: relative; }
.slot .ico { font-size: 22px; color: var(--fg); line-height: 1; margin-bottom: 4px; }
.slot .key { position: absolute; left: 4px; top: 2px; font-size: 10px; }
.slot .cnt { position: absolute; right: 4px; top: 2px; font-size: 11px; color: var(--fg); }
.slot.empty { opacity: 0.35; }
#voiceList { position: absolute; right: 22px; top: 56px; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; font-size: 12px; }
#voiceList .v { opacity: 0.4; }
#voiceList .v.talk { opacity: 1; }
#voiceList .v.radio { color: #e8c35a; }
#voiceList .v.dead { text-decoration: line-through; color: var(--red); }

#phoneOverlay { position: absolute; inset: 4vh 4vw; display: none; font-size: 16px; letter-spacing: 3px; color: #fff; text-shadow: 0 0 4px #000; }
#phoneOverlay.show { display: block; }
#phoneOverlay .rec { position: absolute; left: 18px; top: 14px; display: flex; align-items: center; gap: 8px; }
#phoneOverlay .rec .dot { width: 12px; height: 12px; border-radius: 50%; background: #555; }
#phoneOverlay.recording .rec .dot { background: #ff2a1f; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
#phoneOverlay .phone-time { position: absolute; right: 18px; top: 14px; }
#phoneOverlay .phone-mode { position: absolute; left: 18px; bottom: 14px; font-size: 13px; }
#phoneOverlay .phone-bat { position: absolute; right: 18px; bottom: 14px; font-size: 13px; }
#phoneOverlay .corners i { position: absolute; width: 34px; height: 34px; border: 2px solid rgba(255,255,255,0.8); }
#phoneOverlay .corners i:nth-child(1) { left: 0; top: 0; border-right: 0; border-bottom: 0; }
#phoneOverlay .corners i:nth-child(2) { right: 0; top: 0; border-left: 0; border-bottom: 0; }
#phoneOverlay .corners i:nth-child(3) { left: 0; bottom: 0; border-right: 0; border-top: 0; }
#phoneOverlay .corners i:nth-child(4) { right: 0; bottom: 0; border-left: 0; border-top: 0; }
#hideOverlay { position: absolute; inset: 0; display: none; background: repeating-linear-gradient(0deg, rgba(0,0,0,0.97) 0 7vh, rgba(0,0,0,0.0) 7vh 9vh); }
#hideOverlay.show { display: block; }
#fearVignette { position: absolute; inset: 0; opacity: 0; background: radial-gradient(ellipse at center, transparent 45%, rgba(60, 0, 0, 0.85) 100%); transition: opacity 0.4s; }

#flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 40; }

/* journal */
.journal-panel { width: min(1000px, calc(100vw - 32px)); height: min(720px, calc(100vh - 32px)); display: flex; flex-direction: column; gap: 12px; }
.journal-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab { background: transparent; border: 1px solid var(--line); color: var(--muted); padding: 8px 14px; cursor: pointer; letter-spacing: 2px; }
.tab.active { color: var(--fg); border-color: var(--fg); }
.journal-body { flex: 1; overflow: auto; line-height: 1.6; font-size: 14px; }
.entity-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.entity-card { border: 1px solid var(--line); padding: 14px; cursor: pointer; }
.entity-card.marked { border-color: var(--red-hot); }
.entity-card.ruled { opacity: 0.35; }
.entity-card h4 { margin: 0 0 4px; letter-spacing: 3px; font-weight: normal; font-size: 16px; }
.entity-card .kind { color: var(--muted); font-size: 11px; letter-spacing: 2px; margin-bottom: 8px; }
.entity-card ul { margin: 6px 0; padding-left: 18px; font-size: 13px; }
.entity-card .counter { font-size: 13px; color: #e8c35a; }
.entity-card .mark-row { display: flex; gap: 6px; margin-top: 10px; }
.keys { display: grid; grid-template-columns: 140px 1fr; gap: 4px 14px; font-size: 13px; }
.keys kbd { border: 1px solid var(--line); padding: 0 6px; }

.set-grid { display: flex; flex-direction: column; gap: 12px; margin-bottom: 8px; }
.set-grid label { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13px; }
.set-grid input[type=range] { width: 50%; accent-color: #c9c2b2; }
.info-panel { width: min(760px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 14px; line-height: 1.6; font-size: 14px; }
.info-panel h2 { margin-bottom: 4px; }

/* death */
#death { background: rgba(0,0,0,0.0); cursor: pointer; }
.death-inner { text-align: center; display: flex; flex-direction: column; gap: 10px; }
.death-title { font-size: clamp(32px, 6vw, 64px); letter-spacing: 12px; color: var(--red-hot); text-shadow: 0 0 22px rgba(255, 0, 0, 0.55); }

#results { background: radial-gradient(ellipse at center, #0f0c0a, #000 80%); }
.results-panel { width: min(640px, calc(100vw - 32px)); text-align: center; }
.results-panel h2 { font-size: 30px; }
#resultBody { margin: 14px 0 20px; line-height: 1.9; }
#resultBody .row { display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 4px 0; }

.ctp { font-size: 18px; letter-spacing: 6px; animation: blink 1.6s steps(2) infinite; }
#clickToPlay { cursor: pointer; }

@media (max-width: 640px) {
  #hudBottom { bottom: 90px; }
  #objective { max-width: 70vw; font-size: 11px; }
  .slot { width: 52px; height: 52px; }
}

/* controller */
.pad-only { display: none; }
body.pad .pad-only { display: inline; }
body.pad .kbm-only { display: none; }
body.pad-captured, body.pad-captured * { cursor: none !important; }
body.pad .pad-focus { outline: 2px solid var(--red-hot); outline-offset: 3px; }
body.pad .btn.pad-focus:not(:disabled), body.pad .tab.pad-focus { background: var(--fg); color: #000; }
body.pad .set-grid label:has(.pad-focus) { color: #fff; }
#prompt kbd.pad { border-radius: 10px; min-width: 22px; display: inline-block; text-align: center; }
#prompt kbd.b-A { border-color: #6fcf55; color: #b9f0a8; }
#prompt kbd.b-B { border-color: #e65a4f; color: #ffb4ad; }
#prompt kbd.b-X { border-color: #4f9de6; color: #b4d6ff; }
#prompt kbd.b-Y { border-color: #e8c35a; color: #ffe7a6; }
#padHint { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 60; display: none; gap: 18px; font-size: 12px; color: var(--muted); letter-spacing: 2px; pointer-events: none; white-space: nowrap; }
#padHint b { color: var(--fg); font-weight: normal; border: 1px solid var(--line); border-radius: 9px; padding: 0 5px; }
body.pad.menus #padHint { display: flex; }
#soundHint { display: none; color: #e8c35a; }
body.pad.muted-audio #soundHint { display: inline; }

/* on-screen keyboard */
#osk { position: fixed; inset: 0; z-index: 55; display: none; align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.75); }
#osk.show { display: flex; }
.osk-panel { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.osk-label { color: var(--muted); letter-spacing: 3px; font-size: 12px; }
.osk-value { min-width: 260px; min-height: 1.6em; border-bottom: 1px solid var(--line); font-size: 22px; letter-spacing: 4px; text-align: center; margin-bottom: 8px; }
.osk-row { display: flex; gap: 6px; }
.osk-key { width: 42px; height: 40px; background: transparent; border: 1px solid var(--line); color: var(--fg); font-size: 15px; cursor: pointer; }
.osk-key.wide { width: 110px; letter-spacing: 2px; }
.osk-key:hover { background: rgba(216,210,196,0.15); }
