:root {
    --primary-blue: #3b82f6;
    --light-blue: #60a5fa;
    --dark-blue: #2563eb;
    --bg-dark: #0f172a;
    --bg-slate: #1e293b;
    --text-white: #ffffff;
    --text-light: #e2e8f0;
    --text-muted: #94a3b8;
    --text-subtle: #64748b;
    --border-light: rgba(148, 163, 184, 0.1);
    --border-blue: rgba(59, 130, 246, 0.3);
}

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

html {
    background-color: var(--bg-dark);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Helvetica Neue', sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
    background-attachment: fixed;
    /* Fix gradient in place */
    color: var(--text-light);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    /* Ensure no white flash on mobile pull-to-refresh */
    overscroll-behavior-y: none;
}

/* Grid Overlay */
.grid-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(rgba(148, 163, 184, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 163, 184, 0.03) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
    z-index: 0;
}

.container {
    position: relative;
    z-index: 1;
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 20px;
    text-align: center;
}

.logo-section {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 40px;
}

.logo-full {
    height: 48px;
    width: auto;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 50px;
    margin-bottom: 30px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--primary-blue);
    border-radius: 50%;
}

.status-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--light-blue);
    text-transform: uppercase;
    letter-spacing: 1px;
}

h1 {
    font-size: 42px;
    font-weight: 800;
    color: #ffffff;
    margin-bottom: 16px;
    letter-spacing: -1px;
}

.description {
    font-size: 16px;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 60px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.test-area {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 60px;
}

.speaker-card {
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid var(--border-light);
    border-radius: 20px;
    padding: 40px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    cursor: pointer;
}

.speaker-card:hover {
    background: rgba(30, 41, 59, 0.7);
    border-color: rgba(59, 130, 246, 0.4);
    transform: translateY(-5px);
}

.speaker-card.active {
    border-color: var(--primary-blue);
    box-shadow: 0 0 30px rgba(59, 130, 246, 0.2);
}

.speaker-icon {
    width: 80px;
    height: 80px;
    color: var(--primary-blue);
    transition: transform 0.2s ease;
}

.speaker-card.active .speaker-icon {
    animation: vibrate 0.2s infinite ease-in-out;
}

@keyframes vibrate {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

/* Equalizer Bars */
.equalizer {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 4px;
    height: 40px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.speaker-card.active .equalizer {
    opacity: 1;
}

.equalizer .bar {
    width: 6px;
    background: linear-gradient(180deg, var(--light-blue), var(--primary-blue));
    border-radius: 3px;
    height: 10px;
    animation: none;
}

.speaker-card.active .equalizer .bar {
    animation: equalize 0.6s ease-in-out infinite;
}

.speaker-card.active .equalizer .bar:nth-child(1) {
    animation-delay: 0s;
}

.speaker-card.active .equalizer .bar:nth-child(2) {
    animation-delay: 0.1s;
}

.speaker-card.active .equalizer .bar:nth-child(3) {
    animation-delay: 0.2s;
}

.speaker-card.active .equalizer .bar:nth-child(4) {
    animation-delay: 0.3s;
}

.speaker-card.active .equalizer .bar:nth-child(5) {
    animation-delay: 0.4s;
}

@keyframes equalize {

    0%,
    100% {
        height: 10px;
    }

    50% {
        height: 40px;
    }
}

.speaker-card h3 {
    font-size: 24px;
    font-weight: 700;
    color: #ffffff;
}

.play-btn {
    padding: 12px 30px;
    background: linear-gradient(135deg, var(--primary-blue), var(--dark-blue));
    border: none;
    border-radius: 12px;
    color: #ffffff;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.play-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 20px rgba(59, 130, 246, 0.3);
}

/* Control Panel */
.control-panel {
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 24px;
    margin: 40px auto;
    max-width: 600px;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 16px;
}

.control-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-light);
    font-weight: 600;
    font-size: 14px;
    min-width: 100px;
}

.control-group label svg {
    color: var(--primary-blue);
}

/* Volume Slider */
.slider {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: rgba(148, 163, 184, 0.2);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-blue), var(--dark-blue));
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
    transition: transform 0.2s;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-blue), var(--dark-blue));
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

#volume-value {
    min-width: 45px;
    text-align: right;
    color: var(--light-blue);
    font-weight: 600;
    font-size: 14px;
}

/* Toggle Switch */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}

.toggle-checkbox {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 48px;
    height: 24px;
    background: rgba(148, 163, 184, 0.2);
    border-radius: 12px;
    transition: background 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--text-muted);
    top: 3px;
    left: 3px;
    transition: all 0.3s;
}

.toggle-checkbox:checked+.toggle-slider {
    background: var(--primary-blue);
}

.toggle-checkbox:checked+.toggle-slider::before {
    transform: translateX(24px);
    background: white;
}

.toggle-text {
    color: var(--text-light);
    font-weight: 600;
    font-size: 14px;
}

/* Balance Meter */
.balance-group {
    flex-direction: column;
    align-items: stretch;
}

.balance-meter {
    width: 100%;
}

.balance-bar {
    position: relative;
    height: 8px;
    background: rgba(148, 163, 184, 0.2);
    border-radius: 4px;
    margin-bottom: 8px;
    overflow: hidden;
}

.balance-indicator {
    position: absolute;
    width: 4px;
    height: 100%;
    background: var(--primary-blue);
    border-radius: 2px;
    left: 50%;
    transform: translateX(-50%);
    transition: left 0.3s ease;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.6);
}

.balance-labels {
    display: flex;
    justify-content: space-between;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
}

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 20px;
}

/* Secondary Button (Ghost Style) */
.secondary-btn {
    width: 100%;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.secondary-btn:hover {
    background: linear-gradient(135deg, var(--primary-blue), var(--dark-blue));
    border-color: transparent;
    transform: scale(1.05);
    box-shadow: 0 10px 20px rgba(59, 130, 246, 0.3);
}

@keyframes pulse-border {
    0% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(59, 130, 246, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
    }
}

.footer {
    margin-top: 80px;
    padding-top: 40px;
    border-top: 1px solid var(--border-light);
    color: var(--text-subtle);
    font-size: 14px;
}

@media (max-width: 600px) {
    .container {
        padding: 30px 16px;
    }

    .logo-full {
        height: 40px;
    }

    .status-badge {
        font-size: 11px;
        padding: 6px 16px;
    }

    h1 {
        font-size: 28px;
        margin-bottom: 12px;
        letter-spacing: -0.5px;
    }

    .description {
        font-size: 14px;
        margin-bottom: 40px;
        padding: 0 10px;
    }

    .test-area {
        gap: 12px;
        margin-bottom: 40px;
    }

    .speaker-card {
        padding: 24px 12px;
        gap: 12px;
    }

    .speaker-icon {
        width: 60px;
        height: 60px;
    }

    .speaker-card h3 {
        font-size: 20px;
    }

    .play-btn,
    .secondary-btn {
        padding: 12px 20px;
        font-size: 14px;
        border-radius: 10px;
        min-height: 48px;
        /* Touch-friendly */
    }

    .controls {
        gap: 16px;
        margin-top: 16px;
    }

    /* Control Panel Mobile */
    .control-panel {
        padding: 16px;
        margin: 30px 16px;
        gap: 16px;
    }

    .control-group {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .control-group label {
        min-width: auto;
        font-size: 13px;
    }

    #volume-value {
        position: absolute;
        right: 16px;
    }

    .balance-group {
        gap: 12px;
    }

    .footer {
        margin-top: 60px;
        padding-top: 30px;
        font-size: 12px;
    }

    /* Equalizer bars - slightly smaller on mobile */
    .equalizer {
        height: 35px;
    }

    @keyframes equalize {

        0%,
        100% {
            height: 8px;
        }

        50% {
            height: 35px;
        }
    }
}

/* --- FORM UI EXTENSIONS --- */

/* Input Groups */
.input-group {
    margin-bottom: 35px;
    text-align: left;
}

.input-group label {
    margin-bottom: 15px;
    display: block;
    color: var(--text-muted);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

/* Option Cards (Grid) */
.option-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 12px;
    margin-top: 10px;
}

.option-card {
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 15px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.option-card:hover {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(59, 130, 246, 0.5);
}

.option-card.active {
    background: rgba(59, 130, 246, 0.2);
    border-color: var(--primary-blue);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.15);
}

.card-icon {
    font-size: 24px;
    margin-bottom: 8px;
}

.option-card h3 {
    font-size: 14px;
    color: var(--text-white);
    margin: 0;
}

/* Primary Button */
.primary-btn {
    width: 100%;
    padding: 18px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border: none;
    border-radius: 16px;
    color: white;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 25px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.4);
}

/* Pulse Animation */
.pulse-btn {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(59, 130, 246, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
    }
}