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

:root {
    --primary-color: #6366f1;
    --secondary-color: #8b5cf6;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #0f172a;
    --bg-light: #1e293b;
    --text-color: #f1f5f9;
    --text-muted: #94a3b8;
    --border-radius: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Fredoka', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-color);
    overflow: hidden;
    min-height: 100vh;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s, visibility 0.5s;
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-content {
    text-align: center;
    max-width: 400px;
    padding: 2rem;
}

.game-logo {
    font-size: 3rem;
    margin-bottom: 2rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    animation: bounce 2s infinite;
}

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

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: spin 1s linear infinite;
}

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

.loading-bar {
    width: 100%;
    height: 8px;
    background: rgba(255,255,255,0.2);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 1rem;
}

.loading-progress {
    height: 100%;
    background: white;
    width: 0%;
    transition: width 0.3s;
}

/* App Container */
.app-container {
    width: 100%;
    height: 100vh;
    position: relative;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    overflow-y: auto;
}

.screen.active {
    opacity: 1;
    visibility: visible;
}

/* Profile Screen */
.profile-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 3rem 2rem;
    text-align: center;
}

.title {
    font-size: 3rem;
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.subtitle {
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-bottom: 3rem;
}

.profile-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.profile-card {
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius);
    padding: 2rem;
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
}

.profile-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary-color);
    background: rgba(255,255,255,0.15);
}

.profile-avatar {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.profile-name {
    font-size: 1.2rem;
    font-weight: 600;
}

.profile-score {
    color: var(--warning-color);
    margin-top: 0.5rem;
}

/* Buttons */
.btn {
    padding: 1rem 2rem;
    border: none;
    border-radius: var(--border-radius);
    font-family: 'Fredoka', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

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

.btn-primary:hover {
    background: #4f46e5;
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: rgba(255,255,255,0.2);
    color: white;
}

.btn-secondary:hover {
    background: rgba(255,255,255,0.3);
}

.btn-back {
    background: rgba(255,255,255,0.1);
    color: white;
    padding: 0.75rem 1.5rem;
}

.icon-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
}

.icon-btn:hover {
    background: rgba(255,255,255,0.2);
    transform: scale(1.1);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 2rem;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-light);
    border-radius: var(--border-radius);
    padding: 2rem;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h2 {
    margin-bottom: 1.5rem;
    text-align: center;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border-radius: 8px;
    border: 2px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.05);
    color: white;
    font-family: 'Fredoka', sans-serif;
    font-size: 1rem;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.avatar-selection {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.avatar-option {
    font-size: 3rem;
    padding: 1rem;
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition);
    border: 3px solid transparent;
}

.avatar-option:hover {
    background: rgba(255,255,255,0.1);
}

.avatar-option.selected {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.2);
}

.modal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.modal-actions .btn {
    flex: 1;
}

/* Hub Screen */
.hub-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    background: rgba(0,0,0,0.2);
}

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

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

.player-name {
    font-size: 1.5rem;
    font-weight: 600;
}

.score-display {
    font-size: 1.2rem;
    color: var(--warning-color);
}

.hub-actions {
    display: flex;
    gap: 0.5rem;
}

.hub-title {
    text-align: center;
    font-size: 2.5rem;
    margin: 2rem 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.theme-card {
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius);
    padding: 2rem;
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
}

.theme-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
}

.theme-card:hover {
    transform: translateY(-10px);
    border-color: var(--primary-color);
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

.theme-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    display: block;
}

.theme-title {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.theme-description {
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.theme-modes {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.mode-item {
    padding: 0.75rem;
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mode-locked {
    opacity: 0.5;
}

.lock-icon {
    color: var(--warning-color);
}

/* Game Screen */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: rgba(0,0,0,0.3);
}

.game-stats {
    display: flex;
    gap: 2rem;
}

.stat {
    font-size: 1.2rem;
    font-weight: 600;
}

.game-container {
    position: relative;
    width: 100%;
    height: calc(100vh - 80px);
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.question-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

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

.question-card {
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    border-radius: var(--border-radius);
    padding: 3rem;
    min-width: 400px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.5);
    border: 2px solid rgba(255,255,255,0.1);
}

.question-text {
    font-size: 3rem;
    text-align: center;
    margin-bottom: 2rem;
    font-weight: 700;
}

.answer-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.answer-btn {
    padding: 1.5rem;
    font-size: 1.5rem;
    font-weight: 600;
    background: rgba(255,255,255,0.1);
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 12px;
    color: white;
    cursor: pointer;
    transition: var(--transition);
    font-family: 'Fredoka', sans-serif;
}

.answer-btn:hover {
    background: rgba(255,255,255,0.2);
    transform: scale(1.05);
}

.answer-btn.correct {
    background: var(--success-color);
    border-color: var(--success-color);
}

.answer-btn.incorrect {
    background: var(--error-color);
    border-color: var(--error-color);
}

.visual-aid {
    margin-top: 2rem;
    min-height: 100px;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    align-items: center;
}

.visual-dot {
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 50%;
    animation: popIn 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

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

.feedback-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 20;
}

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

.feedback-content {
    text-align: center;
    max-width: 500px;
    padding: 2rem;
}

.feedback-icon {
    font-size: 5rem;
    margin-bottom: 1rem;
    animation: scaleIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes scaleIn {
    0% { transform: scale(0) rotate(-180deg); }
    100% { transform: scale(1) rotate(0); }
}

.feedback-text {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.feedback-explanation {
    font-size: 1.2rem;
    color: var(--text-muted);
}

/* Dashboard Screen */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    background: rgba(0,0,0,0.2);
}

.dashboard-content {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.stats-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.stat-card {
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius);
    padding: 2rem;
    text-align: center;
}

.stat-value {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.stat-label {
    color: var(--text-muted);
    font-size: 1rem;
}

.mastery-section {
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius);
    padding: 2rem;
    margin-bottom: 2rem;
}

.mastery-section h3 {
    margin-bottom: 1.5rem;
}

.mastery-heatmap {
    display: grid;
    grid-template-columns: repeat(11, 1fr);
    gap: 4px;
    max-width: 600px;
}

.heatmap-cell {
    aspect-ratio: 1;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.heatmap-cell:hover {
    transform: scale(1.2);
    z-index: 10;
}

.heatmap-header {
    background: rgba(255,255,255,0.1);
    font-weight: 700;
}

.mastery-0 { background: rgba(239, 68, 68, 0.3); }
.mastery-1 { background: rgba(251, 146, 60, 0.4); }
.mastery-2 { background: rgba(250, 204, 21, 0.5); }
.mastery-3 { background: rgba(132, 204, 22, 0.6); }
.mastery-4 { background: rgba(34, 197, 94, 0.8); }

.recent-activity {
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius);
    padding: 2rem;
}

.recent-activity h3 {
    margin-bottom: 1.5rem;
}

.recent-games-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.game-item {
    background: rgba(255,255,255,0.05);
    padding: 1rem;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.game-theme-icon {
    font-size: 2rem;
}

.game-details {
    display: flex;
    flex-direction: column;
}

.game-theme-name {
    font-weight: 600;
}

.game-date {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.game-score-display {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--warning-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    .title {
        font-size: 2rem;
    }
    
    .theme-grid {
        grid-template-columns: 1fr;
        padding: 1rem;
    }
    
    .question-card {
        min-width: auto;
        width: 90vw;
        padding: 2rem 1rem;
    }
    
    .question-text {
        font-size: 2rem;
    }
    
    .answer-options {
        grid-template-columns: 1fr;
    }
    
    .stats-overview {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .hub-header {
        flex-direction: column;
        gap: 1rem;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print Styles for Certificates */
@media print {
    body * {
        visibility: hidden;
    }
    
    #certificate-print, #certificate-print * {
        visibility: visible;
    }
    
    #certificate-print {
        position: absolute;
        left: 0;
        top: 0;
    }
}
