/* ============================================
   MORSE CODE TRAINER - NordVPN-inspired Light Theme
   Clean, professional, trustworthy design
   ============================================ */

/* CSS Variables - NordVPN-inspired palette */
:root {
    /* Primary Colors - NordVPN Blue */
    --primary: #4687FF;
    --primary-dark: #3366CC;
    --primary-light: #6BA3FF;
    --primary-subtle: rgba(70, 135, 255, 0.1);

    /* Neutral Colors */
    --white: #FFFFFF;
    --gray-50: #F8FAFC;
    --gray-100: #F1F5F9;
    --gray-200: #E2E8F0;
    --gray-300: #CBD5E1;
    --gray-400: #94A3B8;
    --gray-500: #64748B;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1E293B;
    --gray-900: #0F172A;

    /* Semantic Colors */
    --success: #22C55E;
    --success-light: #DCFCE7;
    --error: #EF4444;
    --error-light: #FEE2E2;
    --warning: #F59E0B;
    --warning-light: #FEF3C7;

    /* Morse Code Colors */
    --dot-color: #4687FF;
    --dash-color: #1E293B;

    /* Background */
    --bg-primary: var(--white);
    --bg-secondary: var(--gray-50);
    --bg-card: var(--white);

    /* Text */
    --text-primary: var(--gray-900);
    --text-secondary: var(--gray-500);
    --text-muted: var(--gray-400);

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 24px;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;

    /* Typography Scale */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    --text-4xl: 2.25rem;
    --text-5xl: 3rem;

    /* Line Heights */
    --leading-tight: 1.25;
    --leading-normal: 1.5;
    --leading-relaxed: 1.625;

    /* Letter Spacing */
    --tracking-tight: -0.025em;
    --tracking-normal: 0;
    --tracking-wide: 0.025em;

    /* Font */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Import Inter font - professional and clean */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Prevent double-tap zoom on mobile */
button,
.btn,
.morse-btn,
.filter-btn,
.nav-link,
.mode-card,
.reference-card,
.backspace-btn,
input,
a {
    touch-action: manipulation;
}

/* Prevent double-tap zoom on mobile */
button,
.btn,
.morse-btn,
.filter-btn,
.nav-link,
.mode-card,
.reference-card,
.backspace-btn,
input,
a {
    touch-action: manipulation;
}

body {
    font-family: var(--font-family);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--text-primary);
    background: #ffffff;
    min-height: 100vh;
}

/* ============================================
   TYPOGRAPHY - Professional hierarchy
   ============================================ */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: var(--leading-tight);
    letter-spacing: var(--tracking-tight);
    color: var(--text-primary);
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }

p {
    color: var(--text-secondary);
    line-height: var(--leading-relaxed);
}

/* ============================================
   HEADER - Clean and minimal with scroll behavior
   ============================================ */
/* Online Users Indicator (inline in navbar) */
.online-users-indicator {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.7rem;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-left: 1rem;
}

.online-dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    animation: pulse-online 2s ease-in-out infinite;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.6);
}

@keyframes pulse-online {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.2);
    }
}

.online-count {
    font-weight: 700;
    font-size: 0.8rem;
    color: #22c55e;
}

.online-text {
    color: var(--text-secondary);
    font-size: 0.7rem;
}

/* Mobile: hide text, show only dot and count */
@media (max-width: 768px) {
    .online-users-indicator {
        padding: 0.25rem 0.5rem;
        margin-left: 0.5rem;
    }

    .online-text {
        display: none;
    }

    .online-dot {
        width: 6px;
        height: 6px;
    }

    .online-count {
        font-size: 0.75rem;
    }
}

.header,
.navbar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding: 0.75rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    transition: all 0.3s ease;
}

/* Collapsed header state (when scrolled) */
.navbar.collapsed {
    padding: 0.5rem 1rem;
    box-shadow: var(--shadow-md);
}

.navbar.collapsed .nav-links {
    display: none;
}

.navbar.collapsed .nav-hamburger {
    display: flex;
}

.navbar.collapsed .nav-logo .logo-text {
    display: none;
}

/* Hamburger Menu Button */
.nav-hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    width: 40px;
    height: 40px;
    background: var(--gray-100);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
    padding: 0;
}

.nav-hamburger:hover {
    background: var(--gray-200);
}

.nav-hamburger.active {
    background: var(--primary);
}

.nav-hamburger.active .hamburger-line {
    background: var(--white);
}

.hamburger-line {
    width: 20px;
    height: 2px;
    background: var(--gray-600);
    border-radius: 1px;
    transition: var(--transition-fast);
}

.nav-hamburger.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(4px, 4px);
}

.nav-hamburger.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.nav-hamburger.active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(4px, -4px);
}

/* Dropdown Menu */
.nav-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    min-width: 200px;
    padding: 0.5rem;
    z-index: 1000;
    animation: dropdownSlide 0.2s ease;
}

@keyframes dropdownSlide {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.nav-dropdown.show {
    display: block;
}

.nav-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: var(--text-sm);
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
}

.nav-dropdown-item:hover {
    background: var(--gray-100);
    color: var(--text-primary);
}

.nav-dropdown-logout {
    color: var(--error);
}

.nav-dropdown-logout:hover {
    background: var(--error-light);
    color: var(--error);
}

.nav-dropdown-login {
    background: var(--primary);
    color: var(--white);
}

.nav-dropdown-login:hover {
    background: var(--primary-dark);
    color: var(--white);
}

.nav-dropdown-divider {
    height: 1px;
    background: var(--gray-200);
    margin: 0.5rem 0;
}

.nav-dropdown-user {
    display: block;
    padding: 0.5rem 1rem;
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
}

/* Username in nav */
.nav-username {
    display: none;
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
}

/* Language Selector */
.lang-selector {
    display: flex;
    align-items: center;
    margin-left: 0.5rem;
}

.lang-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    font-size: 1.25rem;
    text-decoration: none;
    border-radius: var(--radius-md);
    background: var(--gray-100);
    transition: var(--transition-fast);
}

.lang-btn:hover {
    background: var(--gray-200);
    transform: scale(1.05);
}

.nav-dropdown-lang {
    padding: 0.25rem 0;
}

.header-content,
.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

/* Ensure online indicator stays with logo */
.nav-logo-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo,
.nav-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    font-weight: 800;
    font-size: var(--text-lg);
    color: var(--text-primary);
}

.logo-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
}

.logo-dash {
    display: inline-block;
    width: 20px;
    height: 5px;
    background: var(--gray-800);
    border-radius: 3px;
}

.logo-text {
    color: var(--text-primary);
}

.nav,
.nav-links {
    display: flex;
    gap: 0.125rem;
    align-items: center;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem;
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: var(--text-sm);
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
}

.nav-link .nav-icon {
    font-size: 1rem;
    line-height: 1;
}

.nav-link .nav-text {
    /* Visible on desktop */
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--gray-100);
}

.nav-link.active {
    color: var(--primary);
    background: var(--primary-subtle);
}

.btn-compact {
    padding: 0.5rem 1rem;
    font-size: var(--text-sm);
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    background: var(--gray-100);
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--text-primary);
}

/* Level Badge in Navigation */
.user-level-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem 0.75rem;
    background: linear-gradient(135deg, var(--primary-subtle), rgba(139, 92, 246, 0.1));
    border: 1px solid var(--primary);
    border-radius: var(--radius-lg);
    text-decoration: none;
    transition: var(--transition-fast);
    cursor: pointer;
    min-width: 60px;
}

.user-level-badge:hover {
    background: linear-gradient(135deg, rgba(70, 135, 255, 0.2), rgba(139, 92, 246, 0.2));
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(70, 135, 255, 0.3);
}

.level-badge-content {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.level-icon {
    font-size: 1rem;
    line-height: 1;
}

.level-number {
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--primary);
}

/* Mini XP Progress Bar in Navigation */
.level-progress-mini {
    width: 100%;
    height: 4px;
    background: rgba(70, 135, 255, 0.2);
    border-radius: 2px;
    overflow: hidden;
}

.level-progress-fill-mini {
    height: 100%;
    background: linear-gradient(90deg, #FFD700, #FFA500);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.nav-link-logout {
    color: var(--text-muted);
}

.nav-link-logout:hover {
    color: var(--error);
    background: var(--error-light);
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
    min-height: calc(100vh - 140px);
}

/* Mobile compact main content */
@media (max-width: 768px) {
    .main-content {
        padding: 0.75rem;
    }
}

/* ============================================
   HERO SECTION - Clean and impactful
   ============================================ */
.hero {
    text-align: center;
    padding: 4rem 2rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: var(--radius-2xl);
    margin-bottom: 3rem;
}

.hero-title {
    font-size: var(--text-4xl);
    font-weight: 800;
    color: var(--white);
    margin-bottom: 1rem;
    letter-spacing: var(--tracking-tight);
}

.hero-subtitle {
    font-size: var(--text-lg);
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 2rem;
    font-weight: 500;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

/* ============================================
   BUTTONS - Clean with subtle depth
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-family: var(--font-family);
    font-size: var(--text-sm);
    font-weight: 600;
    text-decoration: none;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--gray-800);
    color: var(--white);
}

.btn-secondary:hover {
    background: var(--gray-900);
}

.btn-outline {
    background: var(--white);
    color: var(--text-primary);
    border: 1px solid var(--gray-300);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-subtle);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--gray-100);
    color: var(--text-primary);
}

.btn-large {
    padding: 1rem 2rem;
    font-size: var(--text-base);
}

.btn-xlarge {
    padding: 1.125rem 2.5rem;
    font-size: var(--text-lg);
    border-radius: var(--radius-lg);
}

/* ============================================
   SECTION TITLES
   ============================================ */
.section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.section-subtitle {
    color: var(--text-secondary);
    font-size: var(--text-base);
    margin-bottom: 1.5rem;
}

/* ============================================
   MODE CARDS - Clean and minimal
   ============================================ */
.modes-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

/* Mobile: Keep 2 columns but make cards compact */
@media (max-width: 768px) {
    .modes-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }
}

.mode-card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    text-decoration: none;
    color: inherit;
    border: 1px solid var(--gray-200);
    transition: var(--transition-normal);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.mode-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.mode-card-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
}

.mode-card-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.mode-card-title {
    font-size: var(--text-lg);
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.mode-card-description {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: var(--leading-relaxed);
}

.mode-card-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--primary-subtle);
    color: var(--primary);
    font-size: var(--text-xs);
    font-weight: 600;
    border-radius: var(--radius-full);
}

.mode-card-badge.challenge {
    background: var(--warning-light);
    color: var(--warning);
}

/* Mobile compact mode cards */
@media (max-width: 768px) {
    .mode-card {
        padding: 0.75rem;
        border-radius: var(--radius-lg);
    }

    .mode-card-icon {
        width: 40px;
        height: 40px;
        margin-bottom: 0.5rem;
    }

    .mode-card-title {
        font-size: var(--text-sm);
        margin-bottom: 0.25rem;
    }

    /* Hide descriptions on mobile for compact view */
    .mode-card-description {
        display: none;
    }

    .mode-card-badge {
        padding: 0.125rem 0.5rem;
        font-size: 0.65rem;
    }
}

/* Sections - compact on mobile */
.modes-section {
    margin-bottom: 1rem;
}

@media (max-width: 768px) {
    .modes-section {
        margin-bottom: 0.75rem;
    }

    .section-title {
        font-size: var(--text-base);
        margin-bottom: 0.25rem;
    }

    .section-subtitle {
        font-size: var(--text-xs);
        margin-bottom: 0.75rem;
    }
}

/* Challenge section */
.challenge-section {
    background: var(--bg-card);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-2xl);
    padding: 2rem;
    margin-bottom: 1.5rem;
}

.challenge-section.compact {
    padding: 1.5rem;
}

.challenge-section.compact .section-subtitle {
    font-size: var(--text-sm);
    color: var(--text-muted);
}

/* Mobile compact challenge section */
@media (max-width: 768px) {
    .challenge-section {
        padding: 1rem;
        border-radius: var(--radius-lg);
        margin-bottom: 0.75rem;
    }

    .challenge-section.compact {
        padding: 0.75rem;
    }

    .challenge-section.compact .section-subtitle {
        font-size: var(--text-xs);
    }
}

.scoring-rules {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.scoring-rule {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.scoring-rule-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-xs);
}

.scoring-rule-icon.correct {
    background: var(--success-light);
    color: var(--success);
}

.scoring-rule-icon.incorrect {
    background: var(--error-light);
    color: var(--error);
}

.scoring-rule-icon.bonus {
    background: var(--warning-light);
    color: var(--warning);
}

/* ============================================
   TRAINING INTERFACE
   ============================================ */
.training-container {
    max-width: 600px;
    margin: 0 auto;
}

.training-container.wide {
    max-width: 800px;
}

.training-header {
    text-align: center;
    margin-bottom: 2rem;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: var(--text-sm);
    margin-bottom: 1rem;
    transition: var(--transition-fast);
}

.back-link:hover {
    color: var(--primary);
}

.training-header h1 {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.training-header p {
    color: var(--text-secondary);
    font-size: var(--text-base);
}

.training-area {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 2rem;
    border: 1px solid var(--gray-200);
}

/* Character Display */
.question-display {
    text-align: center;
    margin-bottom: 2rem;
}

.character-display {
    font-size: 6rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
    margin-bottom: 0.5rem;
    text-align: center;
}

.word-display {
    font-size: 4rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
    margin-bottom: 0.5rem;
    text-align: center;
    text-transform: uppercase;
}

/* Game area centering for challenges */
.game-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    width: 100%;
}

.game-area .question-container {
    text-align: center;
    width: 100%;
}

.game-area .answer-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

.game-area .submit-btn {
    margin: 0 auto;
}

.game-area .word-input {
    text-align: center;
}

.character-type {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
}

/* Pattern Display */
.pattern-display {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.pattern-display.large {
    gap: 1.5rem;
}

/* Morse Visual Elements */
.vis-dot {
    display: inline-block;
    width: 16px;
    height: 16px;
    background: var(--primary);
    border-radius: 50%;
    margin: 0 5px;
    vertical-align: middle;
}

.vis-dot.large {
    width: 24px;
    height: 24px;
    margin: 0 8px;
}

.vis-dash {
    display: inline-block;
    width: 40px;
    height: 12px;
    background: var(--gray-800);
    border-radius: 6px;
    margin: 0 5px;
    vertical-align: middle;
}

.vis-dash.large {
    width: 56px;
    height: 16px;
    border-radius: 8px;
    margin: 0 8px;
}

/* Space between letters (within a word) */
.vis-letter-space {
    display: inline-block;
    width: 20px;
    margin: 0 2px;
}

/* Smaller space (legacy) */
.vis-space {
    display: inline-block;
    width: 12px;
}

/* Word separator */
.vis-word-space {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 1.25rem;
}

/* Answer Input Area */
.answer-display {
    background: var(--gray-50);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    min-height: 72px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    border: 2px dashed var(--gray-300);
}

.answer-display .placeholder {
    color: var(--text-muted);
    font-weight: 500;
}

/* Morse Slots - Visual Input */
.morse-slots-container {
    justify-content: space-between;
    padding: 1rem 1.5rem;
}

.morse-slots {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.morse-slot {
    width: 48px;
    height: 48px;
    background: var(--white);
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.morse-slot.filled {
    border-style: solid;
    animation: slotFill 0.2s ease;
}

.morse-slot.dot {
    border-color: var(--primary);
    background: var(--primary-subtle);
}

.morse-slot.dash {
    border-color: var(--gray-800);
    background: rgba(30, 41, 59, 0.1);
}

@keyframes slotFill {
    0% { transform: scale(0.8); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.slot-dot {
    width: 20px;
    height: 20px;
    background: var(--primary);
    border-radius: 50%;
}

.slot-dash {
    width: 32px;
    height: 10px;
    background: var(--gray-800);
    border-radius: 5px;
}

@media (max-width: 480px) {
    .morse-slot {
        width: 40px;
        height: 40px;
    }

    .slot-dot {
        width: 16px;
        height: 16px;
    }

    .slot-dash {
        width: 26px;
        height: 8px;
    }
}

.backspace-btn {
    margin-left: auto;
    background: var(--gray-200);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 1.125rem;
    color: var(--text-secondary);
    transition: var(--transition-fast);
}

.backspace-btn:hover {
    background: var(--error);
    color: var(--white);
}

/* Morse Input Buttons */
.morse-buttons {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.morse-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 1rem 1.5rem;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    font-family: var(--font-family);
    font-weight: 600;
    font-size: var(--text-sm);
    transition: var(--transition-fast);
    min-width: 90px;
}

.morse-btn.dot-btn {
    background: var(--primary);
    color: var(--white);
}

.morse-btn.dot-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.morse-btn.dash-btn {
    background: var(--gray-800);
    color: var(--white);
}

.morse-btn.dash-btn:hover {
    background: var(--gray-900);
    transform: translateY(-1px);
}

.morse-btn.space-btn,
.morse-btn.word-btn {
    background: var(--gray-200);
    color: var(--text-secondary);
}

.morse-btn.space-btn:hover,
.morse-btn.word-btn:hover {
    background: var(--gray-300);
}

.morse-btn-icon {
    font-size: 1.25rem;
}

/* Backspace button styling for morse-btn class */
.morse-btn.backspace-btn {
    background: var(--gray-200);
    color: var(--text-secondary);
}

.morse-btn.backspace-btn:hover {
    background: var(--error);
    color: var(--white);
}

/* Word-to-Morse Input Display */
.word-morse-input {
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
}

/* ============================================
   MORSE INPUT DISPLAY - User's morse code input area
   ============================================ */
.morse-input {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 56px;
    padding: 0.875rem 1.25rem;
    background: var(--gray-50);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-lg);
    margin-bottom: 1rem;
    transition: var(--transition-fast);
}

.morse-input:focus-within,
.morse-input:hover {
    border-color: var(--primary);
    background: var(--white);
    box-shadow: 0 0 0 3px var(--primary-subtle);
}

.morse-input .placeholder {
    color: var(--text-muted);
    font-weight: 500;
    font-size: var(--text-sm);
}

.morse-input .vis-dot {
    width: 16px;
    height: 16px;
    background: var(--primary);
    border-radius: 50%;
    margin: 0 3px;
    box-shadow: 0 1px 3px rgba(70, 135, 255, 0.3);
}

.morse-input .vis-dash {
    width: 36px;
    height: 12px;
    background: var(--gray-800);
    border-radius: 6px;
    margin: 0 3px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.morse-input .vis-space {
    width: 20px;
    height: 12px;
    margin: 0 4px;
    border-left: 2px dashed var(--gray-300);
}

/* Alternative morse-input-display for other contexts */
.morse-input-display {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    min-height: 48px;
    padding: 0.75rem 1rem;
    background: var(--white);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-lg);
    transition: var(--transition-fast);
}

.morse-input-display:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-subtle);
}

.morse-input-display .placeholder {
    color: var(--text-muted);
    font-weight: 500;
}

.morse-input-display .vis-dot {
    width: 14px;
    height: 14px;
    margin: 0 2px;
}

.morse-input-display .vis-dash {
    width: 32px;
    height: 10px;
    margin: 0 2px;
}

.morse-input-display .vis-space {
    width: 16px;
    height: 10px;
    margin: 0 4px;
}

/* Text Input */
.letter-input,
.sentence-input,
.word-input {
    width: 100%;
    padding: 1rem 1.25rem;
    font-family: var(--font-family);
    font-size: var(--text-lg);
    font-weight: 600;
    text-align: center;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-lg);
    background: var(--white);
    color: var(--text-primary);
    transition: var(--transition-fast);
}

.letter-input:focus,
.sentence-input:focus,
.word-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-subtle);
}

.letter-input.large {
    font-size: var(--text-3xl);
    padding: 1.25rem;
    text-transform: uppercase;
}

.letter-input.correct,
.sentence-input.correct,
.word-input.correct {
    border-color: var(--success);
    background: var(--success-light);
}

.letter-input.incorrect,
.sentence-input.incorrect,
.word-input.incorrect {
    border-color: var(--error);
    background: var(--error-light);
    animation: shake 0.4s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-bottom: 1.5rem;
}

/* Feedback Display */
.feedback-display {
    text-align: center;
    padding: 1rem;
    border-radius: var(--radius-lg);
    font-weight: 600;
    opacity: 0;
    transform: translateY(-8px);
    transition: var(--transition-normal);
}

.feedback-display.show {
    opacity: 1;
    transform: translateY(0);
}

.feedback-display.correct {
    background: var(--success-light);
    color: var(--success);
}

.feedback-display.incorrect {
    background: var(--error-light);
    color: var(--error);
}

/* Stats Display */
.stats-display {
    display: flex;
    justify-content: center;
    gap: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--gray-200);
}

.stat-item {
    text-align: center;
}

.stat-label {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: var(--text-2xl);
    font-weight: 800;
    color: var(--primary);
}

.stat-value.streak {
    color: var(--warning);
}

/* Keyboard Hint */
.keyboard-hint {
    text-align: center;
    padding: 0.75rem;
    background: var(--gray-50);
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
}

.keyboard-hint p {
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.keyboard-hint kbd {
    display: inline-block;
    padding: 0.125rem 0.375rem;
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    font-family: var(--font-family);
    font-weight: 600;
    font-size: var(--text-xs);
    margin: 0 0.125rem;
}

/* ============================================
   CHALLENGE MODE
   ============================================ */
.challenge-container {
    max-width: 700px;
    margin: 0 auto;
}

.challenge-pregame {
    text-align: center;
    padding: 1rem;
}

.pregame-content {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 2rem;
    border: 1px solid var(--gray-200);
}

.challenge-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.challenge-description {
    font-size: var(--text-base);
    color: var(--text-secondary);
    margin-bottom: 2rem;
    line-height: var(--leading-relaxed);
}

/* Challenge Rules Card - Compact horizontal layout */
.challenge-rules-card {
    background: var(--gray-50);
    border-radius: var(--radius-lg);
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
}

.rules-grid {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.rule-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.rule-item .rule-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-sm);
}

.rule-item.correct .rule-icon {
    background: var(--success-light);
    color: var(--success);
}

.rule-item.incorrect .rule-icon {
    background: var(--error-light);
    color: var(--error);
}

.rule-item.bonus .rule-icon {
    background: var(--warning-light);
}

.rule-item .rule-text strong {
    color: var(--text-primary);
}

@media (max-width: 480px) {
    .rules-grid {
        gap: 0.75rem;
    }

    .rule-item {
        font-size: var(--text-xs);
    }

    .rule-item .rule-icon {
        width: 24px;
        height: 24px;
        font-size: var(--text-xs);
    }
}

.challenge-game {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 2rem;
    border: 1px solid var(--gray-200);
}

.game-header {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    margin-bottom: 2rem;
}

.timer-display,
.score-display,
.streak-display {
    text-align: center;
}

.timer-icon,
.streak-flames {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.timer-value {
    font-size: var(--text-3xl);
    font-weight: 800;
    color: var(--text-primary);
}

.timer-value.warning {
    color: var(--warning);
}

.timer-value.critical {
    color: var(--error);
    animation: pulse 0.5s ease infinite;
}

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

.timer-label,
.score-label,
.streak-label {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
}

.score-value {
    font-size: var(--text-3xl);
    font-weight: 800;
    color: var(--primary);
}

.streak-value {
    font-size: var(--text-2xl);
    font-weight: 800;
    color: var(--warning);
}

.feedback-flash {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    font-size: var(--text-3xl);
    font-weight: 800;
    padding: 1rem 2rem;
    border-radius: var(--radius-lg);
    opacity: 0;
    pointer-events: none;
    z-index: 1000;
    transition: all 0.15s ease;
}

.feedback-flash.show {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.feedback-flash.correct {
    background: var(--success);
    color: var(--white);
}

.feedback-flash.incorrect {
    background: var(--error);
    color: var(--white);
}

/* Game Over Screen */
.challenge-gameover {
    text-align: center;
    padding: 2rem;
}

.gameover-content {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 3rem;
    border: 1px solid var(--gray-200);
}

.gameover-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.final-score {
    margin: 2rem 0;
}

.final-score-label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
}

.final-score-value {
    font-size: var(--text-5xl);
    font-weight: 800;
    color: var(--primary);
}

.personal-best {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.personal-best.new-best {
    color: var(--warning);
    font-weight: 600;
}

.mini-leaderboard {
    background: var(--gray-50);
    border-radius: var(--radius-lg);
    padding: 1rem;
    margin-bottom: 2rem;
}

.mini-score {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    border-radius: var(--radius-md);
}

.mini-score.highlight {
    background: var(--primary-subtle);
}

.mini-rank {
    width: 32px;
    font-weight: 700;
    color: var(--text-muted);
}

.mini-name {
    flex: 1;
    font-weight: 600;
}

.mini-points {
    font-weight: 700;
    color: var(--primary);
}

.gameover-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
}

/* XP Earned Display */
.xp-earned {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    border-radius: var(--radius-lg);
    margin: 1rem 0;
    animation: xpPop 0.5s ease;
}

@keyframes xpPop {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

.xp-earned-icon {
    font-size: 1.5rem;
}

.xp-earned-value {
    font-size: var(--text-2xl);
    font-weight: 800;
    color: #8B4513;
}

.xp-earned-label {
    font-size: var(--text-xs);
    font-weight: 600;
    color: rgba(139, 69, 19, 0.8);
}

/* New Achievements Display */
.new-achievements {
    background: var(--success-light);
    border: 2px solid var(--success);
    border-radius: var(--radius-lg);
    padding: 1rem;
    margin-bottom: 1.5rem;
    animation: achievementSlide 0.5s ease;
}

@keyframes achievementSlide {
    0% { transform: translateY(-20px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

.new-achievements h3 {
    font-size: var(--text-base);
    font-weight: 700;
    color: var(--success);
    margin-bottom: 0.75rem;
}

.achievements-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
}

.achievement-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.achievement-icon-small {
    width: 32px;
    height: 32px;
}

.achievement-name {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
}

/* ============================================
   REFERENCE PAGE
   ============================================ */
.reference-container {
    max-width: 1000px;
    margin: 0 auto;
}

.reference-header {
    text-align: center;
    margin-bottom: 2rem;
}

.reference-header h1 {
    font-size: var(--text-3xl);
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.reference-legend {
    display: flex;
    justify-content: center;
    gap: 2rem;
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    margin-bottom: 2rem;
    border: 1px solid var(--gray-200);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.dot-symbol {
    display: inline-block;
    width: 14px;
    height: 14px;
    background: var(--primary);
    border-radius: 50%;
}

.dash-symbol {
    display: inline-block;
    width: 32px;
    height: 8px;
    background: var(--gray-800);
    border-radius: 4px;
}

.reference-section {
    margin-bottom: 2rem;
}

.reference-section h2 {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
    padding-left: 0.75rem;
    border-left: 3px solid var(--primary);
}

.reference-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.5rem;
}

.reference-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 1rem 0.75rem;
    text-align: center;
    border: 1px solid var(--gray-200);
    transition: var(--transition-fast);
    cursor: pointer;
}

.reference-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.ref-char {
    display: block;
    font-size: var(--text-2xl);
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 0.375rem;
}

.ref-pattern {
    display: none;
}

.ref-visual {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2px;
    flex-wrap: nowrap;
    min-height: 12px;
    max-width: 100%;
    padding: 0 2px;
}

.ref-visual .vis-dot {
    width: 6px;
    height: 6px;
    min-width: 6px;
    min-height: 6px;
    margin: 0 1px;
    flex-shrink: 0;
    aspect-ratio: 1 / 1;
    vertical-align: middle;
}

.ref-visual .vis-dash {
    width: 14px;
    height: 6px;
    min-width: 14px;
    min-height: 6px;
    margin: 0 1px;
    flex-shrink: 0;
    border-radius: 3px;
    vertical-align: middle;
}

/* ============================================
   CHARACTER MASTERY VISUALIZATION
   ============================================ */

/* Mastery Legend - Simplified Gradient */
.mastery-legend {
    background: var(--bg-card);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
}

.mastery-gradient-legend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.mastery-label-start,
.mastery-label-end {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.mastery-label-end {
    color: #1976D2;
}

.mastery-gradient-bar {
    width: 200px;
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(90deg,
        #E2E8F0 0%,
        #FFF8E1 15%,
        #FFE082 35%,
        #FFD54F 55%,
        #90CAF9 80%,
        #42A5F5 100%
    );
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Mastery Progress */
.mastery-progress {
    display: flex;
    justify-content: center;
    margin-top: 0.75rem;
}

.mastery-progress-text {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-secondary);
}

/* Legacy mastery samples (for backwards compatibility) */
.mastery-sample {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    border: 2px solid transparent;
}

.mastery-sample.mastery-untrained {
    background: var(--gray-100);
    border-color: var(--gray-300);
}

.mastery-sample.mastery-mastered {
    background: linear-gradient(135deg, #E3F2FD 0%, #90CAF9 50%, #42A5F5 100%);
    border-color: #2196F3;
    box-shadow: 0 0 8px rgba(33, 150, 243, 0.4);
}

/* Mastery Card Styles */
.mastery-card {
    position: relative;
    transition: all var(--transition-fast);
}

.mastery-indicator {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

/* Untrained state - gray/white */
.mastery-card.mastery-untrained {
    background: var(--gray-50);
    border-color: var(--gray-200);
}

.mastery-card.mastery-untrained .ref-char {
    color: var(--gray-400);
}

.mastery-card.mastery-untrained .vis-dot {
    background: var(--gray-300);
}

.mastery-card.mastery-untrained .vis-dash {
    background: var(--gray-400);
}

/* Learning state - gold gradient based on intensity (softer for first steps) */
.mastery-card.mastery-learning {
    --gold-intensity: 0.5;
    /* Use CSS variable for dynamic intensity - softer for first steps */
    background: linear-gradient(
        135deg,
        rgba(255, 248, 225, calc(var(--gold-intensity) * 0.8 + 0.2)) 0%,
        rgba(255, 224, 130, calc(var(--gold-intensity) * 0.6)) 100%
    );
    border-color: rgba(255, 213, 79, calc(var(--gold-intensity) * 0.8 + 0.2));
    border-width: 2px;
}

.mastery-card.mastery-learning .ref-char {
    /* Softer orange for first steps, deeper for higher mastery */
    color: rgba(230, 81, 0, calc(var(--gold-intensity) * 0.5 + 0.5));
}

.mastery-card.mastery-learning .vis-dot {
    background: rgba(255, 152, 0, calc(var(--gold-intensity) * 0.5 + 0.5));
}

.mastery-card.mastery-learning .vis-dash {
    background: rgba(230, 81, 0, calc(var(--gold-intensity) * 0.5 + 0.5));
}

.mastery-card.mastery-learning .mastery-indicator {
    background: rgba(255, 152, 0, calc(var(--gold-intensity) * 0.3 + 0.1));
    color: #E65100;
}

/* Mastered state - diamond */
.mastery-card.mastery-mastered {
    background: linear-gradient(135deg, #E3F2FD 0%, #BBDEFB 50%, #90CAF9 100%);
    border-color: #2196F3;
    box-shadow: 0 0 12px rgba(33, 150, 243, 0.3);
}

.mastery-card.mastery-mastered .ref-char {
    color: #1565C0;
    text-shadow: 0 0 8px rgba(33, 150, 243, 0.5);
}

.mastery-card.mastery-mastered .vis-dot {
    background: #1976D2;
    box-shadow: 0 0 4px rgba(33, 150, 243, 0.5);
}

.mastery-card.mastery-mastered .vis-dash {
    background: #0D47A1;
    box-shadow: 0 0 4px rgba(33, 150, 243, 0.5);
}

.mastery-card.mastery-mastered .mastery-indicator {
    font-size: 1rem;
    background: transparent;
}

/* Hover effects for mastery cards */
.mastery-card.mastery-mastered:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 4px 16px rgba(33, 150, 243, 0.4);
}

.mastery-card.mastery-learning:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.3);
}

/* Mobile responsive mastery legend */
@media (max-width: 768px) {
    .mastery-legend {
        padding: 1rem;
    }

    .mastery-legend h3 {
        font-size: var(--text-sm);
    }

    .mastery-legend-items {
        gap: 0.5rem;
    }

    .mastery-legend-item {
        font-size: var(--text-xs);
    }

    .mastery-sample {
        width: 20px;
        height: 20px;
    }

    .mastery-progress-bar {
        max-width: 200px;
    }

    .mastery-progress-text {
        font-size: var(--text-xs);
    }

    .mastery-indicator {
        font-size: 0.6rem;
        min-width: 14px;
        height: 14px;
    }

    .mastery-card.mastery-mastered .mastery-indicator {
        font-size: 0.75rem;
    }
}

/* Tips Section */
.reference-tips {
    background: var(--bg-card);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-xl);
    padding: 2rem;
    margin-bottom: 2rem;
}

.reference-tips h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    border: none;
    padding: 0;
}

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

.tip-card {
    background: var(--gray-50);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.tip-card h3 {
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.375rem;
}

.tip-card p {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: var(--leading-relaxed);
}

.reference-cta {
    text-align: center;
}

/* ============================================
   LEADERBOARD
   ============================================ */
.leaderboard-container {
    max-width: 800px;
    margin: 0 auto;
}

.leaderboard-header {
    text-align: center;
    margin-bottom: 2rem;
}

.leaderboard-filters {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-full);
    font-family: var(--font-family);
    font-weight: 500;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
    text-decoration: none;
}

.filter-btn:hover,
.filter-btn.active {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-subtle);
}

.leaderboard-table {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    overflow: hidden;
    border: 1px solid var(--gray-200);
}

.leaderboard-row {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gray-100);
    transition: var(--transition-fast);
}

.leaderboard-row:last-child {
    border-bottom: none;
}

.leaderboard-row:hover {
    background: var(--gray-50);
}

.leaderboard-row.top-3 {
    background: linear-gradient(90deg, var(--warning-light) 0%, transparent 100%);
}

.rank {
    width: 48px;
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--text-muted);
}

.rank.gold { color: #F59E0B; }
.rank.silver { color: #94A3B8; }
.rank.bronze { color: #CD7F32; }

.rank-medal {
    font-size: 1.25rem;
}

.player-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.player-avatar {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-weight: 700;
    font-size: var(--text-sm);
}

.player-name {
    font-weight: 600;
}

.player-score {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--primary);
}

.player-mode {
    font-size: var(--text-xs);
    color: var(--text-muted);
    padding: 0.25rem 0.5rem;
    background: var(--gray-100);
    border-radius: var(--radius-sm);
}

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-container {
    max-width: 400px;
    margin: 3rem auto;
}

.login-card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 2.5rem 2rem;
    text-align: center;
    border: 1px solid var(--gray-200);
}

.login-mascot {
    font-size: 3rem;
    margin-bottom: 0.75rem;
}

.login-morse {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.login-title {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: var(--text-base);
    margin-bottom: 2rem;
}

.login-form {
    text-align: left;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.form-input {
    width: 100%;
    padding: 0.875rem 1rem;
    font-family: var(--font-family);
    font-size: var(--text-base);
    font-weight: 500;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-lg);
    background: var(--white);
    transition: var(--transition-fast);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-subtle);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.login-hint {
    text-align: center;
    margin-top: 1.5rem;
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.login-error {
    background: var(--error-light);
    color: var(--error);
    padding: 0.75rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    font-weight: 500;
    font-size: var(--text-sm);
}

/* ============================================
   FOOTER
   ============================================ */
.footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.footer-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

/* ============================================
   UTILITIES
   ============================================ */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 768px) {
    /* Compact header for mobile */
    .header,
    .navbar {
        padding: 0.5rem 1rem;
    }

    .header-content,
    .nav-container {
        flex-wrap: nowrap;
        gap: 0.5rem;
    }

    .logo,
    .nav-logo {
        font-size: var(--text-base);
        gap: 0.375rem;
    }

    .logo-dot {
        width: 6px;
        height: 6px;
    }

    .logo-dash {
        width: 16px;
        height: 4px;
    }

    /* Hide logo text on mobile, show only morse symbols */
    .logo-text {
        display: none;
    }

    .nav,
    .nav-links {
        gap: 0.125rem;
        flex-wrap: nowrap;
        overflow-x: auto;
    }

    .nav-link {
        padding: 0.375rem 0.5rem;
        font-size: 0.7rem;
        white-space: nowrap;
    }

    /* Hide nav link text, show only icons on mobile */
    .nav-link .nav-text {
        display: none;
    }

    .nav-link .nav-icon {
        font-size: 1.125rem;
    }

    .btn-compact {
        padding: 0.375rem 0.75rem;
        font-size: var(--text-xs);
    }

    .user-badge {
        padding: 0.25rem 0.5rem;
        font-size: var(--text-xs);
    }

    .user-level-badge {
        padding: 0.25rem 0.5rem;
        min-width: 44px;
        margin-left: 0.25rem;
        flex-shrink: 0;
    }

    .level-icon {
        font-size: 0.875rem;
    }

    .level-number {
        font-size: 0.6rem;
    }

    .level-progress-mini {
        height: 3px;
    }

    /* Ensure nav container doesn't clip content */
    .nav-container {
        padding-right: 0.5rem;
    }

    /* Hide username on mobile to save space */
    .nav-username {
        display: none;
    }

    /* Language selector compact on mobile */
    .lang-selector {
        margin-left: 0.25rem;
    }

    .lang-btn {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }

    .hero-title {
        font-size: var(--text-2xl);
    }

    .character-display {
        font-size: 4rem;
    }

    .morse-buttons {
        flex-wrap: wrap;
    }

    .morse-btn {
        min-width: 80px;
        padding: 0.875rem 1.25rem;
    }

    .game-header {
        flex-wrap: wrap;
        gap: 1rem;
    }

    .timer-value,
    .score-value {
        font-size: var(--text-2xl);
    }

    .reference-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }

    .reference-legend {
        flex-direction: column;
        gap: 0.75rem;
    }

    .scoring-rules {
        flex-direction: column;
        gap: 0.5rem;
    }

    .stats-display {
        gap: 1.5rem;
    }

    .stat-value {
        font-size: var(--text-xl);
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 1.5rem 1rem;
    }

    .hero {
        padding: 2.5rem 1.5rem;
    }

    .training-area {
        padding: 1.5rem 1rem;
    }

    .character-display {
        font-size: 3rem;
    }

    .letter-input.large {
        font-size: var(--text-2xl);
    }

    .action-buttons {
        flex-direction: column;
    }

    .btn-large {
        width: 100%;
    }
}

/* ============================================
   ANIMATIONS - Subtle and professional
   ============================================ */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes popIn {
    0% { transform: scale(0.9); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.pop-in {
    animation: popIn 0.2s ease;
}

/* Success celebration - subtle */
@keyframes celebrate {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.celebrate {
    animation: celebrate 0.3s ease;
}

/* ============================================
   MORSE VISUAL DISPLAY - For sentence challenges
   ============================================ */

/* Letter grouping for better readability */
.morse-word-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
}

.morse-word-group {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    flex-wrap: wrap;
}

/* Lightweight rounded box for each letter */
.morse-letter-box {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 0.375rem 0.5rem;
    background: var(--gray-50);
    border-radius: var(--radius-md);
    min-height: 28px;
}

.morse-letter-box .vis-dot {
    width: 12px;
    height: 12px;
    margin: 0 1px;
}

.morse-letter-box .vis-dash {
    width: 28px;
    height: 10px;
    margin: 0 1px;
}

/* Word gap (spacing between words) */
.vis-word-gap {
    display: inline-block;
    width: 1.5rem;
}

/* Mobile responsive letter boxes */
@media (max-width: 480px) {
    .morse-word-container {
        gap: 0.375rem;
        padding: 0.25rem;
    }

    .morse-word-group {
        gap: 0.25rem;
    }

    .morse-letter-box {
        gap: 2px;
        padding: 0.25rem 0.375rem;
        min-height: 24px;
    }

    .morse-letter-box .vis-dot {
        width: 10px;
        height: 10px;
    }

    .morse-letter-box .vis-dash {
        width: 22px;
        height: 8px;
    }

    .vis-word-gap {
        width: 1rem;
    }
}

.morse-visual-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--gray-50);
    border-radius: var(--radius-lg);
    max-width: 100%;
    overflow-x: auto;
}

.morse-word {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
}

.morse-letter {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 0.25rem 0.375rem;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    min-height: 28px;
}

.morse-vis-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    background: var(--primary);
    border-radius: 50%;
    flex-shrink: 0;
}

.morse-vis-dash {
    display: inline-block;
    width: 28px;
    height: 8px;
    background: var(--gray-800);
    border-radius: 4px;
    flex-shrink: 0;
}

.morse-word-divider {
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--text-muted);
    padding: 0 0.25rem;
}

/* Sentence display for sentence-to-morse mode */
.sentence-display {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    padding: 1rem;
    word-break: break-word;
}

/* Morse display for morse-to-sentence mode */
.morse-display {
    text-align: center;
    padding: 0.5rem;
}

/* ============================================
   IPHONE X OPTIMIZATIONS
   ============================================ */
/* Safe area insets for iPhone X notch */
@supports (padding: max(0px)) {
    .navbar,
    .header {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }

    .main-content {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
        padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
    }

    .footer {
        padding-bottom: max(2rem, env(safe-area-inset-bottom));
    }
}

/* iPhone X specific viewport (375x812) */
@media screen and (max-width: 414px) and (min-height: 700px) {
    /* Compact header for tall phones */
    .navbar,
    .header {
        padding: 0.75rem 1rem;
    }

    .nav-logo {
        font-size: var(--text-lg);
    }

    .logo-dot {
        width: 8px;
        height: 8px;
    }

    .logo-dash {
        width: 18px;
        height: 5px;
    }

    /* Compact navigation */
    .nav-link {
        padding: 0.375rem 0.625rem;
        font-size: 0.7rem;
    }

    .user-level-badge {
        padding: 0.25rem 0.5rem;
        min-width: 50px;
        margin-left: 0.25rem;
        flex-shrink: 0;
    }

    .level-icon {
        font-size: 0.875rem;
    }

    .level-number {
        font-size: 0.65rem;
    }

    /* Ensure nav container has proper padding */
    .nav-container {
        padding-right: 0.75rem;
    }

    /* Challenge game optimizations */
    .challenge-container {
        padding: 0;
    }

    .challenge-game {
        padding: 1rem;
        border-radius: var(--radius-lg);
    }

    .game-header {
        padding-bottom: 1rem;
        margin-bottom: 1rem;
        gap: 0.5rem;
    }

    .timer-value,
    .score-value {
        font-size: var(--text-xl);
    }

    .streak-value {
        font-size: var(--text-lg);
    }

    .timer-label,
    .score-label,
    .streak-label {
        font-size: 0.65rem;
    }

    /* Morse visual display - compact for iPhone */
    .morse-visual-container {
        padding: 0.75rem;
        gap: 0.5rem;
    }

    .morse-word {
        padding: 0.375rem 0.5rem;
        gap: 0.375rem;
    }

    .morse-letter {
        padding: 0.125rem 0.25rem;
        gap: 2px;
        min-height: 24px;
    }

    .morse-vis-dot {
        width: 10px;
        height: 10px;
    }

    .morse-vis-dash {
        width: 22px;
        height: 6px;
    }

    .morse-word-divider {
        font-size: var(--text-base);
        padding: 0 0.125rem;
    }

    /* Sentence display - smaller for mobile */
    .sentence-display {
        font-size: var(--text-lg);
        padding: 0.75rem;
    }

    /* Morse buttons - optimized for thumb reach */
    .morse-buttons {
        gap: 0.5rem;
        margin-bottom: 1rem;
    }

    .morse-buttons.compact {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }

    .morse-buttons.compact .morse-btn {
        min-width: unset;
        padding: 0.75rem 0.5rem;
    }

    .morse-btn {
        min-width: 70px;
        padding: 0.75rem 1rem;
        font-size: var(--text-xs);
    }

    .morse-btn-icon {
        font-size: 1rem;
    }

    /* Submit button - full width on mobile */
    .submit-btn {
        width: 100%;
        padding: 0.875rem;
    }

    /* Answer input area */
    .morse-input {
        min-height: 48px;
        padding: 0.75rem;
        font-size: var(--text-sm);
    }

    .sentence-input,
    .word-input {
        font-size: var(--text-base);
        padding: 0.75rem;
    }

    /* Pregame screen */
    .pregame-content {
        padding: 2rem 1.5rem;
    }

    .challenge-icon {
        font-size: 3rem;
    }

    .challenge-description {
        font-size: var(--text-sm);
    }

    .scoring-rules {
        margin-bottom: 1.5rem;
    }

    .scoring-rules h3 {
        font-size: var(--text-sm);
    }

    .scoring-rules ul {
        font-size: var(--text-xs);
    }

    .btn-xlarge {
        padding: 1rem 2rem;
        font-size: var(--text-base);
    }

    /* Game over screen */
    .gameover-content {
        padding: 2rem 1.5rem;
    }

    .gameover-icon {
        font-size: 3rem;
    }

    .final-score-value {
        font-size: var(--text-4xl);
    }

    .mini-leaderboard {
        padding: 0.75rem;
    }

    .mini-score {
        padding: 0.375rem;
        font-size: var(--text-sm);
    }

    /* Character display for letter modes */
    .character-display {
        font-size: 4rem;
    }

    .character-display.large {
        font-size: 5rem;
    }

    /* Pattern display */
    .pattern-display.large {
        gap: 1rem;
    }

    .vis-dot.large {
        width: 20px;
        height: 20px;
        margin: 0 6px;
    }

    .vis-dash.large {
        width: 44px;
        height: 12px;
        margin: 0 6px;
    }
}

/* Extra small phones */
@media screen and (max-width: 360px) {
    .morse-visual-container {
        padding: 0.5rem;
        gap: 0.375rem;
    }

    .morse-word {
        padding: 0.25rem 0.375rem;
        gap: 0.25rem;
    }

    .morse-letter {
        gap: 1px;
        min-height: 20px;
    }

    .morse-vis-dot {
        width: 8px;
        height: 8px;
    }

    .morse-vis-dash {
        width: 18px;
        height: 5px;
    }

    .sentence-display {
        font-size: var(--text-base);
    }

    .morse-buttons.compact {
        grid-template-columns: repeat(5, 1fr);
    }

    .morse-buttons.compact .morse-btn {
        padding: 0.625rem 0.25rem;
        font-size: 0.65rem;
    }

    .morse-btn-icon {
        font-size: 0.875rem;
    }
}

/* Landscape mode on phones */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .challenge-game {
        padding: 0.75rem;
    }

    .game-header {
        padding-bottom: 0.5rem;
        margin-bottom: 0.75rem;
    }

    .game-area {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
        align-items: center;
    }

    .question-container {
        margin-bottom: 0;
    }

    .answer-container {
        margin-bottom: 0;
    }

    .submit-btn {
        grid-column: span 2;
    }

    .morse-visual-container {
        max-height: 120px;
        overflow-y: auto;
    }
}

/* Duel Section */
.duel-section {
    margin-top: 1rem;
    background: var(--bg-card);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-2xl);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.duel-section.compact {
    padding: 1rem;
}

.duel-promo {
    display: flex;
    justify-content: center;
}

.duel-card {
    max-width: 400px;
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--primary-subtle) 100%);
    border: 2px solid var(--primary);
}

.duel-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(70, 135, 255, 0.3);
}

.duel-icon-large {
    font-size: 3rem;
}

.mode-card-badge.duel {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
}

/* Mobile compact duel section */
@media (max-width: 768px) {
    .duel-section {
        margin-top: 0.75rem;
        padding: 0.75rem;
        border-radius: var(--radius-lg);
        margin-bottom: 0.75rem;
    }

    .duel-section.compact {
        padding: 0.75rem;
    }

    .duel-card {
        max-width: 100%;
        padding: 0.75rem;
    }

    .duel-icon-large {
        font-size: 2rem;
    }
}

/* ============================================
   COMPACT DASHBOARD - Modern, clean design
   ============================================ */
.dashboard {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-width: 900px;
    margin: 0 auto;
}

.dashboard-section {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 1.25rem;
    border: 1px solid var(--gray-200);
}

.dashboard-section.challenge {
    background: linear-gradient(135deg, var(--bg-card) 0%, rgba(245, 158, 11, 0.05) 100%);
    border-color: rgba(245, 158, 11, 0.2);
}

.dashboard-section.pvp {
    background: linear-gradient(135deg, var(--primary-subtle) 0%, rgba(139, 92, 246, 0.1) 100%);
    border-color: var(--primary);
    padding: 0;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--gray-100);
}

.section-header .section-title {
    margin-bottom: 0;
    font-size: var(--text-base);
}

.section-badge {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-muted);
    padding: 0.25rem 0.75rem;
    background: var(--gray-100);
    border-radius: var(--radius-full);
    white-space: nowrap;
}

.section-badge.training {
    background: var(--primary-subtle);
    color: var(--primary);
}

.section-badge.challenge {
    background: var(--warning-light);
    color: var(--warning);
}

/* Compact Grid - 4 columns on desktop, 2 on mobile */
.compact-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

/* Compact Card */
.compact-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 0.75rem;
    background: var(--gray-50);
    border-radius: var(--radius-lg);
    text-decoration: none;
    transition: var(--transition-fast);
    border: 1px solid transparent;
}

.compact-card:hover {
    background: var(--white);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.compact-card.challenge {
    background: rgba(245, 158, 11, 0.08);
}

.compact-card.challenge:hover {
    background: var(--white);
    border-color: var(--warning);
}

.compact-card-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.compact-card-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.compact-card-title {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
    line-height: 1.3;
}

/* PvP Card - Full width, horizontal layout */
.pvp-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    text-decoration: none;
    border-radius: var(--radius-xl);
    transition: var(--transition-fast);
}

.pvp-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(70, 135, 255, 0.2);
}

.pvp-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.pvp-icon {
    font-size: 2.5rem;
    line-height: 1;
}

.pvp-info {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.pvp-title {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.pvp-subtitle {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin: 0;
}

.pvp-badge {
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--white);
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .dashboard {
        gap: 1rem;
    }

    .dashboard-section {
        padding: 1rem;
        border-radius: var(--radius-lg);
    }

    .section-header {
        margin-bottom: 0.75rem;
        padding-bottom: 0.5rem;
    }

    .section-header .section-title {
        font-size: var(--text-sm);
    }

    .section-badge {
        font-size: 0.65rem;
        padding: 0.125rem 0.5rem;
    }

    .compact-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .compact-card {
        padding: 0.75rem 0.5rem;
        border-radius: var(--radius-md);
    }

    .compact-card-icon {
        width: 32px;
        height: 32px;
    }

    .compact-card-title {
        font-size: 0.65rem;
    }

    .pvp-card {
        padding: 1rem;
        border-radius: var(--radius-lg);
    }

    .pvp-icon {
        font-size: 2rem;
    }

    .pvp-title {
        font-size: var(--text-base);
    }

    .pvp-subtitle {
        font-size: var(--text-xs);
    }

    .pvp-badge {
        font-size: var(--text-xs);
        padding: 0.375rem 0.75rem;
    }
}

/* Extra small screens */
@media (max-width: 360px) {
    .compact-card-icon {
        width: 28px;
        height: 28px;
    }

    .compact-card-title {
        font-size: 0.6rem;
    }

    .pvp-icon {
        font-size: 1.5rem;
    }

    .pvp-content {
        gap: 0.75rem;
    }
}

/* ============================================
   TABLET OPTIMIZATIONS (iPad, Android tablets)
   ============================================ */

/* iPad Mini, iPad, Android tablets (768px - 1024px) */
@media screen and (min-width: 768px) and (max-width: 1024px) {
    /* Header adjustments for tablets */
    .unified-header {
        padding: 0.75rem 1.5rem;
    }

    .header-nav-link .nav-text {
        display: inline;
    }

    /* Dashboard grid for tablets */
    .dashboard {
        gap: 1.5rem;
    }

    .compact-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    /* Leaderboard tablet layout */
    .leaderboard-container {
        max-width: 800px;
        margin: 0 auto;
    }

    /* Reference grid - 6 columns on tablet */
    .reference-grid {
        grid-template-columns: repeat(6, 1fr);
    }

    /* Stats grid - 2 columns on tablet */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Training pages - centered content */
    .training-container {
        max-width: 700px;
        margin: 0 auto;
    }

    /* Challenge game - optimal width */
    .challenge-container {
        max-width: 800px;
        margin: 0 auto;
    }

    /* Achievements grid - 4 columns */
    .achievements-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* iPad Pro and large tablets (1024px - 1366px) */
@media screen and (min-width: 1024px) and (max-width: 1366px) {
    .main-content {
        max-width: 1200px;
        margin: 0 auto;
        padding: 5rem 2rem 2rem;
    }

    .reference-grid {
        grid-template-columns: repeat(9, 1fr);
    }

    .compact-grid {
        grid-template-columns: repeat(5, 1fr);
    }

    .achievements-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* Tablet landscape orientation */
@media screen and (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
    .game-area {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 2rem;
        align-items: center;
    }

    .question-container {
        margin-bottom: 0;
    }

    .submit-btn {
        grid-column: span 2;
    }

    /* Duel side-by-side layout */
    .duel-players {
        flex-direction: row;
        gap: 2rem;
    }
}

/* ============================================
   ANDROID PHONE OPTIMIZATIONS
   ============================================ */

/* Common Android phone sizes (360px - 412px) */
@media screen and (min-width: 360px) and (max-width: 412px) {
    /* Same optimizations as iPhone, Android uses similar sizes */
    .unified-header {
        padding: 0.5rem 0.75rem;
    }

    .header-nav-link .nav-text {
        display: none;
    }

    .main-content {
        padding: 4.5rem 0.75rem 1rem;
    }
}

/* Samsung Galaxy S series, Pixel phones (412px - 428px) */
@media screen and (min-width: 412px) and (max-width: 428px) {
    .unified-header {
        padding: 0.5rem 1rem;
    }

    .header-logo {
        font-size: 1.2rem;
    }
}

/* ============================================
   COMPREHENSIVE IPHONE MOBILE OPTIMIZATIONS
   ============================================ */

/* iPhone SE, iPhone 8, iPhone X/XS/11/12/13/14/15 */
@media screen and (max-width: 430px) {
    /* Unified header mobile optimization */
    .unified-header {
        padding: 0.5rem 0.75rem;
    }

    .header-logo {
        font-size: 1.1rem;
        gap: 0.25rem;
    }

    .header-nav {
        gap: 0.25rem;
    }

    .header-nav-link {
        padding: 0.4rem;
        font-size: 0.8rem;
    }

    .header-nav-link .nav-text {
        display: none;
    }

    .header-nav-link .nav-icon {
        font-size: 1.1rem;
    }

    .header-level-badge {
        padding: 0.25rem 0.5rem;
        font-size: 0.7rem;
    }

    .header-username {
        display: none;
    }

    .header-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
    }

    /* Main content mobile padding */
    .main-content {
        padding: 4.5rem 0.75rem 1rem;
    }

    /* Leaderboard mobile */
    .leaderboard-container {
        padding: 0;
    }

    .leaderboard-header h1 {
        font-size: 1.5rem;
    }

    .leaderboard-header p {
        font-size: 0.85rem;
    }

    .leaderboard-filters {
        gap: 0.375rem;
        padding: 0 0.5rem;
    }

    .filter-btn {
        padding: 0.375rem 0.75rem;
        font-size: 0.75rem;
    }

    .leaderboard-row {
        padding: 0.75rem;
        gap: 0.5rem;
    }

    .rank {
        min-width: 32px;
        font-size: 0.9rem;
    }

    .rank-medal {
        font-size: 1.25rem;
    }

    .player-info {
        flex: 1;
        min-width: 0;
    }

    .player-name {
        font-size: 0.85rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .player-avatar {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }

    .player-level,
    .player-mode {
        min-width: 60px;
    }

    .level-badge,
    .mode-badge {
        font-size: 0.7rem;
    }

    .level-name,
    .mode-name {
        font-size: 0.6rem;
    }

    .player-xp,
    .player-score {
        min-width: 50px;
    }

    .xp-value,
    .score-value {
        font-size: 1rem;
    }

    .xp-label,
    .score-label {
        font-size: 0.6rem;
    }

    /* User rank card mobile */
    .user-rank-card {
        gap: 1.5rem;
        padding: 1rem;
    }

    .user-rank-value,
    .user-xp-value {
        font-size: 1.75rem;
    }

    /* Reference table mobile */
    .reference-container {
        padding: 0;
    }

    .reference-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.375rem;
    }

    .reference-card {
        padding: 0.5rem;
    }

    .reference-char {
        font-size: 1.25rem;
    }

    .reference-morse {
        font-size: 0.7rem;
    }

    /* Stats page mobile */
    .stats-container {
        padding: 0;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-value {
        font-size: 1.75rem;
    }

    /* Training pages mobile */
    .training-container {
        padding: 0;
    }

    .training-header h1 {
        font-size: 1.25rem;
    }

    .character-display {
        font-size: 4rem;
    }

    .character-display.large {
        font-size: 5rem;
    }

    .word-display {
        font-size: 2.5rem;
    }

    .morse-buttons {
        gap: 0.5rem;
    }

    .morse-btn {
        padding: 1rem 1.5rem;
        font-size: 1.25rem;
        min-width: 60px;
    }

    .morse-btn.dot-btn,
    .morse-btn.dash-btn {
        flex: 1;
    }

    /* Challenge pages mobile */
    .challenge-container {
        padding: 0;
    }

    .game-header {
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.75rem;
    }

    .timer-display,
    .score-display,
    .streak-display {
        flex: 1;
        min-width: 60px;
    }

    .timer-value,
    .score-value {
        font-size: 1.5rem;
    }

    .game-area {
        padding: 0.75rem;
    }

    .submit-btn {
        width: 100%;
        padding: 1rem;
        font-size: 1rem;
    }

    /* Duel page mobile */
    .duel-container {
        padding: 0;
    }

    .duel-waiting {
        padding: 1.5rem;
    }

    .waiting-title {
        font-size: 1.25rem;
    }

    /* Achievements page mobile */
    .achievements-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .achievement-card {
        padding: 0.75rem;
    }

    .achievement-icon {
        width: 40px;
        height: 40px;
    }

    .achievement-name {
        font-size: 0.75rem;
    }

    /* Buttons mobile */
    .btn {
        padding: 0.75rem 1.25rem;
        font-size: 0.9rem;
    }

    .btn-large {
        padding: 1rem 1.5rem;
        font-size: 1rem;
    }

    /* Forms mobile */
    input[type="text"],
    input[type="password"],
    .letter-input,
    .word-input {
        padding: 0.875rem;
        font-size: 1rem;
    }

    /* Cards mobile */
    .card {
        padding: 1rem;
        border-radius: var(--radius-lg);
    }
}

/* iPhone SE (small) specific */
@media screen and (max-width: 375px) {
    .header-logo {
        font-size: 1rem;
    }

    .header-logo span:nth-child(3) {
        display: none;
    }

    .header-nav-link {
        padding: 0.35rem;
    }

    .header-level-badge {
        padding: 0.2rem 0.4rem;
        font-size: 0.65rem;
    }

    .reference-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .character-display {
        font-size: 3.5rem;
    }

    .word-display {
        font-size: 2rem;
    }

    .achievements-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* Touch-friendly tap targets */
@media (hover: none) and (pointer: coarse) {
    .header-nav-link,
    .header-btn,
    .btn,
    .filter-btn,
    .morse-btn,
    .compact-card,
    .reference-card,
    .achievement-card {
        min-height: 44px;
        min-width: 44px;
    }

    /* Larger touch targets for morse buttons */
    .morse-btn {
        min-height: 56px;
    }

    /* Prevent text selection on buttons */
    button,
    .btn,
    .morse-btn {
        -webkit-user-select: none;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }
}

/* Safe area for iPhone X+ notch and home indicator */
@supports (padding: max(0px)) {
    .unified-header {
        padding-left: max(0.75rem, env(safe-area-inset-left));
        padding-right: max(0.75rem, env(safe-area-inset-right));
    }

    .main-content {
        padding-left: max(0.75rem, env(safe-area-inset-left));
        padding-right: max(0.75rem, env(safe-area-inset-right));
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }

    /* Fixed bottom elements */
    .submit-btn,
    .btn-large {
        margin-bottom: max(0.5rem, env(safe-area-inset-bottom));
    }
}

/* Prevent zoom on input focus (iOS) */
@media screen and (max-width: 768px) {
    input[type="text"],
    input[type="password"],
    input[type="email"],
    input[type="number"],
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* Smooth scrolling for iOS */
html {
    -webkit-overflow-scrolling: touch;
}

/* Prevent pull-to-refresh on game pages */
.challenge-game,
.duel-game {
    overscroll-behavior: contain;
}
