.games-page {
    --games-bg: #F8FAFC;
    --games-surface: rgba(255, 255, 255, 0.88);
    --games-surface-strong: rgba(255, 255, 255, 0.97);
    --games-border: rgba(15, 23, 42, 0.10);
    --games-border-strong: rgba(34, 197, 94, 0.34);
    --games-text: #0F172A;
    --games-muted: #475569;
    --games-shadow: 0 18px 55px rgba(15, 23, 42, 0.09);
    --games-shadow-small: 0 10px 28px rgba(15, 23, 42, 0.07);
    min-height: 100vh;
    background:
        radial-gradient(circle at 10% 0%, rgba(34, 197, 94, 0.18), transparent 28rem),
        radial-gradient(circle at 90% 8%, rgba(239, 68, 68, 0.11), transparent 26rem),
        radial-gradient(circle at 50% 100%, rgba(37, 99, 235, 0.10), transparent 30rem),
        linear-gradient(180deg, #F8FAFC 0%, #EFF6FF 48%, #F8FAFC 100%);
    color: var(--games-text);
}

.games-shell {
    width: min(1180px, calc(100% - 28px));
    margin: 0 auto;
}

.games-topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    border-bottom: 1px solid var(--games-border);
    background: rgba(255, 255, 255, .82);
    backdrop-filter: blur(18px);
}

.games-nav {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.games-brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--games-text);
    font-weight: 900;
    text-decoration: none;
}

.games-back,
.games-icon-btn,
.games-pill,
.games-btn,
.games-ghost-btn {
    border: 1px solid var(--games-border);
    background: rgba(255, 255, 255, .86);
    color: var(--games-text);
    box-shadow: var(--games-shadow-small);
    transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease, background .2s ease;
}

.games-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 16px;
    border-radius: 14px;
    font-weight: 800;
    text-decoration: none;
}

.games-back:hover,
.games-icon-btn:hover,
.games-pill:hover,
.games-btn:hover,
.games-ghost-btn:hover {
    transform: translateY(-1px);
    border-color: var(--games-border-strong);
    box-shadow: var(--games-shadow);
}

.games-logo {
    width: 42px;
    height: 42px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    font-weight: 900;
    background: linear-gradient(135deg, rgba(16, 185, 129, .16), rgba(251, 146, 60, .18));
    border: 1px solid rgba(16, 185, 129, .24);
    color: #065f46;
}

.games-hero {
    padding: 38px 0 18px;
}

.games-hero-card,
.games-panel,
.game-stage,
.game-start,
.game-over-panel {
    border: 1px solid var(--games-border);
    border-radius: 1.5rem;
    background: var(--games-surface);
    box-shadow: var(--games-shadow);
}

.games-hero-card {
    padding: clamp(22px, 4vw, 46px);
    overflow: hidden;
}

.games-eyebrow,
.games-stat-label,
.game-hud-label,
.game-card-kicker {
    margin: 0;
    color: var(--games-muted);
    font-size: .76rem;
    font-weight: 900;
    letter-spacing: .18em;
    text-transform: uppercase;
}

.games-title {
    margin: 12px 0 12px;
    font-size: clamp(2.2rem, 8vw, 5rem);
    line-height: .95;
    font-weight: 900;
    letter-spacing: 0;
}

.games-gradient-text {
    background: linear-gradient(90deg, #065f46, #10b981, #f59e0b, #ef4444);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.games-copy {
    max-width: 760px;
    color: var(--games-muted);
    font-size: clamp(1rem, 2vw, 1.15rem);
    line-height: 1.8;
    font-weight: 700;
}

.games-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 22px;
}

.games-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 46px;
    padding: 0 20px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--color-emerald), var(--color-orange), var(--color-red));
    color: #fff;
    font-weight: 900;
    text-decoration: none;
    border: 0;
    cursor: pointer;
}

.games-ghost-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 18px;
    border-radius: 16px;
    font-weight: 900;
    text-decoration: none;
    cursor: pointer;
}

.games-grid,
.games-stats,
.achievement-grid {
    display: grid;
    gap: 16px;
}

.games-dashboard {
    padding: clamp(14px, 2vw, 20px);
}

.games-stats {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 10px;
    margin: 14px 0 12px;
}

.games-stat {
    min-height: 88px;
    padding: 12px;
    border-radius: .95rem;
    border: 1px solid var(--games-border);
    background: var(--games-surface-strong);
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 6px 9px;
}

.games-stat-icon {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(16, 185, 129, .14), rgba(251, 146, 60, .16));
    border: 1px solid rgba(16, 185, 129, .18);
    font-size: 1rem;
}

.games-stat-label {
    font-size: .64rem;
    letter-spacing: .14em;
}

.games-stat-value {
    grid-column: 1 / -1;
    margin-top: 0;
    color: var(--games-text);
    font-size: 1.22rem;
    line-height: 1.1;
    font-weight: 900;
}

.games-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin: 22px 0 46px;
}

.game-card {
    min-height: 210px;
    padding: 20px;
    border-radius: 1.5rem;
    border: 1px solid var(--games-border);
    background: var(--games-surface);
    box-shadow: var(--games-shadow-small);
    color: var(--games-text);
    text-decoration: none;
    display: flex;
    flex-direction: column;
    gap: 14px;
    transition: transform .22s ease, border-color .22s ease, box-shadow .22s ease;
}

.game-card:hover {
    transform: translateY(-4px);
    border-color: rgba(16, 185, 129, .36);
    box-shadow: var(--games-shadow);
}

.game-card-icon {
    width: 52px;
    height: 52px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, rgba(16, 185, 129, .16), rgba(251, 146, 60, .18));
    border: 1px solid rgba(16, 185, 129, .2);
    color: #065f46;
    font-size: 1.55rem;
    font-weight: 900;
    box-shadow: 0 14px 30px rgba(15, 23, 42, .08);
}

.game-card h2 {
    margin: 0;
    font-size: 1.25rem;
    line-height: 1.25;
    font-weight: 900;
}

.game-card p {
    margin: 0;
    color: var(--games-muted);
    line-height: 1.6;
    font-weight: 700;
}

.game-card-meta {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: #047857;
    font-size: .9rem;
    font-weight: 900;
}

.game-layout {
    padding: 24px 0 42px;
}

.game-play-wrap {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 18px;
    align-items: start;
}

.game-start,
.game-stage,
.game-side-panel {
    padding: clamp(18px, 3vw, 28px);
}

.game-start {
    display: grid;
    gap: 18px;
}

.game-title {
    margin: 0;
    font-size: clamp(2rem, 7vw, 4.5rem);
    line-height: 1;
    font-weight: 900;
}

.game-title-row {
    display: flex;
    align-items: center;
    gap: 16px;
}

.game-play-icon {
    width: clamp(56px, 12vw, 78px);
    height: clamp(56px, 12vw, 78px);
    flex: 0 0 auto;
    border-radius: 24px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, rgba(16, 185, 129, .16), rgba(251, 146, 60, .2));
    border: 1px solid rgba(16, 185, 129, .24);
    color: #065f46;
    font-size: clamp(1.7rem, 6vw, 2.35rem);
    font-weight: 900;
    box-shadow: var(--games-shadow-small);
}

.game-hud-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.game-hud-label span {
    font-size: .95rem;
    letter-spacing: 0;
}

.game-summary {
    margin: 0;
    color: var(--games-muted);
    font-weight: 700;
    line-height: 1.7;
}

.game-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.games-pill {
    min-height: 40px;
    padding: 0 14px;
    border-radius: 999px;
    font-weight: 900;
    cursor: pointer;
}

.games-pill.is-active {
    background: rgba(16, 185, 129, .13);
    border-color: rgba(16, 185, 129, .45);
    color: #047857;
}

.game-hud {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    margin: 18px 0 14px;
}

.game-hud-card {
    padding: 12px;
    border-radius: 16px;
    border: 1px solid var(--games-border);
    background: var(--games-surface-strong);
}

.game-hud-value {
    margin-top: 4px;
    font-size: 1.25rem;
    font-weight: 900;
}

.game-stage {
    min-height: 420px;
    position: relative;
    overflow: hidden;
}

.game-stage-inner {
    min-height: 360px;
}

.game-side-panel {
    border-radius: 1.5rem;
    border: 1px solid var(--games-border);
    background: var(--games-surface-strong);
    box-shadow: var(--games-shadow-small);
    display: grid;
    gap: 14px;
}

.game-side-panel h2,
.game-side-panel h3 {
    margin: 0 0 12px;
    font-size: 1.05rem;
    font-weight: 900;
}

.side-game-head {
    display: flex;
    align-items: center;
    gap: 12px;
}

.side-game-icon {
    width: 48px;
    height: 48px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(16, 185, 129, .16), rgba(251, 146, 60, .18));
    border: 1px solid rgba(16, 185, 129, .22);
    box-shadow: var(--games-shadow-small);
    font-size: 1.35rem;
}

.side-info-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 10px 12px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(236, 253, 245, .72), rgba(239, 246, 255, .72));
    border: 1px solid rgba(16, 185, 129, .16);
}

.side-mini-card {
    padding: 12px;
    border-radius: 18px;
    border: 1px solid var(--games-border);
    background: rgba(255, 255, 255, .72);
}

.side-mini-card h3 {
    display: flex;
    align-items: center;
    gap: 8px;
}

.side-mini-card p {
    margin: 0;
}

.side-mini-card p + p {
    margin-top: 4px;
}

.game-side-panel p,
.game-side-panel li {
    color: var(--games-muted);
    font-weight: 700;
    line-height: 1.6;
}

.game-choice-grid,
.match-grid,
.memory-grid,
.builder-bank,
.builder-answer {
    display: grid;
    gap: 12px;
}

.game-choice-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.match-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.game-token,
.game-choice,
.match-card,
.memory-card {
    border: 1px solid var(--games-border);
    border-radius: 18px;
    background: var(--games-surface-strong);
    color: var(--games-text);
    box-shadow: var(--games-shadow-small);
    font-weight: 900;
    cursor: pointer;
    transition: transform .18s ease, border-color .18s ease, background .18s ease;
}

.game-choice,
.match-card {
    min-height: 70px;
    padding: 14px;
    text-align: left;
}

.game-token {
    padding: 12px 14px;
}

.game-token:hover,
.game-choice:hover,
.match-card:hover,
.memory-card:hover {
    transform: translateY(-2px);
    border-color: rgba(16, 185, 129, .36);
}

.game-token:disabled,
.game-choice:disabled,
.match-card:disabled,
.memory-card:disabled {
    cursor: default;
}

.game-choice:disabled:not(.is-correct):not(.is-wrong),
.game-token:disabled:not(.is-correct):not(.is-wrong) {
    opacity: .68;
}

.match-card.is-selected {
    border-color: rgba(16, 185, 129, .7);
    background: rgba(16, 185, 129, .12);
}

.is-correct {
    border-color: rgba(16, 185, 129, .72) !important;
    background: rgba(16, 185, 129, .14) !important;
}

.is-wrong {
    border-color: rgba(239, 68, 68, .66) !important;
    background: rgba(239, 68, 68, .1) !important;
}

.memory-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.memory-card {
    min-height: 92px;
    display: grid;
    place-items: center;
    padding: 12px;
    text-align: center;
    transform-style: preserve-3d;
    position: relative;
    overflow: hidden;
    font-size: 1.05rem;
    user-select: none;
}

.memory-card:not(.is-open) .memory-face {
    color: transparent;
}

.memory-card:not(.is-open)::after {
    content: "🃏";
    color: #047857;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(16, 185, 129, .14), rgba(251, 146, 60, .18));
    border: 1px solid rgba(16, 185, 129, .22);
    box-shadow: 0 10px 22px rgba(15, 23, 42, .08);
    font-size: 1.4rem;
    font-weight: 900;
}

.memory-card.is-open {
    background: linear-gradient(135deg, rgba(236, 253, 245, .88), rgba(255, 247, 237, .88));
}

.memory-card.is-open:not(.is-correct):not(.is-wrong) {
    border-color: rgba(16, 185, 129, .55);
}

.memory-card.is-selected {
    outline: 3px solid rgba(16, 185, 129, .16);
    outline-offset: 3px;
}

.memory-card.is-wrong {
    animation: memory-shake .32s ease;
}

.memory-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    padding: 12px 14px;
    border: 1px solid var(--games-border);
    border-radius: 18px;
    background: var(--games-surface-strong);
    color: var(--games-muted);
    font-weight: 900;
    user-select: none;
}

.memory-status strong {
    color: #047857;
}

@keyframes memory-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    50% { transform: translateX(4px); }
    75% { transform: translateX(-2px); }
}

.builder-bank,
.builder-answer {
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    margin-top: 14px;
}

.builder-answer {
    min-height: 82px;
    padding: 12px;
    border: 1px dashed rgba(16, 185, 129, .4);
    border-radius: 18px;
    background: rgba(16, 185, 129, .07);
}

.shooter-field {
    min-height: 360px;
    position: relative;
}

.falling-kana {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    min-width: 58px;
    height: 58px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(16, 185, 129, .26);
    background: var(--games-surface-strong);
    box-shadow: var(--games-shadow-small);
    font-size: 1.8rem;
    font-weight: 900;
}

.shooter-controls {
    position: absolute;
    inset-inline: 16px;
    bottom: 16px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.battle-bars {
    display: grid;
    gap: 12px;
    margin-bottom: 18px;
}

.battle-bar {
    height: 12px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(15, 23, 42, .1);
}

.battle-bar span,
.game-progress span {
    display: block;
    height: 100%;
    width: 100%;
    border-radius: inherit;
    background: linear-gradient(135deg, var(--color-emerald), var(--color-orange), var(--color-red));
    transition: width .25s ease;
}

.game-progress {
    height: 10px;
    border-radius: 999px;
    background: rgba(15, 23, 42, .1);
    overflow: hidden;
    margin: 12px 0;
}

.achievement-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
}

.achievement-badge {
    padding: 9px 10px;
    border-radius: 999px;
    border: 1px solid var(--games-border);
    background: var(--games-surface-strong);
    font-size: .82rem;
    font-weight: 900;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.achievement-badge.is-earned {
    border-color: rgba(16, 185, 129, .44);
    background: rgba(16, 185, 129, .1);
}

.game-modal {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(248, 250, 252, .78);
    backdrop-filter: blur(14px);
}

.game-modal.is-open {
    display: flex;
}

.game-over-panel {
    width: min(520px, 100%);
    padding: 26px;
}

.confetti-dot {
    position: fixed;
    width: 8px;
    height: 8px;
    border-radius: 999px;
    pointer-events: none;
    z-index: 99;
    animation: confetti-fall 900ms ease-out forwards;
}

@keyframes confetti-fall {
    from { transform: translate3d(0, -20px, 0) scale(1); opacity: 1; }
    to { transform: translate3d(var(--dx), 180px, 0) scale(.25); opacity: 0; }
}

@media (max-width: 900px) {
    .games-stats,
    .games-grid,
    .game-play-wrap {
        grid-template-columns: 1fr;
    }

    .games-stats {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .achievement-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .game-hud {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .game-side-panel {
        order: -1;
    }
}

@media (max-width: 560px) {
    .games-shell {
        width: min(100% - 20px, 1180px);
    }

    .games-nav {
        min-height: 64px;
    }

    .games-brand span:last-child {
        display: none;
    }

    .games-hero {
        padding-top: 22px;
    }

    .game-choice-grid,
    .match-grid,
    .memory-grid,
    .shooter-controls {
        grid-template-columns: 1fr;
    }

    .games-stats,
    .achievement-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .game-stage {
        min-height: 440px;
    }

    .game-title-row {
        align-items: flex-start;
        gap: 12px;
    }

    .game-controls .games-btn,
    .game-controls .games-ghost-btn,
    .game-controls .games-pill {
        width: 100%;
    }
}

@media (max-width: 380px) {
    .game-title-row {
        flex-direction: column;
    }
}
