/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    padding: 2rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

header h1 {
    font-size: 3rem;
    font-weight: 700;
    color: white;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.subtitle {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.1rem;
}

/* Main content */
main {
    flex: 1;
    padding: 2rem 1rem;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

#game-container {
    background: white;
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

/* Game sections */
#puzzle-info {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #f0f0f0;
}

/* Compact header row for title + lives */
.info-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

#puzzle-info h2 {
    color: #667eea;
    margin-bottom: 0.25rem;
}

#effect-description {
    color: #666;
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

 

/* Audio section */
#audio-section {
    margin-bottom: 2rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

#dry-sample, #effected-sample {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 12px;
    border-left: 4px solid #667eea;
    text-align: center;
    position: relative;
    overflow: hidden;
}

/* Panel chrome */
.theme-dark #dry-sample::before,
.theme-dark #effected-sample::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: 12px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), inset 0 -1px 0 rgba(0,0,0,0.35);
}

#dry-sample h3, #effected-sample h3 {
    color: #495057;
    margin-bottom: 0.5rem;
}

.audio-button {
    background: #667eea;
    color: white;
    border: 1px solid transparent;
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 14px rgba(102, 126, 234, 0.28);
    margin-bottom: 0.5rem;
    min-width: 200px;
}

.audio-button:hover {
    background: #5a6fd8;
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(102, 126, 234, 0.38);
}

.audio-button:active {
    transform: translateY(0);
}

.audio-tip {
    color: #666;
    font-size: 0.9rem;
    font-style: italic;
    margin: 0;
}

/* Guess section */
#guess-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
}

.theme-dark #guess-section::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: 12px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), inset 0 -1px 0 rgba(0,0,0,0.35);
}

#parameter-input {
    margin-bottom: 1.5rem;
}

#parameter-label {
    display: block;
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.75rem;
    font-size: 1rem;
}

.slider-container {
    position: relative;
    margin: 1rem 0;
}

#parameter-slider {
    width: 100%;
    max-width: 420px;
    height: 6px;
    border-radius: 999px;
    background: #ddd;
    outline: none;
    margin: 0;
    cursor: pointer;
}

#parameter-slider::-webkit-slider-thumb {
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #667eea;
    border: 2px solid rgba(255,255,255,0.8);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

#parameter-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 0.25rem;
    font-size: 0.8rem;
    color: #666;
}

.parameter-display {
    margin-top: 1rem;
}

#parameter-value {
    font-weight: 600;
    color: #667eea;
    font-size: 1.5rem;
    font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

#parameter-unit {
    color: #666;
    margin-left: 0.25rem;
    font-size: 1.1rem;
}

/* Audition section */
.audition-section {
    margin-bottom: 1.5rem;
    padding: 0.75rem;
    background: #fff3cd;
    border-radius: 10px;
    border: 1px solid #ffeaa7;
}

.audition-button {
    background: #ffc107;
    color: #212529;
    border: 1px solid transparent;
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 14px rgba(255, 193, 7, 0.28);
    margin-bottom: 0.5rem;
    min-width: 250px;
}

.audition-button:hover {
    background: #e0a800;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 193, 7, 0.4);
}

.audition-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.audition-tip {
    color: #856404;
    font-size: 0.9rem;
    margin: 0;
    font-style: italic;
}

/* Submit button */
.submit-button {
    background: #28a745;
    color: white;
    border: 1px solid transparent;
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 14px rgba(40, 167, 69, 0.28);
    min-width: 200px;
}

.submit-button:hover:not(:disabled) {
    background: #218838;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(40, 167, 69, 0.4);
}

.submit-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    box-shadow: none;
}

/* Results section */
#results {
    text-align: center;
    padding: 1.5rem;
    background: #e8f5e8;
    border-radius: 10px;
    border-left: 4px solid #28a745;
}

.score-display {
    font-size: 2rem;
    font-weight: 700;
    color: #28a745;
    margin-bottom: 1rem;
}

.correct-answer {
    font-size: 1.2rem;
    color: #495057;
    margin-bottom: 0.5rem;
}

.explanation {
    color: #666;
    font-style: italic;
    margin-bottom: 1rem;
}

 

/* Footer */
footer {
    text-align: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
}

/* Utility classes */
.hidden {
    display: none !important;
}

/* Interactive ergonomics */
button,
input[type="range"],
input[type="button"],
input[type="submit"],
a {
    -webkit-tap-highlight-color: transparent;
}

/* Improve slider gesture handling on touch devices */
#parameter-slider {
    touch-action: pan-y;
}

/* Responsive design */
@media (max-width: 768px) {
    header h1 {
        font-size: 2.5rem;
    }
    
    main {
        padding: 1rem;
    }
    
    #game-container {
        padding: 1.5rem;
    }
    
    #parameter-slider {
        max-width: 100%;
        margin: 0;
    }

    #audio-section {
        grid-template-columns: 1fr;
    }
    
    .audio-button,
    .audition-button,
    .submit-button {
        min-width: 100%;
        margin-bottom: 1rem;
    }
    
    .audition-section {
        padding: 0.75rem;
    }
}

@media (max-width: 480px) {
    header {
        padding: 1.25rem 0.75rem;
    }

    header h1 {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    main {
        padding: 0.75rem;
    }

    #game-container {
        padding: 1rem;
        border-radius: 14px;
    }

    #puzzle-info h2 {
        font-size: 1.25rem;
    }

    #effect-description {
        font-size: 1rem;
    }

    

    #dry-sample, #effected-sample {
        padding: 0.75rem;
    }

    #dry-sample h3, #effected-sample h3 {
        font-size: 1rem;
    }

    .audio-button,
    .audition-button,
    .submit-button {
        min-width: 100%;
        min-height: 48px;
        padding: 0.9rem 1rem;
        font-size: 1rem;
    }

    #guess-section {
        padding: 1rem;
    }

    #parameter-label {
        font-size: 1rem;
    }

    #parameter-slider {
        height: 10px;
    }

    #parameter-slider::-webkit-slider-thumb {
        width: 28px;
        height: 28px;
    }

    .slider-labels {
        font-size: 0.8rem;
    }

    #parameter-value {
        font-size: 1.3rem;
    }

    #parameter-unit {
        font-size: 1rem;
    }

    .audio-tip,
    .audition-tip {
        font-size: 0.85rem;
    }

    /* Dialogs */
    .autoplay-message {
        max-width: 90vw;
        width: calc(100vw - 2rem);
        padding: 1.5rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }

    .audio-button:hover,
    .audition-button:hover,
    .submit-button:hover,
    .autoplay-message button:hover {
        transform: none;
        box-shadow: none;
    }
}

/* Loading animation */
#loading {
    text-align: center;
    padding: 3rem;
}

#loading p {
    color: #667eea;
    font-size: 1.2rem;
}

/* Error message styling */
.error-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #f8d7da;
    color: #721c24;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid #f5c6cb;
    z-index: 1000;
    text-align: center;
    max-width: 400px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.error-message button {
    background: #dc3545;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.error-message button:hover {
    background: #c82333;
}

/* Autoplay message styling */
.autoplay-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    text-align: center;
    max-width: 400px;
}

.autoplay-message h3 {
    color: #667eea;
    margin-bottom: 1rem;
}

.autoplay-message p {
    color: #666;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.autoplay-message button {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.autoplay-message button:hover {
    background: #45a049;
    transform: translateY(-2px);
}

/* Dark Theme (VST-style) */
.theme-dark {
	/* Palette */
	--bg-grad-1: #0b0e13;
	--bg-grad-2: #131922;
	--panel: #171a21;
	--panel-alt: #1d2430;
	--border: #2a2f3a;
	--text: #e6edf3;
	--muted: #9aa4b2;
	--accent: #6ea8fe;
	--accent-strong: #5aa0ff;
	--success: #22c55e;
	--warning: #ffb020;
	--danger: #ef4444;
	color-scheme: dark;
	background: radial-gradient(1000px 600px at 20% -10%, rgba(110,168,254,0.12) 0%, transparent 60%),
		radial-gradient(900px 500px at 110% 20%, rgba(34,197,94,0.10) 0%, transparent 60%),
		linear-gradient(135deg, var(--bg-grad-1) 0%, var(--bg-grad-2) 100%);
	color: var(--text);
}

.theme-dark header {
	background: rgba(255, 255, 255, 0.04);
	backdrop-filter: blur(10px);
	border-bottom: 1px solid var(--border);
}

/* Ensure sufficient color contrast in dark theme */
.theme-dark a,
.theme-dark p,
.theme-dark label,
.theme-dark span,
.theme-dark h1,
.theme-dark h2,
.theme-dark h3,
.theme-dark h4 {
	color: var(--text);
}

/* Increase touch targets on mobile */
@media (max-width: 480px) {
    .audio-button,
    .audition-button,
    .submit-button {
        min-height: 48px;
    }
}

.theme-dark header h1 {
	color: var(--text);
	text-shadow: 0 0 24px rgba(110, 168, 254, 0.25);
}

.theme-dark .subtitle {
	color: rgba(230, 237, 243, 0.75);
}

.theme-dark #game-container {
	background: var(--panel);
	border: 1px solid var(--border);
	box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.theme-dark #puzzle-info {
	border-bottom: 1px solid var(--border);
}

.theme-dark .info-row h2 {
	font-size: 1.1rem;
	font-weight: 600;
}

.theme-dark #puzzle-info h2 {
	color: var(--accent);
}

.theme-dark #effect-description {
	color: var(--muted);
}

 

.theme-dark #audio-section { }

.theme-dark #dry-sample, 
.theme-dark #effected-sample {
	background: var(--panel-alt);
	border-left: 4px solid var(--accent);
}

.theme-dark #dry-sample h3, 
.theme-dark #effected-sample h3 {
	color: var(--text);
}

.theme-dark .audio-tip {
	color: var(--muted);
}

.theme-dark .audio-button {
	background: var(--accent);
	box-shadow: 0 4px 18px rgba(110, 168, 254, 0.35);
}

.theme-dark .audio-button:hover {
	background: var(--accent-strong);
	box-shadow: 0 6px 24px rgba(110, 168, 254, 0.45);
}

.theme-dark #guess-section {
	background: var(--panel-alt);
}

.theme-dark #parameter-label {
	color: var(--text);
}

.theme-dark #parameter-slider {
	background: #2a3140;
}

.theme-dark #parameter-slider::-webkit-slider-thumb {
	background: var(--accent);
    border-color: rgba(12,18,28,0.9);
}

.theme-dark .slider-labels {
	color: var(--muted);
}

.theme-dark #parameter-value {
	color: var(--accent);
}

.theme-dark #parameter-unit {
	color: var(--muted);
}

.theme-dark .audition-section {
	background: #2b2210;
	border: 1px solid #403012;
}

.theme-dark .audition-button {
	background: var(--warning);
	color: #1c1c1c;
	box-shadow: 0 4px 18px rgba(255, 176, 32, 0.25);
}

.theme-dark .audition-button:hover {
	background: #eaa10e;
}

.theme-dark .audition-tip {
	color: #ffd58a;
}

.theme-dark .submit-button {
	background: var(--success);
	box-shadow: 0 4px 18px rgba(34, 197, 94, 0.28);
}

.theme-dark .submit-button:hover:not(:disabled) {
	background: #1fab53;
	box-shadow: 0 6px 24px rgba(34, 197, 94, 0.36);
}

.theme-dark .submit-button:disabled {
	background: #3a3f46;
	color: #888;
}

.theme-dark #results {
	background: #0f1b12;
	border-left-color: var(--success);
}

.theme-dark .score-display {
	color: var(--success);
}

.theme-dark .correct-answer {
	color: var(--text);
}

.theme-dark .explanation {
	color: var(--muted);
}

 

.theme-dark footer {
	background: rgba(255, 255, 255, 0.04);
	color: rgba(230, 237, 243, 0.75);
}

/* Tooltips */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translateX(-50%);
    background: rgba(17, 24, 39, 0.95);
    color: #e5e7eb;
    padding: 6px 8px;
    font-size: 12px;
    line-height: 1;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 20;
}

[data-tooltip]:hover::after {
    opacity: 1;
}

.theme-dark [data-tooltip]::after {
	background: var(--panel-alt);
	color: var(--text);
	border: 1px solid var(--border);
}

/* Dialogs & messages */
.theme-dark .autoplay-message {
	background: var(--panel);
	color: var(--text);
	border: 1px solid var(--border);
}

.theme-dark .autoplay-message h3 {
	color: var(--accent);
}

.theme-dark .autoplay-message p {
	color: var(--muted);
}

.theme-dark .autoplay-message button {
	background: var(--success);
}

.theme-dark .error-message {
	background: #2a1416;
	color: #ffb4bd;
	border-color: #4a1f24;
}

.theme-dark .error-message button {
	background: var(--danger);
}

/* Focus visibility for accessibility */
.theme-dark button:focus-visible,
.theme-dark input[type="range"]:focus-visible,
.theme-dark a:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
	box-shadow: 0 0 0 3px rgba(110, 168, 254, 0.35);
}

/* =============================
   DAW/Plugin Controls (Knob)
   ============================= */
.control-row {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 1.25rem;
}

.knob-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.knob {
    --size: 96px;
    --knob-rotation: 0deg;
    width: var(--size);
    height: var(--size);
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #3a4250 0%, #222832 60%, #1a1f27 100%);
    border: 1px solid rgba(0,0,0,0.6);
    position: relative;
    box-shadow: inset 0 8px 20px rgba(255,255,255,0.08), inset 0 -10px 30px rgba(0,0,0,0.6), 0 10px 24px rgba(0,0,0,0.45);
    cursor: grab;
    outline: none;
    transform: translateZ(0);
}

.knob:focus-visible {
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.4), inset 0 8px 20px rgba(255,255,255,0.08), inset 0 -10px 30px rgba(0,0,0,0.6);
}

.knob.dragging { cursor: grabbing; }

.knob::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 6px;
    height: 26px;
    background: linear-gradient(180deg, #c5d2e8 0%, #8fa2c2 100%);
    border-radius: 3px;
    transform-origin: 50% 38px;
    transform: translate(-50%, -38px) rotate(var(--knob-rotation));
    box-shadow: 0 2px 6px rgba(0,0,0,0.5);
}

.knob::after {
    content: '';
    position: absolute;
    inset: 10px;
    border-radius: 50%;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), inset 0 -2px 6px rgba(0,0,0,0.6);
}

.knob-labels {
    display: flex;
    width: 100%;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #666;
}

.visually-hidden {
    position: absolute !important;
    height: 1px; width: 1px;
    overflow: hidden;
    clip: rect(1px, 1px, 1px, 1px);
    white-space: nowrap;
}

.parameter-display { margin-top: 0.25rem; }

/* Theme overrides for knob */
.theme-dark .knob {
    background: radial-gradient(circle at 30% 30%, #3a4250 0%, #1e2530 60%, #151a21 100%);
    border-color: rgba(255,255,255,0.05);
}

.theme-dark .knob::before {
    background: linear-gradient(180deg, #d4e0f7 0%, #93a6c6 100%);
}

.theme-dark .knob-labels { color: var(--muted); }

/* =============================
   Plugin Chrome (Header, Screws, LED)
   ============================= */
.plugin-header {
    position: relative;
    display: grid;
    grid-template-columns: 24px 1fr 10px 24px;
    align-items: center;
    gap: 12px;
    margin-bottom: 1rem;
}

.plugin-header .brand {
    text-transform: uppercase;
    letter-spacing: 0.2em;
    font-weight: 700;
    opacity: 0.9;
    font-size: 0.85rem;
}

.plugin-header .screw {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #9aa4b2 0%, #6b7280 50%, #4b5563 100%);
    box-shadow: inset 0 1px 1px rgba(255,255,255,0.4), inset 0 -1px 2px rgba(0,0,0,0.6);
    position: relative;
}

.plugin-header .screw::before {
    content: '';
    position: absolute;
    left: 50%; top: 50%;
    width: 14px; height: 2px;
    background: #222;
    transform: translate(-50%, -50%) rotate(20deg);
    opacity: 0.6;
}

.plugin-header .led {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: #24313f;
    box-shadow: 0 0 0 2px rgba(0,0,0,0.5), inset 0 -1px 2px rgba(0,0,0,0.5);
}

.theme-dark .plugin-header .brand { color: var(--muted); }
.theme-dark .plugin-header .led.on {
    background: #30e07c;
    box-shadow: 0 0 10px rgba(48,224,124,0.7), 0 0 0 2px rgba(0,0,0,0.6);
}

/* =============================
   Transport & Plugin Controls
   ============================= */
.transport {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 1rem;
}

.transport-button, .toggle-button {
    background: var(--panel-alt);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 0.6rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
}

.transport-button:hover, .toggle-button:hover {
    background: #243040;
}

.toggle-button[aria-pressed="true"] {
    background: #382b2b;
    border-color: #4a2f2f;
}

.plugin-controls {
    display: flex;
    align-items: stretch;
    gap: 1.25rem;
    margin-bottom: 1rem;
}

.fixed-parameters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 1rem;
}

.fixed-knob {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
}

.knob-readonly {
    cursor: default;
}

.knob-caption {
    font-size: 0.8rem;
    color: var(--muted);
}

.knob-value {
    font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.9rem;
    color: var(--text);
}
