* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    overflow: hidden;
    background: #0f0a07;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    -webkit-font-smoothing: antialiased;
}

#container {
    width: 100vw;
    height: 100vh;
    display: block;
}

#app-version {
    position: fixed;
    right: 14px;
    bottom: 12px;
    z-index: 20;
    padding: 6px 10px;
    border: 1px solid rgba(212, 175, 55, 0.25);
    border-radius: 8px;
    background: rgba(11, 9, 8, 0.7);
    color: rgba(255, 255, 255, 0.72);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    pointer-events: none;
    backdrop-filter: blur(6px);
}

/* ── HUD ────────────────────────────────────────────────────── */

#hud-top {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 25;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(15,10,7,0.85) 0%, rgba(15,10,7,0.4) 48%, transparent 100%);
}

#hud-top > * {
    pointer-events: auto;
}

#logo {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    background: linear-gradient(135deg, #f0e8dc, #d4a853);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    user-select: none;
    pointer-events: none;
    text-shadow: none;
    filter: drop-shadow(0 0 20px rgba(212,168,83,0.15));
}

.hud-left, .hud-right {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.icon {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: 0 0 auto;
}

.control-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hud-btn {
    min-width: 38px;
    height: 38px;
    padding: 0 12px;
    border-radius: 8px;
    border: 1px solid rgba(180,140,100,0.18);
    background: rgba(26,18,14,0.7);
    color: #c4b8a8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    transition: transform 0.12s, background 0.12s, border-color 0.12s, color 0.12s;
    user-select: none;
    backdrop-filter: blur(12px);
    box-shadow: 0 10px 28px rgba(0,0,0,0.25);
}

.hud-btn:hover {
    background: rgba(40,30,22,0.8);
    border-color: rgba(212,168,83,0.5);
    color: #f0e8dc;
    transform: translateY(-1px);
}

#player-roster-panel {
    position: absolute;
    top: 64px;
    right: 16px;
    z-index: 24;
    width: min(260px, calc(100vw - 32px));
    max-height: min(430px, calc(100vh - 96px));
    overflow: hidden;
    border: 1px solid rgba(180,140,100,0.2);
    border-radius: 8px;
    background: rgba(18,13,10,0.9);
    color: #c4b8a8;
    box-shadow: 0 18px 48px rgba(0,0,0,0.32);
    backdrop-filter: blur(14px);
}

.player-roster-head {
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    border-bottom: 1px solid rgba(180,140,100,0.14);
    color: #f0e8dc;
    font-size: 13px;
    font-weight: 700;
}

#player-roster-count {
    min-width: 24px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: rgba(212,168,83,0.14);
    color: #d4a853;
    font-size: 12px;
}

#player-roster-list {
    max-height: 278px;
    overflow-y: auto;
    padding: 6px;
}

.player-roster-row {
    min-height: 34px;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 8px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
}

.player-roster-row:hover,
.player-roster-row.selected {
    background: rgba(255,255,255,0.04);
}

.player-roster-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #65d98b;
    box-shadow: 0 0 10px rgba(101,217,139,0.35);
    flex: 0 0 auto;
}

.player-roster-name {
    min-width: 0;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-roster-self {
    flex: 0 0 auto;
    color: #d4a853;
    font-size: 11px;
    font-weight: 700;
}

.player-roster-empty {
    padding: 18px 10px;
    color: #8a7a6a;
    font-size: 13px;
    text-align: center;
}

.player-roster-actions {
    margin: 0 8px 8px;
    border-top: 1px solid rgba(212,168,83,0.16);
    padding-top: 8px;
}

.player-roster-actions-name {
    margin-bottom: 7px;
    color: #f0e8dc;
    font-size: 13px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#player-roster-friend {
    width: 100%;
    height: 32px;
    border: 1px solid rgba(212,168,83,0.42);
    border-radius: 6px;
    background: rgba(212,168,83,0.14);
    color: #f0e8dc;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
}

#player-roster-friend:hover:not(:disabled) {
    background: rgba(212,168,83,0.24);
}

#player-roster-friend:disabled {
    cursor: default;
    opacity: 0.58;
}

.player-roster-status {
    min-height: 16px;
    margin-top: 6px;
    color: #8a7a6a;
    font-size: 12px;
}

.player-roster-status[data-kind="ok"] {
    color: #65d98b;
}

.player-roster-status[data-kind="error"] {
    color: #e06f6f;
}

/* ── Shiftlock ──────────────────────────────────────────────── */

#shiftlock-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 38px;
    height: 38px;
    color: #d4a853;
    z-index: 10;
    pointer-events: none;
    user-select: none;
    opacity: 0;
    filter: drop-shadow(0 0 20px rgba(212,168,83,0.3));
}

#shiftlock-indicator.active {
    opacity: 1;
    animation: shiftlock-pulse 1.2s ease-in-out infinite;
}

#shiftlock-indicator::before,
#shiftlock-indicator::after {
    content: "";
    position: absolute;
    background: currentColor;
    border-radius: 999px;
}

#shiftlock-indicator::before {
    left: 7px;
    right: 7px;
    top: 18px;
    height: 2px;
}

#shiftlock-indicator::after {
    top: 7px;
    bottom: 7px;
    left: 18px;
    width: 2px;
}

#shiftlock-indicator.active {
    box-shadow: inset 0 0 0 2px currentColor;
    border-radius: 50%;
}

@keyframes shiftlock-pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.9; }
    50% { transform: translate(-50%, -50%) scale(1.1); opacity: 0.6; }
}

/* ── Chat ───────────────────────────────────────────────────── */

#chat-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 20;
    pointer-events: none;
}

#chat-panel {
    pointer-events: auto;
    width: 100%;
    max-width: 560px;
    margin: 0 auto 18px;
    padding: 0 16px;
    display: flex;
    flex-direction: column;
}

#chat-messages {
    max-height: 220px;
    overflow-y: auto;
    background: rgba(18,13,10,0.8);
    border: 1px solid rgba(180,140,100,0.15);
    border-radius: 10px 10px 0 0;
    border-bottom: none;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    scrollbar-width: thin;
    scrollbar-color: rgba(180,140,100,0.2) transparent;
    backdrop-filter: blur(14px);
    box-shadow: 0 18px 44px rgba(0,0,0,0.3);
}

#chat-messages::-webkit-scrollbar { width: 4px; }
#chat-messages::-webkit-scrollbar-thumb {
    background: rgba(180,140,100,0.2);
    border-radius: 2px;
}

.chat-msg {
    font-size: 13px;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-author {
    font-weight: 600;
    margin-right: 6px;
}

.chat-text {
    color: #c4b8a8;
}

#chat-input-row {
    display: flex;
    gap: 6px;
    background: rgba(18,13,10,0.92);
    border: 1px solid rgba(180,140,100,0.15);
    border-radius: 0 0 10px 10px;
    padding: 10px 14px;
    backdrop-filter: blur(14px);
}

#chat-input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    padding: 6px 0;
    color: #f0e8dc;
    font-size: 13px;
    outline: none;
    font-family: inherit;
}

#chat-input::placeholder { color: #8a7a6a; }

#chat-send {
    background: #d4a853;
    color: #0f0a07;
    border: none;
    border-radius: 8px;
    min-width: 34px;
    padding: 0 14px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    transition: background 0.12s, transform 0.12s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
}

#chat-send:hover {
    background: #e6c06a;
    transform: translateY(-1px);
}

#chat-send:active {
    background: #c4953a;
    transform: translateY(0);
}

/* ── Menu ───────────────────────────────────────────────────── */

#menu-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(12,8,6,0.78);
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}

#menu-overlay.open { display: flex; }

#menu-modal {
    background: #1a120e;
    border: 1px solid rgba(180,140,100,0.15);
    border-radius: 12px;
    padding: 24px;
    min-width: 270px;
    max-width: 340px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    box-shadow: 0 24px 80px rgba(0,0,0,0.5);
}

#menu-title {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
    text-align: center;
    padding: 6px 0 4px;
    background: linear-gradient(135deg, #f0e8dc, #d4a853);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    user-select: none;
}

#menu-modal h2 {
    color: #f0e8dc;
    font-size: 16px;
    font-weight: 700;
    text-align: center;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(180,140,100,0.12);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.menu-btn {
    background: transparent;
    border: 1px solid rgba(180,140,100,0.12);
    border-radius: 8px;
    color: #f0e8dc;
    width: 100%;
    min-height: 44px;
    font-weight: 500;
    padding: 0 14px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.1s, border-color 0.1s, color 0.1s;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
}

.menu-btn:hover {
    background: rgba(40,30,22,0.6);
    border-color: rgba(212,168,83,0.4);
    color: #f0e8dc;
}

.menu-btn.danger { color: #d97a5a; }

.menu-btn.danger:hover {
    background: rgba(217,122,90,0.08);
    border-color: #d97a5a;
}

.menu-btn.close-btn {
    margin-top: 4px;
    border-color: transparent;
    color: #8a7a6a;
    justify-content: center;
}

.menu-btn.close-btn:hover {
    color: #c4b8a8;
    background: rgba(40,30,22,0.6);
    border-color: rgba(180,140,100,0.12);
}

/* ── Auth ───────────────────────────────────────────────────── */

#auth-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    background:
        radial-gradient(ellipse at 30% 20%, rgba(212,168,83,0.08), transparent 50%),
        radial-gradient(ellipse at 70% 80%, rgba(217,122,90,0.06), transparent 40%),
        radial-gradient(ellipse at center, rgba(15,10,7,0.95), rgba(10,7,5,0.98));
    display: flex;
    align-items: center;
    justify-content: center;
}

#auth-box {
    background: rgba(26,18,14,0.94);
    border: 1px solid rgba(180,140,100,0.15);
    border-radius: 16px;
    padding: 40px 36px 32px;
    width: 360px;
    max-width: 90vw;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    box-shadow:
        0 24px 80px rgba(0,0,0,0.5),
        0 0 60px rgba(212,168,83,0.04);
    backdrop-filter: blur(18px);
}

#auth-box h1 {
    color: #f0e8dc;
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 0;
    margin-bottom: 2px;
    background: linear-gradient(135deg, #f0e8dc, #d4a853);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#auth-tabs {
    display: flex;
    width: 100%;
    border-bottom: 1px solid rgba(180,140,100,0.12);
}

.auth-tab {
    flex: 1;
    background: none;
    border: none;
    color: #8a7a6a;
    font-size: 14px;
    font-weight: 600;
    padding: 10px;
    cursor: pointer;
    font-family: inherit;
    transition: color 0.1s, border-color 0.1s;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.auth-tab:hover { color: #c4b8a8; }

.auth-tab.active {
    color: #d4a853;
    border-bottom-color: #d4a853;
}

#auth-form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#auth-form input {
    width: 100%;
    background: rgba(15,10,7,0.6);
    border: 1px solid rgba(180,140,100,0.15);
    border-radius: 10px;
    padding: 14px 16px;
    color: #f0e8dc;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.1s, box-shadow 0.1s;
}

#auth-form input:focus {
    border-color: rgba(212,168,83,0.4);
    box-shadow: 0 0 0 3px rgba(212,168,83,0.08);
}

#auth-form input::placeholder { color: #8a7a6a; }

.auth-error {
    color: #d97a5a;
    font-size: 13px;
    min-height: 18px;
    text-align: center;
}

#auth-submit {
    width: 100%;
    background: linear-gradient(135deg, #d4a853, #c9953a);
    border: none;
    border-radius: 10px;
    padding: 14px;
    color: #0f0a07;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    font-family: inherit;
    transition: opacity 0.12s, transform 0.12s;
    margin-top: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

#auth-submit:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

#auth-submit:active {
    opacity: 1;
    transform: translateY(0);
}

#auth-submit:disabled {
    opacity: 0.4;
    cursor: default;
    transform: none;
}

/* ── Responsive ─────────────────────────────────────────────── */

@media (max-width: 680px) {
    #hud-top { padding: 10px; }
    .hud-btn { min-width: 36px; height: 36px; }
    #chat-panel { margin-bottom: 10px; padding: 0 10px; }
}
