/* Games Hub — mola backgrounds + card/piece polish */

.games-hub,
.games-hub-active,
.hub-module.games-mola-shell {
    position: relative;
    overflow: hidden;
    background-color: #f8faf6;
    background-image:
        linear-gradient(160deg, rgba(255, 255, 255, 0.88) 0%, rgba(240, 250, 244, 0.78) 55%, rgba(255, 255, 255, 0.85) 100%),
        url("../../Multimedia/Images/Molas - Guna/mola-bg-pattern.jpg");
    background-size: cover, cover;
    background-position: center;
    border: 1px solid rgba(17, 128, 43, 0.14);
}

body.dark-mode .games-hub,
body.dark-mode .games-hub-active,
body.dark-mode .hub-module.games-mola-shell,
html[data-theme="dark"] .games-hub,
html[data-theme="dark"] .games-hub-active,
html[data-theme="dark"] .hub-module.games-mola-shell {
    background-image:
        linear-gradient(160deg, rgba(13, 26, 18, 0.9) 0%, rgba(18, 38, 26, 0.84) 100%),
        url("../../Multimedia/Images/Molas - Guna/mola-bg-pattern.jpg");
    color: #F3FBF5;
}

.game-hub-card {
    position: relative;
    overflow: hidden;
    background:
        linear-gradient(160deg, rgba(255, 255, 255, 0.94) 0%, rgba(255, 254, 249, 0.9) 100%),
        url("../../Multimedia/Images/Molas - Guna/mola-bg-pattern.jpg");
    background-size: cover, 220px auto;
    background-position: center;
    border: 2px solid transparent;
    border-image: repeating-linear-gradient(
        90deg,
        #c00000 0,
        #c00000 10px,
        #e3a008 10px,
        #e3a008 20px,
        #11802b 20px,
        #11802b 30px
    ) 1;
    box-shadow: 0 12px 28px rgba(61, 31, 10, 0.1);
}

.game-hub-card::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.12;
    background:
        radial-gradient(circle at 20% 20%, #e3a008, transparent 40%),
        radial-gradient(circle at 80% 80%, #c00000, transparent 42%);
}

body.dark-mode .game-hub-card,
html[data-theme="dark"] .game-hub-card {
    background:
        linear-gradient(160deg, rgba(18, 38, 26, 0.94) 0%, rgba(13, 26, 18, 0.9) 100%),
        url("../../Multimedia/Images/Molas - Guna/mola-bg-pattern.jpg");
    color: #F3FBF5;
}

/* Memory cards — fix tiny images + stronger mola backs */
.memory-grid-modern .memory-card-modern {
    min-height: 120px;
    aspect-ratio: 3 / 4;
}

.memory-grid-modern .memory-card-modern .card-image {
    width: min(72%, 88px) !important;
    height: auto !important;
    max-height: 48% !important;
    object-fit: contain !important;
    border-radius: 10px;
    margin-bottom: 0.35rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.memory-grid-modern .memory-card-modern .card-front.guna-card-back {
    background:
        linear-gradient(145deg, rgba(139, 21, 48, 0.55) 0%, rgba(196, 30, 58, 0.4) 40%, rgba(212, 98, 42, 0.35) 100%),
        url("../../Multimedia/Images/Molas - Guna/mola-bg-pattern.jpg") center/cover !important;
}

.memory-grid-modern .memory-card-modern .card-back {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.55rem;
    gap: 0.2rem;
}

.memory-grid-modern .card-image.is-broken {
    display: none !important;
}

.memory-grid-modern .card-image:not(.is-broken) + .card-fallback {
    display: none;
}

.memory-grid-modern .card-fallback {
    font-size: 1.8rem;
    line-height: 1;
}

.card-front-mola-mark {
    position: relative;
    z-index: 2;
    width: 52%;
    max-width: 64px;
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(255, 248, 225, 0.92);
    border: 2px solid #1a1a1a;
    color: #c00000;
    font-size: 1.4rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.puzzle-piece.selected {
    outline: 3px solid #e3a008;
    outline-offset: 2px;
}

.memory-grid-modern .card-word {
    font-size: 0.95rem;
    font-weight: 800;
    text-align: center;
    line-height: 1.2;
}

.memory-grid-modern .card-language {
    font-size: 0.68rem;
    opacity: 0.75;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Mola puzzle board */
.mola-puzzle-game {
    display: block;
}

.mola-puzzle-layout {
    display: grid;
    grid-template-columns: minmax(180px, 220px) minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
}

.mola-puzzle-preview {
    border-radius: 1rem;
    overflow: hidden;
    border: 3px solid #e3a008;
    box-shadow: 0 12px 28px rgba(61, 31, 10, 0.14);
    background: #12261a;
}

.mola-puzzle-preview img {
    display: block;
    width: 100%;
    height: auto;
    object-fit: cover;
}

.mola-puzzle-preview figcaption {
    padding: 0.65rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 700;
    background: rgba(18, 38, 26, 0.92);
    color: #F3FBF5;
}

.puzzle-area.mola-puzzle-area {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.puzzle-board.mola-board {
    width: min(100%, 420px);
    aspect-ratio: 1;
    margin: 0 auto;
    display: grid;
    gap: 3px;
    padding: 6px;
    border-radius: 1rem;
    background:
        linear-gradient(145deg, rgba(12, 92, 31, 0.85), rgba(61, 31, 10, 0.8)),
        url("../../Multimedia/Images/Molas - Guna/mola-bg-pattern.jpg") center/cover;
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.2);
}

.puzzle-board.mola-board .puzzle-slot {
    background: rgba(255, 255, 255, 0.12);
    border: 1px dashed rgba(255, 255, 255, 0.28);
    border-radius: 6px;
    min-height: 0;
    position: relative;
}

.puzzle-board.mola-board .puzzle-slot.filled {
    border-style: solid;
    border-color: rgba(227, 160, 8, 0.55);
}

.puzzle-board.mola-board .puzzle-piece,
.pieces-container.mola-pieces .puzzle-piece {
    width: 100%;
    height: 100%;
    min-height: 64px;
    border-radius: 6px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    cursor: grab;
    background-repeat: no-repeat;
}

.pieces-container.mola-pieces {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 0.55rem;
    width: min(100%, 420px);
    margin: 0 auto;
    min-height: 90px;
    padding: 0.75rem;
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(17, 128, 43, 0.15);
}

.pieces-container.mola-pieces .puzzle-piece {
    aspect-ratio: 1;
    min-height: 72px;
}

.puzzle-piece.dragging {
    opacity: 0.55;
    transform: scale(1.03);
}

.mola-puzzle-tip {
    margin: 0 0 1rem;
    padding: 0.85rem 1rem;
    border-radius: 0.9rem;
    background: rgba(255, 255, 255, 0.86);
    border-left: 4px solid #e3a008;
    font-style: italic;
}

body.dark-mode .mola-puzzle-tip,
body.dark-mode .pieces-container.mola-pieces,
html[data-theme="dark"] .mola-puzzle-tip,
html[data-theme="dark"] .pieces-container.mola-pieces {
    background: rgba(18, 38, 26, 0.9);
    color: #F3FBF5;
    border-color: #163222;
}

@media (max-width: 800px) {
    .mola-puzzle-layout {
        grid-template-columns: 1fr;
    }

    .mola-puzzle-preview {
        max-width: 220px;
        margin: 0 auto;
    }
}

/* Lesson activity paging */
.interactive-section[data-paged="true"] .lesson-activity-screen,
.conversation-section[data-paged="true"] .lesson-activity-screen {
    display: none;
    animation: activityFadeIn 0.28s ease;
}

.interactive-section[data-paged="true"] .lesson-activity-screen.active,
.conversation-section[data-paged="true"] .lesson-activity-screen.active {
    display: block !important;
}

.lesson-activity-screen[data-kind="results"].active .quiz-results {
    display: block !important;
}

.activity-progress-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.7rem 1rem;
    border-radius: 999px;
    background: rgba(17, 128, 43, 0.08);
    border: 1px solid rgba(17, 128, 43, 0.16);
    font-weight: 800;
    color: #0c5c1f;
}

.activity-nav {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px dashed rgba(227, 160, 8, 0.4);
}

.activity-nav button {
    border: none;
    border-radius: 12px;
    padding: 0.75rem 1.15rem;
    font-weight: 800;
    cursor: pointer;
    background: linear-gradient(180deg, #89e219, #58cc02);
    color: #fff;
    box-shadow: 0 4px 0 #46a302;
}

.activity-nav button:disabled {
    background: #cfcfcf;
    box-shadow: 0 4px 0 #b0b0b0;
    cursor: not-allowed;
}

.activity-nav button.secondary {
    background: #fff;
    color: #0c5c1f;
    border: 2px solid rgba(17, 128, 43, 0.25);
    box-shadow: none;
}

@keyframes activityFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

body.dark-mode .activity-progress-bar,
html[data-theme="dark"] .activity-progress-bar {
    background: rgba(88, 204, 2, 0.12);
    color: #b7f06a;
    border-color: #163222;
}
