:root {
    --bg-top: #fff7e8;
    --bg-bottom: #dff3ff;
    --brand: #ff7a59;
    --brand-dark: #ec5e38;
    --brand-soft: #ffd9c9;
    --ink: #183153;
    --ink-soft: #4a6283;
    --card: rgba(255, 255, 255, 0.88);
    --line: rgba(24, 49, 83, 0.08);
    --success: #2db67c;
    --warning: #ffb84d;
    --shadow: 0 18px 45px rgba(24, 49, 83, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Nunito', sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(255, 122, 89, 0.18), transparent 30%),
        radial-gradient(circle at bottom right, rgba(45, 182, 124, 0.16), transparent 28%),
        linear-gradient(160deg, var(--bg-top), var(--bg-bottom));
    min-height: 100vh;
    padding-top: 96px;
}

h1, h2, h3, h4, .navbar-brand strong {
    font-family: 'Baloo 2', cursive;
}

a {
    text-decoration: none;
}

.site-header .navbar {
    padding: 0.75rem 0;
    background: rgba(24, 49, 83, 0.92);
    backdrop-filter: blur(12px);
    box-shadow: 0 10px 30px rgba(24, 49, 83, 0.18);
}

.header-shell,
.header-actions {
    display: flex;
    align-items: center;
}

.header-shell {
    justify-content: space-between;
    gap: 1rem;
}

.header-actions {
    gap: 0.75rem;
}

.header-menu-btn {
    display: none;
    width: 44px;
    height: 44px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.12);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 5px;
}

.header-menu-btn span {
    width: 20px;
    height: 2px;
    border-radius: 999px;
    background: #fff;
}

.brand-badge {
    width: 46px;
    height: 46px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #ffd166, #ff7a59);
    color: #132238;
    font-family: 'Baloo 2', cursive;
    font-size: 1.3rem;
    font-weight: 700;
}

.navbar-brand,
.header-action-btn {
    color: #fff;
}

.header-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 0.65rem 1rem;
    font-weight: 800;
    line-height: 1.2;
    font-size: 0.95rem;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    transition: background 0.2s ease, transform 0.2s ease;
    text-decoration: none;
}

.header-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    transform: translateY(-1px);
}

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

.mobile-header-menu {
    background:
        linear-gradient(160deg, rgba(255, 247, 232, 0.98), rgba(223, 243, 255, 0.98));
    color: var(--ink);
}

.mobile-header-menu .offcanvas-header {
    border-bottom: 1px solid rgba(24, 49, 83, 0.08);
}

.mobile-header-menu .offcanvas-body,
.mobile-game-actions {
    display: grid;
    gap: 0.75rem;
}

.mobile-header-menu .header-action-btn {
    width: 100%;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.82);
    border-color: rgba(24, 49, 83, 0.1);
}

.mobile-header-menu .header-action-btn:hover {
    color: var(--ink);
    background: #fff;
}

.hero-section {
    padding: 5rem 0 3rem;
}

.eyebrow,
.section-kicker,
.study-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.8rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    color: var(--ink);
    font-size: 0.85rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.lead,
.section-copy,
.game-card p,
.page-banner p,
.study-card p,
.table,
.game-instructions {
    color: var(--ink-soft);
}

.hero-panel,
.game-card,
.page-banner,
.study-card,
.memory-card,
.catalog-toolbar,
.game-toolbar,
.instruction-modal {
    background: var(--card);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    border-radius: 28px;
}

.hero-panel,
.page-banner,
.study-card {
    padding: 1.75rem;
}

.hero-panel {
    position: relative;
    overflow: hidden;
}

.hero-panel::after {
    content: "";
    position: absolute;
    inset: auto -30px -30px auto;
    width: 120px;
    height: 120px;
    border-radius: 28px;
    background: linear-gradient(135deg, rgba(255, 122, 89, 0.25), rgba(255, 209, 102, 0.45));
    transform: rotate(18deg);
}

.btn-primary,
.btn-card {
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    border: none;
    color: #fff;
    border-radius: 16px;
    padding: 0.8rem 1.2rem;
    font-weight: 800;
    box-shadow: 0 12px 24px rgba(255, 122, 89, 0.25);
}

.btn-primary:hover,
.btn-card:hover {
    color: #fff;
    transform: translateY(-1px);
}

.btn-outline-light,
.btn-outline-primary {
    border-radius: 16px;
    font-weight: 800;
}

.section-title {
    font-size: clamp(2rem, 4vw, 2.8rem);
}

.game-card {
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
}

.game-card::before {
    content: "";
    position: absolute;
    inset: auto -20px -20px auto;
    width: 90px;
    height: 90px;
    background: rgba(255, 209, 102, 0.25);
    border-radius: 24px;
    transform: rotate(20deg);
}

.game-status {
    display: inline-block;
    padding: 0.35rem 0.8rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 800;
}

.status-live {
    background: rgba(45, 182, 124, 0.16);
    color: var(--success);
}

.status-soon {
    background: rgba(255, 184, 77, 0.2);
    color: #a55a00;
}

.game-category {
    display: inline-flex;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    background: rgba(24, 49, 83, 0.08);
    color: var(--ink);
    font-size: 0.8rem;
    font-weight: 800;
}

.catalog-toolbar {
    padding: 1.25rem;
}

.form-control,
.form-select {
    border-radius: 16px;
    border-color: rgba(24, 49, 83, 0.12);
    padding: 0.85rem 1rem;
}

.form-control:focus,
.form-select:focus {
    border-color: rgba(255, 122, 89, 0.6);
    box-shadow: 0 0 0 0.2rem rgba(255, 122, 89, 0.18);
}

.filter-feedback {
    color: var(--ink-soft);
    font-weight: 700;
}

.page-banner {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.95), rgba(255, 244, 223, 0.92));
}

.game-shell {
    max-width: 1120px;
    margin: 0 auto;
}

.memory-game-shell {
    max-width: min(1560px, calc(100vw - 32px));
}

.game-play-shell {
    max-width: 680px;
    margin: 0 auto;
}

.game-panel {
    max-width: 760px;
    margin: 0 auto;
}

.game-instructions {
    margin: 1.25rem 0 0;
    padding-left: 1.25rem;
}

.game-instructions li + li {
    margin-top: 0.6rem;
}

.game-play {
    animation: fadeUp 0.28s ease;
}

.flashcard-stage,
.memory-grid-wrap,
.score-card {
    padding: 1.5rem;
}

.game-toolbar {
    padding: 1rem 1.25rem;
}

.flashcard {
    position: relative;
    min-height: 280px;
    transform-style: preserve-3d;
    transition: transform 0.6s ease;
    cursor: pointer;
}

.flashcard.is-flipped {
    transform: rotateY(180deg);
}

.flashcard-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    border-radius: 24px;
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.flashcard-front {
    background: linear-gradient(140deg, #ffffff, #fff0e8);
}

.flashcard-back {
    background: linear-gradient(140deg, #183153, #28527a);
    color: #fff;
    transform: rotateY(180deg);
}

.flashcard-label {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.8rem;
    font-weight: 800;
    opacity: 0.75;
}

.memory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(var(--memory-card-min, 130px), 1fr));
    gap: var(--memory-grid-gap, 1rem);
}

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

.memory-board-column {
    min-width: 0;
}

.memory-setup-grid,
.player-names-grid {
    display: grid;
    gap: 1rem;
}

.memory-setup-grid {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.player-names-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.setup-card {
    padding: 1.2rem;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(24, 49, 83, 0.08);
    border-radius: 22px;
}

.setup-help {
    color: var(--ink-soft);
    font-size: 0.95rem;
}

.memory-warning {
    padding: 1rem 1.1rem;
    border-radius: 18px;
    background: rgba(255, 184, 77, 0.22);
    color: #8a4f00;
    font-weight: 700;
}

.memory-grid-wrap {
    background: var(--card);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    border-radius: 28px;
    --memory-card-min: 140px;
    --memory-grid-gap: 0.9rem;
}

.memory-grid-wrap.board-size-small {
    --memory-card-min: 150px;
    --memory-grid-gap: 1rem;
}

.memory-grid-wrap.board-size-medium {
    --memory-card-min: 125px;
    --memory-grid-gap: 0.85rem;
}

.memory-grid-wrap.board-size-large {
    --memory-card-min: 105px;
    --memory-grid-gap: 0.7rem;
}

.memory-grid-wrap.board-size-xl {
    --memory-card-min: 88px;
    --memory-grid-gap: 0.55rem;
}

.memory-card {
    min-height: 0;
    aspect-ratio: 1.08 / 1;
    padding: clamp(0.45rem, 1vw, 1rem);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: pointer;
    font-weight: 800;
    color: var(--ink);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.memory-card:hover {
    transform: translateY(-4px);
}

.memory-card.is-open {
    background: linear-gradient(135deg, #fff3d1, #ffffff);
}

.memory-card.is-matched {
    background: linear-gradient(135deg, rgba(45, 182, 124, 0.22), rgba(255, 255, 255, 0.95));
    color: #0d6b45;
    cursor: default;
}

.memory-card-cover {
    background: linear-gradient(145deg, rgba(24, 49, 83, 0.96), rgba(40, 82, 122, 0.95));
    color: #fff;
}

.memory-card-backmark {
    font-size: clamp(1.4rem, 2.4vw, 2rem);
    font-family: 'Baloo 2', cursive;
}

.memory-card-media {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 18px;
    overflow: hidden;
    background: linear-gradient(145deg, rgba(255, 122, 89, 0.14), rgba(223, 243, 255, 0.95));
    display: flex;
    align-items: center;
    justify-content: center;
}

.memory-card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.memory-card-placeholder {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 18px;
    background: linear-gradient(145deg, rgba(255, 122, 89, 0.12), rgba(255, 209, 102, 0.24));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    color: var(--ink);
}

.memory-placeholder-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.72);
    font-size: 0.95rem;
}

.memory-card-caption,
.memory-card-verb {
    margin-top: 0.75rem;
}

.memory-card-verb {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: clamp(0.78rem, 0.95vw, 0.95rem);
    line-height: 1.15;
    max-width: 100%;
    overflow-wrap: anywhere;
}

.memory-card-verb strong {
    font-size: clamp(0.9rem, 1.15vw, 1.1rem);
    color: var(--ink);
}

.memory-grid-large {
    grid-template-columns: repeat(auto-fit, minmax(var(--memory-card-min, 130px), 1fr));
}

.memory-score-panel {
    position: sticky;
    top: 116px;
}

.memory-turn {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--ink);
}

.memory-score-label {
    font-weight: 800;
    color: var(--ink);
}

.scoreboard-list,
.results-list {
    display: grid;
    gap: 0.75rem;
}

.scoreboard-item,
.result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem;
    border-radius: 16px;
    background: rgba(24, 49, 83, 0.06);
    color: var(--ink);
}

.scoreboard-item.is-current {
    background: rgba(255, 122, 89, 0.18);
}

.game-finished-panel {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid rgba(24, 49, 83, 0.08);
}

.site-footer {
    background: rgba(24, 49, 83, 0.92);
    color: #fff;
}

body.is-playing .site-footer {
    display: none;
}

.instruction-modal .modal-header,
.instruction-modal .modal-body {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}

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

@media (max-width: 991.98px) {
    .header-shell,
    .header-actions {
        flex-wrap: wrap;
    }

    .hero-section {
        padding-top: 3rem;
    }

    .flashcard {
        min-height: 240px;
    }

    .memory-score-panel {
        position: static;
    }

    .memory-game-shell {
        max-width: min(100%, calc(100vw - 24px));
    }

    .memory-game-layout {
        grid-template-columns: 1fr;
    }

    .memory-grid-wrap.board-size-small {
        --memory-card-min: 135px;
    }

    .memory-grid-wrap.board-size-medium,
    .memory-grid-wrap.board-size-large,
    .memory-grid-wrap.board-size-xl {
        --memory-card-min: 108px;
        --memory-grid-gap: 0.7rem;
    }
}

@media (max-width: 767.98px) {
    body {
        padding-top: 78px;
    }

    .site-header .navbar {
        padding: 0.55rem 0;
    }

    .brand-badge {
        width: 42px;
        height: 42px;
        border-radius: 14px;
    }

    .navbar-brand {
        min-width: 0;
    }

    .navbar-brand small {
        display: none !important;
    }

    .header-actions {
        display: none;
    }

    .header-menu-btn {
        display: inline-flex;
    }

    .memory-game-shell {
        max-width: 100%;
    }

    .memory-game-layout {
        gap: 0.85rem;
    }

    .memory-score-panel {
        padding: 0.85rem;
    }

    .memory-turn {
        margin-bottom: 0.6rem !important;
        font-size: 0.95rem;
    }

    .single-player-stats p,
    .memory-score-label {
        font-size: 0.92rem;
    }

    .scoreboard-list,
    .results-list {
        gap: 0.45rem;
    }

    .scoreboard-item,
    .result-row {
        padding: 0.55rem 0.7rem;
        border-radius: 12px;
        font-size: 0.9rem;
    }

    .memory-grid-wrap {
        padding: 0.65rem;
        --memory-grid-gap: 0.5rem;
    }

    .memory-grid-wrap.board-size-small {
        --memory-card-min: 92px;
    }

    .memory-grid-wrap.board-size-medium {
        --memory-card-min: 78px;
        --memory-grid-gap: 0.45rem;
    }

    .memory-grid-wrap.board-size-large,
    .memory-grid-wrap.board-size-xl {
        --memory-card-min: 66px;
        --memory-grid-gap: 0.38rem;
    }

    .memory-card {
        padding: 0.38rem;
        aspect-ratio: 1 / 0.92;
    }

    .memory-card-verb {
        font-size: 0.72rem;
    }

    .memory-card-verb strong {
        font-size: 0.82rem;
    }
}

@media (max-width: 575.98px) {
    body {
        padding-top: 76px;
    }

    main.pb-5 {
        padding-bottom: 1.5rem !important;
    }

    .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .hero-panel,
    .page-banner,
    .study-card,
    .game-card,
    .catalog-toolbar,
    .game-toolbar,
    .instruction-modal,
    .memory-grid-wrap {
        border-radius: 22px;
    }

    .memory-grid {
        grid-template-columns: repeat(auto-fit, minmax(var(--memory-card-min, 96px), 1fr));
    }

    .game-header-actions {
        width: 100%;
    }

    .memory-grid-wrap {
        padding: 0.5rem;
    }

    .memory-grid-wrap.board-size-small {
        --memory-card-min: 86px;
        --memory-grid-gap: 0.45rem;
    }

    .memory-grid-wrap.board-size-medium {
        --memory-card-min: 72px;
        --memory-grid-gap: 0.38rem;
    }

    .memory-grid-wrap.board-size-large,
    .memory-grid-wrap.board-size-xl {
        --memory-card-min: 58px;
        --memory-grid-gap: 0.32rem;
    }
}

@media (max-width: 390px) {
    .memory-grid-wrap.board-size-small {
        --memory-card-min: 78px;
    }

    .memory-grid-wrap.board-size-medium {
        --memory-card-min: 64px;
    }

    .memory-grid-wrap.board-size-large,
    .memory-grid-wrap.board-size-xl {
        --memory-card-min: 52px;
    }

    .memory-card-verb {
        font-size: 0.66rem;
    }

    .memory-card-verb strong {
        font-size: 0.75rem;
    }
}
