:root {
    color-scheme: dark;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --panel: rgba(10, 15, 23, 0.9);
    --panel-border: rgba(255, 255, 255, 0.15);
    --accent: #61e4d5;
    --danger: #ff8f98;
}

* {
    box-sizing: border-box;
}

html,
body {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    overscroll-behavior: none;
    background: #020406;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

[hidden] {
    display: none !important;
}

#renderCanvas {
    position: fixed;
    inset: 0;
    display: block;
    width: 100vw;
    height: 100svh;
    outline: none;
    touch-action: none;
}

.full-overlay {
    position: fixed;
    z-index: 30;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    background: radial-gradient(circle at center, rgba(19, 37, 49, 0.78), rgba(2, 4, 7, 0.94));
}

.panel {
    width: min(430px, 100%);
    padding: 24px;
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    background: var(--panel);
    box-shadow: 0 22px 80px rgba(0, 0, 0, 0.48);
    backdrop-filter: blur(14px);
}

.panel h1,
.panel h2,
.panel p {
    margin-top: 0;
}

.panel h1 {
    margin-bottom: 8px;
    font-size: 1.65rem;
}

.panel-copy {
    color: #b8c2cc;
    line-height: 1.45;
}

.steam-login {
    display: block;
    margin: 18px 0 14px;
    padding: 12px 14px;
    border: 1px solid rgba(102, 192, 244, 0.55);
    border-radius: 9px;
    background: rgba(27, 116, 170, 0.34);
    color: #f7fbff;
    font-weight: 750;
    text-align: center;
    text-decoration: none;
}

.steam-login:hover,
.steam-login:focus-visible {
    background: rgba(27, 116, 170, 0.5);
}

.steam-status {
    margin: 18px 0;
    padding: 11px 12px;
    border: 1px solid rgba(97, 228, 213, 0.26);
    border-radius: 9px;
    background: rgba(44, 173, 159, 0.12);
    color: #cde9e5;
    line-height: 1.4;
}

.identity-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #8997a3;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.identity-divider::before,
.identity-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.12);
}

.field {
    display: grid;
    gap: 7px;
    margin: 18px 0;
    color: #dce5ec;
    font-size: 0.9rem;
    font-weight: 650;
}

.field input[type="text"] {
    min-width: 0;
    padding: 12px 13px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 9px;
    outline: none;
    background: rgba(0, 0, 0, 0.28);
    color: white;
    font: inherit;
    user-select: text;
}

.field input[type="text"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(97, 228, 213, 0.14);
}

.color-row {
    grid-template-columns: 1fr auto;
    align-items: center;
}

.color-row input {
    width: 54px;
    height: 42px;
    padding: 3px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 9px;
    background: transparent;
}

button {
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 9px;
    padding: 11px 14px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

button:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.16);
}

button:disabled {
    cursor: wait;
    opacity: 0.6;
}

#joinButton {
    width: 100%;
    border-color: rgba(97, 228, 213, 0.5);
    background: rgba(44, 173, 159, 0.34);
}

.form-error {
    min-height: 1.3em;
    margin: 10px 0;
    color: var(--danger);
    font-size: 0.88rem;
}

.help-text {
    margin: 16px 0 0;
    color: #8997a3;
    font-size: 0.8rem;
    text-align: center;
}

#hud {
    position: fixed;
    z-index: 10;
    top: max(12px, env(safe-area-inset-top));
    left: max(12px, env(safe-area-inset-left));
    min-width: 210px;
    padding: 10px 12px;
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    background: rgba(5, 9, 14, 0.72);
    color: #d9e3ea;
    font-size: 12px;
    line-height: 1.45;
    pointer-events: none;
    backdrop-filter: blur(8px);
}

.connection-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
}

#connectionDot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #e7b04c;
    box-shadow: 0 0 9px currentColor;
}

#connectionDot[data-state="connected"] {
    background: #54df8a;
}

#connectionDot[data-state="offline"],
#connectionDot[data-state="error"] {
    background: #f06e78;
}

#debugText {
    margin-top: 5px;
    color: #9caab5;
    white-space: pre-line;
}

#profileButton {
    position: fixed;
    z-index: 11;
    top: max(12px, env(safe-area-inset-top));
    right: max(12px, env(safe-area-inset-right));
    padding: 8px 11px;
    background: rgba(5, 9, 14, 0.72);
}

#roster {
    position: fixed;
    z-index: 20;
    top: 12%;
    left: 50%;
    width: min(620px, calc(100% - 28px));
    max-height: 72%;
    overflow: auto;
    transform: translateX(-50%);
    padding: 18px;
    border: 1px solid var(--panel-border);
    border-radius: 14px;
    background: rgba(5, 9, 14, 0.92);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.48);
    backdrop-filter: blur(12px);
}

#roster h2 {
    margin: 0 0 12px;
    font-size: 1.1rem;
}

#rosterList {
    display: grid;
    gap: 5px;
    margin: 0;
    padding: 0;
    list-style: none;
}

#rosterList li {
    display: grid;
    grid-template-columns: 14px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.045);
}

.roster-swatch {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.roster-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.roster-badges {
    color: var(--accent);
    font-size: 0.72rem;
    font-weight: 800;
}

#notice {
    position: fixed;
    z-index: 40;
    bottom: max(20px, env(safe-area-inset-bottom));
    left: 50%;
    max-width: min(620px, calc(100% - 30px));
    transform: translateX(-50%);
    padding: 11px 15px;
    border: 1px solid var(--panel-border);
    border-radius: 9px;
    background: rgba(11, 17, 25, 0.94);
    color: #f1f5f8;
    text-align: center;
}

.spinner {
    width: 38px;
    height: 38px;
    margin: 0 auto 18px;
    border: 3px solid rgba(255, 255, 255, 0.14);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@media (pointer: coarse), (max-width: 680px) {
    #hud {
        min-width: 0;
        max-width: calc(100% - 110px);
        font-size: 10px;
    }

    #profileButton {
        font-size: 12px;
    }

    .help-text {
        display: none;
    }
}
