:root {
    --bg: #080808;
    --surface: rgba(18, 18, 18, 0.72);
    --surface-solid: #141414;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.14);
    --text: #f2f2f2;
    --text-muted: #8b8b8b;
    --text-dim: #5c5c5c;
    --accent: #ffffff;
    --accent-soft: rgba(255, 255, 255, 0.1);
    --danger: #ff6b6b;
    --success: #4ade80;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --font: "Inter", system-ui, -apple-system, sans-serif;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
}

body {
    padding: 0;
    margin: 0;
    background-color: var(--bg);
    color: var(--text);
    user-select: none;
    font-family: var(--font);
    font-size: 13px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
}

.material-symbols-outlined {
    font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
    font-size: 18px;
    line-height: 1;
    display: inline-flex;
}

.glass {
    background: var(--surface);
    border: 1px solid var(--border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--shadow);
}

::placeholder {
    color: var(--text-dim);
}

@keyframes fade-in {
    from {
        opacity: 0;
        transform: scale(0.98) translateY(6px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

#view {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#modals-container {
    display: none;
    justify-content: center;
    align-items: center;
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: 20;
}

.center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.red-text {
    color: var(--danger);
}

/* ── Overlay ── */

.overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 2;
}

.stats {
    position: absolute;
    top: var(--space-4);
    left: var(--space-4);
    padding: var(--space-3);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    min-width: 148px;
}

.stat {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.stat .material-symbols-outlined {
    font-size: 15px;
    color: var(--text-dim);
}

.stat--hidden {
    display: none;
}

.leaderboard {
    position: absolute;
    top: var(--space-4);
    right: var(--space-4);
    width: 156px;
    padding: var(--space-2);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    font-size: 11px;
    font-weight: 500;
}

.leaderboard-tile {
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
    overflow-wrap: break-word;
    line-height: 1.3;
}

.leaderboard-tile:first-child {
    color: var(--text);
    font-weight: 600;
    background: transparent;
    padding-bottom: var(--space-1);
}

.leaderboard-tile--me {
    color: var(--text);
    font-weight: 600;
    background: rgba(255, 107, 107, 0.12);
    border: 1px solid rgba(255, 107, 107, 0.35);
    box-shadow: inset 2px 0 0 var(--danger);
}

.minimap {
    position: absolute;
    right: var(--space-4);
    bottom: var(--space-4);
    width: 170px;
    display: flex;
    flex-direction: column;
    border-radius: var(--radius-md);
    pointer-events: none;
    overflow: hidden;
}

.minimap-canvas {
    display: block;
    width: 170px;
    height: 170px;
}

.minimap-coords {
    padding: 6px 8px;
    border-top: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.22);
    font-size: 10px;
    font-weight: 500;
    color: var(--text-muted);
    text-align: center;
    letter-spacing: 0.03em;
    font-variant-numeric: tabular-nums;
}

.chat {
    position: absolute;
    left: var(--space-4);
    bottom: var(--space-4);
    width: 340px;
    height: 248px;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    pointer-events: auto;
}

.chat-content {
    flex: 1;
    display: flex;
    padding: var(--space-3);
    flex-direction: column;
    gap: var(--space-2);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: #1a1a1a #050505;
}

.chat-content::-webkit-scrollbar {
    width: 4px;
}

.chat-content::-webkit-scrollbar-track {
    background: #050505;
    border-radius: 4px;
}

.chat-content::-webkit-scrollbar-thumb {
    background: #1a1a1a;
    border-radius: 4px;
}

.chat-content::-webkit-scrollbar-thumb:hover {
    background: #2a2a2a;
}

.chat-field {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border-top: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
}

.chat-icon {
    font-size: 16px;
    color: var(--text-dim);
    flex-shrink: 0;
}

.chat-input {
    width: 100%;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text);
    font-family: var(--font);
    font-size: 12px;
}

.message-tile {
    width: 100%;
    padding: 6px 8px;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.03);
}

.message-item {
    font-size: 12px;
    font-weight: 500;
}

.message-text {
    display: inline;
    color: var(--text);
    font-weight: 400;
}

.chat-pass {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    margin-right: 5px;
    border-radius: 50%;
    background: #d32f2f;
    color: #ffffff;
    vertical-align: middle;
    flex-shrink: 0;
}

.chat-pass .material-symbols-outlined {
    font-size: 10px;
    font-weight: 700;
}

/* ── Main menu ── */

.main-container {
    position: absolute;
    inset: 0;
    display: flex;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    pointer-events: auto;
    z-index: 5;
}

.anim {
    animation: fade-in 0.18s ease-out;
}

.panel {
    width: min(300px, calc(100vw - 32px));
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    border-radius: var(--radius-lg);
}

.title {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.03em;
    color: var(--text);
    line-height: 1;
}

.panel-subtitle {
    margin: -6px 0 0;
    font-size: 11px;
    color: var(--text-dim);
    font-weight: 400;
}

.panel-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.panel-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.panel-inputs {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.panel-inputs input[type="text"],
.panel-inputs input[type="password"] {
    width: 100%;
    height: 32px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    outline: none;
    color: var(--text);
    background: rgba(255, 255, 255, 0.03);
    font-family: var(--font);
    font-size: 12px;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.panel-inputs input[type="text"]:focus,
.panel-inputs input[type="password"]:focus {
    border-color: var(--border-strong);
    background: rgba(255, 255, 255, 0.05);
}

.panel-pass-input {
    width: 100%;
}

.panel-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.panel-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding-top: 4px;
    border-top: 1px solid var(--border);
}

.panel-footer-btn {
    gap: 5px;
    height: 28px;
    padding: 0 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    background: transparent;
    border: none;
    transition: color 0.15s ease, background 0.15s ease;
}

.panel-footer-btn .material-symbols-outlined {
    font-size: 15px;
    color: var(--text-dim);
}

.panel-footer-btn:hover {
    cursor: pointer;
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
}

.panel-footer-btn:hover .material-symbols-outlined {
    color: var(--text-muted);
}

.button {
    gap: var(--space-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.button:hover {
    cursor: pointer;
    background: var(--accent-soft);
    border-color: var(--border-strong);
}

.button:active {
    transform: scale(0.98);
}

.button--primary {
    width: 100%;
    height: 36px;
    background: var(--accent);
    color: #0a0a0a;
    border-color: transparent;
    font-weight: 600;
    font-size: 12px;
}

.button--primary:hover {
    background: #e8e8e8;
}

.button--ghost {
    width: 100%;
    height: 32px;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    border-color: transparent;
}

.button--ghost:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--border);
}

.button--skin {
    width: 52px;
    height: 52px;
    flex-shrink: 0;
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
    background-color: rgba(255, 255, 255, 0.04);
    overflow: hidden;
    position: relative;
}

.button--skin .skin-fallback {
    font-size: 18px;
    color: var(--text-dim);
}

.button--skin[style*="background-image"] .skin-fallback {
    display: none;
}

#play,
#spectate,
#settings,
#servers,
#skin {
    flex-grow: unset;
    flex-shrink: unset;
}

/* ── Modals ── */

.modal-background {
    width: 100%;
    height: 100%;
    position: absolute;
    backdrop-filter: blur(6px);
    background: rgba(0, 0, 0, 0.5);
}

.modal {
    border-radius: var(--radius-lg);
    background: var(--surface-solid);
    border: 1px solid var(--border);
    position: absolute;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.modal-header {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    box-sizing: border-box;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background 0.15s ease, color 0.15s ease;
}

.modal-close:hover {
    background: var(--accent-soft);
    color: var(--text);
}

.modal-settings-content,
.modal-servers-content {
    width: 100%;
    height: 100%;
    padding: var(--space-4);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    overflow-y: auto;
}

.modal-settings-tile {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
}

.modal-servers-content {
    gap: 4px;
}

.server-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.server-item:last-child {
    border-bottom: none;
}

.server-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.server-item-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    line-height: 1.2;
}

.server-item-host {
    font-size: 10px;
    color: var(--text-dim);
    letter-spacing: 0.02em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.server-item-connect {
    flex-shrink: 0;
    height: 28px;
    padding: 0 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    transition: background 0.15s ease, border-color 0.15s ease;
}

.server-item-connect:hover {
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--border-strong);
}

.modal-profiles-content {
    width: 100%;
    height: 100%;
    padding: var(--space-4);
    box-sizing: border-box;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scrollbar-width: thin;
    scrollbar-color: #1a1a1a #050505;
}

.modal-profiles-content::-webkit-scrollbar {
    width: 4px;
}

.modal-profiles-content::-webkit-scrollbar-track {
    background: #050505;
}

.modal-profiles-content::-webkit-scrollbar-thumb {
    background: #1a1a1a;
    border-radius: 4px;
}

.modal-profiles-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
}

.profile-empty {
    padding: 14px 0;
    font-size: 12px;
    color: var(--text-dim);
    line-height: 1.4;
    text-align: center;
}

.profile-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.profile-card:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--border-strong);
}

.profile-card--active {
    background: rgba(255, 107, 107, 0.1);
    border-color: rgba(255, 107, 107, 0.35);
    box-shadow: inset 2px 0 0 var(--danger);
}

.profile-avatar {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    background-color: rgba(255, 255, 255, 0.04);
}

.profile-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.profile-nick {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-meta {
    font-size: 10px;
    color: var(--text-dim);
}

.profile-pass {
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.profile-no-pass {
    color: var(--text-dim);
    font-style: italic;
}

.round {
    border-radius: 50%;
    border: 1px solid var(--border);
}

input[type="checkbox"] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

#connect-verify-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(7, 10, 18, 0.82);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    justify-content: center;
    align-items: center;
    z-index: 1000;
    pointer-events: auto;
}

#connect-verify {
    color: var(--text);
    text-align: center;
    padding: 28px 32px;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: var(--glass-bg);
    min-width: 280px;
    max-width: min(92vw, 400px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.connect-verify-icon {
    font-size: 42px;
    color: var(--accent);
    display: block;
    margin-bottom: 12px;
}

#connect-verify-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

#connect-verify-text {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 14px;
    line-height: 1.45;
    min-height: 1.45em;
}

.connect-verify-transfer {
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border);
}

.connect-verify-data-stream {
    font-family: Consolas, Monaco, monospace;
    font-size: 11px;
    color: var(--accent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
