:root {
    color-scheme: dark;
    --ink: #f7fbff;
    --muted: #a9b6c6;
    --panel: rgba(10, 14, 20, 0.76);
    --line: rgba(255, 255, 255, 0.16);
    --accent: #33f0a1;
    --danger: #ff4f6d;
    --warn: #ffd166;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    background: #05070a;
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
    font: inherit;
}

#game-shell,
#game-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
}

#game-canvas {
    display: block;
}

#hud {
    position: fixed;
    top: 16px;
    left: 16px;
    right: 16px;
    z-index: 3;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    pointer-events: none;
}

.panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
    backdrop-filter: blur(12px);
}

.vitals {
    width: min(290px, 44vw);
    min-height: 70px;
    padding: 12px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px 12px;
}

.label,
.stats span,
#scoreboard header,
.controls {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0;
}

.health-wrap {
    grid-column: 1 / -1;
    height: 14px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.13);
}

#health-bar {
    width: 100%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), var(--warn));
    transition: width 120ms ease, background 120ms ease;
}

#health-text {
    min-width: 36px;
    text-align: right;
    font-weight: 800;
}

.stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(60px, auto));
    gap: 1px;
    overflow: hidden;
}

.stats div {
    min-width: 66px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.04);
}

.stats strong {
    display: block;
    margin-top: 2px;
    font-size: 20px;
}

.connection {
    margin-left: auto;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
}

#status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--warn);
    box-shadow: 0 0 18px currentColor;
}

#status-dot.online {
    background: var(--accent);
}

#status-dot.offline {
    background: var(--danger);
}

#crosshair {
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: 2;
    width: 20px;
    height: 20px;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

#crosshair::before,
#crosshair::after {
    content: "";
    position: absolute;
    background: rgba(255, 255, 255, 0.88);
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.65);
}

#crosshair::before {
    top: 9px;
    left: 0;
    width: 20px;
    height: 2px;
}

#crosshair::after {
    top: 0;
    left: 9px;
    width: 2px;
    height: 20px;
}

#hit-marker {
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: 3;
    transform: translate(-50%, -50%) scale(0.6);
    color: var(--danger);
    font-size: 38px;
    font-weight: 900;
    opacity: 0;
    pointer-events: none;
    transition: opacity 90ms ease, transform 90ms ease;
}

#hit-marker.active {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

#damage-flash {
    position: fixed;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    background: radial-gradient(circle, transparent 42%, rgba(255, 79, 109, 0.44));
    opacity: 0;
    transition: opacity 180ms ease;
}

#damage-flash.active {
    opacity: 1;
}

#scoreboard {
    position: fixed;
    right: 16px;
    top: 76px;
    z-index: 3;
    width: min(360px, calc(100vw - 32px));
    max-height: min(420px, calc(100vh - 120px));
    overflow: hidden;
    pointer-events: none;
}

#scoreboard header,
.score-row {
    display: grid;
    grid-template-columns: 1fr 42px 42px 52px;
    gap: 8px;
    align-items: center;
}

#scoreboard header {
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
}

#scoreboard-rows {
    max-height: 360px;
    overflow: hidden;
}

.score-row {
    padding: 9px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 14px;
}

.score-row:last-child {
    border-bottom: 0;
}

.player-name {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.swatch {
    width: 12px;
    height: 12px;
    flex: 0 0 12px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.72);
}

#play-overlay {
    position: fixed;
    inset: 0;
    z-index: 5;
    display: grid;
    place-content: center;
    gap: 12px;
    padding: 24px;
    border: 0;
    color: var(--ink);
    background: rgba(5, 7, 10, 0.72);
    cursor: pointer;
    text-align: center;
}

#play-overlay.hidden {
    display: none;
}

.title {
    font-size: clamp(48px, 12vw, 132px);
    line-height: 0.9;
    font-weight: 950;
}

.subtitle {
    font-size: clamp(18px, 4vw, 30px);
    font-weight: 800;
}

.controls {
    max-width: 90vw;
    color: #d6e0eb;
}

@media (max-width: 760px) {
    #hud {
        top: 10px;
        left: 10px;
        right: 10px;
        gap: 8px;
        flex-wrap: wrap;
    }

    .vitals {
        width: calc(100vw - 20px);
        order: 1;
    }

    .stats {
        order: 2;
        grid-template-columns: repeat(3, 1fr);
        width: calc(100vw - 20px);
    }

    .connection {
        order: 0;
        margin-left: 0;
    }

    #scoreboard {
        left: 10px;
        right: 10px;
        top: auto;
        bottom: 10px;
        width: auto;
    }

    #scoreboard-rows {
        max-height: 160px;
    }
}