* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #0f1114;
    --surface: #1a1d23;
    --surface-hover: #22262e;
    --border: #2a2e36;
    --text: #e4e6eb;
    --text-muted: #8a8f98;
    --primary: #4f8cff;
    --primary-hover: #3a7aff;
    --danger: #ff4d4f;
    --success: #52c41a;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}

.screen {
    display: none;
    height: 100vh;
}
.screen.active {
    display: flex;
    flex-direction: column;
}

/* ── Auth ─────────────────────────────────────────── */

#auth-screen {
    align-items: center;
    justify-content: center;
}
.auth-container {
    width: 100%;
    max-width: 380px;
    padding: 2rem;
}
.auth-container h1 {
    font-size: 2rem;
    margin-bottom: 0.25rem;
}
.subtitle {
    color: var(--text-muted);
    margin-bottom: 2rem;
}
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.auth-form input {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.95rem;
}
.auth-form input:focus {
    outline: none;
    border-color: var(--primary);
}
.auth-form button {
    padding: 0.75rem;
    border: none;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}
.auth-form button:hover {
    background: var(--primary-hover);
}
.auth-divider {
    text-align: center;
    margin: 1.5rem 0;
    color: var(--text-muted);
    position: relative;
}
.auth-divider::before,
.auth-divider::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: var(--border);
}
.auth-divider::before { left: 0; }
.auth-divider::after { right: 0; }
.error-msg {
    color: var(--danger);
    margin-top: 1rem;
    text-align: center;
    min-height: 1.2em;
}

/* ── Main Screen ──────────────────────────────────── */

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
header h1 {
    font-size: 1.25rem;
}
.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
#username-display {
    color: var(--text-muted);
}
#logout-btn {
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}
#logout-btn:hover {
    color: var(--danger);
    border-color: var(--danger);
}

/* ── Main Content (column layout) ────────────────── */

.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ── Tabs (vertical sidebar) ─────────────────────── */

.tabs {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    background: var(--surface);
    width: 140px;
    flex-shrink: 0;
}
.tab {
    padding: 0.75rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    border-left: 2px solid transparent;
    text-align: left;
    transition: all 0.2s;
}
.tab:hover {
    color: var(--text);
    background: var(--surface-hover);
}
.tab.active {
    color: var(--primary);
    border-left-color: var(--primary);
}

/* ── Map (center column) ─────────────────────────── */

#map-container {
    width: 35%;
    min-width: 200px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
}

/* ── Chat Panel (right column) ───────────────────── */

.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Connection Status ────────────────────────────── */

.connection-status {
    text-align: center;
    padding: 0.35rem;
    font-size: 0.8rem;
    background: var(--surface);
    color: var(--text-muted);
    display: none;
}
.connection-status.disconnected {
    display: block;
    background: #3a1a1a;
    color: var(--danger);
}
.connection-status.connecting {
    display: block;
    color: #faad14;
}

/* ── Chat ─────────────────────────────────────────── */

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.chat-message {
    padding: 0.6rem 0.8rem;
    background: var(--surface);
    border-radius: 8px;
    max-width: 80%;
}
.chat-message.own {
    align-self: flex-end;
    background: var(--primary);
}
.chat-message .author {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.2rem;
}
.chat-message.own .author {
    color: rgba(255,255,255,0.7);
}
.chat-message .text {
    font-size: 0.95rem;
    word-break: break-word;
}

/* ── Chat Input ───────────────────────────────────── */

.chat-input {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--surface);
}
.chat-input input {
    flex: 1;
    padding: 0.65rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: 0.95rem;
}
.chat-input input:focus {
    outline: none;
    border-color: var(--primary);
}
.chat-input button {
    padding: 0.65rem 1.25rem;
    border: none;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}
.chat-input button:hover {
    background: var(--primary-hover);
}
