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

:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: rgba(255, 255, 255, 0.08);
    --bg-player: rgba(255, 255, 255, 0.05);
    --bg-input: rgba(255, 255, 255, 0.15);
    --bg-btn: rgba(255, 255, 255, 0.1);
    --bg-header: rgba(26, 26, 46, 0.95);
    --bg-bottom: rgba(26, 26, 46, 0.98);
    --text-primary: #fff;
    --text-secondary: #ccc;
    --text-muted: #888;
    --text-label: #aaa;
    --border-color: rgba(255, 255, 255, 0.1);
    --accent-pink: #ff6b9d;
    --accent-pink-dark: #c44569;
    --accent-purple: #667eea;
    --accent-purple-dark: #764ba2;
    --progress-bg: rgba(255, 255, 255, 0.1);
}

body.light-mode {
    --bg-primary: #f5f5f7;
    --bg-secondary: #e8e8ed;
    --bg-card: rgba(0, 0, 0, 0.04);
    --bg-player: rgba(0, 0, 0, 0.03);
    --bg-input: rgba(0, 0, 0, 0.08);
    --bg-btn: rgba(0, 0, 0, 0.08);
    --bg-header: rgba(245, 245, 247, 0.95);
    --bg-bottom: rgba(245, 245, 247, 0.98);
    --text-primary: #1a1a2e;
    --text-secondary: #555;
    --text-muted: #777;
    --text-label: #666;
    --border-color: rgba(0, 0, 0, 0.1);
    --progress-bg: rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    min-height: 100vh;
    color: var(--text-primary);
    transition: background 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    padding-bottom: 100px;
}

header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    text-align: center;
    padding: 15px 20px;
    background: var(--bg-header);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 12px;
}

h1 {
    font-size: 1.8rem;
    background: linear-gradient(90deg, #ff6b9d, #c44569);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}

.pieces-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--bg-btn);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease, transform 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}

.pieces-btn:hover {
    background: var(--progress-bg);
}

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

.pieces-btn .icon {
    width: 22px;
    height: 22px;
}

.filter-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.filter-container label {
    font-size: 1rem;
    color: var(--text-secondary);
}

#actor-filter {
    padding: 12px 20px;
    font-size: 1.1rem;
    border: none;
    border-radius: 25px;
    background: var(--bg-input);
    color: var(--text-primary);
    cursor: pointer;
    min-width: 200px;
    -webkit-appearance: none;
    transition: background 0.3s ease, color 0.3s ease;
}

#actor-filter option {
    background: var(--bg-primary);
    color: var(--text-primary);
}

#actor-filter:focus {
    outline: none;
    box-shadow: 0 0 0 2px #ff6b9d;
}

.tableau-card {
    background: var(--bg-card);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    backdrop-filter: blur(5px);
    border: 2px solid var(--border-color);
    transition: border-color 0.3s, box-shadow 0.3s, background 0.3s;
}

.tableau-card.playing {
    border-color: #ff6b9d;
    box-shadow: 0 0 20px rgba(255, 107, 157, 0.3);
}

.tableau-card.hidden {
    display: none;
}

.tableau-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.tableau-title {
    font-size: 1.4rem;
    font-weight: 600;
    color: #ff6b9d;
}

.actors-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
}

.actor-tag {
    display: inline-block;
    padding: 6px 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    text-transform: capitalize;
}

.audio-container {
    margin-top: 10px;
}

/* Custom Audio Player */
.audio-player {
    background: var(--bg-player);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 10px;
    transition: background 0.3s ease;
}

.audio-player:last-child {
    margin-bottom: 0;
}

.audio-player.playing {
    background: rgba(255, 107, 157, 0.15);
    border: 1px solid var(--accent-pink);
}

body.light-mode .audio-player.playing {
    background: rgba(255, 107, 157, 0.12);
}

.player-scene-label {
    font-size: 0.85rem;
    color: var(--text-label);
    margin-bottom: 8px;
    text-align: center;
}

.player-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.play-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #ff6b9d 0%, #c44569 100%);
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s, box-shadow 0.15s;
    -webkit-tap-highlight-color: transparent;
}

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

.play-btn.playing {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.player-info {
    flex: 1;
    min-width: 0;
}

.progress-container {
    width: 100%;
    height: 8px;
    background: var(--progress-bg);
    border-radius: 4px;
    cursor: pointer;
    margin-bottom: 6px;
    overflow: hidden;
    transition: background 0.3s ease;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #ff6b9d, #c44569);
    border-radius: 4px;
    width: 0%;
    transition: width 0.1s linear;
}

.time-display {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.nav-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--bg-btn);
    color: var(--text-primary);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, color 0.3s;
    -webkit-tap-highlight-color: transparent;
}

.nav-btn:active {
    background: var(--progress-bg);
}

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

/* Hide native audio */
audio {
    display: none;
}

/* Bottom Player Bar */
.bottom-player {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--bg-bottom);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border-color);
    padding: 12px 20px;
    transform: translateY(100%);
    transition: transform 0.3s ease, background 0.3s ease, border-color 0.3s ease;
}

.bottom-player.visible {
    transform: translateY(0);
}

.bottom-player-content {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 15px;
}

.bottom-player-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.bottom-nav-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--bg-btn);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.3s ease, color 0.3s ease;
}

.bottom-nav-btn:active {
    background: var(--progress-bg);
}

.bottom-play-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #ff6b9d 0%, #c44569 100%);
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

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

.bottom-play-btn.playing {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.bottom-player-info {
    flex: 1;
    min-width: 0;
}

.bottom-track-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.bottom-progress-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.bottom-progress-container {
    flex: 1;
    height: 6px;
    background: var(--progress-bg);
    border-radius: 3px;
    cursor: pointer;
    overflow: hidden;
    transition: background 0.3s ease;
}

.bottom-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #ff6b9d, #c44569);
    border-radius: 3px;
    width: 0%;
    transition: width 0.1s linear;
}

.bottom-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    flex-shrink: 0;
    min-width: 75px;
    text-align: right;
}

/* Toggle Buttons (Theme & Mode) */
.theme-toggle,
.mode-toggle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--bg-btn);
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease, transform 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.theme-toggle:hover,
.mode-toggle:hover {
    background: var(--progress-bg);
}

.theme-toggle:active,
.mode-toggle:active {
    transform: scale(0.95);
}

.mode-toggle.continuous {
    background: linear-gradient(135deg, var(--accent-pink) 0%, var(--accent-pink-dark) 100%);
    color: white;
}

/* SVG Icons */
.icon {
    width: 1em;
    height: 1em;
    display: inline-block;
    vertical-align: middle;
}

.play-btn .icon,
.bottom-play-btn .icon {
    width: 24px;
    height: 24px;
}

.bottom-nav-btn .icon {
    width: 18px;
    height: 18px;
}

.theme-toggle .icon,
.mode-toggle .icon {
    width: 22px;
    height: 22px;
}

/* Settings Button */
.settings-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--bg-btn);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease, transform 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

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

.settings-btn .icon {
    width: 22px;
    height: 22px;
}

/* Responsive visibility */
.mobile-only {
    display: none;
}

.desktop-only {
    display: flex;
}

/* Offcanvas Panel */
.offcanvas-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.offcanvas-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.offcanvas-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 280px;
    max-width: 80vw;
    background: var(--bg-primary);
    z-index: 201;
    transform: translateX(100%);
    transition: transform 0.3s ease, background 0.3s ease;
    display: flex;
    flex-direction: column;
}

.offcanvas-panel.visible {
    transform: translateX(0);
}

.offcanvas-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.offcanvas-header h2 {
    font-size: 1.2rem;
    color: var(--text-primary);
    margin: 0;
}

.offcanvas-close {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--bg-btn);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

.offcanvas-close:active {
    background: var(--progress-bg);
}

.offcanvas-close .icon {
    width: 20px;
    height: 20px;
}

.offcanvas-content {
    padding: 20px;
    flex: 1;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid var(--border-color);
}

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

.setting-label {
    font-size: 1rem;
    color: var(--text-primary);
}

/* Pieces Panel (left offcanvas) */
.pieces-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.pieces-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.pieces-panel {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 300px;
    max-width: 85vw;
    background: var(--bg-primary);
    z-index: 201;
    transform: translateX(-100%);
    transition: transform 0.3s ease, background 0.3s ease;
    display: flex;
    flex-direction: column;
}

.pieces-panel.visible {
    transform: translateX(0);
}

.pieces-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.pieces-header h2 {
    font-size: 1.2rem;
    color: var(--text-primary);
    margin: 0;
}

.pieces-close {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--bg-btn);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

.pieces-close:active {
    background: var(--progress-bg);
}

.pieces-close .icon {
    width: 20px;
    height: 20px;
}

.pieces-content {
    padding: 15px;
    flex: 1;
    overflow-y: auto;
}

.pieces-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.piece-item {
    width: 100%;
    padding: 15px 20px;
    border: none;
    border-radius: 12px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 1rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.3s ease, border-color 0.3s ease;
    border: 2px solid transparent;
}

.piece-item:hover {
    background: var(--bg-input);
}

.piece-item.active {
    background: linear-gradient(135deg, rgba(255, 107, 157, 0.2), rgba(196, 69, 105, 0.2));
    border-color: var(--accent-pink);
    color: var(--accent-pink);
    font-weight: 500;
}

@media (max-width: 600px) {
    .container {
        padding: 10px;
        padding-bottom: 90px;
    }

    header {
        padding: 12px 15px;
    }

    h1 {
        font-size: 1.3rem;
    }

    .header-top {
        margin-bottom: 10px;
        gap: 10px;
    }

    .pieces-btn {
        width: 40px;
        height: 40px;
    }

    .pieces-btn .icon {
        width: 20px;
        height: 20px;
    }

    .mobile-only {
        display: flex;
    }

    .desktop-only {
        display: none;
    }

    .filter-container {
        flex-direction: row;
        gap: 10px;
    }

    .filter-container label {
        font-size: 0.9rem;
    }

    #actor-filter {
        flex: 1;
        min-width: 0;
        padding: 12px 16px;
        font-size: 1rem;
    }

    .tableau-card {
        padding: 15px;
    }

    .tableau-title {
        font-size: 1.2rem;
    }

    .play-btn {
        width: 52px;
        height: 52px;
    }

    .nav-btn {
        width: 40px;
        height: 40px;
    }

    .bottom-player {
        padding: 10px 15px;
    }

    .bottom-player-content {
        gap: 10px;
    }

    .bottom-nav-btn {
        width: 36px;
        height: 36px;
        font-size: 12px;
    }

    .bottom-play-btn {
        width: 44px;
        height: 44px;
        font-size: 16px;
    }

    .bottom-track-name {
        font-size: 0.85rem;
    }

    .bottom-time {
        font-size: 0.7rem;
        min-width: 65px;
    }
}
