/* CSS Variables */
:root {
    --font-primary: 'IBM Plex Mono', 'Courier New', monospace;
    --font-fallback: 'Courier New', monospace;
}

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

body {
    font-family: var(--font-primary);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

/* Fixed Score and Round Displays */
.score-display-fixed {
    position: fixed;
    top: 20px;
    left: 20px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.round-display-fixed {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

/* Game Container */
.game-container {
    margin: 0 auto;
    height: 100svh;
    width: 100vw;
    display: flex;
    flex-direction: column;
    background: white;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

/* Color Display Area */
.color-display {
    flex: 0 0 auto;
    height: 40svh;
    min-height: 200px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ff6b6b;
    transition: background-color 0.3s ease;
}

.overlay-content {
    text-align: center;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    margin-top: 35px;
    padding: 3rem;
}

.game-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: -0.025em;
}

.instruction {
    font-size: 1rem;
    opacity: 0.9;
    font-weight: 500;
}

/* Controls Bar */
.controls-bar {
    flex: 0 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.75rem 1rem;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

/* Styles for fixed score/round displays */
.score-display-fixed .score-label, 
.round-display-fixed .round-label {
    font-weight: 600;
    color: #64748b;
    font-size: 0.875rem;
}

.score-display-fixed .score-value, 
.round-display-fixed .round-value {
    font-weight: 700;
    color: #1e293b;
    font-size: 1.125rem;
}

/* Color Heatmap Container */
.heatmap-container {
    flex: 1 1 auto;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    width: 100%;
    overflow: hidden;
}

.color-heatmap {
    width: 100%;
    height: 100%;
    cursor: crosshair;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    touch-action: none;
}

/* Color Preview Tooltip */
.color-preview {
    position: fixed;
    pointer-events: none;
    width: 40px;
    height: 40px;
    border: 3px solid white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 100;
    transform: translate(-50%, -50%) rotate(-45deg);
    display: none;
    border-radius: 50% 50% 50% 0;
}

.color-preview.show {
    display: block;
}

/* Mobile Touch Indicator */
.touch-indicator {
    position: fixed;
    pointer-events: none;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 100;
    transform: translate(-50%, -50%);
    display: none;
}

.touch-indicator.show {
    display: block;
}

/* Confirm Button for Mobile */
.confirm-placement {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 1px solid #ffffff;
    background: #fffff04f;
    backdrop-filter: blur(4px);
    color: white;
    padding: 12px 24px;
    font-family: var(--font-primary);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    display: none;
    z-index: 200;
    transition: opacity 0.3s ease;
    opacity: 1;
}

.confirm-placement.show {
    display: block;
}

.confirm-placement.fading {
    opacity: 0.1;
}

.confirm-placement:active {
    transform: translate(-50%, -50%) scale(0.95);
}

/* Result Stats Container */
.result-stats {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 2rem;
}

/* Color Positions in Modal */
.result-details {
    margin: 2rem 0;
}

.color-positions {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 4px;
}

.position-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    padding: 1rem;
}

#actual {
    background-color: var(--actual-color);
    color: white;
}

#your-guess {
    background-color: var(--guess-color);
    color: white;
}

.position-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.actual-dot {
    background: var(--actual-color);
}

.guess-dot {
    background: var(--guess-color);
}

.position-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: inherit;
}

/* Game Over Modal Styles */
.final-score, .mean-distance {
    margin-bottom: 1.5rem;
    text-align: center;
}

.final-score .score-label, .mean-distance .mean-distance-label {
    font-size: 0.875rem;
    color: #64748b;
    font-weight: 600;
}

.final-score .score-value {
    font-size: 3rem;
    font-weight: 700;
    color: #10b981;
}

.mean-distance .mean-distance-value {
    font-size: 2rem;
    font-weight: 700;
    color: #3b82f6;
}

.high-score {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #fef3c7;
    text-align: center;
    font-weight: 600;
    color: #92400e;
}

/* Reuse .game-over-controls for High Scores actions */
.game-over-controls {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1rem;
}

.scores-list {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 2rem;
    margin-top: 1rem;
    padding-right: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.scores-list::-webkit-scrollbar {
    width: 6px;
}

.scores-list::-webkit-scrollbar-track {
    background: #f1f5f900;
}

.scores-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
}

.scores-list::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.score-entry {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding-left: 10px;
    background: #f8fafc;
    border-left: 4px solid #3b82f6;
}

.score-entry.current {
    border-left-color: #10b981;
    background: #f0fdf4;
}

.score-placement {
    font-weight: 700;
    color: #64748b;
    font-size: 0.875rem;
    min-width: 2rem;
}

.score-separator {
    color: #cbd5e1;
    font-weight: 600;
    font-size: 0.875rem;
}

.score-details {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.score-date {
    font-size: 0.6rem;
    color: #64748b;
}

.score-points {
    font-weight: 700;
    color: #1e293b;
    font-size: 0.875rem;
}

.score-mean-distance {
    font-size: 0.75rem;
    color: #3b82f6;
    font-weight: 600;
}

.colors-container {
    display: flex;
    gap: 0px;
    align-items: center;
}

.score-colors {
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: center;
    padding: 0.25rem;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.color-square {
    width: 18px;
    height: 18px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Control Buttons in Score Container */
.control-buttons {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    font-family: var(--font-primary);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;
}

.btn-primary {
    background: #3b82f6;
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
}

.btn-primary:active {
    transform: scale(0.95);
    background: #1d4ed8;
}

.btn-secondary {
    background: rgba(241, 245, 249, 0.9);
    color: #64748b;
    backdrop-filter: blur(4px);
}

.btn-secondary:hover {
    background: rgba(226, 232, 240, 0.9);
    color: #475569;
}

.btn-secondary:active {
    transform: scale(0.95);
}

.btn-destructive {
    background: #dc2626;
    color: white;
}

.btn-destructive:hover {
    background: #b91c1c;
}

.btn-destructive:active {
    transform: scale(0.95);
    background: #991b1b;
}

.btn-destructive.confirm-state {
    background: #ea580c;
    animation: pulse-warning 1.5s infinite;
}

.btn-destructive.confirm-state:hover {
    background: #c2410c;
}

.btn-destructive.confirm-state:active {
    transform: scale(0.95);
    background: #9a3412;
}

@keyframes pulse-warning {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(234, 88, 12, 0.7);
    }
    50% {
        transform: scale(1.02);
        box-shadow: 0 0 0 4px rgba(234, 88, 12, 0.3);
    }
}

/* Result Modal */
.result-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.result-modal.show {
    display: flex;
}

.result-content {
    background: white;
    padding: 2rem;
    text-align: center;
    margin: 1rem;
    max-width: 450px;
    width: 100%;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

/* Updated result styles */
.result-distance {
    font-size: 3rem;
    font-weight: 700;
    color: #1e293b;
}

.result-score {
    font-size: 1.25rem;
    font-weight: 600;
    color: #10b981;
    margin: 0;
}

/* Responsive Design */
@media (max-width: 480px) {
    .color-display {
        height: 35svh;
        min-height: 150px;
    }
    
    .heatmap-container {
        min-height: 250px;
    }
    
    .game-title {
        font-size: 1.75rem;
    }
    
    .instruction {
        font-size: 0.875rem;
    }
    
    .score-display-fixed, .round-display-fixed {
        padding: 0.5rem 0.75rem;
        top: 15px;
    }
    
    .score-display-fixed {
        left: 15px;
    }
    
    .round-display-fixed {
        right: 15px;
    }
    
    .control-buttons {
        gap: 0.5rem;
        justify-content: center;
    }

    .controls-bar {
        padding: 0.5rem 0.75rem;
    }
    
    .btn {
        padding: 0.625rem 1.25rem;
        font-size: 0.8rem;
    }
    
    .confirm-placement {
        padding: 10px 20px;
        font-size: 0.8rem;
    }
}

@media (max-width: 360px) {
    .color-display {
        height: 45svh;
        min-height: 120px;
    }
    
    .heatmap-container {
        min-height: 200px;
    }
    
    .score-display-fixed, .round-display-fixed {
        padding: 0.5rem 0.625rem;
        top: 10px;
    }
    
    .score-display-fixed {
        left: 10px;
    }
    
    .round-display-fixed {
        right: 10px;
    }
    
    .score-display-fixed .score-label, 
    .round-display-fixed .round-label {
        font-size: 0.75rem;
    }
    
    .score-display-fixed .score-value, 
    .round-display-fixed .round-value {
        font-size: 1rem;
    }
    
    .control-buttons {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .game-over-controls {
        flex-direction: column;
    }
    
    .btn {
        padding: 0.75rem 1rem;
    }
} 