:root {
    --primary-color: #2e7d32; /* Grass green */
    --secondary-color: #0056b3; /* Referee blue for better contrast on light */
    --accent-color: #d32f2f; /* Red card / vibrant red */
    --text-main: #2e2e2e; /* Dark text for light background */
    --text-dark: #1a1a1a;
    --bg-dark: #e8f5e9; /* Light green-tinted background */
    --glass-bg: rgba(255, 255, 255, 0.9);
    --glass-border: rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Tajawal', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow-x: hidden;
}

/* Stadium Background & Pitch */
.stadium-background {
    min-height: 100vh;
    background: 
        radial-gradient(circle at center, rgba(255,255,255,0.3) 0%, rgba(0,0,0,0.3) 100%),
        url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><rect width="100" height="100" fill="%2381c784"/><rect y="50" width="100" height="50" fill="%2366bb6a"/></svg>') repeat;
    background-size: 100% 100%, 100px 100px;
    display: flex;
    flex-direction: column;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    border-radius: 20px;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 5%;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    z-index: 10;
    width: 100%;
    position: sticky;
    top: 0;
}

.player-profile {
    display: flex;
    align-items: center;
    gap: 15px;
}

.avatar-container {
    position: relative;
}

.avatar {
    font-size: 3rem;
    background: #f0f8ff;
    border-radius: 50%;
    width: 80px;
    height: 80px;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 3px solid var(--secondary-color);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.badge {
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--secondary-color);
    color: #ffffff;
    font-size: 0.85rem;
    padding: 4px 12px;
    border-radius: 12px;
    font-weight: 800;
    white-space: nowrap;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

.player-info h1 {
    font-size: 2.2rem;
    font-weight: 900;
    color: var(--primary-color);
    margin-bottom: 2px;
}

.team-name {
    color: var(--text-main);
    font-weight: 700;
    font-size: 1.1rem;
}

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

.stat-box {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 15px;
    padding: 10px 25px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.stat-box:hover {
    transform: translateY(-5px);
    border-color: var(--primary-color);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 900;
    color: var(--primary-color);
}

.stat-label {
    color: var(--text-dark);
    font-weight: 700;
    font-size: 0.95rem;
    margin-top: 5px;
}

/* Pitch Container */
.pitch-container {
    flex: 1;
    position: relative;
    padding: 40px 5%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.pitch-lines {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.3;
}

.center-circle {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 150px;
    height: 150px;
    border: 3px solid white;
    border-radius: 50%;
}

.center-line {
    position: absolute;
    top: 50%; left: 0; right: 0;
    height: 3px;
    background: white;
    transform: translateY(-50%);
}

.lessons-grid {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 1200px;
    display: grid;
    gap: 30px;
}

.welcome-card {
    text-align: center;
    padding: 50px;
    max-width: 600px;
    margin: 0 auto;
}

.welcome-card h2 {
    color: var(--secondary-color);
    margin-bottom: 20px;
    font-size: 2.2rem;
}

.loading-dots {
    margin-top: 30px;
    font-size: 2rem;
}

.loading-dots span {
    display: inline-block;
    animation: bounce 1.5s infinite ease-in-out both;
    margin: 0 5px;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }

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

/* Modals */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 60px 30px 30px 30px;
    position: relative;
    transform: translateY(50px);
    transition: transform 0.3s ease;
}

.modal:not(.hidden) .modal-content {
    transform: translateY(0);
}

.close-btn {
    position: absolute;
    top: 15px; right: 15px;
    background: var(--accent-color);
    color: white;
    border: none;
    width: 40px; height: 40px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.2s;
}

.close-btn:hover {
    transform: scale(1.1) rotate(90deg);
}

/* Dashboard Cards */
.lesson-card {
    padding: 30px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    transition: transform 0.3s;
}

.lesson-card:hover {
    transform: scale(1.02);
    border-color: var(--secondary-color);
}

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

.play-btn, .finish-btn {
    background: var(--primary-color);
    color: white;
    border: 2px solid var(--secondary-color);
    padding: 10px 25px;
    border-radius: 25px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.play-btn:hover, .finish-btn:hover {
    background: var(--secondary-color);
    color: var(--text-dark);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(253, 216, 53, 0.4);
}

/* Lesson Content Layout */
.lesson-scroll {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 20px;
    padding-bottom: 20px;
}

.lesson-games-section {
    background: rgba(255, 255, 255, 0.5);
    border-radius: 10px;
    padding: 15px;
    margin-top: 20px;
    border: 2px dashed var(--primary-color);
}

.games-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 15px;
}

.section-title {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 5px;
    margin-top: 20px;
}

/* Info Cards */
.info-card {
    background: #ffffff;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 12px;
    padding: 20px;
    text-align: right;
    color: var(--text-dark);
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.def-card .term {
    font-weight: bold;
    color: var(--secondary-color);
    font-size: 1.2rem;
    margin-bottom: 10px;
}

.qa-card .question {
    font-weight: bold;
    color: var(--secondary-color);
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.list-card .list-title {
    font-weight: bold;
    color: var(--secondary-color);
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.list-card ul {
    list-style-type: none;
    padding-right: 20px;
}

.list-card li {
    margin-bottom: 8px;
    position: relative;
}

.list-card li::before {
    content: '⚽';
    position: absolute;
    right: -25px;
    top: 2px;
    font-size: 0.9rem;
}

/* Comparison */
.comp-card .comp-title {
    font-weight: bold;
    color: var(--secondary-color);
    margin-bottom: 15px;
    text-align: center;
}

.comp-grid {
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    gap: 15px;
}

.comp-item {
    flex: 1;
    background: rgba(0,0,0,0.03);
    padding: 15px;
    border-radius: 8px;
    border-top: 3px solid var(--secondary-color);
}

.comp-item h4 {
    color: var(--primary-color);
    margin-bottom: 10px;
    text-align: center;
}

.comp-vs {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 1.5rem;
    color: var(--accent-color);
}

/* Quiz Interface */
.quiz-container {
    margin-top: 20px;
    text-align: center;
    color: var(--text-dark);
}

.progress {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-weight: bold;
}

.question-text {
    font-size: 1.5rem;
    margin-bottom: 30px;
    line-height: 1.4;
}

.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.option-btn {
    background: #ffffff;
    border: 2px solid rgba(0,0,0,0.1);
    color: var(--text-dark);
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    padding: 15px;
    border-radius: 10px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.option-btn:hover:not(:disabled) {
    background: rgba(255,255,255,0.2);
    border-color: var(--secondary-color);
}

.option-btn.correct {
    background: var(--primary-color);
    border-color: #69f0ae;
}

.option-btn.wrong {
    background: var(--accent-color);
    border-color: #ff5252;
}

.option-btn:disabled {
    cursor: not-allowed;
    opacity: 0.8;
}

.quiz-results {
    text-align: center;
    padding: 30px;
}

.result-score {
    font-size: 2rem;
    color: var(--secondary-color);
    margin-bottom: 10px;
}

.result-msg {
    font-size: 1.5rem;
    margin-bottom: 30px;
}

.lesson-footer {
    text-align: center;
    margin-top: 20px;
    border-top: 1px solid var(--glass-border);
    padding-top: 20px;
}

/* Advanced Minigames Styling */
.advanced-game-container {
    position: relative;
    width: 100%;
    height: 400px;
    background: linear-gradient(#4caf50, #2e7d32); /* Football Grass */
    border-radius: 15px;
    overflow: hidden;
    margin-top: 20px;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
    color: white;
}

/* Sniper Game */
.sniper-question {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255,255,255,0.1);
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 1.2rem;
    text-align: center;
    width: 80%;
    z-index: 10;
    border: 1px solid rgba(255,255,255,0.3);
}

.sniper-target {
    position: absolute;
    background: radial-gradient(circle, #fff, #ddd);
    color: #333;
    padding: 20px;
    border: 3px solid #333;
    border-radius: 50%;
    cursor: crosshair;
    font-weight: bold;
    text-align: center;
    box-shadow: 0 0 15px rgba(0,0,0,0.3);
    transition: transform 0.1s;
    user-select: none;
}
.football-target::before {
    content: "⚽";
    display: block;
    font-size: 2rem;
    margin-bottom: 5px;
}

.sniper-target:hover {
    transform: scale(1.1);
}

/* Connect Game */
.connect-game {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
    padding: 30px;
}
.tactic-board {
    background: #1b5e20;
    border: 5px solid white;
    border-radius: 15px;
    position: relative;
}
.tactic-board::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100px;
    height: 100px;
    border: 3px solid white;
    border-radius: 50%;
    opacity: 0.5;
}

.connect-term {
    background: #0288d1;
    padding: 20px;
    border-radius: 10px;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.3s;
    z-index: 10;
}

.connect-term.active {
    border-color: #e94560;
    box-shadow: 0 0 20px #e94560;
}

.connect-options {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.connect-opt {
    background: rgba(255,255,255,0.1);
    padding: 15px 20px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.3s;
}

.connect-opt:hover {
    background: rgba(255,255,255,0.3);
}

/* Meteor Game */
.meteor-question {
    position: absolute;
    top: 20px;
    width: 100%;
    text-align: center;
    font-size: 1.2rem;
    background: rgba(0,0,0,0.5);
    padding: 10px 0;
}

.player-basket {
    position: absolute;
    bottom: 20px;
    font-size: 3rem;
    transform: translateX(-50%);
    cursor: pointer;
    user-select: none;
}

.meteor-item {
    position: absolute;
    top: 0;
    left: 0;
    background: transparent;
    color: white;
    text-align: center;
    font-weight: bold;
    padding: 0;
    text-shadow: 0px 2px 4px rgba(0,0,0,0.8);
}
.football-meteor {
    font-size: 2.5rem;
}

/* Game Toast Notification */
.game-toast {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    padding: 20px 40px;
    border-radius: 15px;
    font-size: 2rem;
    font-weight: bold;
    color: white;
    z-index: 100;
    animation: toastPop 1.5s ease forwards;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.toast-success {
    background: linear-gradient(135deg, #4caf50, #81c784);
    box-shadow: 0 10px 30px rgba(76, 175, 80, 0.5);
}

.toast-error {
    background: linear-gradient(135deg, #f44336, #e57373);
    box-shadow: 0 10px 30px rgba(244, 67, 54, 0.5);
}

@keyframes toastPop {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
    20% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
    30% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    80% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
}

/* 4. Sprint Game */
.sprint-question { text-align: center; font-size: 1.5rem; margin-top: 10px; font-weight: bold; text-shadow: 0 2px 4px rgba(0,0,0,0.5); }
.finish-line { position: absolute; right: 100px; top: 0; bottom: 0; width: 10px; background: repeating-linear-gradient(45deg, white, white 10px, black 10px, black 20px); }
.sprint-runner { position: absolute; cursor: pointer; z-index: 10; }

/* 5. Header Game */
.header-question { text-align: center; font-size: 1.5rem; margin-top: 10px; font-weight: bold; z-index: 10; position: relative; }
.player-header { position: absolute; bottom: 20px; left: 50%; font-size: 4rem; z-index: 10; margin-left: -32px; pointer-events: none; }
.header-ball { position: absolute; top: 50px; text-align: center; width: 30%; font-size: 0.9rem; margin-left: -15%; }
.header-ball span { display: inline-block; background: rgba(255,255,255,0.8); color: black; padding: 5px; border-radius: 10px; font-weight: bold; word-break: break-word; }
@keyframes float { from { transform: translateY(0); } to { transform: translateY(-10px); } }

/* 6. Dribble Game */
.dribble-question { text-align: center; font-size: 1.2rem; margin-top: 10px; background: rgba(0,0,0,0.5); padding: 5px; z-index: 10; position: relative; }
.dribble-player { position: absolute; bottom: 20px; left: 50%; font-size: 4rem; z-index: 10; pointer-events: none; }
.dribble-defender { position: absolute; top: 0; left: 0; background: #e53935; color: white; padding: 15px 25px; border-radius: 10px; font-weight: bold; font-size: 1.5rem; text-align: center; box-shadow: 0 4px 6px rgba(0,0,0,0.4); margin-left: -50px; }

/* 7. Referee Game */
.referee-card { background: white; color: black; margin: 40px auto; width: 80%; padding: 30px; border-radius: 15px; font-size: 1.5rem; text-align: center; font-weight: bold; box-shadow: 0 5px 15px rgba(0,0,0,0.3); }
.referee-actions { display: flex; justify-content: space-around; margin-top: 50px; }
.referee-actions button { font-size: 1.5rem; padding: 15px 30px; border-radius: 15px; cursor: pointer; border: none; font-weight: bold; box-shadow: 0 4px 6px rgba(0,0,0,0.3); }

/* 8. Throw-in Game */
.throw-question { text-align: center; font-size: 1.5rem; margin-top: 10px; font-weight: bold; z-index: 10; position: relative; }
.throw-player { position: absolute; bottom: 20px; left: 50%; font-size: 4rem; z-index: 10; pointer-events: none; margin-left: -32px; }
.throw-target { position: absolute; top: 80px; width: 30%; font-size: 0.9rem; padding: 10px; text-align: center; background: rgba(0,0,0,0.6); color: white; border-radius: 10px; word-wrap: break-word; line-height: 1.2; box-shadow: 0 4px 6px rgba(0,0,0,0.5); }
.throw-ball { position: absolute; bottom: 80px; left: 50%; font-size: 2.5rem; margin-left: -20px; z-index: 5; pointer-events: none; }

/* 9. Freekick Game */
.freekick-question { text-align: center; font-size: 1.5rem; margin-top: 10px; font-weight: bold; z-index: 10; position: relative; }
.freekick-wall { position: absolute; top: 130px; left: 50%; font-size: 3rem; background: rgba(255,255,255,0.2); border-radius: 10px; padding: 0 10px; z-index: 8; }
.freekick-player { position: absolute; bottom: 20px; font-size: 4rem; z-index: 10; pointer-events: none; }
.freekick-ball { position: absolute; bottom: 80px; left: 50%; font-size: 2.5rem; margin-left: -20px; z-index: 5; pointer-events: none; }
.freekick-target { position: absolute; top: 60px; padding: 10px 20px; background: rgba(0,0,0,0.6); color: white; border-radius: 10px; font-weight: bold; max-width: 30%; font-size: 0.9rem; text-align: center; }

/* Global Animations */
.correct-anim {
    animation: correctPulse 0.5s ease;
    background: #4caf50 !important;
    box-shadow: 0 0 30px #4caf50 !important;
    color: white !important;
}

.wrong-anim {
    animation: wrongShake 0.5s ease;
    background: #f44336 !important;
    box-shadow: 0 0 30px #f44336 !important;
    color: white !important;
}

@keyframes correctPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.5); }
    100% { transform: scale(0); opacity: 0; }
}

@keyframes wrongShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    50% { transform: translateX(10px); }
    75% { transform: translateX(-10px); }
}

.back-nav-btn {
    background: transparent;
    color: var(--secondary-color);
    border: 2px solid var(--secondary-color);
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    margin-bottom: 20px;
    grid-column: 1 / -1;
    justify-self: center;
    transition: all 0.3s;
}

.back-nav-btn:hover {
    background: var(--secondary-color);
    color: var(--text-dark);
}

@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        gap: 20px;
    }
}
