* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: #1a1a2e;
    color: #e0e0e0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.return-home-btn {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1000;
    padding: 0.5rem 0.9rem;
    border-radius: 6px;
    background-color: #333355;
    color: #ccccdd;
    text-decoration: none;
    font-size: 0.9rem;
    line-height: 1.2;
    transition: background-color 0.2s, transform 0.1s;
}

.return-home-btn:hover {
    background-color: #444466;
    transform: scale(1.02);
}

.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 800px;
    padding: 2rem;
}

.screen.active {
    display: flex;
}

/* Setup Screen */
h1 {
    font-size: 2.2rem;
    color: #ffd700;
    margin-bottom: 0.3rem;
    text-align: center;
}

.subtitle {
    color: #8888aa;
    font-size: 1.1rem;
    margin-bottom: 2.5rem;
}

.control-group {
    width: 100%;
    max-width: 400px;
    margin-bottom: 1.5rem;
}

.control-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 1rem;
    color: #ccccdd;
}

.duration-label {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.toggle-group {
    display: flex;
    justify-content: center;
}

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

#duration-slider {
    width: 100%;
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #333355;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

#duration-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ffd700;
    cursor: pointer;
}

#duration-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ffd700;
    border: none;
    cursor: pointer;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 1rem;
    color: #ccccdd;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #ffd700;
    cursor: pointer;
}

/* Buttons */
.btn-primary, .btn-secondary {
    padding: 0.75rem 2rem;
    font-size: 1.1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.btn-primary {
    background-color: #ffd700;
    color: #1a1a2e;
    font-weight: bold;
}

.btn-primary:hover {
    background-color: #ffed4a;
    transform: scale(1.02);
}

.btn-secondary {
    background-color: #333355;
    color: #ccccdd;
}

.btn-secondary:hover {
    background-color: #444466;
}

/* Player Screen */
.time-display {
    font-size: 1.8rem;
    font-family: 'Consolas', 'Courier New', monospace;
    color: #ccccdd;
    margin-bottom: 2rem;
    text-align: center;
}

.player-hint {
    color: #aeb2d3;
    font-size: 0.95rem;
    margin-bottom: 1.1rem;
    text-align: center;
}

#lyrics-container {
    width: 100%;
    text-align: center;
    margin-bottom: 2rem;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.8rem;
}

.lyric-line {
    font-size: 1.4rem;
    line-height: 1.8;
    transition: opacity 0.3s;
    opacity: 0.3;
}

.lyric-line.active-line {
    opacity: 1;
}

.lyric-line.adjacent-line {
    opacity: 0.6;
}

.word {
    display: inline-block;
    padding: 0.1rem 0.2rem;
    transition: color 80ms, opacity 80ms, transform 80ms, font-weight 80ms;
}

.word.upcoming {
    color: #8888aa;
}

.word.active {
    color: #ffd700;
    font-weight: bold;
    transform: scale(1.08);
}

.word.sung {
    color: #ffd700;
    opacity: 1;
}

.word-link {
    color: inherit;
    cursor: pointer;
    text-decoration: none;
}

.word-link:hover {
    text-decoration: underline;
}

.word-link:focus-visible {
    outline: 2px solid #ffd700;
    outline-offset: 2px;
    border-radius: 3px;
}

.duration-control {
    display: flex;
    align-items: center;
}

#duration-input {
    width: 5.5rem;
    padding: 0.35rem 0.45rem;
    border: 1px solid #444466;
    border-radius: 4px;
    background: #22223c;
    color: #e0e0e0;
    font-size: 0.95rem;
}

#duration-input:focus {
    outline: 2px solid #ffd700;
    outline-offset: 1px;
}

/* Progress Bar */
#progress-bar-container {
    width: 100%;
    height: 8px;
    background: #333355;
    border-radius: 4px;
    margin-bottom: 1.5rem;
    position: relative;
    cursor: pointer;
}

#progress-bar-fill {
    height: 100%;
    background: #ffd700;
    border-radius: 4px;
    width: 0%;
    pointer-events: none;
}

#progress-bar-handle {
    position: absolute;
    top: 50%;
    left: 0%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ffffff;
    pointer-events: none;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
}

/* Player Controls */
.player-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

/* Responsive */
@media (max-width: 600px) {
    .return-home-btn {
        top: 0.75rem;
        left: 0.75rem;
        font-size: 0.85rem;
    }

    .screen {
        padding: 1rem;
    }

    .duration-control {
        align-items: stretch;
    }

    #duration-input {
        width: 5rem;
    }

    h1 {
        font-size: 1.6rem;
    }

    .lyric-line {
        font-size: 1.1rem;
    }

    .time-display {
        font-size: 1.4rem;
    }

    body.player-active {
        overflow: hidden;
        align-items: stretch;
    }

    body.player-active #player-screen.active {
        width: 100%;
        height: 100vh;
        height: 100dvh;
        max-width: 800px;
        margin: 0 auto;
        padding-top: 3.25rem;
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
        gap: 0.75rem;
    }

    body.player-active #player-title {
        margin-bottom: 0;
    }

    body.player-active .player-hint {
        margin-bottom: 0.4rem;
    }

    body.player-active .time-display {
        margin-bottom: 0;
    }

    body.player-active #lyrics-container {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        margin-bottom: 0;
        justify-content: flex-start;
        padding: 0.25rem 0 0.75rem;
        -webkit-overflow-scrolling: touch;
    }

    body.player-active #progress-bar-container,
    body.player-active .player-controls {
        flex-shrink: 0;
    }

    body.player-active #progress-bar-container {
        margin-bottom: 0;
    }
}
