/**
 * US States Tap Trainer - Mobile-first CSS
 * Dark mode default with high-contrast colors
 */

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #1a1a1a;
    color: #ffffff;
    overflow: hidden;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Game container */
#game-container {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
}

/* Welcome message */
#welcome-message {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #38b000;
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 18px;
    font-weight: bold;
    z-index: 2000;
    animation: slideDown 0.5s ease-out, fadeOut 0.5s ease-out 2.5s forwards;
    box-shadow: 0 4px 12px rgba(56, 176, 0, 0.4);
}

@keyframes slideDown {
    from {
        top: -50px;
        opacity: 0;
    }
    to {
        top: 20px;
        opacity: 1;
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
        visibility: hidden;
    }
}

/* Top bar */
#top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background-color: rgba(26, 26, 26, 0.95);
    backdrop-filter: blur(10px);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    border-bottom: 2px solid #333;
    min-height: 60px;
}

#state-prompt {
    font-size: 18px;
    flex: 1;
}

#current-state {
    font-weight: bold;
    color: #38b000;
    font-size: 20px;
}

#progress {
    font-size: 16px;
    margin: 0 16px;
    color: #aaa;
}

#timer {
    font-size: 16px;
    font-family: monospace;
    color: #38b000;
}

/* Score dropdown */
#score-dropdown {
    position: relative;
}

#score-toggle {
    background-color: #38b000;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s;
}

#score-toggle:hover {
    background-color: #2d8f00;
}

/* Score panel */
#score-panel {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    width: 250px;
    background-color: rgba(26, 26, 26, 0.95);
    backdrop-filter: blur(10px);
    border: 2px solid #38b000;
    border-radius: 8px;
    padding: 16px;
    z-index: 1001;
    transition: all 0.3s ease;
    max-height: 400px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

#score-panel.collapsed {
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
}

#score-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.score-item {
    background-color: rgba(56, 176, 0, 0.1);
    border: 1px solid #38b000;
    border-radius: 4px;
    padding: 8px;
    font-size: 14px;
}

.score-item .date {
    color: #aaa;
    font-size: 12px;
}

.score-item .score {
    font-weight: bold;
    color: #38b000;
}

.score-item .time {
    color: #888;
    font-size: 12px;
}


/* Game controls */
#game-controls {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 12px;
    z-index: 999;
}

#game-controls button {
    background-color: #3388ff;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(51, 136, 255, 0.3);
}

#game-controls button:hover {
    background-color: #2266dd;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(51, 136, 255, 0.4);
}

#game-controls button:active {
    transform: translateY(0);
}

/* Map container */
#map {
    position: fixed;
    inset: 0;
    z-index: 1;
}

/* History view */
#history-view {
    position: fixed;
    inset: 0;
    background-color: #1a1a1a;
    padding: 20px;
    overflow-y: auto;
    z-index: 2000;
}

#history-view h2 {
    font-size: 24px;
    margin-bottom: 20px;
    color: #38b000;
}

#back-to-game {
    background-color: #3388ff;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    margin-bottom: 20px;
    transition: background-color 0.3s;
}

#back-to-game:hover {
    background-color: #2266dd;
}

#back-to-game:active {
    transform: scale(0.95);
}

/* History content */
#history-content {
    max-width: 600px;
    margin: 0 auto;
}

#history-chart {
    margin-bottom: 30px;
    max-height: 300px;
}

/* History table */
#history-table table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

#history-table th,
#history-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #333;
}

#history-table th {
    background-color: #2a2a2a;
    color: #38b000;
    font-weight: bold;
}

#history-table tr:hover {
    background-color: #2a2a2a;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    #score-panel {
        width: 200px;
        font-size: 12px;
        right: -50px;
    }
    
    .score-item {
        font-size: 12px;
        padding: 6px;
    }
    
    #score-toggle {
        font-size: 12px;
        padding: 4px 8px;
    }
    
    #top-bar {
        padding: 8px 12px;
        min-height: auto;
    }
    
    #state-prompt {
        font-size: 16px;
    }
    
    #current-state {
        font-size: 18px;
    }
    
    #progress,
    #timer {
        font-size: 14px;
    }
    
    #game-controls {
        bottom: 10px;
    }
    
    #game-controls button {
        font-size: 12px;
        padding: 8px 16px;
    }
}

/* Landscape mode adjustments */
@media (max-height: 500px) {
    #score-panel {
        max-height: 300px;
    }
    
    #top-bar {
        padding: 4px 12px;
        min-height: auto;
    }
    
    #state-prompt {
        font-size: 14px;
    }
    
    #current-state {
        font-size: 16px;
    }
    
    #progress,
    #timer {
        font-size: 12px;
    }
    
    #score-toggle {
        font-size: 12px;
        padding: 4px 8px;
    }
}

/* Custom Leaflet overrides for better mobile experience */
.leaflet-container {
    background: #1a1a1a;
    font-family: inherit;
}

.leaflet-popup-content-wrapper {
    background: rgba(26, 26, 26, 0.9);
    color: white;
}

.leaflet-popup-tip {
    background: rgba(26, 26, 26, 0.9);
}

/* State labels */
.state-label {
    background: none;
    border: none;
    font-weight: bold;
    font-size: 12px;
    text-align: center;
    white-space: nowrap;
    pointer-events: none;
}

.state-label div {
    color: white;
    text-shadow: 
        1px 1px 2px rgba(0, 0, 0, 0.8),
        -1px -1px 2px rgba(0, 0, 0, 0.8),
        1px -1px 2px rgba(0, 0, 0, 0.8),
        -1px 1px 2px rgba(0, 0, 0, 0.8);
}

/* Prevent iOS bounce effect */
html,
body {
    position: fixed;
    overflow: hidden;
    width: 100%;
    height: 100%;
}