:root {
    --primary: #4f46e5;
    --bg: #f8fafc;
    --sidebar-bg: #1e293b;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --key-bg: #ffffff;
    --key-border: #e2e8f0;
    --correct: #22c55e;
    --incorrect: #ef4444;
    --active: #fbbf24;
}

body {
    margin: 0;
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg);
    color: var(--text-main);
    overflow: hidden;
    zoom: 0.80;
}

.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    color: white;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.brand h1 {
    font-size: 1.5rem;
    margin: 0 0 2rem 0;
    color: #818cf8;
}

.lesson-nav h3 {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    margin-bottom: 1rem;
}

.lesson-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    max-height: 70vh;
}

.lesson-nav li {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 0.25rem;
    font-size: 0.95rem;
}

.lesson-nav li:hover {
    background: #334155;
}

.lesson-nav li.active {
    background: var(--primary);
    color: white;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
}

.stats-bar {
    display: flex;
    gap: 2rem;
    background: white;
    padding: 1rem 2rem;
    border-radius: 1rem;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    margin-bottom: 2rem;
    width: 100%;
    max-width: 900px;
    justify-content: space-around;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-item .label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.stat-item .value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

.nav-btn {
    background: var(--primary);
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    transition: opacity 0.2s;
}

.nav-btn:hover {
    opacity: 0.9;
}

/* Typing Area */
.typing-container {
    position: relative;
    width: 100%;
    max-width: 900px;
    background: white;
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    margin-bottom: 2rem;
}

.text-display {
    font-family: 'Roboto Mono', monospace;
    font-size: 1.5rem;
    line-height: 1.6;
    word-break: break-all;
    color: #94a3b8;
    min-height: 120px;
}

.char.current {
    border-bottom: 3px solid var(--primary);
    color: var(--text-main);
    background: #eef2ff;
}

.char.correct {
    color: var(--correct);
}

.char.incorrect {
    color: var(--incorrect);
    background: #fee2e2;
}

#hidden-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.message-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 1rem;
    z-index: 10;
}

/* Keyboard Styles */
.visuals-container {
    width: 100%;
    max-width: 1400px;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    /* Align hands with keyboard */
    gap: 1rem;
    margin-top: 1rem;
}

.hand-pane {
    width: 180px;
    height: 180px;
    flex-shrink: 0;
}

.hand-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.keyboard {
    background: #e2e8f0;
    padding: 1rem;
    border-radius: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    user-select: none;
    flex-shrink: 1;
    /* Allow scaling if needed, though transform is better */
}

.row {
    display: flex;
    justify-content: center;
    gap: 0.4rem;
}

.key {
    background: var(--key-bg);
    border: 1px solid var(--key-border);
    border-radius: 0.5rem;
    width: 54px;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.1s;
    text-align: center;
    line-height: 1.1;
}

.key.active-key {
    background: var(--active);
    color: white;
    transform: translateY(2px);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.key.space {
    width: 360px;
}

.key.backspace {
    width: 100px;
}

.key.tab {
    width: 60px;
}

.key.caps {
    width: 75px;
}

.key.enter {
    width: 85px;
}

.key.shift-l,
.key.shift-r {
    width: 100px;
}

/* Hands */
.hand-shape {
    stroke: #cbd5e1;
    transition: stroke 0.3s;
}

.finger-dot {
    transition: opacity 0.2s;
}

button {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    background: var(--primary);
    color: white;
    font-weight: 700;
    cursor: pointer;
    margin: 0.5rem;
}

/* ==================== STARTUP POPUP ==================== */
.startup-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: 1rem;
    box-sizing: border-box;
    animation: popupFadeIn 0.4s ease-out;
}

.startup-popup.hidden {
    display: none;
}

.popup-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #1e1b4b 100%);
    background-size: 400% 400%;
    animation: gradientShift 8s ease infinite;
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

@keyframes popupFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.popup-content {
    position: relative;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 1.5rem;
    padding: 2.5rem;
    max-width: 520px;
    width: 100%;
    text-align: center;
    box-shadow:
        0 25px 50px -12px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.2) inset;
    animation: popupSlideUp 0.5s ease-out;
    overflow: hidden;
}

@keyframes popupSlideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.popup-glow {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, rgba(79, 70, 229, 0.15) 0%, transparent 50%);
    animation: glowPulse 3s ease-in-out infinite;
    pointer-events: none;
}

@keyframes glowPulse {

    0%,
    100% {
        opacity: 0.5;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.1);
    }
}

.popup-header {
    margin-bottom: 1.5rem;
}

.popup-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    animation: iconBounce 2s ease infinite;
}

@keyframes iconBounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

.popup-header h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 0.5rem 0;
}

.popup-header .highlight {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.popup-subtitle {
    color: #64748b;
    font-size: 1rem;
    margin: 0;
}

.finger-guide-container {
    margin: 1.5rem 0;
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.15);
    border: 3px solid #e2e8f0;
    transition: all 0.3s ease;
}

.finger-guide-container:hover {
    transform: scale(1.02);
    box-shadow: 0 15px 40px -5px rgba(79, 70, 229, 0.25);
    border-color: #4f46e5;
}

.finger-guide-image {
    width: 100%;
    height: auto;
    display: block;
}

.popup-instructions {
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border-radius: 1rem;
    padding: 1.25rem;
    margin: 1.5rem 0;
    text-align: left;
}

.popup-instructions h3 {
    font-size: 1rem;
    color: #1e293b;
    margin: 0 0 0.75rem 0;
}

.popup-instructions ul {
    list-style: none;
    padding: 0;
    margin: 0 0 0.75rem 0;
}

.popup-instructions li {
    padding: 0.4rem 0;
    font-size: 0.9rem;
    color: #475569;
    display: flex;
    gap: 0.5rem;
}

.popup-instructions li::before {
    content: "•";
    color: #4f46e5;
    font-weight: bold;
}

.finger-left {
    color: #dc2626;
    font-weight: 600;
}

.finger-right {
    color: #2563eb;
    font-weight: 600;
}

.finger-thumb {
    color: #16a34a;
    font-weight: 600;
}

.popup-instructions .tip {
    font-size: 0.85rem;
    color: #7c3aed;
    background: rgba(124, 58, 237, 0.1);
    padding: 0.75rem;
    border-radius: 0.5rem;
    margin: 0;
    font-weight: 500;
}

.popup-start-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    border: none;
    padding: 1rem 2.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.4);
    margin: 0.5rem 0;
}

.popup-start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(79, 70, 229, 0.5);
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}

.popup-start-btn:active {
    transform: translateY(0);
}

.popup-start-btn svg {
    transition: transform 0.3s ease;
}

.popup-start-btn:hover svg {
    transform: translateX(4px);
}

.dont-show-again {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
    font-size: 0.85rem;
    color: #64748b;
    cursor: pointer;
    transition: color 0.2s;
}

.dont-show-again:hover {
    color: #4f46e5;
}

.dont-show-again input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #4f46e5;
    cursor: pointer;
}

/* Responsive adjustments for popup */
@media (max-width: 600px) {
    .popup-content {
        padding: 1.5rem;
        margin: 0.5rem;
    }

    .popup-header h2 {
        font-size: 1.4rem;
    }

    .popup-instructions {
        padding: 1rem;
    }

    .popup-start-btn {
        width: 100%;
        padding: 1rem;
    }
}