/* ===== Reset & Base ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #0a0a0a;
    --bg-card: #1a1a1a;
    --bg-input: #252525;
    --text: #ffffff;
    --text-dim: #999;
    --accent: #0077C8; /* WMATA Blue */
    --accent-hover: #339dd8;
    --accent-text: #fff; /* White text on blue buttons */
    --wmata-red: #BF0D3E;
    --wmata-orange: #ED8B00;
    --wmata-blue: #0077C8;
    --wmata-green: #00B140;
    --wmata-yellow: #FFD100;
    --wmata-silver: #A2A4A1;
    --red: #BF0D3E;
    --border: #333;
    --radius: 12px;
    --radius-sm: 8px;
}

html, body {
    height: 100vh;
    height: 100dvh;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

/* ===== Layout ===== */
#app {
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* ===== Header ===== */
#header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--bg-card);
    border-bottom: 2px solid var(--accent);
    z-index: 100;
    flex-shrink: 0;
}

.logo {
    font-size: 1.4rem;
    font-weight: 900;
    letter-spacing: -0.5px;
}

.logo-where {
    color: var(--text);
}

.logo-mata {
    color: var(--accent);
}

.header-info {
    display: flex;
    gap: 16px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-dim);
}

#score-display {
    color: var(--accent);
}

/* ===== Screens ===== */
.screen {
    display: none;
    flex: 1;
    overflow-y: auto;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* ===== Start Screen ===== */
#start-screen {
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 24px;
}

.start-content h1 {
    font-size: 3rem;
    margin-bottom: 8px;
}

.start-content h1 .logo-where { color: var(--text); }
.start-content h1 .logo-mata { color: var(--accent); }

.tagline {
    color: var(--text-dim);
    font-size: 1.1rem;
    margin-bottom: 32px;
}

.how-to-play {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    text-align: left;
    margin: 0 auto 32px auto;
    max-width: 400px;
}

.how-to-play h3 {
    margin-bottom: 12px;
    color: var(--accent);
}

.how-to-play ul {
    list-style: none;
}

.how-to-play li {
    padding: 6px 0;
    font-size: 0.95rem;
    color: var(--text-dim);
}

.cross-promo {
    color: var(--text-dim);
    font-size: 0.95rem;
    margin-bottom: 24px;
}

.cross-link {
    color: var(--text);
    text-decoration: underline;
    font-weight: 600;
}

.cross-link:hover {
    color: var(--accent);
}

.daily-note {
    margin-top: 16px;
    color: var(--text-dim);
    font-size: 0.85rem;
}

.alpha-disclosure {
    margin-top: 12px;
    color: #666;
    font-size: 0.75rem;
    letter-spacing: 0.3px;
}

.alpha-highlight {
    color: var(--accent);
    font-weight: 600;
}

.alpha-link {
    color: var(--text);
    text-decoration: underline;
    font-weight: 600;
}

.alpha-link:hover {
    color: var(--accent);
}

/* ===== Buttons ===== */
.btn {
    border: none;
    padding: 14px 28px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent);
    color: var(--accent-text);
}

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

.btn-secondary {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: #333;
}

/* ===== Game Screen ===== */
#game-screen {
    flex-direction: column;
}

#map-container {
    flex: 1;
    position: relative;
    min-height: 0;
}

#map {
    width: 100%;
    height: 100%;
}

.mapboxgl-ctrl-bottom-left,
.mapboxgl-ctrl-bottom-right,
.mapboxgl-ctrl-top-left,
.mapboxgl-ctrl-top-right {
    display: none !important;
}

/* ===== Station Arrow Marker ===== */
.station-arrow {
    color: #0077C8;
    font-size: 28px;
    text-shadow: 0 0 6px rgba(0,0,0,0.8), 0 2px 4px rgba(0,0,0,0.5);
    line-height: 1;
    pointer-events: none;
}

#zoom-badge {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: var(--accent);
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.9rem;
    z-index: 10;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(0,119,200,0.3);
}

#game-controls {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 16px 20px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    flex-shrink: 0;
}

#guess-section {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.input-wrapper {
    flex: 1;
    position: relative;
}

#guess-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.15s;
}

#guess-input:focus {
    border-color: var(--accent);
}

#guess-input::placeholder {
    color: #555;
}

/* ===== Autocomplete ===== */
.autocomplete-list {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    max-height: 240px;
    overflow-y: auto;
    z-index: 50;
    margin-bottom: 4px;
}

.autocomplete-list.visible {
    display: block;
}

.autocomplete-item {
    padding: 10px 16px;
    cursor: pointer;
    font-size: 0.95rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    transition: background 0.1s;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
    background: var(--accent);
    color: #fff;
}

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

/* ===== Line Badges ===== */
.line-badge {
    display: inline-block;
    width: 22px;
    height: 22px;
    line-height: 22px;
    text-align: center;
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: 700;
    margin-left: 2px;
    vertical-align: middle;
}

.ac-name {
    vertical-align: middle;
}

.autocomplete-item .line-badge {
    width: 18px;
    height: 18px;
    line-height: 18px;
    font-size: 0.6rem;
}

.breakdown-name .line-badge {
    width: 20px;
    height: 20px;
    line-height: 20px;
    font-size: 0.65rem;
}

#action-buttons {
    display: flex;
    gap: 10px;
}

#zoom-in-btn,
#zoom-out-btn {
    flex: 1;
}

#guess-btn {
    padding: 12px 24px;
}

#zoom-bonus-indicator {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-top: 8px;
}

#zoom-bonus-indicator strong {
    color: var(--accent);
}

/* ===== Round Result ===== */
#round-result {
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 24px;
}

.result-content {
    max-width: 500px;
    width: 100%;
}

.result-emoji {
    font-size: 4rem;
    margin-bottom: 12px;
}

.result-content h2 {
    font-size: 1.6rem;
    margin-bottom: 8px;
}

#result-station {
    color: var(--text-dim);
    font-size: 1.1rem;
    margin-bottom: 4px;
}

#result-points {
    color: var(--accent);
    font-weight: 700;
    font-size: 1.2rem;
    margin-bottom: 20px;
}

#result-map-container {
    width: 100%;
    height: 200px;
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

#result-map {
    width: 100%;
    height: 100%;
}

/* ===== Final Results ===== */
#results-screen {
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 24px;
}

.results-content {
    max-width: 500px;
    width: 100%;
}

.results-content h1 {
    margin-bottom: 16px;
}

.final-score {
    font-size: 3rem;
    font-weight: 900;
    color: var(--accent);
    margin-bottom: 24px;
}

#results-breakdown {
    margin-bottom: 24px;
}

.breakdown-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.breakdown-station {
    text-align: left;
}

.breakdown-name {
    font-weight: 600;
}

.breakdown-detail {
    font-size: 0.85rem;
    color: var(--text-dim);
}

.breakdown-score {
    font-size: 1.4rem;
    font-weight: 700;
}

.breakdown-score.correct {
    color: var(--accent);
}

.breakdown-score.wrong {
    color: var(--red);
}

#share-section {
    margin-bottom: 24px;
}

.share-copied {
    color: var(--accent);
    font-size: 0.9rem;
    margin-top: 8px;
    opacity: 0;
    transition: opacity 0.3s;
}

.share-copied.visible {
    opacity: 1;
}

#next-game-timer {
    color: var(--text-dim);
    font-size: 0.95rem;
}

#countdown {
    color: var(--accent);
    font-weight: 700;
}

/* ===== Leaderboard Entry Screen ===== */
#leaderboard-entry-screen {
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 24px;
}

.lb-entry-content {
    max-width: 400px;
    width: 100%;
}

.lb-entry-emoji {
    font-size: 4rem;
    margin-bottom: 12px;
}

.lb-entry-content h2 {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.lb-entry-score {
    color: var(--text-dim);
    font-size: 1.1rem;
    margin-bottom: 24px;
}

.lb-entry-score strong {
    color: var(--accent);
    font-size: 1.3rem;
}

.lb-entry-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#lb-name-input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
    letter-spacing: 1px;
    outline: none;
    transition: border-color 0.15s;
}

#lb-name-input:focus {
    border-color: var(--accent);
}

#lb-name-input::placeholder {
    color: #555;
    font-weight: 400;
    letter-spacing: 0;
}

.lb-name-hint {
    color: var(--text-dim);
    font-size: 0.8rem;
    margin-top: -4px;
}

/* ===== Leaderboard Display (Results Screen) ===== */
.leaderboard-section {
    margin-bottom: 20px;
}

.lb-rank-display {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 12px;
    font-size: 0.95rem;
    color: var(--text-dim);
}

.lb-rank-display .lb-rank-number {
    color: var(--accent);
    font-weight: 700;
    font-size: 1.1rem;
}

.lb-top5 {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.lb-top5-title {
    padding: 10px 16px;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--border);
}

.lb-top5-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    font-size: 0.95rem;
}

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

.lb-top5-row.lb-highlight {
    background: rgba(0, 119, 200, 0.08);
}

.lb-top5-rank {
    width: 28px;
    font-weight: 700;
    color: var(--text-dim);
}

.lb-top5-rank.gold { color: #ffd700; }
.lb-top5-rank.silver { color: #c0c0c0; }
.lb-top5-rank.bronze { color: #cd7f32; }

.lb-top5-name {
    flex: 1;
    font-weight: 600;
    margin-left: 8px;
}

.lb-top5-score {
    font-weight: 700;
    color: var(--accent);
}

.lb-loading {
    text-align: center;
    padding: 16px;
    color: var(--text-dim);
    font-size: 0.9rem;
}

.lb-error {
    text-align: center;
    padding: 12px;
    color: var(--red);
    font-size: 0.85rem;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 3px;
}

/* ===== Mobile ===== */
@media (max-width: 600px) {
    .start-content h1 {
        font-size: 2.2rem;
    }

    .tagline {
        font-size: 0.95rem;
    }

    #header {
        padding: 10px 16px;
    }

    .logo {
        font-size: 1.2rem;
    }

    #game-controls {
        padding: 12px 16px;
    }

    #guess-section {
        flex-direction: column;
    }

    #guess-btn {
        width: 100%;
    }
}
