:root {
    --bg: #0f172a;
    --panel: #111827;
    --panel-2: #172033;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --line: rgba(255, 255, 255, .1);
    --accent: #38bdf8;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --shadow: 0 18px 50px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: radial-gradient(circle at top left, #1e3a8a 0, #0f172a 35%, #020617 100%);
    color: var(--text);
}

a { color: var(--accent); }
button, input, select {
    font: inherit;
}
button {
    border: 0;
    border-radius: 14px;
    padding: 12px 16px;
    color: #06111f;
    background: linear-gradient(135deg, #7dd3fc, #38bdf8);
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(56, 189, 248, .22);
}
button:hover { filter: brightness(1.06); }
button:disabled { cursor: wait; opacity: .7; }
button.secondary {
    color: var(--text);
    background: rgba(255,255,255,.08);
    box-shadow: none;
    border: 1px solid var(--line);
}
input, select {
    width: 100%;
    margin-top: 7px;
    border: 1px solid var(--line);
    background: rgba(2, 6, 23, .65);
    color: var(--text);
    border-radius: 12px;
    padding: 12px 13px;
    outline: none;
}
input:focus, select:focus {
    border-color: rgba(56, 189, 248, .8);
    box-shadow: 0 0 0 4px rgba(56, 189, 248, .14);
}
label { color: #cbd5e1; font-weight: 650; }

.page-lobby {
    min-height: 100%;
    padding: 36px;
}
.hero {
    max-width: 1100px;
    margin: 0 auto 24px;
    padding: 34px;
    border-radius: 28px;
    background: linear-gradient(135deg, rgba(255,255,255,.12), rgba(255,255,255,.04));
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}
.eyebrow {
    margin: 0 0 8px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .16em;
    text-transform: uppercase;
}
h1, h2 { margin-top: 0; }
.hero h1 {
    font-size: clamp(44px, 7vw, 82px);
    margin: 0;
    line-height: .92;
}
.hero-text {
    max-width: 720px;
    font-size: 18px;
    color: #cbd5e1;
    margin-bottom: 0;
}
.lobby-grid {
    max-width: 1100px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px;
}
.card {
    border-radius: 24px;
    background: rgba(17, 24, 39, .82);
    border: 1px solid var(--line);
    padding: 24px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}
.howto {
    max-width: 1100px;
    margin: 22px auto 0;
}
.stack { display: grid; gap: 16px; }
.two-cols {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}
.muted { color: var(--muted); }
.form-message { min-height: 22px; color: var(--muted); margin: 0; }
.form-message.success { color: var(--success); }
.form-message.error { color: #fca5a5; }

.page-game {
    height: 100vh;
    overflow: hidden;
    background: #020617;
}
.game-shell {
    display: grid;
    grid-template-columns: 360px 1fr;
    height: 100vh;
}
.side-panel {
    overflow: auto;
    padding: 22px;
    background: rgba(15, 23, 42, .96);
    border-right: 1px solid var(--line);
}
.room-header {
    display: grid;
    gap: 10px;
    margin-bottom: 24px;
}
.room-header h1 {
    font-size: 44px;
    margin: 0;
    letter-spacing: .06em;
}
.panel-section, .join-inline {
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, .04);
    border-radius: 18px;
    padding: 16px;
    margin-bottom: 14px;
}
.panel-section h2, .join-inline h2 {
    font-size: 15px;
    margin: 0 0 12px;
    color: #f8fafc;
}
.status-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 900;
    background: rgba(245, 158, 11, .14);
    color: #fbbf24;
    margin-bottom: 12px;
}
.status-badge[data-status="playing"] {
    color: #86efac;
    background: rgba(34, 197, 94, .14);
}
.status-badge[data-status="finished"] {
    color: #fca5a5;
    background: rgba(239, 68, 68, .14);
}
.players-list, .checkpoint-list {
    display: grid;
    gap: 9px;
}
.player-row, .checkpoint-row {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
    align-items: center;
    padding: 10px;
    border-radius: 14px;
    background: rgba(2, 6, 23, .32);
}
.player-row small, .checkpoint-row small {
    display: block;
    color: var(--muted);
    margin-top: 2px;
}
.dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: var(--muted);
}
.dot.online { background: var(--success); box-shadow: 0 0 0 4px rgba(34,197,94,.16); }
.dot.offline { background: #64748b; }
.checkpoint-row > span {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: rgba(148, 163, 184, .18);
    font-weight: 900;
}
.checkpoint-row.done {
    border: 1px solid rgba(34,197,94,.28);
}
.checkpoint-row.done > span {
    background: rgba(34,197,94,.22);
    color: #86efac;
}
.checkpoint-row.next {
    border: 1px solid rgba(56, 189, 248, .4);
    background: rgba(56, 189, 248, .08);
}
.progress-line {
    padding: 8px 0;
    color: #cbd5e1;
}
.small-help p { margin-bottom: 0; color: var(--muted); }
.play-area {
    position: relative;
    min-width: 0;
    min-height: 0;
}
.map-pane {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: #111827;
}
.hidden { display: none !important; }
.missing-key {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: grid;
    place-content: center;
    text-align: center;
    padding: 24px;
    background: #020617;
}
.missing-key code {
    background: rgba(255,255,255,.1);
    border-radius: 8px;
    padding: 3px 6px;
}
.spectator-hint {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 4;
    max-width: 320px;
    border-radius: 16px;
    padding: 16px;
    background: rgba(15, 23, 42, .9);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}
.spectator-hint p { margin-bottom: 0; color: var(--muted); }
.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    z-index: 99;
    transform: translate(-50%, 16px);
    opacity: 0;
    padding: 12px 18px;
    border-radius: 999px;
    background: rgba(15, 23, 42, .95);
    color: #f8fafc;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    transition: .2s ease;
}
.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

@media (max-width: 900px) {
    .page-lobby { padding: 18px; }
    .lobby-grid { grid-template-columns: 1fr; }
    .game-shell { grid-template-columns: 1fr; grid-template-rows: 46vh 54vh; }
    .side-panel { order: 2; border-right: 0; border-top: 1px solid var(--line); }
    .play-area { order: 1; }
}

@media (max-width: 560px) {
    .two-cols { grid-template-columns: 1fr; }
    .hero, .card { padding: 18px; border-radius: 18px; }
    .room-header h1 { font-size: 34px; }
}


.ad-panel {
    max-width: 1100px;
    margin: 22px auto 0;
    padding: 14px;
    border-radius: 18px;
    background: rgba(17, 24, 39, .72);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.ad-label {
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .12em;
    text-align: center;
}
.ad-panel .adsbygoogle {
    display: block;
    min-height: 90px;
}
.side-panel .ad-panel {
    margin: 14px 0 0;
    padding: 12px;
    box-shadow: none;
    background: rgba(255, 255, 255, .04);
}
.side-panel .ad-panel .adsbygoogle {
    min-height: 250px;
}
@media (max-width: 900px) {
    .side-panel .ad-panel .adsbygoogle {
        min-height: 90px;
    }
}

.timer-box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 96px;
    margin: 0 0 12px;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(2, 6, 23, .5);
    border: 1px solid var(--line);
    color: #f8fafc;
    font-size: 24px;
    font-weight: 900;
    letter-spacing: .06em;
    font-variant-numeric: tabular-nums;
}
.timer-box[data-timer-status="playing"] {
    border-color: rgba(34, 197, 94, .28);
    box-shadow: 0 0 0 4px rgba(34, 197, 94, .08);
}
.timer-box[data-timer-status="finished"] {
    border-color: rgba(245, 158, 11, .32);
    box-shadow: 0 0 0 4px rgba(245, 158, 11, .08);
}
.stats-list {
    display: grid;
    gap: 10px;
}
.team-stat {
    border-left: 4px solid var(--team-color, var(--accent));
    border-radius: 14px;
    padding: 10px;
    background: rgba(2, 6, 23, .35);
}
.team-stat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 4px;
}
.team-stat small {
    display: block;
    color: var(--muted);
    margin-top: 3px;
}
.dot.online {
    background: var(--team-color, var(--success));
}
.play-area {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
}
.play-viewport {
    position: relative;
    min-width: 0;
    min-height: 0;
}
.play-bottom-ad {
    position: relative;
    z-index: 2;
    background: #020617;
    border-top: 1px solid var(--line);
    padding: 8px 12px;
}
.play-bottom-ad:empty {
    display: none;
}
.play-bottom-ad .ad-panel {
    max-width: 970px;
    margin: 0 auto;
    padding: 8px 12px;
    border-radius: 14px;
    box-shadow: none;
    background: rgba(15, 23, 42, .88);
}
.play-bottom-ad .ad-label {
    margin-bottom: 4px;
}
.play-bottom-ad .adsbygoogle {
    min-height: 90px;
}
.start-lock {
    position: absolute;
    left: 50%;
    top: 24px;
    z-index: 6;
    transform: translateX(-50%);
    width: min(520px, calc(100% - 32px));
    border-radius: 18px;
    padding: 18px;
    text-align: center;
    background: rgba(15, 23, 42, .92);
    border: 1px solid rgba(56, 189, 248, .28);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
}
.start-lock h2 {
    margin-bottom: 6px;
}
.start-lock p {
    margin: 0;
    color: #cbd5e1;
}
@media (max-width: 900px) {
    .game-shell { grid-template-rows: 52vh 48vh; }
    .play-bottom-ad {
        padding: 6px;
    }
    .play-bottom-ad .adsbygoogle {
        min-height: 70px;
    }
}
