/**
 * Chordflow: Yamaha Keyboard Workstation Stylesheet
 * High-fidelity digital synthesizer aesthetic, responsive multi-touch keyboard deck,
 * ivory/ebony 3D key depression, glowing LED guide strips, and backlit LCD display.
 */

:root {
    --chassis-bg: #141720;
    --chassis-metal: linear-gradient(180deg, #252b38 0%, #171b24 60%, #10131a 100%);
    --panel-inset: #0d0f15;
    --border-dark: #2c3242;
    --border-accent: #00f0ff;
    
    /* Yamaha LCD */
    --lcd-glass: #071512;
    --lcd-border: #14352f;
    --lcd-glow: #00ffcc;
    --lcd-dim: rgba(0, 255, 204, 0.25);
    --lcd-text: #00ffcc;
    --lcd-subtext: #6ce9d1;
    
    /* Keys & Accents */
    --felt-strip: #b3162b;
    --key-white-top: #ffffff;
    --key-white-base: #e1e5ee;
    --key-white-shadow: #9aa4b6;
    --key-black-top: #2c2f38;
    --key-black-base: #111317;
    --led-glow-cyan: #00ffff;
    --accent-gold: #ffbe3b;
    --accent-red: #ff3366;
    --accent-green: #00e676;
    
    --text-primary: #f0f3f8;
    --text-muted: #8b96a8;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #0a0c10;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    color: var(--text-primary);
}

/* Master Workstation Enclosure */
.workstation-app {
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100vh;
    background: var(--chassis-bg);
    overflow: hidden;
    position: relative;
}

/* Top Navigation / Brand Bar */
.top-header {
    height: 48px;
    background: #0f1218;
    border-bottom: 1px solid #232836;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    flex-shrink: 0;
    z-index: 10;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 10px;
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 6px;
    background: #1b202c;
    border: 1px solid #2a3142;
    transition: all 0.2s ease;
}

.back-btn:hover {
    color: #fff;
    border-color: var(--border-accent);
    background: #242b3b;
}

.app-title {
    font-size: 17px;
    font-weight: 800;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    background: linear-gradient(135deg, #ffffff 30%, var(--border-accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.model-badge {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--accent-gold);
    background: rgba(255, 190, 59, 0.12);
    border: 1px solid rgba(255, 190, 59, 0.35);
    padding: 2px 8px;
    border-radius: 12px;
    text-transform: uppercase;
}

.header-status {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: var(--text-muted);
}

.midi-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
}

.midi-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #444d60;
}

.midi-dot.connected {
    background: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green);
}

/* Upper Deck: Yamaha Hardware Console */
.hardware-console {
    background: var(--chassis-metal);
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-bottom: 3px solid #0a0c10;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
    flex-shrink: 0;
}

.console-main-row {
    display: flex;
    gap: 16px;
    align-items: stretch;
}

/* Yamaha Backlit LCD Screen */
.yamaha-lcd {
    flex: 1.6;
    background: var(--lcd-glass);
    border: 3px solid var(--lcd-border);
    border-radius: 8px;
    padding: 10px 16px;
    box-shadow: inset 0 0 24px rgba(0, 255, 204, 0.12), 0 3px 10px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 94px;
    position: relative;
    overflow: hidden;
}

.yamaha-lcd::after {
    /* Subtle LCD scanline overlay */
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%);
    background-size: 100% 4px;
    pointer-events: none;
    opacity: 0.6;
}

.lcd-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    border-bottom: 1px dashed rgba(0, 255, 204, 0.2);
    padding-bottom: 4px;
}

.lcd-chord-title {
    font-family: "Courier New", Courier, monospace;
    font-size: 28px;
    font-weight: 900;
    color: var(--lcd-text);
    text-shadow: 0 0 10px rgba(0, 255, 204, 0.65);
    letter-spacing: 1.5px;
    line-height: 1;
}

.lcd-chord-subtitle {
    font-size: 13px;
    color: var(--lcd-subtext);
    font-style: italic;
}

.lcd-beat-tracker {
    display: flex;
    align-items: center;
    gap: 6px;
}

.lcd-beat-pill {
    width: 26px;
    height: 26px;
    border: 1px solid rgba(0, 255, 204, 0.35);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: monospace;
    font-size: 14px;
    font-weight: 800;
    color: rgba(0, 255, 204, 0.35);
    transition: all 0.04s ease;
}

.lcd-beat-pill.active {
    background: var(--lcd-text);
    color: #000;
    box-shadow: 0 0 12px var(--lcd-text);
    border-color: var(--lcd-text);
    transform: scale(1.06);
}

.lcd-footer-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: monospace;
    font-size: 12px;
    color: #49b89d;
    padding-top: 4px;
}

/* Console Control Banks */
.console-bank {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: var(--panel-inset);
    border: 1px solid var(--border-dark);
    border-radius: 8px;
    padding: 8px 12px;
}

.bank-label {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.btn-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.c-btn {
    background: #1e2432;
    border: 1px solid #323b4e;
    color: #d8deeb;
    padding: 6px 10px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.12s ease;
    outline: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.c-btn:hover {
    background: #2a3346;
    border-color: var(--border-accent);
    color: #fff;
}

.c-btn.active {
    background: linear-gradient(135deg, #00f0ff 0%, #0088ff 100%);
    border-color: #00f0ff;
    color: #000;
    font-weight: 800;
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
}

.c-btn.primary-drum {
    background: linear-gradient(180deg, #ff3366, #bf1740);
    border: none;
    color: #fff;
    padding: 6px 14px;
    box-shadow: 0 2px 8px rgba(255, 51, 102, 0.35);
}

.c-btn.primary-drum.running {
    background: linear-gradient(180deg, #00e676, #00964b);
    box-shadow: 0 2px 8px rgba(0, 230, 118, 0.45);
}

.bpm-ctrl {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-family: monospace;
    color: var(--text-muted);
}

.bpm-ctrl input[type="range"] {
    width: 80px;
    accent-color: var(--border-accent);
    cursor: pointer;
}

/* Active Interactive Playground / Visualizer Area */
.play-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: #0d0f14;
    overflow: hidden;
}

/* Highway / Falling Waterfall Canvas */
.waterfall-zone {
    flex: 1;
    position: relative;
    background: linear-gradient(180deg, #0c0f16 0%, #11151f 100%);
    overflow: hidden;
}

#waterfallCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

.hit-target-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, transparent 0%, var(--border-accent) 20%, #ff0077 50%, var(--border-accent) 80%, transparent 100%);
    box-shadow: 0 0 12px var(--border-accent);
    z-index: 5;
}

/* Lower Deck: Yamaha Piano Bed */
.keyboard-deck {
    background: #090a0d;
    padding: 10px 16px 14px;
    border-top: 3px solid #000;
    box-shadow: inset 0 10px 20px rgba(0, 0, 0, 0.8);
    position: relative;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Red Yamaha Felt Cushion Strip */
.felt-cushion {
    width: 100%;
    max-width: 1100px;
    height: 6px;
    background: var(--felt-strip);
    border-radius: 2px 2px 0 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.25);
    margin-bottom: 2px;
}

/* Piano Keys Bed */
.keys-container {
    position: relative;
    width: 100%;
    max-width: 1100px;
    height: 190px;
    display: flex;
    justify-content: center;
    touch-action: none; /* Prevents mobile gestures while playing */
}

/* White Keys */
.key-w {
    position: relative;
    flex: 1;
    height: 100%;
    background: linear-gradient(180deg, var(--key-white-top) 0%, var(--key-white-base) 80%, #c9cfdc 100%);
    border: 1px solid #7c8699;
    border-top: none;
    border-radius: 0 0 6px 6px;
    cursor: pointer;
    z-index: 1;
    box-shadow: inset 0 -5px 0 var(--key-white-shadow), 0 5px 8px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    padding-bottom: 8px;
    color: #2b313e;
    font-size: 13px;
    font-weight: 800;
    transition: transform 0.04s ease, box-shadow 0.04s ease, background 0.04s ease;
}

.key-w:active, .key-w.is-pressed {
    background: linear-gradient(180deg, #dde2ec 0%, #c5cbd8 100%);
    box-shadow: inset 0 -2px 0 #858e9f, 0 1px 3px rgba(0, 0, 0, 0.6);
    transform: translateY(3px);
}

.key-w.is-lit {
    background: linear-gradient(180deg, #b8faf2 0%, #4ae9d8 100%);
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.85), inset 0 -3px 0 #00bfa5;
    border-color: #00d2c4;
}

/* Black Keys */
.key-b {
    position: absolute;
    width: 30px;
    height: 60%;
    background: linear-gradient(180deg, var(--key-black-top) 0%, var(--key-black-base) 85%, #050608 100%);
    border: 1px solid #000;
    border-radius: 0 0 5px 5px;
    cursor: pointer;
    z-index: 3;
    box-shadow: inset 0 -3px 0 #3b4252, 0 6px 10px rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    padding-bottom: 6px;
    color: #798499;
    font-size: 11px;
    font-weight: 700;
    transition: transform 0.04s ease, box-shadow 0.04s ease, background 0.04s ease;
}

.key-b:active, .key-b.is-pressed {
    background: #020305;
    box-shadow: inset 0 -1px 0 #1b1e26, 0 2px 4px rgba(0, 0, 0, 0.9);
    transform: translateY(3px);
}

.key-b.is-lit {
    background: linear-gradient(180deg, #0077ff 0%, #00f0ff 100%);
    box-shadow: 0 0 22px rgba(0, 240, 255, 0.95);
    border-color: #00f0ff;
    color: #000;
}

/* LED Guide Lamp Strip */
.key-led {
    position: absolute;
    top: 5px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #252b38;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.6);
    transition: all 0.08s ease;
}

.key-w.is-lit .key-led, .key-b.is-lit .key-led {
    background: var(--led-glow-cyan);
    box-shadow: 0 0 12px var(--led-glow-cyan), 0 0 24px var(--led-glow-cyan);
}

.finger-badge {
    position: absolute;
    top: 20px;
    font-size: 10px;
    font-weight: 800;
    color: #007799;
    opacity: 0;
    transition: opacity 0.1s ease;
}

.key-w.is-lit .finger-badge, .key-b.is-lit .finger-badge {
    opacity: 1;
}

.key-qwerty {
    font-size: 9px;
    font-weight: 600;
    color: #8c96a8;
}

/* Bottom Deck Utility Strip */
.deck-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1100px;
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-muted);
}

.octave-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.octave-btn {
    background: #191f2b;
    border: 1px solid #2d3648;
    color: #e2e8f4;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
}

.octave-btn:hover {
    border-color: var(--border-accent);
}

/* Mobile & Touch Responsiveness */
@media (max-width: 768px) {
    .console-main-row {
        flex-direction: column;
        gap: 8px;
    }
    
    .yamaha-lcd {
        min-height: 80px;
        padding: 8px 12px;
    }
    
    .lcd-chord-title {
        font-size: 22px;
    }

    .keys-container {
        height: 155px;
    }

    .c-btn {
        padding: 5px 8px;
        font-size: 10px;
    }
}

/* ==========================================================================
   GAMIFICATION HUD OVERLAY
   ========================================================================== */
.game-hud-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 42px;
    background: rgba(10, 13, 20, 0.85);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(0, 240, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 15;
}

.hud-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.song-badge {
    background: rgba(0, 240, 255, 0.12);
    border: 1px solid var(--border-accent);
    color: var(--border-accent);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
}

.song-badge:hover {
    background: rgba(0, 240, 255, 0.25);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
}

.hud-player-xp {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
}

.hud-level-pill {
    background: linear-gradient(135deg, #ff9500, #ff2d55);
    color: #fff;
    font-weight: 900;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
}

.hud-xp-track {
    width: 80px;
    height: 6px;
    background: #1c2230;
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid #2f384c;
}

.hud-xp-fill {
    height: 100%;
    width: 25%;
    background: linear-gradient(90deg, #00f0ff, #00ff88);
    transition: width 0.3s ease;
}

.hud-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.hud-stat-box {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.hud-stat-label {
    font-size: 9px;
    font-weight: 800;
    color: var(--text-muted);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.hud-stat-value {
    font-family: monospace;
    font-size: 17px;
    font-weight: 900;
    color: #fff;
    line-height: 1;
}

.hud-streak-pill {
    background: linear-gradient(135deg, #ff9500, #ff3366);
    color: #fff;
    font-size: 10px;
    font-weight: 900;
    padding: 3px 8px;
    border-radius: 12px;
    box-shadow: 0 0 12px rgba(255, 51, 102, 0.6);
    animation: pulseGlow 0.8s infinite alternate ease-in-out;
}

@keyframes pulseGlow {
    from { transform: scale(1); box-shadow: 0 0 8px rgba(255, 51, 102, 0.4); }
    to { transform: scale(1.06); box-shadow: 0 0 16px rgba(255, 51, 102, 0.9); }
}

.hud-progress-meter {
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: rgba(255, 255, 255, 0.1);
}

.hud-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--border-accent);
    box-shadow: 0 0 8px var(--border-accent);
    transition: width 0.1s linear;
}

/* ==========================================================================
   MODAL WINDOWS (Missions, Victory, Codex)
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(5, 7, 12, 0.85);
    backdrop-filter: blur(12px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}

.modal-dialog {
    background: linear-gradient(180deg, #1b212e 0%, #11151f 100%);
    border: 2px solid #2e384c;
    border-radius: 16px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8), 0 0 30px rgba(0, 240, 255, 0.15);
    max-width: 600px;
    width: 100%;
    overflow: hidden;
    animation: modalIn 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalIn {
    from { transform: scale(0.92); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-header {
    background: #232a3b;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #333d52;
}

.modal-title {
    font-size: 18px;
    font-weight: 800;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 22px;
    font-weight: bold;
    cursor: pointer;
}

.modal-close-btn:hover {
    color: #fff;
}

.modal-body {
    padding: 20px;
    max-height: 70vh;
    overflow-y: auto;
}

/* Mission Track Cards */
.missions-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mission-card {
    background: #141924;
    border: 1px solid #283244;
    border-radius: 10px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.15s ease;
}

.mission-card:hover {
    border-color: var(--border-accent);
    background: #1a2130;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 240, 255, 0.2);
}

.mission-info h4 {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 4px;
}

.mission-info p {
    font-size: 12px;
    color: var(--text-muted);
}

.mission-meta {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mission-stars {
    color: var(--accent-gold);
    font-size: 15px;
    letter-spacing: 2px;
}

.mission-play-btn {
    background: linear-gradient(135deg, #00f0ff, #0077ff);
    border: none;
    color: #000;
    font-weight: 800;
    font-size: 12px;
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 240, 255, 0.4);
}

/* Victory Celebration Modal */
.victory-card {
    text-align: center;
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.victory-grade {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff9500, #ffbe3b);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 38px;
    font-weight: 900;
    color: #000;
    box-shadow: 0 0 30px rgba(255, 190, 59, 0.7);
    border: 3px solid #fff;
}

.victory-stars {
    font-size: 32px;
    color: var(--accent-gold);
    letter-spacing: 6px;
    text-shadow: 0 0 15px rgba(255, 190, 59, 0.8);
}

.victory-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    width: 100%;
    margin-top: 8px;
}

.v-stat {
    background: #141824;
    border: 1px solid #283144;
    border-radius: 8px;
    padding: 10px;
}

.v-stat-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
}

.v-stat-val {
    font-size: 20px;
    font-weight: 900;
    color: #fff;
    font-family: monospace;
    margin-top: 4px;
}

.victory-actions {
    display: flex;
    gap: 12px;
    width: 100%;
    margin-top: 10px;
}

.v-btn {
    flex: 1;
    padding: 12px;
    font-size: 14px;
    font-weight: 800;
    border-radius: 8px;
    cursor: pointer;
    border: none;
    transition: all 0.15s ease;
}

.v-btn-primary {
    background: linear-gradient(135deg, #00f0ff, #0088ff);
    color: #000;
    box-shadow: 0 4px 15px rgba(0, 240, 255, 0.4);
}

.v-btn-secondary {
    background: #252e40;
    color: #fff;
    border: 1px solid #3c4860;
}
