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

html, body {
    height: 100%;
    overflow-x: hidden;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #fff;
    min-height: 100vh;
    color: #000;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    padding-top: 20px;
}

.container {
    text-align: center;
    width: 100%;
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

h1 {
    margin-bottom: 15px;
    color: #000;
    font-size: clamp(1.5rem, 4vw, 2.5rem);
}

.wheel-container {
    position: relative;
    width: 100%;
    max-width: min(90vw, calc(100vh - 120px), 600px);
    margin: 0 auto;
    overflow: visible;
    aspect-ratio: 1;
}

#wheel {
    width: 100%;
    height: 100%;
    cursor: pointer;
    overflow: visible;
}

#outer-ring {
    transition: transform 0.3s ease-out;
    transform-origin: 0 0;
}

/* Outer ring note labels */
.outer-note {
    font-size: 14px;
    font-weight: bold;
    fill: #000;
    cursor: pointer;
    transition: fill 0.2s, transform 0.3s ease-out;
    user-select: none;
}

.outer-note:hover {
    fill: #333;
}

.outer-note.active {
    fill: #000;
}

/* Frequency ring labels */
.freq-note {
    font-size: 8px;
    fill: #444;
    transition: transform 0.3s ease-out;
    user-select: none;
    font-weight: 500;
}

.freq-note.active {
    fill: #000;
}

/* Main frequency in center */
.freq-main {
    font-size: 8px;
    font-weight: 600;
    fill: #333;
}

/* Boundary frequency labels (smaller) */
.freq-boundary-label {
    font-size: 5px;
    font-weight: 400;
    fill: #666;
    display: none;
}

/* Frequency dial marks */
.freq-dial {
    transition: transform 0.3s ease-out;
}

.dial-center {
    stroke: #333;
    stroke-width: 2;
}

.dial-edge {
    stroke: #999;
    stroke-width: 1;
}

/* Boundary dial marks (hidden by default) */
.dial-boundary {
    display: none;
}

/* Frequency detection clock hand */
.freq-hand {
    transform-origin: 0 0;
}

.freq-hand line {
    filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.3));
    transition: stroke 0.15s ease-out;
}

.freq-hand circle {
    filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.2));
    transition: fill 0.15s ease-out;
}

/* Trailing dot visualization */
#trail-container {
    pointer-events: none;
}

.trail-segment {
    pointer-events: none;
    filter: blur(1px);
}

#trail-dot {
    pointer-events: none;
    filter: drop-shadow(0 0 10px currentColor) drop-shadow(0 0 20px currentColor);
    transition: fill 0.1s ease-out;
}

/* Waveform canvas visualization - below wheel, scrollable */
.waveform-canvas {
    position: absolute;
    left: 0;
    width: 100vw;
    z-index: -1;
    pointer-events: none;
    /* Top position and height set dynamically by JS */
}


/* Outer ring slice backgrounds */
.outer-slice {
    fill: transparent;
    stroke: #ccc;
    stroke-width: 1;
    cursor: pointer;
}

.outer-slice:hover {
    fill: rgba(0, 0, 0, 0.05);
}

.outer-slice.active {
    fill: rgba(0, 0, 0, 0.08);
}

/* Inner ring (Sargam) slices */
.inner-slice {
    stroke: #fff;
    stroke-width: 1;
}

/* Inner ring (Sargam) labels */
.inner-note {
    font-size: 11px;
    font-weight: bold;
    fill: #fff;
    user-select: none;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}


/* ==================== RESPONSIVE BREAKPOINTS ==================== */

/* Mobile - Small (up to 480px) */
@media (max-width: 480px) {
    body {
        padding: 10px;
        padding-top: 15px;
    }
    
    .wheel-container {
        max-width: min(95vw, calc(100vh - 80px));
    }
    
    h1 {
        margin-bottom: 10px;
    }
    
    .outer-note {
        font-size: 10px;
    }
    
    .inner-note {
        font-size: 8px;
    }
    
    .freq-note {
        font-size: 5px;
    }
}

/* Mobile - Medium (481px to 600px) */
@media (min-width: 481px) and (max-width: 600px) {
    .wheel-container {
        max-width: min(90vw, calc(100vh - 100px));
    }
    
    .outer-note {
        font-size: 11px;
    }
    
    .inner-note {
        font-size: 9px;
    }
    
    .freq-note {
        font-size: 6px;
    }
}

/* Tablet (601px to 900px) */
@media (min-width: 601px) and (max-width: 900px) {
    .wheel-container {
        max-width: min(80vw, calc(100vh - 100px), 550px);
    }
    
    .outer-note {
        font-size: 12px;
    }
    
    .inner-note {
        font-size: 10px;
    }
    
    .freq-note {
        font-size: 6px;
    }
}

/* Laptop / Desktop (901px to 1400px) */
@media (min-width: 901px) and (max-width: 1400px) {
    .wheel-container {
        max-width: min(80vw, calc(100vh - 120px), 800px);
    }
    
    .outer-note {
        font-size: 16px;
    }
    
    .inner-note {
        font-size: 12px;
    }
    
    .freq-note {
        font-size: 8px;
    }
}

/* Large Desktop / Ultra-wide (1401px and above) */
@media (min-width: 1401px) {
    .container {
        max-width: 1600px;
    }
    
    .wheel-container {
        max-width: min(70vw, calc(100vh - 120px), 950px);
    }
    
    .outer-note {
        font-size: 18px;
    }
    
    .inner-note {
        font-size: 14px;
    }
    
    .freq-note {
        font-size: 9px;
    }
    
    h1 {
        font-size: 2.5rem;
    }
}

/* Extra Large screens (1800px and above) */
@media (min-width: 1800px) {
    .wheel-container {
        max-width: min(65vw, calc(100vh - 120px), 1100px);
    }
    
    .outer-note {
        font-size: 20px;
    }
    
    .inner-note {
        font-size: 16px;
    }
    
    .freq-note {
        font-size: 10px;
    }
}

/* Landscape mode on mobile */
@media (max-height: 500px) and (orientation: landscape) {
    body {
        padding: 10px;
        padding-top: 10px;
    }
    
    .wheel-container {
        max-width: min(calc(100vh - 60px), 50vw);
    }
    
    h1 {
        font-size: 1rem;
        margin-bottom: 5px;
    }
}

/* Very tall screens (portrait mode on tablets/phones) */
@media (min-aspect-ratio: 1/2) and (max-aspect-ratio: 2/3) {
    .wheel-container {
        max-width: min(85vw, calc(100vh - 120px));
    }
}

/* Ultra-wide monitors (21:9 and wider) */
@media (min-aspect-ratio: 21/9) {
    .wheel-container {
        max-width: min(50vw, calc(100vh - 120px), 1100px);
    }
}

/* ==================== SETTINGS PANEL ==================== */

/* Settings toggle button */
.settings-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid #ddd;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s, box-shadow 0.3s;
    z-index: 100;
}

.settings-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.settings-toggle svg {
    width: 24px;
    height: 24px;
    color: #555;
    transition: transform 0.3s;
}

.settings-toggle:hover svg {
    transform: rotate(45deg);
}

/* Settings panel */
.settings-panel {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 320px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 99;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.3s, visibility 0.3s, transform 0.3s;
    overflow: hidden;
}

.settings-panel.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
}

.settings-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
}

.settings-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.settings-close:hover {
    color: #333;
}

.settings-content {
    padding: 20px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.settings-section {
    margin-bottom: 25px;
}

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-section h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 12px;
}

.settings-hint {
    font-size: 0.75rem;
    color: #888;
    margin-top: 8px;
}

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

.toggle-label input {
    display: none;
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    background: #ddd;
    border-radius: 12px;
    transition: background 0.3s;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s;
}

.toggle-label input:checked + .toggle-switch {
    background: #4C9AFF;
}

.toggle-label input:checked + .toggle-switch::after {
    transform: translateX(20px);
}

/* Octave selector */
.octave-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
    transition: background 0.2s;
}

.radio-label:hover {
    background: rgba(0, 0, 0, 0.03);
}

.radio-label input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: #4C9AFF;
}

.radio-label span {
    font-size: 0.9rem;
    color: #333;
}

/* Reverb section - indented as sub-option of listening */
.reverb-section {
    margin-left: 20px;
    margin-top: -8px;
    padding-top: 0;
    border-left: 2px solid #e0e0e0;
    padding-left: 15px;
}

/* Color grid */
.color-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.color-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-item label {
    font-size: 0.85rem;
    color: #333;
    min-width: 35px;
}

.color-item input[type="color"] {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    padding: 0;
    background: none;
}

.color-item input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-item input[type="color"]::-webkit-color-swatch {
    border: 1px solid #ddd;
    border-radius: 6px;
}

/* Responsive settings panel */
@media (max-width: 480px) {
    .settings-panel {
        width: calc(100vw - 40px);
        right: 20px;
        left: 20px;
        bottom: 80px;
    }
    
    .settings-toggle {
        width: 44px;
        height: 44px;
    }
    
    .settings-toggle svg {
        width: 20px;
        height: 20px;
    }
    
    .color-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Visualization mode selector */
.viz-mode-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
}


/* ==================== THEATER MODE ==================== */
.theater-popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000;
    z-index: 10000;
    transition: background-color 0.2s ease-out;
}

/* Smooth color blending for note changes */
.theater-popup.transitioning {
    transition: background-color 0.4s ease-in-out;
}

.theater-popup.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.theater-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 48px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
    z-index: 10001;
}

.theater-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.theater-content {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.theater-note {
    font-size: 25vw;
    font-weight: bold;
    color: white;
    text-shadow: 
        0 0 30px rgba(255, 255, 255, 0.3),
        0 0 60px rgba(255, 255, 255, 0.2),
        0 0 100px rgba(0, 0, 0, 0.5);
    transition: opacity 0.3s ease-out, text-shadow 0.3s ease-out;
    user-select: none;
}

/* ==================== SINGLE NOTE MODE ==================== */
body.singlenote-mode {
    transition: background-color 0.15s ease-out;
}

body.singlenote-mode .container {
    background: transparent;
}


/* Highlight effect for single note mode - the matching slices */
body.singlenote-mode .inner-slice.highlighted,
body.singlenote-mode .outer-slice.highlighted {
    filter: brightness(1.1);
    transition: filter 0.15s ease-out;
}

/* Dim non-matching slices */
body.singlenote-mode .inner-slice:not(.highlighted),
body.singlenote-mode .outer-slice:not(.highlighted) {
    opacity: 0.3;
    transition: opacity 0.15s ease-out;
}

/* Keep text visible even when slice is dimmed */
body.singlenote-mode .outer-note,
body.singlenote-mode .inner-note,
body.singlenote-mode .freq-main {
    opacity: 0.6;
}
