:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --bg-color: #0f172a;
    --text-color: #f8fafc;
    --glass-bg: rgba(15, 23, 42, 0.75);
    --glass-border: rgba(255, 255, 255, 0.1);
    --success: #10b981;
    --error: #ef4444;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow: hidden; /* Prevent scrolling, map takes full screen */
}

#map {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
}

.ui-container {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 1000;
    width: 400px;
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 24px;
    border-radius: 16px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
}

.glass {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
}

.title {
    font-size: 24px;
    font-weight: 800;
    text-align: center;
    background: linear-gradient(135deg, #a5b4fc 0%, #6366f1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 10px;
}

.stats {
    display: flex;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 15px;
}

.stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #94a3b8;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 20px;
    font-weight: 600;
}

.city-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 5px;
}

.city-dropdown {
    padding: 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-color);
    font-size: 16px;
    font-family: inherit;
    outline: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.city-dropdown:focus {
    border-color: var(--primary-color);
}

.city-dropdown option {
    background-color: var(--bg-color);
    color: var(--text-color);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

input[type="text"] {
    width: 100%;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-color);
    font-size: 16px;
    font-family: inherit;
    outline: none;
    transition: all 0.2s ease;
}

input[type="text"]:focus {
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.3);
}

input[type="text"]::placeholder {
    color: #64748b;
}

.btn {
    padding: 14px;
    border: none;
    border-radius: 8px;
    background: var(--primary-color);
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.message {
    min-height: 24px;
    font-size: 14px;
    text-align: center;
    font-weight: 600;
    transition: color 0.3s;
}

.message.success { color: var(--success); }
.message.error { color: var(--error); }
.message.loading { color: #facc15; }

.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--glass-border);
    padding-top: 15px;
}

.test-mode-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
    color: #cbd5e1;
}

.test-mode-label input {
    cursor: pointer;
}

.guessed-list-container {
    flex-grow: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.guessed-list {
    list-style: none;
    overflow-y: auto;
    padding-right: 5px;
    max-height: 150px;
    margin-top: 8px;
}

.guessed-list li {
    padding: 8px;
    background: rgba(255, 255, 255, 0.05);
    margin-bottom: 4px;
    border-radius: 6px;
    font-size: 14px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05); 
    border-radius: 4px;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2); 
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3); 
}

/* ---------- User bar ---------- */
.user-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: -10px;
}

.user-info {
    font-size: 14px;
    color: #cbd5e1;
}

.user-info strong {
    color: #a5b4fc;
}

.user-actions {
    display: flex;
    gap: 6px;
}

.btn-small {
    padding: 8px 12px;
    font-size: 12px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ---------- Modals ---------- */
.overlay {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(2, 6, 23, 0.6);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    animation: fadeIn 0.25s ease;
}

.overlay.hidden {
    display: none;
}

.modal {
    width: 100%;
    max-width: 420px;
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 28px;
    border-radius: 18px;
    background: rgba(15, 23, 42, 0.92);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(99, 102, 241, 0.15);
    animation: popIn 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.modal-wide {
    max-width: 680px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 22px;
    font-weight: 800;
    background: linear-gradient(135deg, #a5b4fc 0%, #6366f1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.modal-sub {
    font-size: 14px;
    color: #94a3b8;
    margin-bottom: 6px;
}

.modal label.stat-label {
    margin-top: 6px;
    margin-bottom: 0;
}

input[type="password"] {
    width: 100%;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-color);
    font-size: 18px;
    letter-spacing: 4px;
    font-family: inherit;
    outline: none;
    transition: all 0.2s ease;
}

input[type="password"]:focus {
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.3);
}

.warning-box {
    margin-top: 8px;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.5;
    color: #fde68a;
    background: rgba(250, 204, 21, 0.08);
    border: 1px solid rgba(250, 204, 21, 0.35);
}

@keyframes popIn {
    from { opacity: 0; transform: scale(0.94) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ---------- Leaderboard ---------- */
.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 6px 0;
}

.tab {
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.05);
    color: #cbd5e1;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab:hover {
    background: rgba(255, 255, 255, 0.12);
}

.tab.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

.lb-content {
    overflow-y: auto;
    min-height: 120px;
}

.lb-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.lb-table th {
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #94a3b8;
    padding: 8px;
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    background: rgba(15, 23, 42, 0.98);
}

.lb-table td {
    padding: 10px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.lb-table tr {
    animation: fadeIn 0.3s ease both;
}

.lb-table tr.me td {
    background: rgba(99, 102, 241, 0.15);
}

.rank {
    font-weight: 800;
    width: 40px;
}

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.badge.won { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.badge.timeout { background: rgba(250, 204, 21, 0.12); color: #facc15; }
.badge.abandoned { background: rgba(239, 68, 68, 0.15); color: var(--error); }
.badge.restarted { background: rgba(148, 163, 184, 0.15); color: #cbd5e1; }
.badge.in_progress { background: rgba(99, 102, 241, 0.2); color: #a5b4fc; }

.lb-empty {
    text-align: center;
    color: #94a3b8;
    padding: 30px 0;
    font-size: 14px;
}
