/* Miku Boxing - Enhanced Styles */
:root {
    --primary: #39c5bb;
    --primary-glow: rgba(57, 197, 187, 0.6);
    --secondary: #ff6b9d;
    --accent: #a855f7;
    --bg-dark: #0a0a1a;
    --bg-card: rgba(20, 20, 40, 0.9);
    --text: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.6);
    --perfect: #ffd700;
    --good: #39c5bb;
    --miss: #ff4757;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    background: var(--bg-dark);
}

body {
    font-family: 'Outfit', sans-serif;
    color: var(--text);
    position: fixed; 
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    touch-action: none; /* HARD LOCK EVERYTHING */
}

#game-container {
    width: 100vw;
    height: 100vh;
    position: absolute;
    top: 0;
    left: 0;
    overflow: hidden;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 20px;
    overflow: hidden;
}

.screen.active {
    display: flex;
}

/* Start Screen */
#start-screen {
    gap: 5px; /* Tighter gap */
    padding-top: 5px; /* Minimal top padding */
    padding-bottom: 20px;
    justify-content: flex-start;
}

.title-container {
    text-align: center;
    margin-bottom: 0px;
}

.title {
    font-size: 2rem; /* Slightly smaller title */
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: pulse 2s ease-in-out infinite;
}

.subtitle {
    font-size: 1rem;
    color: var(--text-muted);
    margin-top: 5px;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.select-section {
    width: 100%;
    max-width: 450px;
    z-index: 20;
    position: relative;
}

.select-section h2 {
    font-size: 0.9rem;
    margin-bottom: 5px;
    color: var(--text-muted);
}

.song-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 350px; /* Increased height */
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y !important;
    padding-right: 10px;
    position: relative;
    z-index: 21;
}

.song-item {
    background: var(--bg-card);
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 12px 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.song-item:hover, .song-item.selected {
    border-color: var(--primary);
    box-shadow: 0 0 15px var(--primary-glow);
}

.song-item .song-title {
    font-weight: 600;
    font-size: 1rem;
    flex: 1;
}

.song-item .song-artist {
    font-size: 0.85rem;
    color: var(--text-muted);
    width: 100%;
}

.song-item .song-bpm {
    font-size: 0.75rem;
    color: var(--secondary);
    background: rgba(255, 107, 157, 0.2);
    padding: 2px 8px;
    border-radius: 10px;
}

/* Difficulty Selection */
.difficulty-select {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.difficulty-btn {
    background: var(--bg-card);
    border: 2px solid transparent;
    color: var(--text);
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 10px 5px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.difficulty-btn small {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-top: 2px;
}

.difficulty-btn:hover {
    border-color: var(--primary);
}

.difficulty-btn.selected {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(57, 197, 187, 0.2), rgba(255, 107, 157, 0.2));
    box-shadow: 0 0 15px var(--primary-glow);
}

/* Buttons */
.main-buttons {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 5px;
    margin-bottom: 5px;
}

.glow-btn {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    color: white;
    font-family: 'Outfit', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    padding: 16px 50px;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0 25px var(--primary-glow);
}

.icon-btn {
    background: var(--bg-card);
    border: 2px solid var(--text-muted);
    color: white;
    font-size: 1.5rem;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.icon-btn:hover {
    border-color: var(--primary);
    transform: scale(1.1);
}

.glow-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 40px var(--primary-glow);
}

.glow-btn:active {
    transform: scale(0.98);
}

.secondary-btn {
    background: transparent;
    border: 2px solid var(--text-muted);
    color: var(--text);
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    padding: 12px 35px;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.secondary-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.instructions {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
}

/* Game Screen */
#game-screen {
    padding: 0;
    background: #000;
}

#game-background {
    position: absolute;
    top: -2%;
    left: -10%;
    width: 120%;
    height: 110%;
    background-size: cover;
    background-position: center top;
    z-index: 1;
    transform-origin: center top;
    transition: transform 0.1s linear;
}

#game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2;
    pointer-events: none;
}

.game-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    background: linear-gradient(to bottom, rgba(0,0,0,0.6), transparent);
}

.score-display {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

#combo {
    font-size: 1rem;
    color: var(--secondary);
    font-weight: 600;
    min-height: 1.2em;
}

#score {
    font-size: 1.8rem;
    font-weight: 800;
}

.pause-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 1.5rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
}

.pause-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.pause-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#progress-bar {
    width: 120px;
    height: 6px;
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
    overflow: hidden;
}

#progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    transition: width 0.1s linear;
}

#game-canvas {
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 5;
    touch-action: none; /* NO SLIDING ON GAME */
}

#hit-feedback {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.8rem;
    font-weight: 800;
    pointer-events: none;
    opacity: 0;
    text-shadow: 0 0 20px currentColor;
}

#hit-feedback.perfect { color: var(--perfect); }
#hit-feedback.good { color: var(--good); }
#hit-feedback.miss { color: var(--miss); }

#hit-feedback.show {
    opacity: 1;
    animation: hitPop 0.3s ease-out;
}

@keyframes hitPop {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    50% { transform: translate(-50%, -50%) scale(1.2); }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* Results Screen */
#results-screen {
    gap: 15px;
    justify-content: center;
    padding: 30px 20px;
}

.results-title {
    font-size: 2rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.grade-container {
    margin: 5px 0;
}

.grade {
    font-size: 4.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--perfect), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradeAppear 0.5s ease-out;
}

@keyframes gradeAppear {
    0% { transform: scale(0) rotate(-20deg); opacity: 0; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.results-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    width: 100%;
    max-width: 350px;
}

.stat {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 12px;
    text-align: center;
}

.stat.large {
    grid-column: span 2;
}

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

.stat-value {
    font-size: 1.3rem;
    font-weight: 700;
}

.stat.large .stat-value {
    font-size: 2rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.results-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    margin-top: 10px;
}

/* Overlays */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 26, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.overlay.hidden {
    display: none;
}

.overlay-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.overlay-content h2 {
    font-size: 2rem;
}

#countdown-overlay {
    background: rgba(10, 10, 26, 0.85);
}

#countdown-number {
    font-size: 6rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: countdownPulse 0.7s ease-in-out infinite;
}

/* Settings Modal Specifics */
.settings-modal {
    background: var(--bg-card);
    padding: 30px;
    border-radius: 24px;
    border: 2px solid var(--primary);
    width: 90%;
    max-width: 400px;
    box-shadow: 0 0 30px rgba(0,0,0,0.5);
}

.settings-group {
    text-align: left;
    margin-bottom: 25px;
}

.settings-group label {
    display: block;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--primary);
}

.setting-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.toggle-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.toggle-group label {
    margin-bottom: 0;
}

/* Range Input Styling */
input[type=range] {
    width: 100%;
    background: transparent;
    -webkit-appearance: none;
}

input[type=range]:focus {
    outline: none;
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 8px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

input[type=range]::-webkit-slider-thumb {
    height: 24px;
    width: 24px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    -webkit-appearance: none;
    margin-top: -8px;
    box-shadow: 0 0 10px var(--primary-glow);
}

/* Toggle Switch Styling */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: var(--primary);
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.slider.round {
    border-radius: 24px;
}

.slider.round:before {
    border-radius: 50%;
}

@keyframes countdownPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* Mobile Optimizations */
@media (max-width: 480px) {
    .title {
        font-size: 2rem;
    }
    
    .glow-btn {
        font-size: 1.2rem;
        padding: 14px 40px;
    }
    
    .difficulty-select {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .song-list {
        max-height: 150px;
    }
    
    #hit-feedback {
        font-size: 1.5rem;
    }
}

/* Landscape mode adjustments */
@media (max-height: 500px) {
    #start-screen {
        padding-top: 10px;
        gap: 10px;
    }
    
    .title {
        font-size: 1.8rem;
    }
    
    .song-list {
        max-height: 100px;
    }
    
    .glow-btn {
        padding: 12px 35px;
        font-size: 1.1rem;
    }
}
