:root {
    --primary: #FF4B55;
    --accent: #4B9FFF;
    --dark: #0F172A;
    --surface: #1e293b;
    --border: #334155;
    --text: #F8FAFC;
    --text-muted: #94A3B8;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--dark);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}

#app {
    position: relative;
    width: 100vw;
    height: 100vh;
}

#map {
    width: 100%;
    height: 100%;
    z-index: 1;
    background: #1a1a1a;
}

.ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    pointer-events: none;
    display: flex;
    flex-direction: column;
}

.header {
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--dark);
    border-bottom: 1px solid var(--border);
    pointer-events: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand h1 {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.dot {
    width: 10px;
    height: 10px;
    background: var(--primary);
    border-radius: 50%;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.icon-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid var(--border);
    color: var(--text);
    width: 36px;
    height: 36px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

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

.hint-btn {
    background: rgba(255,255,255,0.1);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.hint-btn:hover {
    background: rgba(255,255,255,0.15);
}

.hint-popup {
    position: absolute;
    top: 70px;
    right: 16px;
    background: var(--surface);
    border: 1px solid var(--accent);
    padding: 16px;
    border-radius: 8px;
    max-width: 250px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    pointer-events: auto;
    z-index: 1100;
}

.status-badge {
    position: absolute;
    top: 70px;
    left: 16px;
    background: rgba(75, 159, 255, 0.1);
    border: 1px solid rgba(75, 159, 255, 0.3);
    color: var(--accent);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: auto;
}

.timer-badge {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 16px;
    border-radius: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.2rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: auto;
    backdrop-filter: blur(4px);
}

.pulse {
    width: 6px;
    height: 6px;
    background: currentColor;
    border-radius: 50%;
    opacity: 0.8;
}

.controls {
    flex: 1;
    display: flex;
    align-items: flex-end;
    padding: 20px;
    padding-bottom: 40px;
    pointer-events: none;
}

.controls.victory-mode {
    align-items: center;
    justify-content: center;
    padding-bottom: 0;
    background: rgba(0,0,0,0.5);
    pointer-events: auto;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    width: 100%;
    max-width: 380px;
    pointer-events: auto;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
}

.controls.victory-mode .card {
    max-width: 450px;
    border-color: #10b981;
}

.card h2 {
    font-size: 1.1rem;
    margin-bottom: 6px;
    color: var(--text);
}

.mission-brief {
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.4;
    margin-bottom: 16px;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.stats-grid.single-col {
    grid-template-columns: 1fr;
}

.controls.victory-mode .stats-grid.single-col {
    grid-template-columns: 1fr 1fr 1fr;
}

.stat {
    background: var(--dark);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    text-align: center;
}

.stat label {
    display: block;
    color: var(--text-muted);
    font-size: 0.7rem;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.stat span {
    font-size: 1.1rem;
    font-weight: 600;
}

#finalTimeStat span {
    color: #10b981;
    font-family: 'JetBrains Mono', monospace;
}

.rank-badge {
    color: #F59E0B;
}

.primary-btn {
    width: 100%;
    background: var(--primary);
    color: white;
    border: none;
    padding: 14px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.primary-btn:hover {
    opacity: 0.9;
}

/* NEW INPUT STYLES */
.input-group {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    margin-bottom: 16px;
}

#playerNameInput {
    flex: 1;
    background: var(--dark);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 12px;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

#playerNameInput:focus {
    border-color: var(--primary);
}

#submitScoreBtn {
    width: auto;
    padding: 0 20px;
}

.share-btn {
    width: 100%;
    background: #5865F2;
    color: white;
    border: none;
    padding: 14px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
}

.share-btn:hover {
    opacity: 0.9;
}

.feedback-message {
    margin-top: 12px;
    padding: 10px;
    border-radius: 8px;
    background: rgba(255,255,255,0.05);
    text-align: center;
    font-weight: 500;
    font-size: 0.85rem;
}

.feedback-message.hidden {
    display: none;
}

.card-footer {
    margin-top: 16px;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 1px;
    text-transform: lowercase;
    opacity: 0.5;
}

.hidden {
    display: none !important;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 3000; /* Higher z-index than everything else */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    pointer-events: auto; /* Ensure clicks work */
}

.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
    padding: 24px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    pointer-events: auto;
}

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

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.tab-btn {
    background: rgba(255,255,255,0.05);
    border: none;
    color: var(--text-muted);
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    white-space: nowrap;
}

.tab-btn.active {
    background: var(--primary);
    color: white;
}

.leaderboard-list {
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    min-height: 150px;
    max-height: 300px;
    overflow-y: auto;
    padding: 8px;
}

.score-row {
    display: flex;
    justify-content: space-between;
    padding: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    font-size: 0.9rem;
}

.score-row:last-child {
    border-bottom: none;
}

.score-time {
    font-family: 'JetBrains Mono', monospace;
    color: #10b981;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 0;
    font-style: italic;
    font-size: 0.9rem;
}

/* Leaflet Overrides */
.leaflet-popup-content-wrapper {
    background: var(--surface);
    color: var(--text);
    border-radius: 8px;
    font-size: 12px;
}
.leaflet-popup-tip {
    background: var(--surface);
}
.custom-div-icon {
    background: transparent;
    border: none;
}

@media (max-width: 600px) {
    .controls {
        padding: 12px;
    }
    
    .status-badge {
        top: 60px;
    }

    .timer-badge {
        bottom: auto;
        top: 110px;
        left: 16px;
        right: auto;
        font-size: 1rem;
        padding: 6px 12px;
    }
    
    .controls.victory-mode .stats-grid.single-col {
        grid-template-columns: 1fr;
    }
}