* {
    box-sizing: border-box;
}

:root {
    --bg: #090e1b;
    --surface: #11182b;
    --surface-2: #151f37;
    --border: #293653;
    --text: #edf2ff;
    --muted: #8f9bb7;
    --blue: #377dff;
    --red: #d9475f;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 20% 0%, #172448 0, transparent 35%),
        var(--bg);
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
    font: inherit;
}

.topbar {
    min-height: 76px;
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    background: rgba(17, 24, 43, .95);
    border-bottom: 1px solid var(--border);
}

.logo {
    font-weight: 900;
    font-size: 25px;
    letter-spacing: 3px;
}

.tagline {
    margin-top: 2px;
    color: #7f8ca9;
    font-size: 11px;
    letter-spacing: 2px;
}

.player-select {
    display: flex;
    align-items: center;
    gap: 14px;
}

.current-class {
    font-weight: 850;
    font-size: 15px;
    letter-spacing: .5px;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid #3a4869;
    border-radius: 10px;
    padding: 9px 16px;
}

.button.logout {
    padding: 9px 16px;
    border: 1px solid #3b496a;
    border-radius: 10px;
    color: var(--muted);
    background: transparent;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    transition: .15s ease;
}

.button.logout:hover {
    color: white;
    border-color: var(--red);
    background: rgba(217, 71, 95, .12);
}

.container {
    max-width: 1500px;
    margin: 0 auto;
    padding: 26px;
}

.hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
    margin-bottom: 22px;
}

.eyebrow {
    margin: 0 0 5px;
    color: #668fff;
    font-weight: 800;
    font-size: 12px;
    letter-spacing: 2px;
}

h1 {
    margin: 0;
    font-size: clamp(32px, 4vw, 48px);
    line-height: 1;
}

.intro {
    max-width: 720px;
    margin: 12px 0 0;
    color: var(--muted);
    line-height: 1.6;
}

.stat-grid {
    display: flex;
    gap: 10px;
}

.stat-card {
    min-width: 112px;
    padding: 13px 16px;
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
}

.stat-card span {
    display: block;
    font-size: 22px;
    font-weight: 850;
}

.stat-card small {
    color: var(--muted);
}

.game-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 20px;
}

.map-card,
.panel {
    background: rgba(17, 24, 43, .96);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
}

.map-card {
    position: relative;
}

#map {
    height: 670px;
    background: #172033;
}

.map-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    padding: 13px;
}

.button {
    padding: 11px 15px;
    border: 1px solid #3b496a;
    border-radius: 10px;
    color: white;
    background: #1a2540;
    cursor: pointer;
    transition: .15s ease;
}

.button:hover:not(:disabled) {
    transform: translateY(-1px);
    filter: brightness(1.12);
}

.button:disabled {
    opacity: .38;
    cursor: not-allowed;
}

.button.primary {
    background: var(--blue);
    border-color: var(--blue);
    font-weight: 800;
}

.button.danger {
    background: var(--red);
    border-color: var(--red);
    font-weight: 800;
}

.status {
    min-height: 45px;
    padding: 0 15px 15px;
    color: #98a5c2;
    font-size: 13px;
}

.checkpoint-prompt {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: rgba(20, 27, 48, .96);
    border: 1px solid #ffd166;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
    font-size: 13px;
    font-weight: 700;
}

.checkpoint-prompt[hidden] {
    display: none;
}

.checkpoint-prompt .button {
    padding: 8px 14px;
    font-size: 13px;
}

.player-marker-container {
    background: transparent;
    border: 0;
}

.player-marker {
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    border: 3px solid white;
    border-radius: 50%;
    background: var(--blue);
    box-shadow: 0 2px 9px rgba(9, 14, 27, .55);
    font-size: 23px;
    line-height: 1;
}

.checkpoint-marker-container {
    background: transparent;
    border: 0;
}

.checkpoint-marker {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    font-size: 22px;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .5));
}

.gps-dialog {
    width: min(420px, calc(100% - 32px));
    padding: 20px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid #3b496a;
    border-radius: 10px;
    box-shadow: 0 22px 60px rgba(0, 0, 0, .55);
}

.gps-dialog::backdrop {
    background: rgba(2, 6, 15, .7);
}

.gps-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.gps-dialog h2 {
    margin: 0;
    font-size: 19px;
}

.dialog-close {
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    padding: 0;
    color: var(--muted);
    background: transparent;
    border: 0;
    cursor: pointer;
    font-size: 26px;
}

.gps-empty {
    margin: 22px 0 4px;
    color: var(--muted);
}

.gps-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 20px 0 0;
}

.gps-stats div {
    min-width: 0;
    padding: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 7px;
}

.gps-stats dt {
    color: var(--muted);
    font-size: 11px;
}

.gps-stats dd {
    margin: 4px 0 0;
    overflow-wrap: anywhere;
    font-size: 14px;
    font-weight: 750;
}

.gps-dialog-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 18px;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.panel {
    padding: 18px;
}

.panel h2 {
    margin: 0 0 14px;
    font-size: 18px;
}

.panel-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-title span {
    color: #71e0a1;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.rank {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #25304a;
}

.rank:last-child {
    border-bottom: 0;
}

.rank-number {
    width: 25px;
    color: #8997b8;
    font-size: 17px;
    font-weight: 900;
}

.rank-name {
    flex: 1;
    font-weight: 750;
}

.rank-name small {
    display: block;
    margin-top: 3px;
    color: #7f8ca8;
    font-size: 11px;
    font-weight: 400;
}

.rank-area {
    font-size: 13px;
    font-weight: 800;
}

.online-badge {
    color: #71e0a1;
    font-weight: 700;
}

.loading,
.empty {
    color: var(--muted);
    font-size: 13px;
}

.rules {
    margin: 0;
    padding-left: 22px;
    color: #a2aec7;
    line-height: 1.75;
}

.rules strong {
    color: white;
}

.privacy {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: 18px;
    padding: 12px;
    border: 1px solid #293653;
    border-radius: 10px;
    background: #0d1426;
    font-size: 12px;
    line-height: 1.5;
}

.privacy span {
    color: var(--muted);
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
    background: #11182b;
    color: white;
}

/* ---- Class picker overlay ---- */
.class-picker {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background:
        radial-gradient(circle at 30% 20%, rgba(55, 125, 255, .18) 0, transparent 45%),
        radial-gradient(circle at 80% 80%, rgba(217, 71, 95, .12) 0, transparent 45%),
        rgba(6, 10, 20, .82);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.class-picker[hidden] {
    display: none;
}

.class-picker-card {
    width: 100%;
    max-width: 560px;
    padding: 34px 32px 28px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .55);
    text-align: center;
}

.class-picker-logo {
    font-weight: 900;
    font-size: 15px;
    letter-spacing: 4px;
    color: #668fff;
    margin-bottom: 10px;
}

.class-picker-card h2 {
    margin: 0 0 8px;
    font-size: 26px;
    font-weight: 850;
}

.class-picker-card>p {
    margin: 0 0 22px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.55;
}

.class-picker-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 22px;
}

.class-chip {
    padding: 14px 10px;
    border: 1px solid #3a4869;
    border-radius: 12px;
    background: var(--surface-2);
    color: var(--text);
    font-weight: 800;
    font-size: 15px;
    letter-spacing: .5px;
    cursor: pointer;
    transition: .15s ease;
}

.class-chip:hover {
    transform: translateY(-1px);
    border-color: #4a5a80;
    filter: brightness(1.1);
}

.class-chip.selected {
    background: var(--blue);
    border-color: var(--blue);
    color: white;
    box-shadow: 0 6px 18px rgba(55, 125, 255, .35);
}

.class-picker-card .button.primary {
    width: 100%;
    padding: 14px;
    font-size: 15px;
}

@media (max-width: 520px) {
    .class-picker-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .class-picker-card {
        padding: 26px 20px 22px;
    }
}

@media (max-width: 950px) {
    .game-layout {
        grid-template-columns: 1fr;
    }

    .hero {
        display: block;
    }

    .stat-grid {
        margin-top: 16px;
    }

    #map {
        height: 58vh;
        min-height: 450px;
    }
}

@media (max-width: 600px) {
    .topbar {
        padding: 13px 15px;
        align-items: flex-start;
    }

    .player-select {
        display: block;
    }

    .container {
        padding: 15px;
    }

    .logo {
        font-size: 21px;
    }

    .tagline {
        display: none;
    }

    .stat-card {
        min-width: 0;
        flex: 1;
    }

    .stat-grid {
        width: 100%;
    }

    .map-controls .button {
        flex: 1 1 auto;
    }
}