/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Performance optimizations */
.screen {
    will-change: opacity, transform;
    backface-visibility: hidden;
    transform: translateZ(0);
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

#game-container {
    width: 100%;
    min-height: 100vh;
    position: relative;
}

/* Screen Management */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translateY(20px);
}

.screen.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Welcome Screen */
.welcome-content {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 48px;
    text-align: center;
    max-width: 700px;
    width: 90%;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
    animation: slideInUp 0.6s ease-out;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.game-title {
    font-family: 'Orbitron', monospace;
    font-size: 3.5rem;
    font-weight: 900;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 16px;
    text-shadow: none;
    letter-spacing: -2px;
}

.game-subtitle {
    font-size: 1.6rem;
    color: #4a5568;
    margin-bottom: 32px;
    font-weight: 500;
    opacity: 0.9;
}

.game-description {
    margin-bottom: 30px;
    line-height: 1.6;
    color: #4a5568;
}

.player-setup {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    justify-content: center;
    flex-wrap: wrap;
}

.player-setup input,
.player-setup select {
    padding: 16px 24px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 16px;
    transition: all 0.2s ease;
    background: white;
    min-width: 200px;
    font-weight: 500;
}

.player-setup input:focus,
.player-setup select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15);
    transform: translateY(-1px);
}

.game-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.feature {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 10px;
    font-weight: 500;
    color: #4a5568;
}

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

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 18px 36px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn-primary:hover::before {
    left: 100%;
}

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

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.9);
    color: #4a5568;
    border: 2px solid #e2e8f0;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: white;
    border-color: #667eea;
    color: #667eea;
}

.btn-audio {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-audio:hover {
    transform: scale(1.05);
}

.btn-audio:active {
    transform: scale(0.95);
}

/* Stop audio button specific styling */
#stop-audio {
    background: linear-gradient(135deg, #e53e3e 0%, #c53030 100%);
}

#stop-audio:hover {
    background: linear-gradient(135deg, #c53030 0%, #a53030 100%);
}

/* Game Screen */
#game-screen {
    flex-direction: column;
    padding: 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    gap: 20px;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.player-info {
    display: flex;
    align-items: center;
    gap: 20px;
    font-weight: 600;
    color: #4a5568;
}



.game-stats {
    display: flex;
    gap: 20px;
}

.stat {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: #4a5568;
}

.stat-icon {
    font-size: 1.2rem;
}

.global-audio-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.global-audio-controls .btn-audio {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e0 100%);
    color: #718096;
    cursor: not-allowed;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.global-audio-controls .btn-audio:enabled {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.global-audio-controls .btn-audio:enabled:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.game-layout {
    display: flex;
    gap: 24px;
    flex: 1;
    height: calc(100vh - 200px);
}

.table-of-contents {
    width: 280px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    overflow-y: auto;
    flex-shrink: 0;
}

.table-of-contents h3 {
    color: #4a5568;
    font-size: 1.2rem;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e2e8f0;
}

.toc-nav-controls {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    justify-content: center;
}

.toc-nav-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e0 100%);
    color: #4a5568;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
}

.toc-nav-btn:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.toc-nav-btn:active {
    transform: translateY(0);
}

.toc-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toc-item {
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid transparent;
    font-size: 14px;
    color: #4a5568;
    margin-bottom: 4px;
}

.toc-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toc-number {
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

.toc-title {
    flex: 1;
    font-size: 13px;
    line-height: 1.3;
}

.toc-status {
    font-size: 11px;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

.toc-item:hover {
    background: rgba(102, 126, 234, 0.1);
    border-color: rgba(102, 126, 234, 0.3);
    transform: translateX(2px);
}

.toc-item.current {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.15) 100%);
    border-color: #667eea;
    color: #667eea;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.toc-item.current .toc-status {
    background: rgba(102, 126, 234, 0.2);
    color: #667eea;
}

.toc-item.completed {
    background: rgba(72, 187, 120, 0.1);
    border-color: rgba(72, 187, 120, 0.3);
    color: #48bb78;
}

.toc-item.completed .toc-status {
    background: rgba(72, 187, 120, 0.2);
    color: #48bb78;
}

.toc-item.next {
    background: rgba(255, 193, 7, 0.1);
    border-color: rgba(255, 193, 7, 0.3);
    color: #f59e0b;
}

.toc-item.next .toc-status {
    background: rgba(255, 193, 7, 0.2);
    color: #f59e0b;
}

.toc-item.available {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
    color: #3b82f6;
}

.toc-item.available .toc-status {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
}

.toc-item.locked {
    background: rgba(156, 163, 175, 0.1);
    border-color: rgba(156, 163, 175, 0.3);
    color: #9ca3af;
    cursor: not-allowed;
}

.toc-item.locked:hover {
    background: rgba(156, 163, 175, 0.1);
    border-color: rgba(156, 163, 175, 0.3);
    transform: none;
}

.toc-item.locked .toc-status {
    background: rgba(156, 163, 175, 0.2);
    color: #9ca3af;
}

/* Assessment-specific styling */
.toc-assessment {
    border-top: 2px solid #e2e8f0;
    margin-top: 12px;
    padding-top: 12px;
}

.toc-assessment .toc-number {
    font-size: 16px;
}

.toc-assessment.current {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.15) 0%, rgba(139, 92, 246, 0.15) 100%);
    border-color: #a855f7;
    color: #a855f7;
    box-shadow: 0 2px 8px rgba(168, 85, 247, 0.2);
}

.toc-assessment.current .toc-status {
    background: rgba(168, 85, 247, 0.2);
    color: #a855f7;
}

.toc-assessment.completed {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.3);
    color: #22c55e;
}

.toc-assessment.completed .toc-status {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.toc-assessment.next {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.3);
    color: #f59e0b;
}

.toc-assessment.next .toc-status {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

/* Disabled navigation buttons */
.toc-nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e0 100%) !important;
    color: #9ca3af !important;
    transform: none !important;
    box-shadow: none !important;
}

.game-content {
    flex: 1;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.2);
    max-height: none;
}

/* Lesson Styles */
.lesson-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e2e8f0;
}

.lesson-header h2 {
    color: #4a5568;
    font-size: 2rem;
    font-weight: 700;
}

.lesson-progress {
    display: flex;
    align-items: center;
    gap: 15px;
}

.progress-bar {
    width: 200px;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    transition: width 0.5s ease;
    width: 20%;
}

.lesson-text {
    font-size: 15px;
    line-height: 1.7;
    color: #2d3748;
    margin-bottom: 20px;
    padding: 24px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(248, 250, 252, 0.95) 100%);
    border-radius: 16px;
    border-left: 5px solid #667eea;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    overflow-y: auto;
    max-height: 60vh;
    word-wrap: break-word;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.lesson-text strong {
    color: #2d3748;
    font-weight: 700;
}

.lesson-text h1, .lesson-text h2, .lesson-text h3 {
    color: #1a202c;
    margin-top: 24px;
    margin-bottom: 16px;
    font-weight: 700;
}

.lesson-text h1 {
    font-size: 1.8rem;
    border-bottom: 2px solid #667eea;
    padding-bottom: 8px;
}

.lesson-text h2 {
    font-size: 1.4rem;
    color: #667eea;
}

.lesson-text h3 {
    font-size: 1.2rem;
    color: #4a5568;
}

.lesson-text ul, .lesson-text ol {
    margin-left: 20px;
    margin-bottom: 16px;
}

.lesson-text li {
    margin-bottom: 8px;
    padding-left: 8px;
}

.lesson-text code {
    background: rgba(102, 126, 234, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.lesson-text pre {
    background: #1a202c;
    color: #e2e8f0;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 16px 0;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    line-height: 1.4;
}

.lesson-text blockquote {
    border-left: 4px solid #667eea;
    padding-left: 16px;
    margin: 16px 0;
    font-style: italic;
    color: #4a5568;
    background: rgba(102, 126, 234, 0.05);
    padding: 12px 16px;
    border-radius: 0 8px 8px 0;
}



/* Quiz Styles */
.quiz-header {
    text-align: center;
    margin-bottom: 30px;
}

.quiz-header h2 {
    color: #4a5568;
    font-size: 2rem;
    margin-bottom: 10px;
}

.quiz-progress {
    color: #718096;
    font-weight: 500;
}

.quiz-question {
    font-size: 20px;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 10px;
    border-left: 4px solid #667eea;
}

.quiz-options {
    display: grid;
    gap: 15px;
    margin-bottom: 30px;
}

.quiz-option {
    padding: 18px 24px;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 16px;
    color: #4a5568;
    position: relative;
    overflow: hidden;
}

.quiz-option::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.quiz-option:hover::before {
    opacity: 1;
}

.quiz-option:hover {
    border-color: #667eea;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.quiz-option.selected {
    border-color: #667eea;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    color: #667eea;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.quiz-option.correct {
    border-color: #48bb78;
    background: rgba(72, 187, 120, 0.1);
    color: #48bb78;
}

.quiz-option.incorrect {
    border-color: #f56565;
    background: rgba(245, 101, 101, 0.1);
    color: #f56565;
}

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

/* Challenge Styles */
.challenge-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e2e8f0;
}

.challenge-header h2 {
    color: #4a5568;
    font-size: 2rem;
    font-weight: 700;
}

.challenge-timer {
    background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: 600;
    animation: pulse 2s infinite;
}

.challenge-description {
    font-size: 18px;
    line-height: 1.8;
    color: #4a5568;
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 10px;
    border-left: 4px solid #667eea;
}

.challenge-interaction {
    margin-bottom: 30px;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 10px;
    border: 2px dashed #667eea;
}

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

/* Game Navigation */
.game-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

/* Progress Screen */
.progress-content {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 32px;
    max-width: 900px;
    width: 95%;
    margin: 20px auto;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    scrollbar-width: thin;
    scrollbar-color: #667eea #e2e8f0;
}

/* Custom scrollbar for progress screen */
.progress-content::-webkit-scrollbar {
    width: 8px;
}

.progress-content::-webkit-scrollbar-track {
    background: rgba(226, 232, 240, 0.5);
    border-radius: 4px;
}

.progress-content::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 4px;
}

.progress-content::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);
}

.progress-content h2 {
    text-align: center;
    color: #4a5568;
    font-size: 2.5rem;
    margin-bottom: 40px;
}

.progress-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
    padding: 0 8px;
}

.progress-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 24px 20px;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.progress-card h3 {
    font-size: 1.2rem;
    margin-bottom: 15px;
    opacity: 0.9;
}

.progress-number {
    font-size: 2.5rem;
    font-weight: 900;
    font-family: 'Orbitron', monospace;
}

.badges-section h3 {
    color: #4a5568;
    font-size: 1.6rem;
    margin-bottom: 24px;
    text-align: center;
    padding: 0 16px;
}

.badges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
    max-width: 100%;
    padding: 0 8px;
}

.badge {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px 12px;
    text-align: center;
    transition: all 0.3s ease;
    opacity: 0.6;
    width: 100%;
    max-width: 240px;
    box-sizing: border-box;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.badge.earned {
    opacity: 1;
    border-color: #667eea;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.2);
}

.badge.locked {
    opacity: 0.4;
    background: rgba(255, 255, 255, 0.8);
}

.badge-icon {
    font-size: 2rem;
    margin-bottom: 10px;
}

.badge-name {
    font-size: 14px;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 8px;
}

.badge-description {
    font-size: 12px;
    color: #718096;
    margin-bottom: 6px;
    line-height: 1.4;
}

.badge-requirement {
    font-size: 11px;
    color: #a0aec0;
    font-style: italic;
}

/* Certificate Styles */
.certificate-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.certificate-preview {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border: 3px solid #667eea;
    border-radius: 20px;
    padding: 40px;
    margin-bottom: 30px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.certificate-preview::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="25" cy="25" r="1" fill="%23f0f0f0"/><circle cx="75" cy="75" r="1" fill="%23f0f0f0"/><circle cx="50" cy="10" r="0.5" fill="%23f0f0f0"/><circle cx="10" cy="60" r="0.5" fill="%23f0f0f0"/><circle cx="90" cy="40" r="0.5" fill="%23f0f0f0"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
    opacity: 0.3;
    pointer-events: none;
}

.certificate-preview::after {
    content: 'OFFICIAL DOCUMENT';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    font-size: 3rem;
    font-weight: 900;
    color: rgba(102, 126, 234, 0.08);
    letter-spacing: 4px;
    pointer-events: none;
    z-index: 0;
    white-space: nowrap;
}

.certificate-header {
    text-align: center;
    margin-bottom: 40px;
    position: relative;
    z-index: 1;
}

.certificate-logo {
    font-size: 4rem;
    margin-bottom: 20px;
}

.certificate-header h1 {
    color: #2d3748;
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.certificate-subtitle {
    color: #718096;
    font-size: 1.2rem;
    font-weight: 500;
}

.certificate-body {
    text-align: center;
    margin-bottom: 40px;
    position: relative;
    z-index: 1;
}

.certificate-text {
    color: #4a5568;
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 20px;
}

.certificate-name {
    color: #667eea;
    font-size: 2rem;
    font-weight: 700;
    margin: 20px 0;
    padding: 10px 20px;
    border-bottom: 3px solid #667eea;
    display: inline-block;
}

.certificate-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 30px;
    padding: 20px;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 12px;
}

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

.detail-label {
    color: #718096;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 5px;
}

.detail-value {
    color: #2d3748;
    font-size: 1rem;
    font-weight: 600;
}

.certificate-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: 40px;
    position: relative;
    z-index: 1;
    padding: 24px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.03) 0%, rgba(118, 75, 162, 0.03) 100%);
    border-radius: 16px;
    border: 1px solid rgba(102, 126, 234, 0.1);
}

.signature-section {
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.fancy-signature {
    margin-bottom: 8px;
}

.signature-svg {
    width: 100%;
    max-width: 400px;
    height: auto;
    filter: drop-shadow(0 4px 8px rgba(26, 32, 44, 0.25));
    transform: rotate(-3deg);
    transform-origin: center;
}

.signature-letter {
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    animation: drawLetter 1.2s ease-in-out forwards;
    opacity: 0;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Add subtle variations to make it look more handwritten */
.signature-letter:nth-child(odd) {
    stroke-width: 2.3px;
}

.signature-letter:nth-child(even) {
    stroke-width: 2.7px;
}

.signature-letter:nth-child(1) { animation-delay: 0.3s; }
.signature-letter:nth-child(2) { animation-delay: 0.6s; }
.signature-letter:nth-child(3) { animation-delay: 0.9s; }
.signature-letter:nth-child(4) { animation-delay: 1.2s; }
.signature-letter:nth-child(5) { animation-delay: 1.5s; }
.signature-letter:nth-child(6) { animation-delay: 1.8s; }
.signature-letter:nth-child(7) { animation-delay: 2.1s; }
.signature-letter:nth-child(8) { animation-delay: 2.4s; }
.signature-letter:nth-child(9) { animation-delay: 2.7s; }
.signature-letter:nth-child(10) { animation-delay: 3.0s; }
.signature-letter:nth-child(11) { animation-delay: 3.3s; }
.signature-letter:nth-child(12) { animation-delay: 3.6s; }
.signature-letter:nth-child(13) { animation-delay: 3.9s; }
.signature-letter:nth-child(14) { animation-delay: 4.2s; }
.signature-letter:nth-child(15) { animation-delay: 4.5s; }
.signature-letter:nth-child(16) { animation-delay: 4.8s; }
.signature-letter:nth-child(17) { animation-delay: 5.1s; }
.signature-letter:nth-child(18) { animation-delay: 5.4s; }
.signature-letter:nth-child(19) { animation-delay: 5.7s; }
.signature-letter:nth-child(20) { animation-delay: 6.0s; }
.signature-letter:nth-child(21) { animation-delay: 6.3s; }
.signature-letter:nth-child(22) { animation-delay: 6.6s; }
.signature-letter:nth-child(23) { animation-delay: 6.9s; }
.signature-letter:nth-child(24) { animation-delay: 7.2s; }
.signature-letter:nth-child(25) { animation-delay: 7.5s; }
.signature-letter:nth-child(26) { animation-delay: 7.8s; }
.signature-letter:nth-child(27) { animation-delay: 8.1s; }
.signature-letter:nth-child(28) { animation-delay: 8.4s; }
.signature-letter:nth-child(29) { animation-delay: 8.7s; }
.signature-letter:nth-child(30) { animation-delay: 9.0s; }

.signature-flourish {
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    animation: drawFlourish 1s ease-in-out 9.3s forwards;
    opacity: 0;
}

.signature-dot {
    opacity: 0;
    animation: fadeInDot 0.5s ease-in-out forwards;
}

.signature-dot:nth-child(2) { animation-delay: 0.3s; }
.signature-dot:nth-child(4) { animation-delay: 0.6s; }
.signature-dot:nth-child(6) { animation-delay: 1.2s; }
.signature-dot:nth-child(8) { animation-delay: 1.5s; }

@keyframes drawLetter {
    to {
        stroke-dashoffset: 0;
        opacity: 1;
    }
}

@keyframes drawFlourish {
    to {
        stroke-dashoffset: 0;
        opacity: 1;
    }
}

@keyframes fadeInDot {
    to {
        opacity: 1;
    }
}

.signature-line {
    width: 200px;
    height: 2px;
    background: #2d3748;
    margin-bottom: 10px;
}

.signature-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.signature-name {
    color: #2d3748;
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 0;
    font-family: 'Georgia', serif;
    letter-spacing: 0.5px;
}

.signature-title {
    color: #667eea;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0;
}

.signature-org {
    color: #718096;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0;
    font-style: italic;
}

.certificate-stamp {
    text-align: center;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    width: 80px;
    height: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
}

.stamp-icon {
    font-size: 1.5rem;
    margin-bottom: 5px;
}

.stamp-text {
    font-size: 0.8rem;
    font-weight: 600;
}

.certificate-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Pause Menu */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.pause-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.pause-content h2 {
    color: #4a5568;
    font-size: 2rem;
    margin-bottom: 30px;
}

.pause-options {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Animations */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

@keyframes shimmer {
    0% {
        background-position: -200px 0;
    }
    100% {
        background-position: calc(200px + 100%) 0;
    }
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-5px);
    }
}

/* Loading animation */
.loading-shimmer {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200px 100%;
    animation: shimmer 1.5s infinite;
}

/* Floating animation for badges */
.badge.earned {
    animation: float 3s ease-in-out infinite;
}

/* Responsive Design */
@media (max-width: 768px) {
    .welcome-content,
    .progress-content {
        padding: 20px;
        margin: 12px;
        border-radius: 20px;
        max-height: 85vh;
    }
    
    .game-title {
        font-size: 2.5rem;
        letter-spacing: -1px;
    }
    
    .game-subtitle {
        font-size: 1.3rem;
    }
    
    .player-setup {
        flex-direction: column;
        align-items: center;
        gap: 16px;
    }
    
    .player-setup input,
    .player-setup select {
        min-width: 250px;
        width: 100%;
        max-width: 300px;
    }
    
    .game-header {
        flex-direction: column;
        gap: 16px;
        text-align: center;
        padding: 20px;
    }
    
    .game-stats {
        justify-content: center;
        gap: 16px;
    }
    
    .lesson-header {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }
    
    .progress-bar {
        width: 200px;
    }
    
    .game-navigation {
        flex-direction: column;
        gap: 12px;
        padding: 16px;
    }
    
    .game-content {
        padding: 24px;
        margin: 0;
    }
    
    .lesson-text {
        font-size: 16px;
        padding: 20px;
    }
    
    .quiz-option {
        padding: 16px 20px;
        font-size: 15px;
    }
    
    .badges-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 12px;
    }
    
    .progress-overview {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 12px;
    }
    
    .progress-card {
        padding: 20px 16px;
    }
    
    .progress-content h2 {
        font-size: 2rem;
        margin-bottom: 24px;
    }
    
    .game-layout {
        flex-direction: column;
        gap: 16px;
    }
    
    .table-of-contents {
        width: 100%;
        max-height: 200px;
        order: 2;
    }
    
    .game-content {
        order: 1;
    }
    
    .badge {
        max-width: 250px;
        padding: 16px;
    }
    
    .pause-options {
        flex-direction: column;
        gap: 12px;
    }
    
    .btn-primary {
        padding: 16px 28px;
        font-size: 15px;
    }
    
    .btn-secondary {
        padding: 14px 20px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .welcome-content,
    .progress-content {
        padding: 16px;
        margin: 8px;
        max-height: 80vh;
    }
    
    .game-title {
        font-size: 2rem;
    }
    
    .game-subtitle {
        font-size: 1.1rem;
    }
    
    .player-setup input,
    .player-setup select {
        min-width: 200px;
        padding: 14px 20px;
    }
    
    .game-content {
        padding: 20px;
    }
    
    .lesson-text {
        font-size: 15px;
        padding: 16px;
    }
    
    .progress-overview {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .badges-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .progress-card {
        padding: 18px 16px;
    }
    
    .progress-content h2 {
        font-size: 1.8rem;
        margin-bottom: 20px;
    }
    
    .badges-section h3 {
        font-size: 1.4rem;
        margin-bottom: 20px;
    }
    
    .signature-svg {
        max-width: 220px;
    }
    
    .certificate-footer {
        flex-direction: column;
        align-items: center;
        gap: 20px;
        text-align: center;
    }
    
    .signature-section {
        text-align: center;
    }
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

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

/* Success/Error Messages */
.message {
    padding: 16px 20px;
    border-radius: 12px;
    margin: 16px 0;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid;
    position: relative;
    overflow: hidden;
}

.message::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
}

.message:hover::before {
    transform: translateX(100%);
}

.message.success {
    background: linear-gradient(135deg, rgba(72, 187, 120, 0.1) 0%, rgba(56, 178, 172, 0.1) 100%);
    color: #48bb78;
    border-color: rgba(72, 187, 120, 0.3);
}

.message.error {
    background: linear-gradient(135deg, rgba(245, 101, 101, 0.1) 0%, rgba(237, 100, 166, 0.1) 100%);
    color: #f56565;
    border-color: rgba(245, 101, 101, 0.3);
}

.message.info {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    color: #667eea;
    border-color: rgba(102, 126, 234, 0.3);
}

/* Loading States */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--border-light);
    border-top: 2px solid var(--primary-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Footer Styles */
.course-footer {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-align: center;
    padding: 1rem;
    margin-top: 2rem;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
}

.footer-content p {
    margin: 0;
    font-size: 1rem;
    font-weight: 500;
    color: white;
}

.footer-content strong {
    color: #FFD700;
    font-weight: 600;
}

/* Table Styling */
.lesson-text table {
    width: 100%;
    border-collapse: collapse;
    margin: 2px 0 12px 0;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    font-size: 14px;
}

.lesson-text table th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 10px;
    text-align: left;
    font-weight: 600;
    font-size: 15px;
    border: none;
}

.lesson-text table td {
    padding: 10px 10px;
    border-bottom: 1px solid #e1e8ed;
    vertical-align: top;
    line-height: 1.4;
}

.lesson-text table tr:last-child td {
    border-bottom: none;
}

.lesson-text table tr:nth-child(even) {
    background-color: #f8fafc;
}

.lesson-text table tr:hover {
    background-color: #f1f5f9;
    transition: background-color 0.2s ease;
}

.lesson-text table tr:hover td {
    border-bottom-color: #cbd5e1;
}

/* Responsive table */
@media (max-width: 768px) {
    .lesson-text table {
        font-size: 13px;
    }
    
    .lesson-text table th,
    .lesson-text table td {
        padding: 12px 8px;
    }
    
    .lesson-text table {
        overflow-x: auto;
        display: block;
    }
}

/* Reduce spacing around table titles */
.lesson-text h3 + table,
.lesson-text h4 + table,
.lesson-text p + table {
    margin-top: 0px;
}

/* Remove extra spacing before tables */
.lesson-text table {
    margin-top: 0;
}

/* Compact table layout */
.lesson-text table {
    border-spacing: 0;
}

.lesson-text table tr:first-child td {
    padding-top: 8px;
}

.lesson-text table tr:last-child td {
    padding-bottom: 8px;
}

/* Remove any paragraph spacing before tables */
.lesson-text p:has(+ table) {
    margin-bottom: 0px !important;
}

/* Target specific table spacing */
.lesson-text table {
    margin-top: 0 !important;
    margin-bottom: 8px !important;
}

/* Remove all spacing before tables */
.lesson-text * + table {
    margin-top: 0 !important;
}

/* Remove spacing from elements that might come before tables */
.lesson-text h1 + table,
.lesson-text h2 + table,
.lesson-text h3 + table,
.lesson-text h4 + table,
.lesson-text h5 + table,
.lesson-text h6 + table,
.lesson-text p + table,
.lesson-text div + table,
.lesson-text span + table {
    margin-top: 0 !important;
}

/* Force compact spacing */
.lesson-text table {
    margin: 0 0 8px 0 !important;
}

/* Override any lesson text spacing that might affect tables */
.lesson-text {
    line-height: 1.4;
}

.lesson-text p {
    margin-bottom: 4px;
    margin-top: 4px;
}

.lesson-text p:last-of-type {
    margin-bottom: 0;
}

/* Reduce spacing between all elements */
.lesson-text * {
    margin-top: 2px;
    margin-bottom: 2px;
}

.lesson-text h1, .lesson-text h2, .lesson-text h3, .lesson-text h4, .lesson-text h5, .lesson-text h6 {
    margin-top: 8px;
    margin-bottom: 4px;
}

.lesson-text ul, .lesson-text ol {
    margin-top: 4px;
    margin-bottom: 4px;
    padding-left: 20px;
}

.lesson-text li {
    margin-bottom: 2px;
}

/* Clean table spacing */
.lesson-text table {
    margin: 8px 0 16px 0;
    border: none;
}

/* Table container for better spacing control */
.table-container {
    margin: 8px 0 16px 0;
    display: block;
}

/* Ensure no extra spacing before tables */
.lesson-text .table-container {
    margin-top: 4px;
}

/* Remove any inherited spacing from parent elements */
.lesson-text h2 + .table-container,
.lesson-text h3 + .table-container,
.lesson-text h4 + .table-container {
    margin-top: 8px;
}

/* Ensure tables have no top spacing regardless of what comes before */
.lesson-text table {
    margin-top: 0 !important;
    padding-top: 0 !important;
    border-top: none !important;
}

/* Remove any potential spacing from table wrapper */
.lesson-text table,
.lesson-text table * {
    box-sizing: border-box;
}

/* Remove spacing from table container */
.lesson-text table {
    display: block;
    margin: 0 !important;
    padding: 0 !important;
}

/* Force remove all spacing from any element before table */
.lesson-text *:not(table) + table {
    margin-top: 0 !important;
}

i s/* Nuclear option: Force all tables to have no top spacing */
table {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

/* Target lesson text specifically */
.lesson-text table {
    margin-top: 0 !important;
    padding-top: 0 !important;
    border-top: none !important;
}

/* Remove any potential line breaks or spaces */
.lesson-text br + table,
.lesson-text p + table,
.lesson-text div + table {
    margin-top: -10px !important;
}
