/* ═══ Cold Spots — candlelit haunted-house theme ═══ */

:root {
    --bg: #0b0810;
    --panel: #161020;
    --panel2: #1f172c;
    --line: #362a4a;
    --candle: #ffc46a;
    --spirit: #8ac4d4;
    --danger: #ff4040;
    --green: #7dff4d;
    --text: #eee6f5;
    --muted: #9a8ab0;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    min-height: 100%;
}
body {
    background-image:
        radial-gradient(ellipse at 20% -10%, rgba(90, 60, 130, .25), transparent 55%),
        radial-gradient(ellipse at 90% 110%, rgba(255, 196, 106, .08), transparent 50%);
}

h1, h2, h3 { font-weight: 700; letter-spacing: .04em; }
h2 { font-size: 1.05rem; color: var(--candle); text-transform: uppercase; margin-bottom: 12px; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.mono { font-family: 'Consolas', monospace; }
.hidden { display: none !important; }

.btn {
    display: inline-block; background: var(--panel2); color: var(--text);
    border: 1px solid var(--line); border-radius: 8px; padding: 10px 18px;
    font-size: .95rem; font-weight: 600; cursor: pointer; transition: all .15s;
    font-family: inherit;
}
.btn:hover { border-color: var(--candle); box-shadow: 0 0 14px rgba(255, 196, 106, .3); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(180deg, #5a4020, #3c2a12); border-color: #8a6a34; color: #ffe9c4; }
.btn-large { width: 100%; padding: 14px; font-size: 1.1rem; margin-top: 14px; }
.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn:disabled { opacity: .45; cursor: default; box-shadow: none; }

input, select {
    width: 100%; background: #100a18; border: 1px solid var(--line); border-radius: 8px;
    color: var(--text); padding: 11px 12px; font-size: 1rem; margin: 6px 0 14px;
    font-family: inherit;
}
input:focus, select:focus { outline: none; border-color: var(--candle); box-shadow: 0 0 12px rgba(255, 196, 106, .25); }
label { font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.check-row { display: flex; align-items: center; gap: 8px; text-transform: none; letter-spacing: 0; font-size: .9rem; margin-bottom: 6px; }
.check-row input { width: auto; margin: 0; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; }

/* ── Home / lobby ── */
.home-container { max-width: 1000px; margin: 0 auto; padding: 28px 16px 60px; }
.hero { text-align: center; padding: 22px 0 30px; }
.game-title {
    font-size: clamp(2.2rem, 7.5vw, 3.6rem); letter-spacing: .12em; color: #f4eeff;
    text-shadow: 0 0 22px rgba(138, 196, 212, .5);
    animation: hauntFlicker 8s infinite;
}
@keyframes hauntFlicker {
    0%, 90%, 94%, 100% { opacity: 1; }
    91%, 93% { opacity: .55; }
}
.tagline { margin-top: 12px; color: var(--muted); line-height: 1.6; }
.tagline-hot { color: #ffb0a0; }
.error-banner {
    background: rgba(255, 64, 64, .12); border: 1px solid #7a2020; color: #ffb0a0;
    border-radius: 10px; padding: 12px 16px; margin-bottom: 18px; text-align: center;
}
.home-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 760px) { .home-grid { grid-template-columns: 1fr; } }

.registry-head { margin: 20px 0 8px; font-size: .9rem; color: var(--muted); text-transform: uppercase; }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.room-browser { list-style: none; max-height: 220px; overflow-y: auto; }
.room-row { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-bottom: 1px solid #1d1428; cursor: pointer; }
.room-row:hover { background: rgba(255, 196, 106, .06); }
.room-code { font-family: monospace; font-size: 1.05rem; color: var(--spirit); letter-spacing: .12em; }
.room-row .btn { margin-left: auto; }
.empty-msg { padding: 14px 6px; }

.leaderboard-card { margin-top: 18px; }
.leaderboard { width: 100%; border-collapse: collapse; font-size: .9rem; }
.leaderboard th { color: var(--muted); text-align: left; font-size: .75rem; text-transform: uppercase; padding: 6px 8px; }
.leaderboard td { padding: 8px; border-top: 1px solid #1d1428; }
.crew-names { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.how-to { margin-top: 34px; }
.how-to > h2 { text-align: center; margin-bottom: 18px; }
.how-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.how-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.how-icon { font-size: 1.6rem; display: block; margin-bottom: 8px; }
.how-card b { color: #fff; }
.how-card p { color: var(--muted); font-size: .87rem; margin-top: 6px; line-height: 1.5; }
.home-footer { text-align: center; margin-top: 30px; }

.lobby-container { max-width: 640px; margin: 0 auto; padding: 26px 16px 50px; text-align: center; }
.lobby-card { text-align: left; margin-bottom: 14px; }
.room-code-display { margin: 18px 0 6px; font-size: 1.1rem; }
.room-code-display .code { font-family: monospace; font-size: 1.6rem; color: var(--spirit); letter-spacing: .25em; margin: 0 8px; }
.share-hint { color: var(--muted); margin-bottom: 22px; font-size: .9rem; }
.player-list { list-style: none; }
.player-item { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid #1d1428; }
.player-dot { width: 13px; height: 13px; border-radius: 50%; box-shadow: 0 0 8px currentColor; flex: none; }
.player-name { font-weight: 600; }
.host-badge {
    background: #3a2a00; color: var(--candle); font-size: .65rem;
    border: 1px solid #6a5210; padding: 2px 7px; border-radius: 20px; letter-spacing: .1em;
}
.waiting-msg { margin-top: 22px; color: var(--muted); }
.blink { animation: pulse 1.6s infinite; }
.start-hint { color: var(--muted); font-size: .85rem; margin-top: 10px; }

/* ═══ GAME SCREEN ═══ */
.game-body { position: fixed; inset: 0; overflow: hidden; background: #060409; }
#board { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }

#hunt-vignette {
    position: absolute; inset: 0; pointer-events: none; z-index: 6; opacity: 0;
    background: radial-gradient(ellipse at center, transparent 45%, rgba(150, 0, 0, .55));
    transition: opacity .5s;
}
#hunt-vignette.on { opacity: 1; animation: huntPulse 1s infinite; }
@keyframes huntPulse { 50% { opacity: .55; } }

#hud-top {
    position: absolute; top: 0; left: 0; right: 0; z-index: 10;
    display: flex; align-items: center; gap: 10px;
    padding: calc(8px + env(safe-area-inset-top)) 10px 6px;
    background: linear-gradient(180deg, rgba(6, 4, 9, .92), rgba(6, 4, 9, 0));
    pointer-events: none;
}
#hud-top > * { pointer-events: auto; }
.mini-logo { font-weight: 800; letter-spacing: .05em; color: var(--spirit); white-space: nowrap; }
#room-chip {
    font-size: .78rem; font-weight: 700; letter-spacing: .08em; padding: 4px 12px;
    border-radius: 20px; border: 1px solid var(--line); color: var(--candle);
    white-space: nowrap;
}
#activity-wrap { flex: 1; max-width: 200px; }
#activity-label { font-size: .6rem; color: var(--muted); letter-spacing: .12em; }
#activity-bar { height: 8px; background: #140e1e; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
#activity-fill { height: 100%; width: 10%; background: linear-gradient(90deg, #4a7a9a, #b06ad4, #e03030); transition: width .6s; }
#skulls { margin-left: auto; font-size: 1rem; letter-spacing: .1em; }
.hud-icon-btn {
    background: rgba(22, 16, 32, .85); border: 1px solid var(--line); color: var(--text);
    width: 38px; height: 38px; border-radius: 10px; font-size: 1.1rem; cursor: pointer;
}

#evidence-strip {
    position: absolute; top: calc(48px + env(safe-area-inset-top)); left: 50%;
    transform: translateX(-50%); z-index: 9; display: flex; gap: 6px; flex-wrap: wrap;
    justify-content: center; pointer-events: none; max-width: 96vw;
}
.ev-chip {
    font-size: .68rem; font-weight: 700; letter-spacing: .06em; padding: 3px 10px;
    border-radius: 20px; border: 1px solid var(--line); color: var(--muted);
    background: rgba(11, 8, 16, .8);
}
.ev-chip.found { color: #0e1a0a; background: var(--green); border-color: var(--green); }

#readings-log {
    position: absolute; left: 8px; bottom: calc(170px + env(safe-area-inset-bottom));
    z-index: 8; max-width: 320px; display: flex; flex-direction: column; gap: 3px;
    font-size: .78rem; pointer-events: none;
}
.reading-line {
    background: rgba(11, 8, 16, .82); border-radius: 8px; padding: 4px 9px;
    animation: readFade 12s forwards;
}
.reading-line b { margin-right: 4px; }
.reading-line .ev { color: var(--green); font-weight: 800; }
.reading-line.sys { color: var(--spirit); font-style: italic; }
.reading-line.bad { color: #ffa090; }
@keyframes readFade { 0%, 85% { opacity: 1; } 100% { opacity: .2; } }

#event-banner {
    position: absolute; top: 22%; left: 50%; transform: translateX(-50%); z-index: 12;
    font-size: clamp(1rem, 4vw, 1.7rem); font-weight: 800; letter-spacing: .12em;
    color: #d6ecff; text-shadow: 0 0 20px rgba(138, 196, 212, .8); text-align: center;
    opacity: 0; pointer-events: none; transition: opacity .3s; white-space: nowrap;
}
#event-banner.show { opacity: 1; }
#event-banner.bad { color: #ffc0b0; text-shadow: 0 0 20px rgba(255, 60, 60, .8); }
#event-banner.good { color: #d0ffd0; text-shadow: 0 0 20px rgba(60, 255, 120, .8); }

/* controls */
#controls {
    position: absolute; left: 0; right: 0; bottom: calc(64px + env(safe-area-inset-bottom));
    z-index: 10; padding: 0 14px;
    display: flex; align-items: flex-end; justify-content: space-between; pointer-events: none;
}
#joystick {
    width: 120px; height: 120px; border-radius: 50%; position: relative;
    background: rgba(40, 30, 60, .35); border: 1px solid rgba(138, 196, 212, .25);
    pointer-events: auto; touch-action: none; display: none;
}
#joystick .stick {
    position: absolute; width: 50px; height: 50px; border-radius: 50%;
    background: rgba(138, 196, 212, .35); border: 1px solid var(--spirit);
    left: 35px; top: 35px;
}
body.touch #joystick { display: block; }
#action-cluster { display: flex; flex-direction: column; gap: 10px; align-items: flex-end; pointer-events: auto; }
.action-btn {
    min-width: 118px; padding: 13px 20px; border-radius: 14px; font-weight: 800;
    font-size: .92rem; letter-spacing: .06em; border: 1px solid; cursor: pointer;
    font-family: inherit;
}
#revive-btn { background: rgba(20, 70, 30, .92); border-color: var(--green); color: #d8ffd8; display: none; }
#revive-btn.show { display: block; }
#use-btn {
    background: rgba(60, 42, 18, .95); border-color: var(--candle); color: #ffe9c4;
    position: relative; overflow: hidden;
}
#use-btn .cd-fill { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(0, 0, 0, .55); width: 0%; }
#use-btn .lbl { position: relative; }

#toolbar {
    position: absolute; left: 50%; transform: translateX(-50%);
    bottom: calc(8px + env(safe-area-inset-bottom)); z-index: 10;
    display: flex; gap: 6px; background: rgba(11, 8, 16, .85);
    border: 1px solid var(--line); border-radius: 14px; padding: 6px;
}
.tool-btn {
    width: 46px; height: 46px; border-radius: 10px; font-size: 1.3rem;
    background: var(--panel2); border: 1px solid var(--line); cursor: pointer;
}
.tool-btn.sel { border-color: var(--candle); box-shadow: 0 0 12px rgba(255, 196, 106, .5); }

#downed-overlay {
    position: absolute; inset: 0; z-index: 20; pointer-events: none; display: none;
    align-items: center; justify-content: center; flex-direction: column; gap: 10px;
    background: radial-gradient(ellipse at center, rgba(40, 0, 20, .4), rgba(8, 0, 4, .85));
}
#downed-overlay.show { display: flex; }
#downed-overlay h2 { color: #ff9090; font-size: 1.6rem; letter-spacing: .18em; animation: pulse 1.2s infinite; }
#downed-overlay p { color: #d0a0a0; }

/* overlays */
.overlay {
    position: fixed; inset: 0; z-index: 40; display: flex; align-items: center;
    justify-content: center; background: rgba(4, 2, 7, .85); padding: 14px;
}
.overlay-card {
    background: var(--panel); border: 1px solid #4a3a6a; border-radius: 16px;
    width: min(560px, 100%); max-height: 88vh; overflow-y: auto; padding: 24px;
    text-align: center;
}
.journal-card { text-align: left; }
#journal-evidence { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 16px; }
#journal-ghosts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 560px) { #journal-ghosts { grid-template-columns: 1fr; } }
.ghost-row {
    border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
    background: #120c1c;
}
.ghost-row.impossible { opacity: .32; }
.ghost-row.only { border-color: var(--green); box-shadow: 0 0 12px rgba(125, 255, 77, .3); }
.ghost-row b { display: block; color: #fff; }
.ghost-row .fp { font-size: .74rem; color: var(--muted); line-height: 1.5; }
.ghost-row .fp .have { color: var(--green); font-weight: 700; }
.ghost-row .banish-btn { margin-top: 8px; width: 100%; padding: 6px; font-size: .8rem; }

#result-title { font-size: 1.6rem; letter-spacing: .12em; }
#result-title.win { color: var(--green); text-shadow: 0 0 20px rgba(125, 255, 77, .5); }
#result-title.lose { color: var(--danger); text-shadow: 0 0 20px rgba(255, 64, 64, .5); }
.result-time { font-family: monospace; font-size: 2.1rem; color: var(--spirit); margin: 10px 0; }
.crew-results { margin: 12px 0; text-align: left; }
.crew-result-row {
    display: flex; align-items: center; gap: 9px; padding: 7px 6px;
    border-bottom: 1px solid #1d1428; font-size: .88rem;
}
.crew-result-row .st { margin-left: auto; color: var(--muted); font-size: .78rem; }
.results-actions { display: flex; gap: 10px; justify-content: center; margin-top: 14px; flex-wrap: wrap; align-items: center; }

@media (max-width: 700px) {
    .mini-logo { display: none; }
    #readings-log { max-width: 230px; bottom: calc(200px + env(safe-area-inset-bottom)); }
}
