:root {
    --primary-color: #00ff41;
    --secondary-color: #ff6b35;
    --background-color: #0a0a0a;
    --surface-color: #1a1a1a;
    --panel-color: #2a2a2a;
    --text-primary: #00ff41;
    --text-secondary: #ffffff;
    --text-dim: #888888;
    --accent-color: #ff6b35;
    --success-color: #00ff41;
    --warning-color: #ffff00;
    --error-color: #ff0040;
    --border-color: #333333;
    --shadow: 0 0 20px rgba(0, 255, 65, 0.3);
    --shadow-lg: 0 0 30px rgba(0, 255, 65, 0.5);
    --neon-glow: 0 0 10px currentColor;
}

/* Cyber theme */
[data-theme="cyber"] {
    --primary-color: #00bfff;
    --secondary-color: #ff1493;
    --background-color: #0a0a0f;
    --surface-color: #1a1a2a;
    --panel-color: #2a2a3a;
    --text-primary: #00bfff;
    --text-secondary: #ffffff;
    --text-dim: #8888aa;
    --accent-color: #ff1493;
    --success-color: #00bfff;
    --warning-color: #ffaa00;
    --error-color: #ff0080;
    --border-color: #4444aa;
    --shadow: 0 0 20px rgba(0, 191, 255, 0.3);
    --shadow-lg: 0 0 30px rgba(0, 191, 255, 0.5);
    --neon-glow: 0 0 10px currentColor;
}

/* Neon theme */
[data-theme="neon"] {
    --primary-color: #ff00ff;
    --secondary-color: #00ffff;
    --background-color: #0f0a0f;
    --surface-color: #2a1a2a;
    --panel-color: #3a2a3a;
    --text-primary: #ff00ff;
    --text-secondary: #ffffff;
    --text-dim: #aa88aa;
    --accent-color: #00ffff;
    --success-color: #ff00ff;
    --warning-color: #ffff00;
    --error-color: #ff0040;
    --border-color: #aa44aa;
    --shadow: 0 0 20px rgba(255, 0, 255, 0.3);
    --shadow-lg: 0 0 30px rgba(255, 0, 255, 0.5);
    --neon-glow: 0 0 10px currentColor;
}

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

body {
    font-family: 'Press Start 2P', 'Space Mono', 'Courier New', monospace;
    background: var(--background-color);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
    background-image: 
        radial-gradient(circle at 20% 20%, rgba(0, 255, 65, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(255, 107, 53, 0.1) 0%, transparent 50%);
    font-size: 8px;
    line-height: 1.6;
    touch-action: manipulation; /* Desactiva zoom en doble tap */
}

/* Prevent pull-to-refresh */
body {
    overscroll-behavior-y: contain;
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 100vw;
    overflow-x: hidden;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--surface-color);
    border-bottom: 2px solid var(--primary-color);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.back-btn {
    background: none;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    padding: 0.5rem;
    margin-right: 1rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    text-shadow: var(--neon-glow);
}

.back-btn:hover {
    background: var(--primary-color);
    color: var(--background-color);
    box-shadow: var(--shadow);
}

.title {
    font-size: 1rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: var(--neon-glow);
    flex-grow: 1; /* Make title take available space */
    text-align: center; /* Center text within that space */
    white-space: nowrap; /* Ensure single line */
    overflow: hidden; /* Hide overflow */
    text-overflow: ellipsis; /* Add ellipsis if truncated */
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 1rem;
}

.screen {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Home Screen */
.welcome-section {
    text-align: center;
    margin-bottom: 2rem;
}

.app-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    filter: drop-shadow(0 0 10px var(--primary-color));
}

.welcome-section h2 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 1px;
    text-shadow: var(--neon-glow);
}

.welcome-section p {
    color: var(--text-dim);
    font-size: 1rem;
}

.menu-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 400px;
    margin: 0 auto;
}

.menu-btn {
    display: flex;
    align-items: center;
    padding: 1.5rem;
    background: var(--panel-color);
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    color: var(--text-primary);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-family: inherit; /* Apply retro font to menu buttons */
}

.menu-btn:hover {
    background: var(--primary-color);
    color: var(--background-color);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.menu-icon {
    font-size: 1.5rem;
    margin-right: 1.5rem;
    filter: drop-shadow(0 0 5px currentColor);
}

/* Tuner Screen Styles */
.panel-title {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    font-size: 1.2rem;
    letter-spacing: 2px;
    text-shadow: var(--neon-glow);
}

.tuner-strings {
    margin-bottom: 1.5rem;
}

.string-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.string-btn {
    padding: 0.8rem;
    background: var(--surface-color);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-dim);
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    font-size: 0.7rem;
    text-align: center;
}

.string-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--background-color);
    box-shadow: var(--shadow);
}

.string-btn:hover:not(.active) {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.string-note {
    display: block;
    font-size: 0.9rem;
    font-weight: 400;
    margin-bottom: 0.3rem;
}

.string-name {
    display: block;
    font-size: 0.6rem;
    opacity: 0.8;
}

/* Detector Screen - Synth Panel */
.detector-container {
    display: flex;
    justify-content: center;
    padding: 0;
}

.synth-panel {
    background: linear-gradient(145deg, var(--panel-color), var(--surface-color));
    border: 3px solid var(--primary-color);
    border-radius: 16px;
    padding: 1.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    position: relative;
}

.synth-panel::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, var(--primary-color), var(--accent-color));
    border-radius: 18px;
    z-index: -1;
    opacity: 0.3;
}

.led-display {
    background: #000;
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.frequency-readout {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.frequency-readout .label {
    font-size: 0.8rem;
    color: var(--text-dim);
    letter-spacing: 1px;
}

.frequency-readout .value {
    font-size: 1rem;
    color: var(--primary-color);
    text-shadow: var(--neon-glow);
    font-weight: 400;
}

.note-section {
    margin-bottom: 1.5rem;
}

.note-display {
    text-align: center;
    background: #000;
    border: 2px solid var(--accent-color);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.note-main {
    font-size: 2.5rem;
    font-weight: 400;
    color: var(--accent-color);
    text-shadow: 0 0 20px var(--accent-color);
    margin-bottom: 0.5rem;
    font-family: inherit;
}

.note-secondary {
    font-size: 1.5rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.cents-display {
    font-size: 1rem;
    color: var(--warning-color);
    font-weight: 400;
    text-shadow: var(--neon-glow);
}

.scale-display {
    width: 100%;
    max-width: 400px;
    text-align: center;
    padding: 1.5rem;
    background: var(--surface-color);
    border-radius: 1rem;
    border: 1px solid var(--border-color);
}

.scale-display h3 {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.scale-name {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 1rem;
    color: var(--success-color);
}

.scale-notes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.scale-note {
    padding: 0.25rem 0.75rem;
    background: var(--primary-color);
    border-radius: 1rem;
    font-size: 0.875rem;
    color: white;
}

.controls {
    display: flex;
    gap: 1rem;
}

.control-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 2rem;
    border: none;
    border-radius: 1rem;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.control-btn.primary {
    background: var(--success-color);
    border-color: var(--success-color);
    color: var(--background-color);
}

.control-btn.danger {
    background: var(--error-color);
    border-color: var(--error-color);
    color: white;
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.tuner-section {
    margin-bottom: 1.5rem;
}

.tuner-visual {
    position: relative;
    height: 80px;
    background: #000;
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    padding: 1rem;
    overflow: hidden;
}

.tuner-marks {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
    font-size: 1.2rem;
    color: var(--text-dim);
}

.tuner-marks .center {
    color: var(--success-color);
    text-shadow: var(--neon-glow);
}

.tuner-needle {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 3px;
    height: 30px;
    background: var(--accent-color);
    transform: translateX(-50%) translateY(-50%);
    transform-origin: bottom;
    transition: transform 0.1s;
    box-shadow: 0 0 10px var(--accent-color);
    border-radius: 2px;
}

.tuner-arc {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 30px;
    border: 2px solid var(--primary-color);
    border-bottom: none;
    border-radius: 60px 60px 0 0;
    opacity: 0.5;
}

.controls-section {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.synth-btn {
    flex: 1;
    padding: 1rem;
    border: 2px solid;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.synth-btn.primary {
    background: var(--success-color);
    border-color: var(--success-color);
    color: var(--background-color);
}

.synth-btn.danger {
    background: var(--error-color);
    border-color: var(--error-color);
    color: white;
}

.synth-btn.secondary {
    background: var(--surface-color);
    border-color: var(--text-dim);
    color: var(--text-primary);
}
.synth-btn.secondary:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.synth-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 20px currentColor;
}

.btn-light {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.7;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* Confidence meter */
.confidence-meter {
    margin-top: 1rem;
    background: #000;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.5rem;
}

.confidence-label {
    font-size: 0.7rem;
    color: var(--text-dim);
    text-align: center;
    margin-bottom: 0.3rem;
    letter-spacing: 1px;
}

.confidence-track {
    width: 100%;
    height: 10px;
    background: var(--surface-color);
    border-radius: 5px;
    overflow: hidden;
}

.confidence-bar {
    height: 100%;
    width: 0%;
    background: var(--success-color); /* Default to green */
    border-radius: 5px;
    transition: width 0.1s ease-out, background-color 0.1s ease-out;
}

/* Settings Screen */
.settings-container {
    display: flex;
    justify-content: center;
}

.settings-container .synth-panel {
    max-width: 400px;
}

.settings-container h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    font-size: 1.2rem;
    letter-spacing: 2px;
    text-shadow: var(--neon-glow);
}

.setting-group {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.setting-group label {
    display: block;
    margin-bottom: 0.75rem;
    font-weight: 400;
    font-size: 0.8rem;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.setting-group input[type="range"] {
    flex: 1;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

.setting-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px var(--primary-color);
}

.synth-select {
    width: 100%;
    padding: 0.75rem;
    background: var(--background-color);
    border: 2px solid var(--primary-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
}

.setting-value {
    color: var(--accent-color);
    font-weight: 400;
    font-size: 0.9rem;
    min-width: 35px;
    text-align: center;
    text-shadow: var(--neon-glow);
}

/* Footer */
.footer {
    padding: 1.5rem;
    text-align: center;
    background: var(--surface-color);
    border-top: 2px solid var(--primary-color);
    margin-top: 20px;
}

.version {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.credits {
    font-size: 0.8rem;
    color: var(--text-dim);
}

.credits a {
    color: var(--accent-color);
    text-decoration: none;
    text-shadow: var(--neon-glow);
}

.credits a:hover {
    text-decoration: underline;
}

/* Modal - Retro Style */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-overlay.active {
    display: flex;
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    background: var(--panel-color);
    border: 3px solid var(--primary-color);
    border-radius: 16px;
    max-width: 350px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from { transform: translateY(-20px) scale(0.95); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem 0;
}

.modal-header h3 {
    color: var(--primary-color);
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-shadow: var(--neon-glow);
}

.modal-close {
    background: none;
    border: 2px solid var(--accent-color);
    color: var(--accent-color);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--accent-color);
    color: var(--background-color);
}

.modal-body {
    padding: 1.5rem;
}

.modal-body p {
    color: var(--text-secondary);
    line-height: 1.8;
    font-size: 1rem;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    padding: 0 1.5rem 1.5rem;
    justify-content: flex-end;
}

.modal-btn {
    padding: 0.75rem 1.5rem;
    border: 2px solid;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.2s;
    font-family: inherit;
}

.modal-btn.primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--background-color);
}

.modal-btn.secondary {
    background: transparent;
    border-color: var(--text-dim);
    color: var(--text-dim);
}

.modal-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 15px currentColor;
}

/* Responsive */
@media (max-width: 480px) {
    body {
        font-size: 7px;
    }
    
    .main-content {
        padding: 0.75rem;
    }
    
    .synth-panel {
        padding: 1rem;
    }
    
    .note-main {
        font-size: 2rem;
    }
    
    .controls-section {
        flex-direction: column;
    }
    
    .synth-btn {
        width: 100%;
    }
}