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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Comic Sans MS', 'Chalkboard SE', sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    overflow-x: hidden;
}

.container {
    background: white;
    border-radius: 30px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    overflow: hidden;
}

/* Header */
.header {
    background: linear-gradient(135deg, #b8860b 0%, #8b4513 100%);
    padding: 30px;
    text-align: center;
    color: white;
}

.header h1 {
    font-size: 3em;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
    margin-bottom: 10px;
}

.header p {
    font-size: 1.2em;
    opacity: 0.9;
}

/* Score Board */
.score-board {
    background: linear-gradient(135deg, #fff3cd 0%, #ffe8a1 100%);
    padding: 15px 20px;
    text-align: center;
    font-size: 1.1em;
    font-weight: bold;
    color: #856404;
    border-bottom: 3px solid #ffc107;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Topic Selector */
.topic-selector {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    padding: 16px 20px;
    text-align: center;
    border-bottom: 3px solid #0f3460;
}

.topic-label {
    color: #a0aec0;
    font-size: 0.85em;
    margin-bottom: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.topic-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.topic-btn {
    background: rgba(255,255,255,0.08);
    color: #cbd5e0;
    border: 2px solid rgba(255,255,255,0.15);
    padding: 10px 18px;
    border-radius: 30px;
    font-size: 0.9em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
}

.topic-btn:hover {
    background: rgba(255,255,255,0.18);
    color: white;
    transform: translateY(-2px);
}

.topic-btn.active {
    background: linear-gradient(135deg, #b8860b 0%, #8b4513 100%);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 15px rgba(139, 69, 19, 0.5);
    transform: translateY(-2px);
}

/* Match word cards — smaller font for multi-word entries */
.match-word-card {
    font-size: 1em !important;
    word-break: break-word;
    hyphens: auto;
    line-height: 1.3;
    padding: 18px 10px !important;
}

/* Quiz visual image container */
.quiz-image {
    margin: 0 auto 10px;
    max-width: 600px;
    overflow-x: auto;
}

/* Glossary label under words */
.card-explica {
    display: block;
    font-size: 0.62em;
    color: #8b4513;
    font-weight: normal;
    margin-top: 4px;
    font-style: italic;
}

/* Tabs */
.tabs {
    display: flex;
    flex-wrap: wrap;
    background: #f8f9fa;
    border-bottom: 3px solid #dee2e6;
}

.tab {
    flex: 1;
    min-width: 100px;
    padding: 16px 10px;
    text-align: center;
    cursor: pointer;
    background: #e9ecef;
    border: none;
    font-size: 1em;
    font-weight: bold;
    transition: all 0.3s;
    color: #495057;
}

.tab:hover {
    background: #dee2e6;
}

.tab.active {
    background: white;
    color: #8b4513;
    border-bottom: 4px solid #b8860b;
}

.tab[hidden] {
    display: none !important;
}

/* Game Container */
.game-container {
    padding: 40px;
    min-height: 500px;
}

.game-section {
    display: none;
}

.game-section.active {
    display: block;
    animation: fadeIn 0.5s;
}

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

/* Instructions */
.instructions {
    background: #e7f3ff;
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 25px;
    border-left: 5px solid #2196F3;
}

.instructions h3 {
    color: #1976D2;
    margin-bottom: 10px;
}

.emoji-icon {
    font-size: 1.5em;
    margin-right: 10px;
}

/* Match Game */
.match-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.match-card {
    background: linear-gradient(135deg, #f6d365 0%, #fda085 100%);
    padding: 25px;
    border-radius: 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    border: 3px solid transparent;
    font-size: 1.2em;
    font-weight: bold;
}

/* Emoji cards need a much bigger glyph than word cards so the icon is
   actually legible/distinguishable — small emoji at ~19px are hard to
   tell apart on a phone (e.g. 🐎 vs other icons). */
.match-card[data-type="emoji"] {
    font-size: 2.6em;
    line-height: 1;
    display: flex;
    justify-content: center;
}

/* A light circular backdrop behind every emoji so it stands out from the
   card's own orange gradient — emoji glyphs are full-colour images, not
   styleable text, so a CSS gradient can't tint them; a contrasting badge
   is what actually makes a same-hue icon (e.g. 🐎 on orange) legible. */
.emoji-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5em;
    height: 1.5em;
    border-radius: 50%;
    background: linear-gradient(135deg, #fffdf5 0%, #ffe8c2 100%);
    box-shadow: 0 3px 8px rgba(0,0,0,0.25), inset 0 0 0 2px rgba(139,69,19,0.15);
}

/* Country silhouette icons (Portugal, Espanha) — real map outlines from
   local SVG assets, sized to fit inside the emoji-badge circle. */
.country-icon {
    width: 68%;
    height: 68%;
    object-fit: contain;
}

.match-card:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.match-card.selected {
    border-color: #8b4513;
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    transform: scale(1.08);
}

.match-card.correct {
    background: linear-gradient(135deg, #84fab0 0%, #8fd3f4 100%);
    border-color: #28a745;
    animation: bounce 0.6s;
}

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

/* Quiz Game */
.quiz-question {
    background: linear-gradient(135deg, #cfd9df 0%, #e2ebf0 100%);
    padding: 30px;
    border-radius: 20px;
    margin-bottom: 20px;
    font-size: 1.4em;
    font-weight: bold;
    text-align: center;
    color: #2c3e50;
}

.quiz-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-top: 20px;
}

.quiz-option {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    padding: 25px;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
    font-size: 1.15em;
    font-weight: bold;
    border: 3px solid transparent;
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

.quiz-option:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.quiz-option.correct {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    animation: pulse 0.5s;
}

.quiz-option.wrong {
    background: linear-gradient(135deg, #eb3349 0%, #f45c43 100%);
    animation: shake 0.5s;
}

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

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

/* Unscramble Game */
.unscramble-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 25px;
    margin-top: 30px;
}

.unscramble-item {
    background: linear-gradient(135deg, #f6d365 0%, #fda085 100%);
    padding: 25px;
    border-radius: 15px;
    text-align: center;
}

.scrambled-word {
    font-size: 1.8em;
    font-weight: bold;
    color: #8b4513;
    margin-bottom: 15px;
    letter-spacing: 3px;
}

.unscramble-input {
    width: 100%;
    padding: 15px;
    font-size: 1.3em;
    border: 3px solid #dee2e6;
    border-radius: 10px;
    text-align: center;
    font-weight: bold;
}

.unscramble-input.correct {
    border-color: #28a745;
    background: #d4edda;
}

.unscramble-input.wrong {
    border-color: #dc3545;
    background: #f8d7da;
}

/* Complete Sentence Game */
.complete-exercise {
    background: linear-gradient(135deg, #e0c3fc 0%, #8ec5fc 100%);
    padding: 30px;
    border-radius: 20px;
    margin-bottom: 25px;
}

.complete-sentence {
    font-size: 1.3em;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 20px;
    line-height: 1.8;
}

.complete-blank {
    display: inline-block;
    min-width: 150px;
    padding: 5px 15px;
    margin: 0 5px;
    background: white;
    border: 3px dashed #2a5298;
    border-radius: 8px;
    font-weight: bold;
    color: #2a5298;
    cursor: pointer;
    transition: all 0.3s;
}

.complete-blank:hover {
    background: #f0f0f0;
    transform: scale(1.05);
}

.complete-blank.filled {
    background: #e7f3ff;
    border: 3px solid #2196F3;
    color: #1976D2;
}

.complete-blank.correct {
    background: #d4edda;
    border: 3px solid #28a745;
    color: #155724;
}

.complete-blank.wrong {
    background: #f8d7da;
    border: 3px solid #dc3545;
    color: #721c24;
    animation: shake 0.5s;
}

.word-bank {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin-top: 25px;
    padding: 20px;
    background: rgba(255,255,255,0.3);
    border-radius: 15px;
}

.word-option {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    padding: 12px 25px;
    border-radius: 25px;
    font-weight: bold;
    font-size: 1.05em;
    cursor: pointer;
    transition: all 0.3s;
    border: 3px solid transparent;
}

.word-option:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.3);
}

.word-option.selected {
    background: linear-gradient(135deg, #b8860b 0%, #8b4513 100%);
    transform: scale(1.1);
}

.word-option.used {
    opacity: 0.3;
    pointer-events: none;
}

.check-answer-btn {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.3em;
    font-weight: bold;
    border-radius: 25px;
    cursor: pointer;
    margin-top: 20px;
    transition: all 0.3s;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.check-answer-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}

.check-answer-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Timeline Game */
.timeline-track {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
}

.timeline-slot {
    display: flex;
    align-items: center;
    gap: 15px;
    min-height: 70px;
    background: rgba(255,255,255,0.4);
    border: 3px dashed #2a5298;
    border-radius: 12px;
    padding: 10px 20px;
    transition: all 0.3s;
}

.timeline-slot.filled {
    border-style: solid;
}

.timeline-slot-number {
    font-weight: bold;
    color: #2a5298;
    font-size: 1.2em;
    min-width: 30px;
}

.timeline-pool {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin-top: 25px;
    padding: 20px;
    background: rgba(255,255,255,0.3);
    border-radius: 15px;
}

.timeline-card {
    background: linear-gradient(135deg, #b8860b 0%, #8b4513 100%);
    color: white;
    padding: 14px 20px;
    border-radius: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
    border: 3px solid transparent;
    max-width: 220px;
}

.timeline-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.3);
}

.timeline-card.selected {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    transform: scale(1.08);
}

.timeline-card.used {
    opacity: 0.25;
    pointer-events: none;
}

.timeline-year-tag {
    display: inline-block;
    font-size: 0.7em;
    opacity: 0.85;
    margin-top: 4px;
}

.timeline-ruler {
    display: flex;
    justify-content: space-between;
    background: linear-gradient(90deg, #cfd9df 0%, #e2ebf0 100%);
    border-radius: 10px;
    padding: 10px 20px;
    margin-bottom: 20px;
    font-size: 0.85em;
    color: #2c3e50;
    font-weight: bold;
}

/* Map Label Game */
.maplabel-wrap {
    text-align: center;
}

.maplabel-image {
    max-width: 600px;
    margin: 0 auto 25px;
}

.maplabel-pool {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin-bottom: 25px;
}

.maplabel-term {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    padding: 12px 22px;
    border-radius: 25px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    border: 3px solid transparent;
}

.maplabel-term:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.3);
}

.maplabel-term.selected {
    background: linear-gradient(135deg, #b8860b 0%, #8b4513 100%);
    transform: scale(1.1);
}

.maplabel-term.used {
    opacity: 0.3;
    pointer-events: none;
}

.maplabel-definitions {
    display: grid;
    gap: 15px;
}

.maplabel-def-row {
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(255,255,255,0.5);
    border-radius: 12px;
    padding: 14px 20px;
    text-align: left;
}

.maplabel-def-text {
    flex: 1;
    color: #2c3e50;
}

.maplabel-answer-slot {
    min-width: 130px;
    padding: 8px 16px;
    background: white;
    border: 3px dashed #2a5298;
    border-radius: 8px;
    font-weight: bold;
    color: #2a5298;
    text-align: center;
    cursor: pointer;
}

.maplabel-answer-slot.filled {
    border-style: solid;
    background: #e7f3ff;
    color: #1976D2;
}

.maplabel-answer-slot.correct {
    background: #d4edda;
    border-color: #28a745;
    color: #155724;
}

.maplabel-answer-slot.wrong {
    background: #f8d7da;
    border-color: #dc3545;
    color: #721c24;
    animation: shake 0.5s;
}

/* Progress Bar */
.progress-bar-container {
    background: #e9ecef;
    border-radius: 20px;
    height: 14px;
    margin: 10px 0 5px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    border-radius: 20px;
    transition: width 0.4s ease;
}

.progress-label {
    text-align: center;
    font-size: 0.95em;
    color: #6c757d;
    margin-bottom: 15px;
}

/* Feedback Modal */
.feedback {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: white;
    padding: 50px;
    border-radius: 30px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    text-align: center;
    z-index: 1000;
    transition: all 0.3s;
}

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

.feedback-emoji {
    font-size: 5em;
    margin-bottom: 20px;
}

.feedback-text {
    font-size: 2em;
    font-weight: bold;
    color: #2c3e50;
}

/* Buttons */
.btn {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.2em;
    font-weight: bold;
    border-radius: 25px;
    cursor: pointer;
    margin: 10px;
    transition: all 0.3s;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
}

.btn-hint {
    background: linear-gradient(135deg, #FFA500 0%, #FF8C00 100%);
    font-size: 1em;
    padding: 10px 25px;
}

.hint-box {
    display: none;
    margin-top: 15px;
    padding: 15px;
    background: #fff3cd;
    border-radius: 10px;
    font-size: 1.15em;
    color: #856404;
}

/* Responsive Design */

/* Tablets and small laptops */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .container {
        border-radius: 18px;
    }

    .header {
        padding: 20px 15px;
    }

    .header h1 {
        font-size: 1.8em;
        line-height: 1.3;
    }

    .header p {
        font-size: 1em;
    }

    .score-board {
        padding: 12px 10px;
        font-size: 0.95em;
    }

    .score-board > div {
        gap: 14px 20px !important;
    }

    .topic-selector {
        padding: 12px 10px;
    }

    .topic-btn {
        padding: 8px 14px;
        font-size: 0.85em;
    }

    .match-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .quiz-options {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .quiz-question {
        font-size: 1.15em;
        padding: 20px;
    }

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

    .tabs {
        flex-wrap: wrap;
    }

    .tab {
        font-size: 0.8em;
        padding: 12px 6px;
        min-width: 90px;
    }

    .game-container {
        padding: 18px;
        min-height: unset;
    }

    .complete-exercise {
        padding: 18px;
    }

    .complete-sentence {
        font-size: 1.1em;
    }

    .complete-blank {
        min-width: 110px;
        display: inline-block;
        margin: 3px;
    }

    .maplabel-def-row {
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }

    .timeline-slot {
        flex-wrap: wrap;
        gap: 6px;
        padding: 10px 14px;
    }

    .feedback {
        padding: 30px 25px;
        width: 85%;
        max-width: 320px;
    }

    .feedback-emoji {
        font-size: 3.5em;
    }

    .feedback-text {
        font-size: 1.4em;
    }
}

/* Small phones */
@media (max-width: 420px) {
    .header h1 {
        font-size: 1.4em;
    }

    .header p {
        font-size: 0.85em;
    }

    .score-board {
        font-size: 0.8em;
    }

    .score-board span[style*="font-size: 1.8em"] {
        font-size: 1.3em !important;
    }

    .topic-btn {
        padding: 7px 12px;
        font-size: 0.78em;
    }

    .tab {
        min-width: 72px;
        font-size: 0.7em;
        padding: 10px 4px;
    }

    .match-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .match-card {
        padding: 16px 8px;
        font-size: 1em;
    }

    .match-card[data-type="emoji"] {
        font-size: 2.2em;
    }

    .quiz-option {
        padding: 18px 14px;
        font-size: 1em;
    }

    .word-bank,
    .timeline-pool,
    .maplabel-pool {
        gap: 8px;
        padding: 14px;
    }

    .word-option,
    .timeline-card,
    .maplabel-term {
        padding: 9px 16px;
        font-size: 0.9em;
    }

    .btn {
        padding: 12px 24px;
        font-size: 1em;
    }
}

/* Large desktop screens */
@media (min-width: 1400px) {
    .container {
        max-width: 1100px;
    }

    .header h1 {
        font-size: 3.4em;
    }
}
