:root {
    --primary: #4CAF50;
    --danger: #f44336;
    --dark: #2c3e50;
    --light: #ecf0f1;
    --bg: #f5f6fa;
    --panel-bg: white;
    --text: var(--dark);
    --border: #ddd;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1a1a1a;
        --panel-bg: #2d2d2d;
        --text: #ecf0f1;
        --light: #3d3d3d;
        --dark: #ecf0f1;
        --border: #404040;  /* Darker border for unselected state */
    }

    .beat-indicator {
        background: #404040;
    }

    input, select {
        background: var(--light);
        color: var(--text);
        border-color: var(--border);
    }

    input:focus, select:focus {
        border-color: var(--primary);
    }

    select option {
        background: var(--panel-bg);
        color: var(--text);
    }

    .panel {
        box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    }

    .info { 
        color: #999; 
    }

    .setting-label {
        color: #999;
    }
}

body { 
    font-family: 'Segoe UI', system-ui, sans-serif;
    max-width: 600px;
    margin: 40px auto;
    text-align: center;
    background: var(--bg);
    color: var(--text);
}

.panel {
    background: var(--panel-bg);
    margin: 20px 0;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: none; /* Hide all panels by default */
}

#initial-panel {
    display: block; /* Show only initial panel */
}

.info { color: #666; margin: 15px 0; }

button {
    margin: 5px;
    padding: 10px 20px;
    cursor: pointer;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    transition: all 0.3s ease;
    background: var(--primary);
    color: white;
}

button:hover { transform: translateY(-2px); }

input, select {
    margin: 5px;
    padding: 10px;
    width: 120px;
    border: 2px solid var(--border); /* Replace #ddd with variable */
    border-radius: 6px;
    font-size: 16px;
    text-align: center;
}

input:focus {
    outline: none;
    border-color: var(--primary);
}

select {
    text-align: left;  /* Override center alignment for selects */
    appearance: none;  /* Remove default dropdown arrow */
    background: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'%3E%3Cpath fill='%23666' d='M7 10l5 5 5-5H7z'/%3E%3C/svg%3E") no-repeat right 8px center; /* Custom dropdown arrow */
    padding-right: 30px; /* Space for custom arrow */
}

select#subdivision,
select#sound-select {
    min-width: 160px;  /* Increase width for better text visibility */
}

.room-code {
    font-size: 32px;
    color: var(--dark);
    margin: 20px 0;
    font-weight: bold;
    letter-spacing: 2px;
}

.status {
    font-weight: 500;
    margin: 10px 0;
    padding: 10px;
    border-radius: 6px;
    background: var(--light);
}

.leave {
    background: var(--danger);
    margin-top: 30px;
}

h2, h3 {
    color: var(--dark);
    margin-bottom: 20px;
}

.copy-btn {
    background: #7f8c8d;
    padding: 5px 10px;
    font-size: 14px;
}

#tempo {
    width: 80px;
    font-size: 20px;
    font-weight: bold;
}

.controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin: 20px 0;
    flex-direction: column;
    gap: 20px;
}

.control-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.control-group select {
    min-width: 120px;
}

.panel-section {
    border-top: 2px solid var(--light);
    padding-top: 20px;
    margin-top: 20px;
    transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
    overflow: hidden;
}

.panel-section.minimized {
    max-height: 0 !important;
    padding-top: 0;
    opacity: 0;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 10px 0;
}

.minify-btn {
    background: none;
    color: var(--dark);
    padding: 5px;
    font-size: 20px;
    transform: rotate(0deg);
    transition: transform 0.3s ease;
}

.minify-btn.minimized {
    transform: rotate(180deg);
}

.metronome-display {
    font-size: 48px;
    font-weight: bold;
    color: var(--primary);
    margin: 20px 0;
    font-family: monospace;
}

.beat-indicator {
    display: inline-block;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #ddd;
    margin: 0 5px;
}

.beat-indicator.active {
    background: var(--primary);
    transform: scale(1.2);
}

.current-settings {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 20px 0;
    text-align: left;
    background: var(--light);
    padding: 15px;
    border-radius: 8px;
}

.setting-label {
    color: #666;
    font-size: 14px;
}

.setting-value {
    font-weight: bold;
    font-size: 16px;
}

.room-controls {
    transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
    overflow: hidden;
}

.room-controls.minimized {
    max-height: 0 !important;
    padding-top: 0;
    opacity: 0;
}

.host-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.client-header {
    border-bottom: 2px solid var(--light);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.visualizer {
    background: var(--light);
    padding: 30px;
    border-radius: 12px;
    margin: 20px 0;
}

.tempo-display {
    font-size: 64px;
    font-weight: bold;
    color: var(--primary);
    font-family: monospace;
    margin: 20px 0;
}

.tempo-label {
    font-size: 16px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.beat-indicator.accent {
    border: 2px solid var(--primary);
}

.connection-status {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 8px;
}

.connection-status.connected { background: var(--primary); }
.connection-status.disconnected { background: var(--danger); }
.connection-status.connecting { 
    background: #ff9800; 
    animation: blink 1s infinite;
}
.connection-status.playing { animation: pulse 1s infinite; }

@keyframes blink {
    0% { opacity: 0.4; }
    50% { opacity: 1; }
    100% { opacity: 0.4; }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.controls-row {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
}

.accent-control {
    background: var(--light);
    padding: 8px 15px;
    border-radius: 6px;
    gap: 8px;
}

.accent-control input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--primary);
}

.accent-control label {
    cursor: pointer;
    user-select: none;
}

.error-banner {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background-color: #ff5252;
    color: white;
    padding: 10px;
    text-align: center;
    z-index: 1000;
    font-weight: bold;
    animation: fadeInOut 0.5s ease-in-out;
}

.browser-info {
    font-size: 14px;
    color: #666;
    margin-bottom: 20px;
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translateY(-20px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* Mobile optimizations for iOS */
@supports (-webkit-touch-callout: none) {
    /* iOS specific styles */
    button, input, select {
        font-size: 16px; /* Prevents iOS zoom on input */
    }
    
    input[type="tel"] {
        font-size: 16px;
        -webkit-appearance: none;
        border-radius: 0;
    }
}

/* Debug information panel for connection troubleshooting */
.debug-info {
    position: fixed;
    bottom: 0;
    right: 0;
    background: rgba(0,0,0,0.8);
    color: #00ff00;
    font-family: monospace;
    padding: 10px;
    font-size: 12px;
    max-width: 300px;
    max-height: 200px;
    overflow: auto;
    z-index: 1000;
    display: none;
}

.debug-info.active {
    display: block;
}