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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;
    min-height: 100vh;
    background: linear-gradient(to bottom, #87CEEB 0%, #98D8F8 50%, #B8E6B8 100%);
}

/* ===== 3D CANVAS BACKGROUND ===== */
#canvas-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none; /* Allow clicks to pass through to UI */
    opacity: 0.8; /* Make background slightly visible through containers */
}

.app-container {
    position: relative;
    z-index: 10; /* Above 3D canvas */
    max-width: 700px; /* Reduced from 900px */
    margin: 0 auto;
}

/* ===== SPA STATE MANAGEMENT ===== */
/* Hide containers by default until auth state is determined */
.auth-container, .main-container {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease-in-out, visibility 0.5s;
    position: relative;
    width: 100%;
    min-height: 100vh;
}

/* Show auth container when unauthenticated */
body.unauthenticated .auth-container {
    opacity: 1;
    visibility: visible;
}

/* Show main app when authenticated */
body.authenticated .main-container {
    opacity: 1;
    visibility: visible;
}

/* ===== BEAUTIFUL LANDING PAGE STYLES ===== */
.auth-container {
    position: relative;
    z-index: 10; /* Above 3D canvas */
}

.landing-container {
    position: relative;
    z-index: 10; /* Above 3D canvas */
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-card {
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-radius: 30px;
    padding: 50px 40px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15),
                inset 0 0 0 1px rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.3);
    animation: floatIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
}

.auth-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(
        circle at center,
        rgba(255, 255, 255, 0.1) 0%,
        transparent 70%
    );
    animation: shimmer 15s infinite linear;
}

@keyframes shimmer {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes floatIn {
    0% {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.logo-section {
    text-align: center;
    margin-bottom: 35px;
    position: relative;
}

.app-title {
    font-size: 2.8em;
    font-weight: 800;
    color: #2c3e50;
    margin-bottom: 8px;
    letter-spacing: -1px;
}

.app-subtitle {
    color: rgba(44, 62, 80, 0.7);
    font-size: 1.1em;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.form-group {
    margin-bottom: 22px;
    position: relative;
}

.form-input {
    width: 100%;
    padding: 18px 20px;
    font-size: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(10px);
    color: #333;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
}

.form-input::placeholder {
    color: rgba(0, 0, 0, 0.4);
}

.form-input:focus {
    outline: none;
    border-color: rgba(52, 152, 219, 0.5);
    background: rgba(255, 255, 255, 0.35);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(52, 152, 219, 0.15);
}

.floating-label {
    position: absolute;
    top: -10px;
    left: 15px;
    color: #3498db;
    padding: 0 8px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    opacity: 0;
    transition: all 0.3s ease;
}

.form-input:focus ~ .floating-label,
.form-input:not(:placeholder-shown) ~ .floating-label {
    opacity: 1;
}

.button-group {
    display: flex;
    gap: 12px;
    margin-top: 25px;
}

.btn {
    flex: 1;
    padding: 18px 24px;
    font-size: 16px;
    font-weight: 700;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: #3498db;
    color: white;
    box-shadow: 0 8px 20px rgba(52, 152, 219, 0.2);
}

.btn-primary:hover {
    background: #2980b9;
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(52, 152, 219, 0.3);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.3);
    color: #2c3e50;
    border: 2px solid rgba(44, 62, 80, 0.2);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.5);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.divider {
    text-align: center;
    margin: 30px 0;
    position: relative;
}

.divider::before,
.divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: calc(50% - 30px);
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(52, 152, 219, 0.2), transparent);
}

.divider::before { left: 0; }
.divider::after { right: 0; }

.divider span {
    color: rgba(0, 0, 0, 0.5);
    font-size: 14px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-google {
    width: 100%;
    padding: 18px 24px;
    font-size: 16px;
    font-weight: 600;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.35);
    color: #333;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    position: relative;
    z-index: 15;
    pointer-events: auto;
}

.btn-google:hover {
    background: rgba(255, 255, 255, 0.5);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #dc2626;
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 14px;
    display: none;
    animation: slideDown 0.3s ease;
}

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

.success-message {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #16a34a;
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 14px;
    display: none;
    animation: slideDown 0.3s ease;
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 30px;
    z-index: 100;
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(102, 126, 234, 0.2);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.weather-controls {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    display: flex;
    gap: 10px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    padding: 10px 15px;
    border-radius: 20px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.weather-btn {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.weather-btn:hover {
    background: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
}

.weather-btn.active {
    background: #3498db;
    color: white;
}

@media (max-width: 480px) {
    .auth-card {
        padding: 40px 30px;
    }

    .app-title {
        font-size: 1.8em;
    }

    .weather-controls {
        bottom: 20px;
        padding: 8px 12px;
    }

    .weather-btn {
        padding: 8px 15px;
        font-size: 13px;
    }
}

.main-container {
    position: fixed; /* Fixed positioning to overlay canvas */
    top: 50%; /* Center vertically */
    left: 50%; /* Center horizontally */
    transform: translate(-50%, -50%); /* Complete centering */
    z-index: 10; /* Above 3D canvas */
    display: none;
    background: rgba(255, 255, 255, 0.05); /* 95% translucent */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    width: 90%; /* Responsive width */
    max-width: 700px; /* Maximum width constraint */
    max-height: 90vh; /* Prevent extending too far down */
    overflow-y: auto; /* Allow scrolling within container */
    box-sizing: border-box;
}

.main-container.active {
    display: block;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    border-bottom: 2px solid rgba(238, 238, 238, 0.5);
    background: rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

h1 {
    color: #4a7c59;
    font-size: 2.2em;
}

.user-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4a7c59 0%, #2d5a3d 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

.user-info {
    text-align: right;
}

.user-name {
    font-weight: bold;
    color: #333;
}

.user-level {
    font-size: 0.85em;
    color: #666;
}

.auth-form {
    margin-top: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #666;
    font-size: 0.9em;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #4a7c59;
}

.form-group input.error {
    border-color: #e74c3c;
    background-color: #fdf2f2;
}

.form-group input.success {
    border-color: #27ae60;
    background-color: #f2fdf2;
}

.form-error {
    color: #e74c3c;
    font-size: 0.85em;
    margin-top: 5px;
    display: none;
}

.form-error.show {
    display: block;
}

.auth-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.btn {
    flex: 1;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, #4a7c59 0%, #2d5a3d 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: white;
    color: #4a7c59;
    border: 2px solid #4a7c59;
}

.btn-secondary:hover {
    background: #f5f5f5;
}

.btn-google {
    background: white;
    color: #333;
    border: 2px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    margin-top: 20px;
}

.btn-google:hover {
    background: #f5f5f5;
}

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 2px solid rgba(238, 238, 238, 0.3);
    padding-bottom: 8px;
}

.tab {
    padding: 8px 15px;
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
    margin-bottom: -10px;
}

.tab.active {
    color: #4a7c59;
    border-bottom-color: #4a7c59;
}

.difficulty-selector {
    background: rgba(249, 249, 249, 0.75);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.difficulty-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
    margin-top: 15px;
}

.difficulty-card {
    padding: 10px;
    border-radius: 8px;
    border: 2px solid rgba(224, 224, 224, 0.6);
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.difficulty-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.difficulty-card.active {
    background: linear-gradient(135deg, #4a7c59 0%, #2d5a3d 100%);
    color: white;
    border-color: transparent;
}

.difficulty-number {
    font-size: 1.3em;
    font-weight: bold;
}

.difficulty-label {
    font-size: 0.8em;
    margin-top: 5px;
}

.word-display {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.75) 0%, rgba(248, 249, 250, 0.75) 100%);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 20px;
    position: relative;
    min-height: 300px; /* Reduced from 400px */
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    border: 1px solid rgba(255,255,255,0.3);
}

.word-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 25px;
    gap: 20px;
}

.word-main {
    flex: 1;
    min-width: 0; /* Prevents flex item from overflowing */
}

.word {
    font-size: clamp(2em, 4vw, 2.8em); /* Reduced from 2.5em-3.5em */
    color: #2c3e50;
    font-weight: 700;
    margin-bottom: 10px;
    line-height: 1.1;
    word-break: break-word;
}

.phonetic-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.phonetic {
    color: #6c757d;
    font-size: 1.3em;
    font-style: italic;
    font-family: 'Courier New', monospace;
    background: rgba(108, 117, 125, 0.1);
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid rgba(108, 117, 125, 0.2);
}

.audio-button {
    background: linear-gradient(135deg, #4a7c59 0%, #2d5a3d 100%);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
    font-size: 1.1em;
}

.audio-button:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.audio-button:disabled {
    background: #e9ecef;
    color: #6c757d;
    cursor: not-allowed;
    transform: none;
}

.audio-button:active:not(:disabled) {
    transform: scale(0.95);
}

.audio-button.loading {
    background: linear-gradient(135deg, #ffc107 0%, #ff9800 100%);
    animation: pulse 1.5s ease-in-out infinite;
}

.audio-button.playing {
    background: linear-gradient(135deg, #4caf50 0%, #4a7c59 100%);
    animation: playing 0.8s ease-in-out infinite;
}

.audio-button.error {
    background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%);
    animation: shake 0.5s ease-in-out;
}

.audio-button.ready {
    background: linear-gradient(135deg, #4a7c59 0%, #2d5a3d 100%);
}

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

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

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

.word-stats {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    min-width: 140px;
}

.frequency-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: 25px;
    font-size: 0.9em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    border: 2px solid rgba(255,255,255,0.3);
}

.frequency-badge::before {
    content: '●';
    font-size: 1.2em;
}

.freq-very-common { 
    background: linear-gradient(135deg, #8fbc8f 0%, #4a7c59 100%); 
    color: white; 
}
.freq-common { 
    background: linear-gradient(135deg, #a8d8a8 0%, #8fbc8f 100%); 
    color: white; 
}
.freq-uncommon { 
    background: linear-gradient(135deg, #FFC107 0%, #ffb300 100%); 
    color: #2c3e50; 
}
.freq-rare { 
    background: linear-gradient(135deg, #FF9800 0%, #f57c00 100%); 
    color: white; 
}
.freq-very-rare { 
    background: linear-gradient(135deg, #FF5722 0%, #e64a19 100%); 
    color: white; 
}
.freq-extremely-rare { 
    background: linear-gradient(135deg, #8b7355 0%, #6b5b47 100%); 
    color: white; 
}

.corpus-count {
    color: #6c757d;
    font-size: 0.85em;
    font-weight: 500;
    background: rgba(108, 117, 125, 0.1);
    padding: 4px 8px;
    border-radius: 12px;
    text-align: center;
}

.difficulty-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
}

.difficulty-stars {
    display: flex;
    gap: 2px;
}

.difficulty-star {
    width: 12px;
    height: 12px;
    background: #e9ecef;
    border-radius: 2px;
    transition: background-color 0.3s ease;
}

.difficulty-star.filled {
    background: linear-gradient(135deg, #4a7c59 0%, #2d5a3d 100%);
}

.definitions {
    margin: 25px 0;
}

.definition-group {
    margin-bottom: 25px;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 20px;
    border: 1px solid rgba(102, 126, 234, 0.2);
}

.part-of-speech {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(135deg, #4a7c59 0%, #2d5a3d 100%);
    color: white;
    padding: 8px 16px;
    border-radius: 25px;
    font-size: 0.9em;
    font-weight: 600;
    margin-bottom: 15px;
    text-transform: capitalize;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.part-of-speech::before {
    content: '•';
    margin-right: 6px;
    color: #4a7c59;
    font-weight: bold;
}

.definition-item {
    margin-bottom: 18px;
    position: relative;
}

.definition-item:not(:last-child)::after {
    content: '';
    position: absolute;
    bottom: -9px;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.3) 0%, transparent 100%);
}

.definition-text {
    color: #2c3e50;
    font-size: 1.1em;
    line-height: 1.7;
    margin-bottom: 12px;
    font-weight: 400;
}

.definition-text::before {
    content: '•';
    color: #4a7c59;
    font-weight: bold;
    margin-right: 8px;
}

.example {
    color: #495057;
    font-style: italic;
    padding: 15px 18px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    margin-top: 12px;
    border-left: 4px solid #4a7c59;
    position: relative;
    font-size: 1.05em;
    line-height: 1.6;
}

.example::before {
    content: '"';
    position: absolute;
    left: 8px;
    top: 8px;
    font-size: 1.5em;
    color: #4a7c59;
    font-weight: bold;
}

.example::after {
    content: '"';
    position: absolute;
    right: 8px;
    bottom: 8px;
    font-size: 1.5em;
    color: #4a7c59;
    font-weight: bold;
}

.synonyms {
    margin-top: 12px;
    padding: 10px 15px;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 10px;
    border: 1px solid rgba(102, 126, 234, 0.1);
}

.synonyms-label {
    font-size: 0.9em;
    font-weight: 600;
    color: #4a7c59;
    margin-right: 8px;
}

.synonym {
    display: inline-block;
    background: linear-gradient(135deg, #4a7c59 0%, #2d5a3d 100%);
    color: white;
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 0.85em;
    margin-right: 6px;
    margin-bottom: 4px;
    font-weight: 500;
}

.etymology-section {
    margin-top: 30px;
    padding: 25px;
    background: linear-gradient(135deg, #fff9e6 0%, #fef7cd 100%);
    border-radius: 15px;
    border: 2px solid rgba(255, 214, 0, 0.3);
    position: relative;
    overflow: hidden;
}

.etymology-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #ffd600 0%, #ffb300 100%);
}

.etymology-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    color: #f57f17;
    margin-bottom: 15px;
    font-size: 1em;
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

.etymology-title::before {
    content: '◦';
    font-size: 1.2em;
    color: #8b4513;
    font-weight: bold;
}

.etymology-text {
    color: #5d4037;
    line-height: 1.7;
    font-size: 1.05em;
    font-weight: 400;
    background: rgba(255,255,255,0.5);
    padding: 15px;
    border-radius: 10px;
    border: 1px solid rgba(255, 214, 0, 0.2);
}

.etymology-text .small-caps {
    font-variant: small-caps;
    font-weight: 500;
}

.word-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 8px;
    margin-bottom: 20px;
}

.action-btn {
    padding: 10px 15px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85em; /* Reduced from 0.95em */
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-discover {
    background: linear-gradient(135deg, #4a7c59 0%, #2d5a3d 100%);
    color: white;
    font-weight: bold;
}

.btn-learn {
    background: #8fbc8f;
    color: white;
}

.btn-favorite {
    background: #FFC107;
    color: #333;
}

.btn-audio {
    background: #2196F3;
    color: white;
}

.btn-share {
    background: #FF5722;
    color: white;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.action-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* Enhanced Action Button States */
.action-btn.available {
    opacity: 1;
    cursor: pointer;
}

.action-btn.completed {
    opacity: 0.8;
    position: relative;
    background: linear-gradient(135deg, #8fbc8f 0%, #4a7c59 100%);
    color: white;
}

.action-btn.completed::after {
    content: '';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn.completed.btn-learn::after {
    content: '✓';
    font-size: 8px;
    color: #8fbc8f;
    font-weight: bold;
}

.action-btn.completed.btn-favorite::after {
    content: '★';
    font-size: 8px;
    color: #FFC107;
    font-weight: bold;
}

.action-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #e9ecef;
    color: #6c757d;
}

.action-btn.loading {
    opacity: 0.8;
    cursor: wait;
    position: relative;
}

.action-btn.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: button-spin 1s linear infinite;
}

@keyframes button-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Hover effects for different states */
.action-btn.available:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.action-btn.completed:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(76, 175, 80, 0.3);
}

.action-btn.disabled:hover {
    transform: none;
    box-shadow: none;
}

/* Specific button type enhancements */
.btn-discover.available {
    background: linear-gradient(135deg, #4a7c59 0%, #2d5a3d 100%);
    color: white;
}

.btn-discover.loading {
    background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%);
}

.btn-learn.available {
    background: linear-gradient(135deg, #8fbc8f 0%, #4a7c59 100%);
    color: white;
}

.btn-learn.loading {
    background: linear-gradient(135deg, #66bb6a 0%, #4caf50 100%);
}

.btn-favorite.available {
    background: linear-gradient(135deg, #FFC107 0%, #ffb300 100%);
    color: #333;
}

.btn-favorite.loading {
    background: linear-gradient(135deg, #ffca28 0%, #ffc107 100%);
}

.btn-audio.available {
    background: linear-gradient(135deg, #2196F3 0%, #1976d2 100%);
    color: white;
}

.btn-audio.loading {
    background: linear-gradient(135deg, #42a5f5 0%, #2196f3 100%);
}

.btn-share.available {
    background: linear-gradient(135deg, #FF5722 0%, #e64a19 100%);
    color: white;
}

.btn-share.loading {
    background: linear-gradient(135deg, #ff7043 0%, #ff5722 100%);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid rgba(238, 238, 238, 0.3);
}

.stat-card {
    padding: 15px;
    background: rgba(249, 249, 249, 0.75);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 10px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.stat-value {
    font-size: 2em; /* Reduced from 2.5em */
    font-weight: bold;
    background: linear-gradient(135deg, #4a7c59 0%, #2d5a3d 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stat-label {
    color: #666;
    font-size: 0.9em;
    margin-top: 5px;
}

.stat-progress {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    margin-top: 10px;
    overflow: hidden;
}

.stat-progress-bar {
    height: 100%;
    background: linear-gradient(135deg, #4a7c59 0%, #2d5a3d 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.leaderboard {
    margin-top: 30px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 12px;
}

.leaderboard-title {
    font-weight: bold;
    color: #333;
    margin-bottom: 15px;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    padding: 12px;
    background: white;
    border-radius: 8px;
    margin-bottom: 10px;
}

.leaderboard-rank {
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, #4a7c59 0%, #2d5a3d 100%);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-right: 15px;
}

.leaderboard-user {
    flex: 1;
    font-weight: 500;
}

.leaderboard-score {
    color: #4a7c59;
    font-weight: bold;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #4a7c59;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 15px 30px;
    border-radius: 50px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
    z-index: 1000;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { 
        transform: translate(-50%, 100px); 
        opacity: 0;
    }
    to { 
        transform: translate(-50%, 0); 
        opacity: 1;
    }
}

.word-not-found {
    text-align: center;
    padding: 40px;
    color: #999;
}

.suggested-words {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

.suggested-word {
    padding: 8px 16px;
    background: #f5f5f5;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.suggested-word:hover {
    background: #4a7c59;
    color: white;
}

.tab-content {
    display: none;
}

.tab-content:first-child {
    display: block;
}

/* Enhanced Responsive Design System */

/* Base responsive utilities */
.container-fluid {
    width: 100%;
    padding-left: 15px;
    padding-right: 15px;
}

.row {
    display: flex;
    flex-wrap: wrap;
    margin-left: -15px;
    margin-right: -15px;
}

.col {
    flex: 1;
    padding-left: 15px;
    padding-right: 15px;
}

/* Touch-friendly interactions */
@media (hover: none) and (pointer: coarse) {
    .btn, .action-btn, .tab, .difficulty-card {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 16px;
    }
    
    .audio-button {
        min-width: 44px;
        min-height: 44px;
    }
    
    .review-action-btn {
        min-width: 44px;
        min-height: 44px;
    }
}

/* Improved mobile viewport handling */
:root {
    --vh: 1vh;
}

@supports (-webkit-touch-callout: none) {
    .app-container {
        min-height: -webkit-fill-available;
        min-height: calc(var(--vh, 1vh) * 100);
    }
    
    body {
        min-height: -webkit-fill-available;
        min-height: calc(var(--vh, 1vh) * 100);
    }
}

/* Fix for mobile browsers address bar */
.full-height {
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
}

/* Enhanced responsive breakpoints */

/* Extra small devices (phones, 576px and down) */
@media (max-width: 575.98px) {
    body {
        padding: 10px;
    }
    
    .app-container {
        max-width: 100%;
    }
    
    .auth-container {
        margin: 20px auto;
        padding: 25px 20px;
        max-width: 100%;
    }
    
    .main-container {
        padding: 20px 15px;
    }
    
    h1 {
        font-size: 1.8em;
    }
    
    .header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .user-section {
        flex-direction: column;
        gap: 10px;
    }
    
    .tabs {
        flex-wrap: wrap;
        gap: 5px;
    }
    
    .tab {
        flex: 1;
        min-width: calc(50% - 2.5px);
        font-size: 0.9em;
        padding: 12px 8px;
    }
    
    .difficulty-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .difficulty-card {
        padding: 12px 8px;
    }
    
    .difficulty-number {
        font-size: 1.3em;
    }
    
    .difficulty-label {
        font-size: 0.75em;
    }
    
    .word-display {
        padding: 20px 15px;
        min-height: 250px;
    }
    
    .word-header {
        flex-direction: column;
        gap: 15px;
    }
    
    .word-stats {
        align-items: flex-start;
        width: 100%;
        flex-direction: row;
        justify-content: space-between;
    }
    
    .word {
        font-size: clamp(1.8em, 10vw, 2.2em);
        line-height: 1.1;
    }
    
    .phonetic-container {
        justify-content: flex-start;
        flex-wrap: wrap;
    }
    
    .phonetic {
        font-size: 1em;
        padding: 4px 8px;
    }
    
    .audio-button {
        width: 36px;
        height: 36px;
        font-size: 0.9em;
    }
    
    .frequency-badge {
        font-size: 0.75em;
        padding: 6px 10px;
    }
    
    .definition-group {
        padding: 15px 12px;
    }
    
    .definition-text {
        font-size: 0.95em;
    }
    
    .example {
        font-size: 0.9em;
        padding: 12px 15px;
    }
    
    .etymology-section {
        padding: 15px 12px;
    }
    
    .word-actions {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .action-btn {
        padding: 12px 8px;
        font-size: 0.85em;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .stat-card {
        padding: 15px;
    }
    
    .stat-value {
        font-size: 2em;
    }
    
    .review-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .review-word-card {
        padding: 15px;
    }
    
    .leaderboard-item {
        padding: 10px;
        font-size: 0.9em;
    }
}

/* Small devices (landscape phones, 576px and up) */
@media (min-width: 576px) and (max-width: 767.98px) {
    .auth-container {
        max-width: 500px;
        padding: 35px 30px;
    }
    
    .main-container {
        padding: 30px 25px;
    }
    
    .difficulty-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .word-actions {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .review-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) and (max-width: 991.98px) {
    .auth-container {
        max-width: 450px;
    }
    
    .main-container {
        padding: 35px 30px;
    }
    
    .header {
        flex-direction: row;
    }
    
    .tabs {
        flex-wrap: nowrap;
    }
    
    .tab {
        flex: none;
        min-width: auto;
    }
    
    .difficulty-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .word-display {
        padding: 30px 25px;
        min-height: 350px;
    }
    
    .word-header {
        flex-direction: row;
        gap: 20px;
    }
    
    .word-stats {
        align-items: flex-end;
        width: auto;
        flex-direction: column;
    }
    
    .word {
        font-size: clamp(2.2em, 6vw, 2.8em);
    }
    
    .word-actions {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .review-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .app-container {
        max-width: 960px;
    }
    
    .difficulty-grid {
        grid-template-columns: repeat(6, 1fr);
    }
    
    .word-actions {
        grid-template-columns: repeat(5, 1fr);
    }
    
    .review-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
    .app-container {
        max-width: 1140px;
    }
    
    .review-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Landscape orientation adjustments */
@media (orientation: landscape) and (max-height: 500px) {
    .auth-container {
        margin: 20px auto;
        padding: 20px;
    }
    
    .main-container {
        padding: 20px;
    }
    
    .header {
        margin-bottom: 20px;
        padding-bottom: 15px;
    }
    
    .word-display {
        min-height: 200px;
        padding: 20px;
    }
    
    .stats-grid {
        margin-top: 20px;
        padding-top: 20px;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .frequency-badge,
    .part-of-speech,
    .action-btn {
        border: 0.5px solid rgba(255, 255, 255, 0.2);
    }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .spinner {
        animation: none;
        border: 3px solid #4a7c59;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #1a1a1a;
        --bg-secondary: #2d2d2d;
        --text-primary: #ffffff;
        --text-secondary: #cccccc;
        --border-color: #404040;
    }
    
    body {
        background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    }
    
    .auth-container,
    .main-container {
        background: var(--bg-secondary);
        color: var(--text-primary);
    }
    
    .word-display {
        background: linear-gradient(135deg, #2d2d2d 0%, #3a3a3a 100%);
        color: var(--text-primary);
    }
    
    .definition-group {
        background: rgba(255, 255, 255, 0.05);
    }
    
    .etymology-section {
        background: linear-gradient(135deg, #3a3a2a 0%, #4a4a3a 100%);
    }
    
    .stat-card,
    .leaderboard,
    .review-word-card {
        background: var(--bg-secondary);
        color: var(--text-primary);
        border-color: var(--border-color);
    }
}

/* Accessibility Features */

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.sr-only:focus {
    position: static;
    width: auto;
    height: auto;
    padding: 0.5rem;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
    background: #4a7c59;
    color: white;
    border-radius: 4px;
    z-index: 1000;
}

/* Enhanced focus indicators */
*:focus {
    outline: 3px solid #4a7c59;
    outline-offset: 2px;
}

/* High contrast focus for better visibility */
.btn:focus,
.action-btn:focus,
.tab:focus,
.difficulty-card:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 3px solid #4a7c59;
    outline-offset: 2px;
    box-shadow: 0 0 0 6px rgba(102, 126, 234, 0.2);
}

/* Focus within for containers */
.word-display:focus-within,
.stat-card:focus-within,
.review-word-card:focus-within {
    outline: 2px solid #4a7c59;
    outline-offset: 2px;
}

/* Skip link for keyboard navigation */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #4a7c59;
    color: white;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 1000;
    transition: top 0.3s ease;
}

.skip-link:focus {
    top: 6px;
}

/* Keyboard navigation improvements */
.difficulty-card[role="radio"]:focus {
    outline: 3px solid #4a7c59;
    outline-offset: 2px;
}

.difficulty-card[aria-checked="true"] {
    background: linear-gradient(135deg, #4a7c59 0%, #2d5a3d 100%);
    color: white;
    border-color: transparent;
}

/* Tab navigation improvements */
.tab[aria-selected="true"] {
    color: #4a7c59;
    border-bottom-color: #4a7c59;
    font-weight: bold;
}

.tab[aria-selected="false"] {
    color: #666;
    border-bottom-color: transparent;
}

/* Progress bar accessibility */
.stat-progress[role="progressbar"] {
    position: relative;
}

.stat-progress[role="progressbar"]::after {
    content: attr(aria-valuenow) "%";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.7em;
    color: white;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

/* Error states for accessibility */
.form-group input[aria-invalid="true"] {
    border-color: #e74c3c;
    background-color: #fdf2f2;
}

.form-error[role="alert"] {
    color: #e74c3c;
    font-size: 0.85em;
    margin-top: 5px;
    font-weight: 500;
}

/* Loading states for screen readers */
.loading[role="status"] {
    position: relative;
}

.loading[role="status"]::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
}

/* Button state indicators */
.action-btn[aria-pressed="true"] {
    background: linear-gradient(135deg, #8fbc8f 0%, #4a7c59 100%);
    color: white;
}

.action-btn[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
    background: #e9ecef;
    color: #6c757d;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btn,
    .action-btn,
    .tab,
    .difficulty-card {
        border: 2px solid currentColor;
    }
    
    .frequency-badge,
    .part-of-speech {
        border: 2px solid currentColor;
    }
    
    .word-display {
        border: 2px solid #333;
    }
    
    .definition-group {
        border: 1px solid #666;
    }
}

/* Reduced transparency for better readability */
@media (prefers-contrast: high) {
    .etymology-section {
        background: #fff9e6;
        border: 2px solid #ffd600;
    }
    
    .example {
        background: #f8f9fa;
        border: 1px solid #666;
    }
}

/* Color blind friendly indicators */
.difficulty-star.filled {
    background: linear-gradient(135deg, #4a7c59 0%, #2d5a3d 100%);
    position: relative;
}

.difficulty-star.filled::after {
    content: "★";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 8px;
    line-height: 1;
}

/* Improved text contrast */
.word {
    color: #1a1a1a;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

.definition-text {
    color: #1a1a1a;
    font-weight: 500;
}

/* Keyboard navigation for radiogroup */
.difficulty-grid[role="radiogroup"] {
    position: relative;
}

.difficulty-card[role="radio"] {
    cursor: pointer;
    border: 2px solid #e0e0e0;
    transition: all 0.3s ease;
}

.difficulty-card[role="radio"]:hover {
    border-color: #4a7c59;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

/* Live region styling */
[aria-live] {
    position: relative;
}

/* Toast notifications accessibility */
.toast {
    role: alert;
    aria-live: assertive;
    aria-atomic: true;
}

/* Modal accessibility */
.modal-content {
    role: dialog;
    aria-modal: true;
}

.modal-content:focus {
    outline: none;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.4em;
}

/* Print styles */
@media print {
    body {
        background: white !important;
        color: black !important;
    }
    
    .auth-container,
    .main-container {
        box-shadow: none !important;
        background: white !important;
        color: black !important;
    }
    
    .tabs,
    .word-actions,
    .btn,
    .action-btn,
    .mobile-nav-toggle,
    .mobile-nav-overlay {
        display: none !important;
    }
    
    .word-display {
        background: white !important;
        color: black !important;
        box-shadow: none !important;
        border: 1px solid #ccc !important;
    }
    
    .sr-only {
        position: static !important;
        width: auto !important;
        height: auto !important;
        clip: auto !important;
        overflow: visible !important;
        white-space: normal !important;
    }
}
/* Pr
ogress Tracking and Gamification Styles */

/* Animated statistics */
.stat-updating {
    animation: statPulse 0.8s ease-out;
    color: #4a7c59;
    font-weight: bold;
}

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

/* Animated progress bars */
.progress-animating {
    animation: progressGlow 0.8s ease-out;
}

@keyframes progressGlow {
    0% { box-shadow: 0 0 0 rgba(102, 126, 234, 0); }
    50% { box-shadow: 0 0 20px rgba(102, 126, 234, 0.6); }
    100% { box-shadow: 0 0 0 rgba(102, 126, 234, 0); }
}

/* Enhanced level display */
.level-display {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.level-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.level-number {
    font-size: 1.1em;
    font-weight: bold;
    color: #4a7c59;
}

.xp-info {
    font-size: 0.9em;
    color: #666;
}

.level-progress-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.level-progress-bar {
    width: 100%;
    height: 8px;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
}

.level-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4a7c59 0%, #2d5a3d 100%);
    border-radius: 4px;
    transition: width 1s ease-out;
}

.next-level-info {
    font-size: 0.8em;
    color: #888;
    text-align: center;
}

/* Achievement notifications */
.achievement-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    pointer-events: none;
}

.achievement-notification {
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, #4a7c59 0%, #2d5a3d 100%);
    color: white;
    padding: 15px 20px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    margin-bottom: 10px;
    transform: translateX(100%);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.achievement-notification.show {
    transform: translateX(0);
    opacity: 1;
}

.achievement-icon {
    font-size: 1.5em;
    animation: bounce 0.6s ease-out;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

.achievement-message {
    font-weight: 500;
    font-size: 0.95em;
}

/* Enhanced stats grid */
.stats-grid .stat-card {
    position: relative;
    overflow: hidden;
}

.stats-grid .stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    transition: left 0.6s ease;
}

.stats-grid .stat-card:hover::before {
    left: 100%;
}

/* Progress bar enhancements */
.progress-bar {
    position: relative;
    overflow: hidden;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, 
        rgba(255,255,255,0.2) 25%, 
        transparent 25%, 
        transparent 50%, 
        rgba(255,255,255,0.2) 50%, 
        rgba(255,255,255,0.2) 75%, 
        transparent 75%);
    background-size: 20px 20px;
    animation: progressStripes 1s linear infinite;
}

@keyframes progressStripes {
    0% { background-position: 0 0; }
    100% { background-position: 20px 0; }
}

/* Enhanced mobile interactions and touch targets */
.touch-target {
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Swipe gesture support */
.swipeable {
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
}

.swipe-indicator {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    transition: opacity 0.3s ease;
    font-size: 1.5em;
    color: #4a7c59;
}

.swipe-indicator.left {
    left: 10px;
}

.swipe-indicator.right {
    right: 10px;
}

.swipe-indicator.active {
    opacity: 1;
}

/* Mobile-optimized form controls */
@media (max-width: 768px) {
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 14px 12px;
    }

    .btn,
    .action-btn {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 14px 20px;
    }

    /* Enhanced mobile 3D canvas visibility */
    #canvas-container {
        z-index: 1;
        opacity: 0.8; /* Slightly more visible on mobile */
        pointer-events: none;
    }

    /* Improved text contrast on mobile */
    .auth-card {
        background: rgba(255, 255, 255, 0.25); /* More opacity for better contrast */
        backdrop-filter: blur(25px);
        -webkit-backdrop-filter: blur(25px);
        border: 2px solid rgba(255, 255, 255, 0.4);
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    }

    .difficulty-card {
        background: rgba(255, 255, 255, 0.9); /* Better contrast */
        border: 2px solid rgba(74, 124, 89, 0.3);
        color: #2d2d2d; /* Darker text for readability */
        font-weight: 600;
        font-size: 16px;
        min-height: 50px; /* Better touch targets */
        transition: all 0.2s ease;
    }

    .difficulty-card:hover,
    .difficulty-card:focus {
        background: rgba(255, 255, 255, 0.95);
        border-color: #4a7c59;
        transform: translateY(-1px);
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    }

    .difficulty-card.active {
        background: linear-gradient(135deg, #4a7c59 0%, #2d5a3d 100%);
        color: white;
        border-color: transparent;
        font-weight: 700;
        box-shadow: 0 8px 25px rgba(74, 124, 89, 0.3);
    }

    .difficulty-number {
        font-size: 1.4em;
        font-weight: 700;
    }

    .difficulty-label {
        font-size: 0.9em;
        opacity: 0.9;
    }

    /* Better mobile header visibility */
    .app-header h1 {
        color: #2d2d2d;
        text-shadow: 2px 2px 4px rgba(255, 255, 255, 0.8);
        font-weight: 700;
    }

    .level-display {
        background: rgba(255, 255, 255, 0.9);
        padding: 8px 12px;
        border-radius: 15px;
        border: 1px solid rgba(74, 124, 89, 0.3);
    }

    /* Main container improvements */
    .main-container {
        background: rgba(255, 255, 255, 0.1);
        backdrop-filter: blur(15px);
        -webkit-backdrop-filter: blur(15px);
        border-radius: 20px;
        /* margin removed to preserve centering */
        padding: 20px 15px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    }
}

/* Improved mobile navigation */
.mobile-nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5em;
    color: #4a7c59;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background-color 0.3s ease;
}

.mobile-nav-toggle:hover {
    background-color: rgba(102, 126, 234, 0.1);
}

@media (max-width: 575.98px) {
    .mobile-nav-toggle {
        display: block;
    }

    .tabs {
        position: fixed;
        top: 0;
        left: -100%;
        width: 80%;
        height: 100vh;
        background: white;
        flex-direction: column;
        padding: 60px 20px 20px;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
        transition: left 0.3s ease;
        z-index: 1000;
    }

    .tabs.mobile-open {
        left: 0;
    }

    .tab {
        width: 100%;
        text-align: left;
        padding: 15px 20px;
        border-bottom: 1px solid #eee;
        border-radius: 0;
        margin-bottom: 0;
    }

    .mobile-nav-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }

    .mobile-nav-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    /* Enhanced mobile layout spacing */
    .auth-card {
        margin: 15px;
        padding: 30px 25px;
        max-width: calc(100vw - 30px);
    }

    .difficulty-selector {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        margin: 20px 0;
    }

    .difficulty-card {
        min-height: 55px;
        padding: 12px 8px;
        font-size: 14px;
    }

    .difficulty-number {
        font-size: 1.3em !important;
        margin-bottom: 4px;
    }

    .difficulty-label {
        font-size: 0.8em !important;
        line-height: 1.2;
    }

    /* Main app mobile layout */
    .main-container {
        /* Keep existing centering and fixed positioning */
        width: 95%; /* Slightly wider on mobile */
        padding: 15px 12px;
        max-height: 85vh; /* Prevent too tall on mobile */
    }

    .app-header {
        padding: 10px 0;
        margin-bottom: 15px;
    }

    .app-header h1 {
        font-size: 1.8em;
        margin-bottom: 8px;
    }

    .level-display {
        font-size: 0.9em;
        padding: 6px 10px;
    }

    /* Better mobile word display */
    .word-card {
        margin: 15px 0;
        padding: 20px 15px;
        font-size: 0.95em;
    }

    .word-header h2 {
        font-size: 1.6em;
        margin-bottom: 8px;
    }

    .phonetic {
        font-size: 0.9em;
    }

    /* Mobile button improvements */
    .btn, .action-btn {
        padding: 12px 20px;
        font-size: 15px;
        min-height: 48px;
        border-radius: 12px;
    }

    /* Mobile-specific form improvements */
    .form-group {
        margin-bottom: 16px;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 14px 12px;
        font-size: 16px;
        border-radius: 10px;
        min-height: 48px;
    }

    /* Safe area adjustments for newer phones */
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}

/* Enhanced touch feedback */
.btn:active,
.action-btn:active,
.tab:active,
.difficulty-card:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
}

/* Improved scrolling for mobile */
.scrollable-content {
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
    max-height: calc(100vh - 200px);
}

/* Mobile-optimized modals */
@media (max-width: 575.98px) {
    .modal-content {
        width: 95%;
        max-height: 90vh;
        margin: 20px;
        border-radius: 12px;
    }
    
    .modal-header {
        padding: 20px 20px 15px;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .modal-header h2 {
        font-size: 1.3em;
    }
}

/* Responsive adjustments for progress tracking */
@media (max-width: 768px) {
    .achievement-container {
        top: 10px;
        right: 10px;
        left: 10px;
    }
    
    .achievement-notification {
        padding: 12px 16px;
        font-size: 0.9em;
    }
    
    .level-display {
        gap: 6px;
    }
    
    .level-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .level-progress-bar {
        height: 6px;
    }
}

/* Responsive typography scaling */
@media (max-width: 575.98px) {
    .stat-label {
        font-size: 0.8em;
    }
    
    .leaderboard-title {
        font-size: 1.1em;
    }
    
    .part-of-speech {
        font-size: 0.8em;
        padding: 6px 12px;
    }
    
    .etymology-title {
        font-size: 0.9em;
    }
    
    .etymology-text {
        font-size: 0.95em;
    }
}

/* Improved focus indicators for mobile */
@media (max-width: 768px) {
    .btn:focus,
    .action-btn:focus,
    .tab:focus,
    .difficulty-card:focus {
        outline: 3px solid rgba(102, 126, 234, 0.5);
        outline-offset: 2px;
    }
}
/* Review 
Interface Styles */
.review-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #eee;
}

.review-header h3 {
    color: #333;
    font-size: 1.4em;
    margin: 0;
}

.review-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.review-controls select {
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: white;
    color: #333;
    font-size: 0.9em;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.review-controls select:hover {
    border-color: #4a7c59;
}

.review-controls select:focus {
    outline: none;
    border-color: #4a7c59;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.review-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.review-grid.list-view {
    grid-template-columns: 1fr;
}

.review-word-card {
    background: white;
    border: 2px solid #eee;
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.review-word-card:hover {
    border-color: #4a7c59;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.15);
}

.review-word-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.review-word-title {
    font-size: 1.3em;
    font-weight: bold;
    color: #333;
    line-height: 1.2;
}

.review-word-xp {
    background: linear-gradient(135deg, #4a7c59 0%, #2d5a3d 100%);
    color: white;
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 0.8em;
    font-weight: bold;
    white-space: nowrap;
}

.review-word-info {
    margin-bottom: 15px;
}

.review-word-definition {
    color: #555;
    line-height: 1.5;
    margin-bottom: 12px;
    font-size: 0.95em;
}

.review-word-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85em;
    color: #777;
}

.review-difficulty .difficulty-stars.mini {
    display: flex;
    gap: 2px;
}

.review-difficulty .difficulty-stars.mini .difficulty-star {
    width: 8px;
    height: 8px;
    background: #ddd;
    border-radius: 50%;
}

.review-difficulty .difficulty-stars.mini .difficulty-star.filled {
    background: linear-gradient(135deg, #4a7c59 0%, #2d5a3d 100%);
}

.review-date {
    font-style: italic;
}

.review-word-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.review-action-btn {
    background: none;
    border: 2px solid #eee;
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    font-size: 1.1em;
    transition: all 0.3s ease;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.review-action-btn:hover {
    border-color: #4a7c59;
    background: rgba(102, 126, 234, 0.1);
    transform: scale(1.1);
}

.review-pagination {
    text-align: center;
    margin-top: 30px;
}

/* Word Detail Modal */
.word-detail-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.word-detail-modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    cursor: pointer;
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 15px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 30px 20px;
    border-bottom: 2px solid #eee;
}

.modal-header h2 {
    color: #333;
    margin: 0;
    font-size: 1.6em;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.8em;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: #f5f5f5;
    color: #333;
}

.modal-body {
    padding: 25px 30px 30px;
}

.word-detail-info {
    margin-bottom: 25px;
}

.word-detail-info > div {
    margin-bottom: 15px;
    line-height: 1.5;
}

.word-detail-phonetic .phonetic {
    color: #4a7c59;
    font-style: italic;
    font-size: 1.1em;
}

.word-detail-definition,
.word-detail-pos,
.word-detail-difficulty,
.word-detail-xp,
.word-detail-learned {
    color: #555;
}

.word-detail-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.word-detail-actions .btn {
    flex: 1;
    min-width: 120px;
}

/* Empty and Error States */
.empty-state,
.error-state {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.empty-icon,
.error-icon {
    font-size: 4em;
    margin-bottom: 20px;
    opacity: 0.7;
}

.empty-state h3,
.error-state h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.4em;
}

.empty-state p,
.error-state p {
    margin-bottom: 25px;
    line-height: 1.6;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

/* Loading States */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #666;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #eee;
    border-top: 4px solid #4a7c59;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive Design for Review Interface */
@media (max-width: 768px) {
    .review-header {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .review-controls {
        justify-content: space-between;
    }
    
    .review-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .review-word-card {
        padding: 15px;
    }
    
    .review-word-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .review-word-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .modal-content {
        width: 95%;
        margin: 20px;
    }
    
    .modal-header,
    .modal-body {
        padding: 20px;
    }
    
    .word-detail-actions {
        flex-direction: column;
    }
    
    .word-detail-actions .btn {
        min-width: auto;
    }
}

@media (max-width: 480px) {
    .review-word-actions {
        justify-content: center;
        margin-top: 15px;
    }
    
    .review-action-btn {
        width: 40px;
        height: 40px;
        font-size: 1.2em;
    }
}/*
 Review Search and Filter Controls */
.review-search {
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: white;
    color: #333;
    font-size: 0.9em;
    width: 200px;
    transition: border-color 0.3s ease;
}

.review-search:focus {
    outline: none;
    border-color: #4a7c59;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.review-search::placeholder {
    color: #999;
}

/* Review Statistics */
.review-stats {
    display: flex;
    gap: 20px;
    margin-bottom: 25px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 2px solid #eee;
}

.review-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    flex: 1;
}

.review-stat .stat-value {
    font-size: 1.5em;
    font-weight: bold;
    color: #4a7c59;
    margin-bottom: 5px;
}

.review-stat .stat-label {
    font-size: 0.85em;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Enhanced Review Controls Layout */
@media (max-width: 768px) {
    .review-controls {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .review-search {
        width: 100%;
        order: -1;
    }
    
    .review-stats {
        flex-direction: column;
        gap: 15px;
    }
    
    .review-stat {
        flex-direction: row;
        justify-content: space-between;
        text-align: left;
    }
    
    .review-stat .stat-value {
        margin-bottom: 0;
    }
}

@media (max-width: 480px) {
    .review-controls select {
        min-width: 120px;
    }
    
    .review-search {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}
/*
 Leaderboard Styles */
.leaderboard {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    border: 1px solid rgba(255,255,255,0.2);
}

.leaderboard-title {
    font-size: 1.5em;
    font-weight: bold;
    color: #333;
    text-align: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #eee;
}

.current-user-rank {
    background: linear-gradient(135deg, #4a7c59 0%, #2d5a3d 100%);
    color: white;
    padding: 15px 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    text-align: center;
}

.rank-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.rank-label {
    font-size: 0.9em;
    opacity: 0.9;
}

.rank-number {
    font-size: 1.2em;
    font-weight: bold;
}

.rank-xp {
    font-size: 0.9em;
    opacity: 0.9;
}

.leaderboard-separator {
    text-align: center;
    color: #666;
    font-size: 0.9em;
    margin: 15px 0;
    padding: 10px 0;
    border-top: 1px solid #eee;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
    border-radius: 8px;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    margin-bottom: 10px;
    background: #f8f9fa;
    border-radius: 12px;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.leaderboard-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    background: #fff;
}

.leaderboard-item.current-user {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    border-color: #4a7c59;
}

.leaderboard-item.rank-first {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.1) 0%, rgba(255, 193, 7, 0.1) 100%);
    border-color: #ffd700;
}

.leaderboard-item.rank-second {
    background: linear-gradient(135deg, rgba(192, 192, 192, 0.1) 0%, rgba(169, 169, 169, 0.1) 100%);
    border-color: #c0c0c0;
}

.leaderboard-item.rank-third {
    background: linear-gradient(135deg, rgba(205, 127, 50, 0.1) 0%, rgba(184, 115, 51, 0.1) 100%);
    border-color: #cd7f32;
}

.leaderboard-item.rank-top-five {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
}

.leaderboard-rank {
    width: 50px;
    text-align: center;
    margin-right: 15px;
}

.rank-medal {
    font-size: 1.5em;
}

.rank-number {
    font-size: 1.2em;
    font-weight: bold;
    color: #4a7c59;
}

.leaderboard-user {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-weight: bold;
    color: #333;
    font-size: 1.1em;
    margin-bottom: 3px;
}

.user-stats {
    font-size: 0.85em;
    color: #666;
}

.leaderboard-score {
    text-align: right;
    margin-right: 10px;
}

.xp-amount {
    font-size: 1.2em;
    font-weight: bold;
    color: #4a7c59;
}

.xp-label {
    font-size: 0.8em;
    color: #666;
    margin-top: 2px;
}

.user-streak {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
    color: white;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: bold;
    white-space: nowrap;
}

.empty-state, .error-state {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.empty-icon, .error-icon {
    font-size: 3em;
    margin-bottom: 15px;
}

.empty-state h3, .error-state h3 {
    color: #333;
    margin-bottom: 10px;
}

.empty-state p, .error-state p {
    margin-bottom: 20px;
    line-height: 1.5;
}

/* Loading spinner for leaderboard */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #666;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #4a7c59;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive design for leaderboard */
@media (max-width: 768px) {
    .leaderboard {
        padding: 20px 15px;
    }
    
    .leaderboard-item {
        padding: 12px 15px;
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .leaderboard-rank {
        width: 40px;
        margin-right: 10px;
    }
    
    .rank-info {
        flex-direction: column;
        gap: 5px;
    }
    
    .user-name {
        font-size: 1em;
    }
    
    .user-stats {
        font-size: 0.8em;
    }
    
    .xp-amount {
        font-size: 1.1em;
    }
    
    .user-streak {
        padding: 4px 8px;
        font-size: 0.75em;
    }
}

@media (max-width: 480px) {
    .leaderboard-item {
        padding: 10px 12px;
    }
    
    .leaderboard-rank {
        width: 35px;
        margin-right: 8px;
    }
    
    .rank-medal {
        font-size: 1.3em;
    }
    
    .user-name {
        font-size: 0.95em;
    }
    
    .xp-amount {
        font-size: 1em;
    }
}/
* Community Tab Styles */
.community-header {
    margin-bottom: 25px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 12px;
    border: 1px solid #e9ecef;
}

.privacy-controls {
    display: flex;
    justify-content: center;
    align-items: center;
}

.privacy-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.95em;
    color: #333;
}

.privacy-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #4a7c59;
    cursor: pointer;
}

.privacy-label {
    user-select: none;
}

.community-stats {
    margin-top: 30px;
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    border: 1px solid rgba(255,255,255,0.2);
}

.community-stats-title {
    font-size: 1.3em;
    font-weight: bold;
    color: #333;
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #eee;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.stat-card {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid #e9ecef;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    background: #fff;
}

.stat-value {
    font-size: 1.8em;
    font-weight: bold;
    color: #4a7c59;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.85em;
    color: #666;
    font-weight: 500;
}

/* Enhanced leaderboard title */
.leaderboard-title {
    background: linear-gradient(135deg, #4a7c59 0%, #2d5a3d 100%);
    color: white;
    margin: -25px -25px 25px -25px;
    padding: 20px 25px;
    border-radius: 15px 15px 0 0;
    font-size: 1.3em;
}

/* Responsive design for community features */
@media (max-width: 768px) {
    .community-header {
        padding: 15px;
        margin-bottom: 20px;
    }
    
    .community-stats {
        padding: 20px 15px;
        margin-top: 25px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 12px;
    }
    
    .stat-card {
        padding: 15px 10px;
    }
    
    .stat-value {
        font-size: 1.5em;
    }
    
    .stat-label {
        font-size: 0.8em;
    }
    
    .community-stats-title {
        font-size: 1.2em;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .stat-card {
        padding: 12px 8px;
    }
    
    .stat-value {
        font-size: 1.3em;
    }
    
    .privacy-toggle {
        font-size: 0.9em;
    }
}
/
* Analytics Dashboard Styles */
.analytics-dashboard {
    max-width: 1200px;
    margin: 0 auto;
}

.analytics-section {
    margin-bottom: 40px;
    background: #f8f9fa;
    border-radius: 15px;
    padding: 25px;
    border: 1px solid #e9ecef;
}

.section-title {
    color: #333;
    font-size: 1.3em;
    font-weight: 600;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Enhanced Stats Grid for Analytics */
.analytics-section .stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 0;
}

.stat-card.highlight {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card.highlight::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(135deg, #4a7c59 0%, #2d5a3d 100%);
}

.stat-card.highlight:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.15);
    border-color: #4a7c59;
}

.stat-trend {
    font-size: 0.8em;
    color: #6c757d;
    margin-top: 5px;
    font-style: italic;
}

/* Progress Insights */
.insights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.insight-card {
    background: white;
    border-radius: 10px;
    padding: 20px;
    border-left: 4px solid #4a7c59;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.insight-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}

.insight-card.level {
    border-left-color: #8fbc8f;
}

.insight-card.consistency {
    border-left-color: #FF9800;
}

.insight-card.velocity {
    border-left-color: #2196F3;
}

.insight-card.vocabulary {
    border-left-color: #8b7355;
}

.insight-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.insight-title {
    font-weight: 600;
    color: #333;
    font-size: 0.95em;
}

.insight-value {
    font-weight: bold;
    color: #4a7c59;
    font-size: 1.1em;
}

.insight-description {
    color: #666;
    font-size: 0.9em;
    line-height: 1.4;
}

/* Recommendations */
.recommendations {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    border: 1px solid #ffeaa7;
    border-radius: 10px;
    padding: 20px;
    margin-top: 20px;
}

.recommendations h4 {
    color: #856404;
    margin-bottom: 15px;
    font-size: 1.1em;
}

.recommendation-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.recommendation-item {
    background: rgba(255,255,255,0.7);
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    border-left: 3px solid #ffc107;
    color: #333;
    font-size: 0.95em;
    line-height: 1.4;
}

.recommendation-item:last-child {
    margin-bottom: 0;
}

/* Learning Patterns */
.patterns-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.pattern-card {
    background: white;
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    border: 2px solid #e9ecef;
    transition: all 0.3s ease;
}

.pattern-card:hover {
    border-color: #4a7c59;
    transform: translateY(-2px);
}

.pattern-title {
    font-size: 0.85em;
    color: #666;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pattern-value {
    font-size: 1.8em;
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
}

.pattern-value.velocity-accelerating {
    color: #8fbc8f;
}

.pattern-value.velocity-slowing {
    color: #FF5722;
}

.pattern-value.velocity-steady {
    color: #2196F3;
}

.pattern-label {
    font-size: 0.8em;
    color: #999;
}

/* Activity Chart */
.activity-chart {
    background: white;
    border-radius: 10px;
    padding: 20px;
    margin-top: 20px;
}

.activity-chart h4 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1em;
}

.activity-grid {
    display: grid;
    grid-template-columns: repeat(30, 1fr);
    gap: 3px;
    max-width: 100%;
    overflow-x: auto;
}

.activity-day {
    aspect-ratio: 1;
    background: #e9ecef;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7em;
    color: #666;
    transition: all 0.3s ease;
    cursor: pointer;
    min-width: 25px;
    min-height: 25px;
}

.activity-day.active {
    background: linear-gradient(135deg, #4a7c59 0%, #2d5a3d 100%);
    color: white;
}

.activity-day:hover {
    transform: scale(1.1);
    z-index: 1;
}

.activity-count {
    font-weight: bold;
}

/* Difficulty Analysis */
.difficulty-analysis {
    background: white;
    border-radius: 10px;
    padding: 20px;
}

.difficulty-bar {
    margin-bottom: 15px;
}

.difficulty-bar:last-child {
    margin-bottom: 0;
}

.difficulty-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.difficulty-label {
    font-weight: 500;
    color: #333;
}

.difficulty-count {
    font-size: 0.9em;
    color: #666;
}

.difficulty-progress {
    width: 100%;
    height: 12px;
    background: #f0f0f0;
    border-radius: 6px;
    overflow: hidden;
}

.difficulty-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.8s ease;
}

.difficulty-fill.difficulty-1 {
    background: linear-gradient(135deg, #8fbc8f 0%, #4a7c59 100%);
}

.difficulty-fill.difficulty-2 {
    background: linear-gradient(135deg, #a8d8a8 0%, #8fbc8f 100%);
}

.difficulty-fill.difficulty-3 {
    background: linear-gradient(135deg, #FFC107 0%, #ffb300 100%);
}

.difficulty-fill.difficulty-4 {
    background: linear-gradient(135deg, #FF9800 0%, #f57c00 100%);
}

.difficulty-fill.difficulty-5 {
    background: linear-gradient(135deg, #FF5722 0%, #e64a19 100%);
}

.difficulty-fill.difficulty-6 {
    background: linear-gradient(135deg, #8b7355 0%, #6b5b47 100%);
}

/* Performance Metrics */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.metric-card {
    background: white;
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    border: 2px solid #e9ecef;
    transition: all 0.3s ease;
}

.metric-card:hover {
    border-color: #4a7c59;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.15);
}

.metric-name {
    font-size: 0.9em;
    color: #666;
    margin-bottom: 10px;
    font-weight: 500;
}

.metric-value {
    font-size: 1.5em;
    font-weight: bold;
    color: #4a7c59;
    margin-bottom: 8px;
}

.metric-description {
    font-size: 0.8em;
    color: #999;
    line-height: 1.3;
}

/* Analytics Footer */
.analytics-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    margin-top: 30px;
    border: 1px solid #e9ecef;
}

.data-timestamp {
    font-size: 0.85em;
    color: #666;
    font-style: italic;
}

/* Empty and Error States */
.empty-state, .error-state {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.empty-icon, .error-icon {
    font-size: 3em;
    margin-bottom: 20px;
    opacity: 0.7;
}

.empty-state h3, .error-state h3 {
    color: #333;
    margin-bottom: 10px;
    font-size: 1.3em;
}

.empty-state p, .error-state p {
    color: #666;
    line-height: 1.5;
    margin-bottom: 20px;
}

/* Responsive Design for Analytics */
@media (max-width: 768px) {
    .analytics-section {
        padding: 20px 15px;
        margin-bottom: 25px;
    }
    
    .section-title {
        font-size: 1.2em;
    }
    
    .insights-grid {
        grid-template-columns: 1fr;
    }
    
    .patterns-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }
    
    .activity-grid {
        grid-template-columns: repeat(15, 1fr);
        gap: 2px;
    }
    
    .activity-day {
        min-width: 20px;
        min-height: 20px;
        font-size: 0.6em;
    }
    
    .analytics-footer {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .metrics-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .analytics-section {
        padding: 15px 10px;
    }
    
    .stat-card.highlight {
        padding: 15px;
    }
    
    .insight-card, .pattern-card, .metric-card {
        padding: 15px;
    }
    
    .activity-chart {
        padding: 15px;
    }
    
    .difficulty-analysis {
        padding: 15px;
    }
}
/* En
hanced Notification System Styles */

/* Notification Container */
.notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    pointer-events: none;
    max-width: 400px;
}

/* Toast Notifications */
.toast {
    background: #333;
    color: white;
    padding: 16px 20px;
    border-radius: 12px;
    margin-bottom: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transform: translateX(100%);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
    position: relative;
    overflow: hidden;
    max-width: 100%;
    word-wrap: break-word;
}

.toast.toast-show {
    transform: translateX(0);
    opacity: 1;
}

.toast.toast-hide {
    transform: translateX(100%);
    opacity: 0;
}

/* Toast Types */
.toast.toast-success {
    background: linear-gradient(135deg, #8fbc8f 0%, #4a7c59 100%);
    border-left: 4px solid #2e7d32;
}

.toast.toast-error {
    background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%);
    border-left: 4px solid #c62828;
}

.toast.toast-warning {
    background: linear-gradient(135deg, #ff9800 0%, #f57c00 100%);
    border-left: 4px solid #ef6c00;
    color: #fff;
}

.toast.toast-info {
    background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%);
    border-left: 4px solid #1565c0;
}

.toast.toast-loading {
    background: linear-gradient(135deg, #9c27b0 0%, #6b5b47 100%);
    border-left: 4px solid #6a1b9a;
}

/* Toast Content */
.toast-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    position: relative;
}

.toast-icon {
    font-size: 1.2em;
    flex-shrink: 0;
    margin-top: 2px;
}

.toast-message {
    flex: 1;
    line-height: 1.4;
    font-size: 0.95em;
    font-weight: 500;
}

.toast-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    margin-left: 32px;
}

.toast-action-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.toast-action-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.toast-dismiss {
    position: absolute;
    top: -4px;
    right: -4px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.toast-dismiss:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Loading Container */
.loading-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    pointer-events: none;
}

/* Loading Indicators */
.loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: auto;
}

.loading-indicator.loading-show {
    opacity: 1;
}

.loading-indicator.loading-hide {
    opacity: 0;
}

.loading-indicator.loading-overlay {
    background: rgba(0, 0, 0, 0.7);
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 300px;
    min-width: 200px;
}

.loading-message {
    margin-top: 16px;
    color: #333;
    font-size: 1em;
    font-weight: 500;
}

.loading-cancel-btn {
    margin-top: 16px;
    background: #f44336;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.2s ease;
}

.loading-cancel-btn:hover {
    background: #d32f2f;
}

/* Spinner Animations */
.spinner {
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner-circle {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #4a7c59;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.spinner-dots {
    display: flex;
    gap: 4px;
}

.spinner-dot {
    width: 8px;
    height: 8px;
    background: #4a7c59;
    border-radius: 50%;
    animation: dot-bounce 1.4s ease-in-out infinite both;
}

.spinner-dot:nth-child(1) { animation-delay: -0.32s; }
.spinner-dot:nth-child(2) { animation-delay: -0.16s; }

.spinner-pulse {
    width: 40px;
    height: 40px;
    background: #4a7c59;
    border-radius: 50%;
    animation: pulse-scale 1s ease-in-out infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes dot-bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

@keyframes pulse-scale {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 0;
    }
}

/* Progress Bar */
.progress-container {
    width: 100%;
    margin: 16px 0;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4a7c59 0%, #2d5a3d 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-text {
    text-align: center;
    margin-top: 8px;
    font-size: 0.9em;
    color: #666;
    font-weight: 500;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 40px;
    color: #666;
}

.empty-state-icon {
    font-size: 4em;
    margin-bottom: 20px;
    opacity: 0.7;
}

.empty-state-title {
    font-size: 1.5em;
    color: #333;
    margin-bottom: 12px;
    font-weight: 600;
}

.empty-state-message {
    font-size: 1em;
    line-height: 1.5;
    margin-bottom: 24px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.empty-state-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Guidance Tooltip */
.guidance-tooltip {
    position: fixed;
    background: #333;
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    max-width: 250px;
    font-size: 0.9em;
    line-height: 1.4;
    z-index: 10001;
    animation: guidance-fade-in 0.3s ease;
}

.guidance-tooltip::before {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border: 6px solid transparent;
}

.guidance-tooltip.guidance-bottom::before {
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    border-bottom-color: #333;
}

.guidance-tooltip.guidance-top::before {
    bottom: -12px;
    left: 50%;
    transform: translateX(-50%);
    border-top-color: #333;
}

.guidance-tooltip.guidance-left::before {
    right: -12px;
    top: 50%;
    transform: translateY(-50%);
    border-left-color: #333;
}

.guidance-tooltip.guidance-right::before {
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    border-right-color: #333;
}

.guidance-content {
    position: relative;
}

.guidance-dismiss {
    position: absolute;
    top: -8px;
    right: -8px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes guidance-fade-in {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .notification-container {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .toast {
        margin-bottom: 8px;
        padding: 14px 16px;
    }
    
    .loading-content {
        margin: 20px;
        padding: 24px;
        min-width: auto;
    }
    
    .empty-state {
        padding: 40px 20px;
    }
    
    .empty-state-icon {
        font-size: 3em;
    }
    
    .guidance-tooltip {
        max-width: 200px;
        font-size: 0.85em;
    }
}

@media (max-width: 480px) {
    .toast-actions {
        flex-direction: column;
        gap: 6px;
    }
    
    .toast-action-btn {
        width: 100%;
        text-align: center;
    }
    
    .empty-state-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .empty-state-actions .btn {
        width: 100%;
        max-width: 200px;
    }
}

/* Accessibility Enhancements */
@media (prefers-reduced-motion: reduce) {
    .toast,
    .loading-indicator,
    .guidance-tooltip {
        transition: none;
        animation: none;
    }
    
    .spinner-circle,
    .spinner-dot,
    .spinner-pulse {
        animation: none;
    }
    
    .progress-fill {
        transition: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .toast {
        border: 2px solid currentColor;
    }
    
    .loading-content {
        border: 2px solid #333;
    }
    
    .guidance-tooltip {
        border: 2px solid white;
    }
}

/* =================================================================== */
/* CONSOLIDATED MOBILE FIXES */
/* All mobile issues consolidated into main stylesheet */
/* =================================================================== */

/* Critical Mobile Scrolling and Layout Fixes */
@media screen and (max-width: 768px) {
    /* Critical: Fix body and html scrolling */
    html {
        overflow: initial !important;
        height: 100% !important;
        position: static !important;
    }

    body {
        overflow-x: hidden !important;
        overflow-y: auto !important;
        height: auto !important;
        min-height: 100vh !important;
        position: relative !important;
        -webkit-overflow-scrolling: touch !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Remove absolute positioning from main containers */
    .app-container {
        position: relative !important;
        overflow: visible !important;
        height: auto !important;
        background: transparent !important;
    }

    .main-container,
    .auth-container {
        position: fixed !important; /* Changed to fixed to overlay canvas */
        top: 0 !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        overflow-y: auto !important;
        height: 100vh !important;
        width: 100% !important;
        max-width: 100vw !important;
        /* DO NOT override opacity/visibility - let SPA state management handle this */
    }

    /* Main container with better transparency - only when authenticated */
    body.authenticated .main-container {
        background: rgba(255, 255, 255, 0.85) !important;
        backdrop-filter: blur(10px) !important;
        -webkit-backdrop-filter: blur(10px) !important;
        border: 1px solid rgba(255, 255, 255, 0.3) !important;
        margin: 10px !important;
        padding: 15px !important;
        border-radius: 20px !important;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1) !important;
        max-width: calc(100vw - 20px) !important;
    }

    /* Auth container transparency - only when unauthenticated */
    body.unauthenticated .auth-container {
        background: transparent !important;
    }

    body.unauthenticated .auth-card {
        background: rgba(255, 255, 255, 0.75) !important;
        backdrop-filter: blur(20px) !important;
        -webkit-backdrop-filter: blur(20px) !important;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1) !important;
        border: 1px solid rgba(255, 255, 255, 0.5) !important;
        max-width: calc(100vw - 30px) !important;
        margin: 15px auto !important;
        max-height: none !important;
        overflow: visible !important;
        width: 100% !important;
        padding: 30px 20px !important;
        border-radius: 20px !important;
    }

    /* Improve form elements on mobile */
    body.unauthenticated .form-input {
        font-size: 16px !important; /* Prevents zoom on iOS */
        padding: 14px 16px !important;
        width: 100% !important;
        border-radius: 12px !important;
        margin-bottom: 8px !important;
    }

    body.unauthenticated .btn {
        padding: 12px 20px !important;
        font-size: 15px !important;
        width: 100% !important;
        margin-bottom: 8px !important;
        border-radius: 12px !important;
    }

    body.unauthenticated .btn-google {
        width: 100% !important;
        padding: 12px 20px !important;
        font-size: 15px !important;
        border-radius: 12px !important;
    }

    body.unauthenticated .app-title {
        font-size: 2em !important;
        margin-bottom: 8px !important;
    }

    body.unauthenticated .app-subtitle {
        font-size: 1em !important;
        margin-bottom: 20px !important;
    }

    /* Ensure canvas doesn't block interactions */
    #canvas-container,
    .nature-scene-container {
        pointer-events: none !important;
        touch-action: none !important;
        opacity: 1 !important;
        z-index: 1 !important;
        position: fixed !important;
    }

    /* Make all content containers scrollable */
    .tab-content,
    .word-display,
    .difficulty-selector,
    .stats-grid,
    .review-words,
    .leaderboard,
    .analytics-content {
        overflow: visible !important;
        height: auto !important;
        max-height: none !important;
    }

    /* Tab content scrolling */
    .tab-content {
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        max-height: none !important;
    }

    /* Word display with transparency */
    .word-display {
        background: rgba(255, 255, 255, 0.8) !important;
        backdrop-filter: blur(15px) !important;
        -webkit-backdrop-filter: blur(15px) !important;
        padding: 20px !important;
        margin-bottom: 15px !important;
        border: 1px solid rgba(135, 206, 235, 0.2) !important;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08) !important;
        overflow-y: auto !important;
        max-height: none !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }

    /* Difficulty selector with transparency and scrolling */
    .difficulty-selector {
        background: rgba(255, 255, 255, 0.7) !important;
        backdrop-filter: blur(10px) !important;
        padding: 15px !important;
        margin-bottom: 15px !important;
        border: 1px solid rgba(74, 124, 89, 0.15) !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .difficulty-grid {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        gap: 10px !important;
        padding: 10px 0 !important;
    }

    .difficulty-card {
        background: rgba(255, 255, 255, 0.85) !important;
        backdrop-filter: blur(5px) !important;
        border: 1px solid rgba(74, 124, 89, 0.2) !important;
        min-height: 50px !important;
        padding: 10px 8px !important;
        flex: 0 0 auto !important;
        min-width: 100px !important;
    }

    .difficulty-card.active {
        background: rgba(74, 124, 89, 0.9) !important;
        color: white !important;
        border: 1px solid rgba(74, 124, 89, 0.4) !important;
        box-shadow: 0 4px 12px rgba(74, 124, 89, 0.3) !important;
    }

    /* Fix input zoom on iOS */
    input, select, textarea, .form-input {
        font-size: 16px !important;
    }

    /* Ensure buttons are always clickable */
    button, .btn, .action-btn, .tab, .difficulty-card,
    input[type="button"], input[type="submit"] {
        pointer-events: auto !important;
        position: relative !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: rgba(0,0,0,0.1);
        z-index: 100 !important;
    }

    /* Header with transparency - only for authenticated state */
    body.authenticated .header {
        background: rgba(255, 255, 255, 0.7) !important;
        backdrop-filter: blur(15px) !important;
        -webkit-backdrop-filter: blur(15px) !important;
        margin: -15px -15px 15px -15px !important;
        padding: 15px !important;
        border-radius: 20px 20px 0 0 !important;
        border-bottom: 1px solid rgba(74, 124, 89, 0.2) !important;
        position: sticky !important;
        top: 0 !important;
        z-index: 1000 !important;
    }

    /* Compact header layout for mobile */
    body.authenticated .header {
        flex-direction: column !important;
        gap: 10px !important;
        align-items: center !important;
        text-align: center !important;
    }

    body.authenticated .header h1 {
        font-size: 1.3em !important;
        margin: 0 !important;
    }

    body.authenticated .user-section {
        width: 100% !important;
        justify-content: space-between !important;
        align-items: center !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    body.authenticated .user-info {
        font-size: 0.8em !important;
        text-align: left !important;
    }

    body.authenticated .user-avatar {
        width: 28px !important;
        height: 28px !important;
        font-size: 0.8em !important;
    }

    /* Tabs with transparency and scrolling */
    .tabs {
        background: rgba(255, 255, 255, 0.6) !important;
        backdrop-filter: blur(10px) !important;
        padding: 8px !important;
        border-radius: 12px !important;
        margin-bottom: 15px !important;
        border: 1px solid rgba(74, 124, 89, 0.15) !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        white-space: nowrap !important;
        padding-bottom: 10px !important;
    }

    .tab {
        background: rgba(255, 255, 255, 0.3) !important;
        backdrop-filter: blur(5px) !important;
        border: 1px solid rgba(74, 124, 89, 0.1) !important;
        display: inline-block !important;
        white-space: nowrap !important;
    }

    .tab.active {
        background: rgba(74, 124, 89, 0.8) !important;
        color: white !important;
        border: 1px solid rgba(74, 124, 89, 0.3) !important;
    }

    /* Action buttons with transparency and scrolling */
    .word-actions {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .action-btn {
        background: rgba(255, 255, 255, 0.8) !important;
        backdrop-filter: blur(5px) !important;
        border: 2px solid rgba(74, 124, 89, 0.3) !important;
    }

    .action-btn:hover {
        background: rgba(74, 124, 89, 0.9) !important;
        color: white !important;
    }

    /* Stats grid with transparency */
    .stats-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
    }

    .stat-card {
        background: rgba(255, 255, 255, 0.75) !important;
        backdrop-filter: blur(10px) !important;
        border: 1px solid rgba(143, 188, 143, 0.2) !important;
        padding: 15px !important;
    }
}

/* iOS-specific fixes */
@supports (-webkit-touch-callout: none) {
    @media screen and (max-width: 768px) {
        body {
            min-height: -webkit-fill-available !important;
        }

        .main-container,
        .auth-container {
            min-height: -webkit-fill-available !important;
        }
    }
}

/* Landscape orientation fixes */
@media screen and (max-width: 896px) and (orientation: landscape) {
    body {
        min-height: 100vh !important;
    }

    .main-container {
        min-height: calc(100vh - 20px) !important;
        margin: 10px !important;
    }

    @media (max-height: 500px) {
        .main-container {
            min-height: auto !important;
            margin: 5px !important;
            padding: 10px !important;
        }

        .header {
            padding: 8px !important;
        }

        .word-display {
            padding: 15px !important;
            min-height: auto !important;
        }

        .difficulty-selector {
            padding: 10px !important;
        }
    }
}

/* Very small screen fixes */
@media screen and (max-width: 380px) {
    .main-container {
        margin: 5px !important;
        padding: 10px !important;
        border-radius: 10px !important;
    }

    .word-display {
        padding: 15px !important;
        font-size: 0.9em !important;
    }

    .difficulty-grid {
        gap: 5px !important;
    }

    .difficulty-card {
        min-width: 80px !important;
        padding: 8px 5px !important;
    }

    .action-btn {
        font-size: 0.75em !important;
        padding: 8px 5px !important;
    }

    .user-level {
        display: none !important;
    }

    .corpus-count {
        display: none !important;
    }

    .difficulty-label {
        font-size: 0.7em !important;
    }
}

/* Safe area insets for modern phones */
@supports (padding: env(safe-area-inset-top)) {
    @media screen and (max-width: 768px) {
        .main-container {
            margin-top: calc(10px + env(safe-area-inset-top)) !important;
            margin-bottom: calc(10px + env(safe-area-inset-bottom)) !important;
            margin-left: calc(10px + env(safe-area-inset-left)) !important;
            margin-right: calc(10px + env(safe-area-inset-right)) !important;
        }

        .header {
            padding-top: calc(15px + env(safe-area-inset-top)) !important;
        }

        .stats-grid {
            padding-bottom: calc(15px + env(safe-area-inset-bottom)) !important;
        }

        .auth-card {
            margin: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left) !important;
        }
    }
}

/* Prevent horizontal scroll from word overflow */
* {
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
}

/* Ensure modals are accessible on mobile */
@media screen and (max-width: 768px) {
    .modal-content,
    .word-detail-modal .modal-content {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        max-width: 90vw !important;
        max-height: 90vh !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
}

/* Touch-friendly adjustments */
@media (hover: none) and (pointer: coarse) {
    /* Ensure all interactive elements have minimum touch target size */
    button, .btn, .action-btn, .tab, .difficulty-card, a {
        min-height: 44px !important;
        min-width: 44px !important;
    }

    /* Add active states for better touch feedback */
    button:active, .btn:active, .action-btn:active {
        transform: scale(0.98) !important;
        opacity: 0.9 !important;
    }
}

/* Performance optimizations for mobile */
@media screen and (max-width: 768px) {
    /* Disable heavy animations on mobile */
    * {
        animation-duration: 0.2s !important;
    }

    /* Optimize shadows for performance */
    * {
        box-shadow: none !important;
    }

    .main-container,
    .word-display,
    .auth-card {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    }

    /* Reduce backdrop filter blur for better performance on older devices */
    @supports not (backdrop-filter: blur(10px)) {
        .main-container,
        .auth-card,
        .word-display,
        .stat-card {
            background: rgba(255, 255, 255, 0.95) !important;
            backdrop-filter: none !important;
            -webkit-backdrop-filter: none !important;
        }
    }
}

/* Connection status banner positioning */
#connection-status {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 10001 !important;
}

/* Z-index hierarchy for proper layering */
@media screen and (max-width: 768px) {
    #canvas-container,
    .nature-scene-container {
        z-index: 1 !important;
    }

    .app-container {
        z-index: 10 !important;
    }

    .main-container,
    .auth-container {
        z-index: 20 !important;
    }

    .tabs {
        z-index: 30 !important;
    }

    .mobile-nav-overlay {
        z-index: 998 !important;
    }

    .tabs.mobile-open {
        z-index: 999 !important;
    }

    .notification-container,
    .toast {
        z-index: 10000 !important;
    }
}

/* Focus indicators for keyboard navigation */
.toast-action-btn:focus,
.toast-dismiss:focus,
.loading-cancel-btn:focus,
.guidance-dismiss:focus {
    outline: 2px solid #fff;
    outline-offset: 2px;
}