/* =========================================================
   AJIAS Games — shared styles for the game list + pack game
   ========================================================= */

:root {
    --games-bg: #f4f6fb;
    --games-bg-2: #eef2ff;
    --games-surface: #ffffff;
    --games-surface-2: #f8fafc;
    --games-ink: #182230;
    --games-muted: #5b6b7f;
    --games-line: #e2e8f0;
    --games-brand: #667eea;
    --games-brand-2: #764ba2;
    --games-accent: #f59e0b;
    --games-good: #22c55e;
    --games-bad: #ef4444;
    --games-shadow: 0 24px 70px rgba(30, 41, 59, .13);
    --games-shadow-sm: 0 8px 24px rgba(30, 41, 59, .08);
    --games-radius: 24px;
    --games-font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

[data-theme="dark"] {
    --games-bg: #111827;
    --games-bg-2: #1e1b4b;
    --games-surface: #1f2937;
    --games-surface-2: #273244;
    --games-ink: #f1f5f9;
    --games-muted: #a9b6c8;
    --games-line: #3b4a5f;
    --games-shadow: 0 24px 70px rgba(0, 0, 0, .45);
    --games-shadow-sm: 0 8px 24px rgba(0, 0, 0, .28);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

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

[data-theme="dark"] {
    color-scheme: dark;
}

body {
    margin: 0;
    min-height: 100vh;
    touch-action: pan-x pan-y;
    font-family: var(--games-font);
    color: var(--games-ink);
    background:
        radial-gradient(circle at 12% 0%, rgba(102, 126, 234, .16), transparent 32rem),
        radial-gradient(circle at 88% 12%, rgba(118, 75, 162, .12), transparent 28rem),
        var(--games-bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a {
    color: inherit;
}

button {
    font-family: inherit;
}

.hidden {
    display: none !important;
}

/* Game pages are not text documents: no selection / long-press copy callout. */
body.game-page,
body.game-page * {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

body.game-page * {
    touch-action: pan-x pan-y;
}

body.game-page button,
body.game-page a,
body.game-page .btn,
body.game-page .level-dot {
    touch-action: manipulation;
}

body.game-page .board,
body.game-page .board-grid,
body.game-page .pieces-layer,
body.game-page .piece,
body.game-page .tray,
body.game-page .tray-chip {
    touch-action: none;
}

/* ============ top bar ============ */

.g-topbar {
    width: min(1120px, 100%);
    margin: 0 auto;
    padding: 22px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
}

.g-brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    color: var(--games-ink);
    text-decoration: none;
    font-weight: 800;
    letter-spacing: -.02em;
    font-size: 1.08rem;
}

.g-brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    font-size: 20px;
    color: #fff;
    background: linear-gradient(135deg, var(--games-brand), var(--games-brand-2));
    box-shadow: 0 8px 20px rgba(102, 126, 234, .35);
}

.g-nav {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    color: var(--games-muted);
    font-size: 13px;
}

.g-nav > a {
    text-decoration: none;
    padding: 7px 9px;
    border-radius: 9px;
    transition: color .15s ease, background .15s ease;
}

.g-nav > a:hover {
    color: var(--games-ink);
    background: var(--games-surface);
}

.lang-switch {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--games-line);
    background: var(--games-surface-2);
    border-radius: 999px;
}

.lang-switch a {
    text-decoration: none;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    color: var(--games-muted);
    transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}

.lang-switch a.active,
.lang-switch a:hover {
    color: var(--games-ink);
    background: var(--games-surface);
    box-shadow: 0 2px 8px rgba(30, 41, 59, .09);
}

.theme-toggle {
    width: 36px;
    height: 36px;
    border: 1px solid var(--games-line);
    border-radius: 50%;
    background: var(--games-surface);
    color: var(--games-ink);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    display: grid;
    place-items: center;
    transition: transform .15s ease, background .15s ease;
}

.theme-toggle:hover {
    transform: rotate(12deg) scale(1.04);
    background: var(--games-surface-2);
}

/* ============ list page ============ */

.games-hero {
    width: min(860px, 100%);
    margin: 0 auto;
    padding: 54px 24px 34px;
    text-align: center;
}

.eyebrow {
    margin: 0 0 10px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--games-brand);
}

.games-hero h1 {
    margin: 0;
    font-size: clamp(2.5rem, 6vw, 4.4rem);
    line-height: 1.02;
    letter-spacing: -.055em;
}

.games-hero p {
    margin: 16px auto 0;
    max-width: 620px;
    color: var(--games-muted);
    font-size: 1.02rem;
    line-height: 1.75;
}

.game-grid {
    width: min(1120px, 100%);
    margin: 0 auto;
    padding: 10px 24px 54px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 26px;
    align-items: stretch;
}

.game-card {
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--games-surface);
    border: 1px solid var(--games-line);
    border-radius: var(--games-radius);
    box-shadow: var(--games-shadow-sm);
    transition: transform .2s ease, box-shadow .2s ease;
}

.game-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--games-shadow);
}

.game-cover {
    position: relative;
    height: 238px;
    display: grid;
    place-items: center;
    overflow: hidden;
    background:
        radial-gradient(circle at 18% 20%, rgba(255, 255, 255, .8), transparent 34%),
        linear-gradient(135deg, #dfe9ff 0%, #e9e1ff 52%, #ffe8d6 100%);
}

[data-theme="dark"] .game-cover {
    background:
        radial-gradient(circle at 18% 20%, rgba(255, 255, 255, .12), transparent 34%),
        linear-gradient(135deg, #23305a 0%, #35235a 52%, #4a2d2a 100%);
}

.game-cover::before,
.game-cover::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
}

.game-cover::before {
    width: 170px;
    height: 170px;
    left: -60px;
    bottom: -80px;
    background: rgba(102, 126, 234, .16);
}

.game-cover::after {
    width: 130px;
    height: 130px;
    right: -40px;
    top: -50px;
    background: rgba(118, 75, 162, .14);
}

.cover-art {
    position: relative;
    width: 204px;
    height: 164px;
    z-index: 1;
}

.suitcase {
    position: absolute;
    inset: 16px 0 0;
    padding: 10px;
    border-radius: 22px;
    background: linear-gradient(160deg, #40506b, #162033 72%);
    box-shadow:
        0 22px 30px rgba(20, 30, 50, .26),
        inset 0 1px 0 rgba(255, 255, 255, .22);
    transform: rotate(-3deg);
}

.suitcase::before {
    content: "";
    position: absolute;
    left: 50%;
    top: -15px;
    width: 62px;
    height: 24px;
    transform: translateX(-50%);
    border: 8px solid #40506b;
    border-bottom: 0;
    border-radius: 13px 13px 0 0;
}

.suitcase-body {
    height: 100%;
    padding: 7px;
    border-radius: 14px;
    background: #f8fafc;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 4px;
}

.block {
    display: grid;
    place-items: center;
    border-radius: 7px;
    font-size: 18px;
    line-height: 1;
    box-shadow:
        inset 0 -3px 0 rgba(0, 0, 0, .13),
        inset 0 1px 0 rgba(255, 255, 255, .32);
    user-select: none;
}

.block-1 { grid-area: 1 / 1 / 3 / 3; background: #f97316; }
.block-2 { grid-area: 1 / 3 / 3 / 4; background: #0ea5e9; }
.block-3 { grid-area: 1 / 4 / 3 / 5; background: #eab308; }
.block-4 { grid-area: 3 / 1 / 4 / 3; background: #8b5cf6; }
.block-5 { grid-area: 3 / 3 / 5 / 4; background: #22c55e; }
.block-6 { grid-area: 3 / 4 / 5 / 5; background: #ec4899; }
.block-7 { grid-area: 4 / 1 / 5 / 3; background: #14b8a6; }

.float-icon {
    position: absolute;
    z-index: 2;
    font-size: 24px;
    line-height: 1;
    filter: drop-shadow(0 4px 8px rgba(20, 30, 50, .2));
    animation: bob 4.6s ease-in-out infinite;
}

.float-icon-1 {
    left: -6px;
    top: 14px;
    animation-delay: -.8s;
}

.float-icon-2 {
    right: -4px;
    bottom: 30px;
    animation-delay: -2.1s;
}

@keyframes bob {
    0%, 100% { transform: translateY(0) rotate(-4deg); }
    50% { transform: translateY(-8px) rotate(4deg); }
}

.game-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    padding: 24px 26px 26px;
}

.tag {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--games-brand);
    background: rgba(102, 126, 234, .12);
}

.game-body h2 {
    margin: 12px 0 0;
    font-size: 1.6rem;
    letter-spacing: -.03em;
}

.game-body p {
    margin: 10px 0 0;
    color: var(--games-muted);
    line-height: 1.68;
    font-size: .96rem;
}

.meta {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin: 17px 0 22px;
}

.meta span {
    padding: 5px 9px;
    border-radius: 999px;
    background: var(--games-surface-2);
    border: 1px solid var(--games-line);
    color: var(--games-muted);
    font-size: 12px;
    white-space: nowrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 11px 18px;
    border: 1px solid transparent;
    border-radius: 13px;
    font-size: 14px;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}

.btn:active {
    transform: translateY(1px);
}

.btn:focus-visible,
.g-btn:focus-visible,
.tray-chip:focus-visible,
.level-dot:focus-visible,
.theme-toggle:focus-visible {
    outline: 3px solid var(--games-brand);
    outline-offset: 2px;
}

.btn-primary {
    color: #fff;
    background: linear-gradient(135deg, var(--games-brand), var(--games-brand-2));
    box-shadow: 0 12px 24px rgba(102, 126, 234, .3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 28px rgba(102, 126, 234, .38);
}

.btn-secondary {
    color: var(--games-ink);
    background: var(--games-surface-2);
    border-color: var(--games-line);
}

.btn-secondary:hover {
    background: var(--games-surface);
}

.game-card .btn {
    margin-top: auto;
    align-self: flex-start;
}

.coming-card {
    min-height: 100%;
    display: grid;
    place-items: center;
    padding: 34px;
    border: 1.5px dashed var(--games-line);
    border-radius: var(--games-radius);
    background: transparent;
    box-shadow: none;
    text-align: center;
    color: var(--games-muted);
}

.coming-card:hover {
    transform: none;
    box-shadow: none;
}

.coming-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 14px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    font-size: 26px;
    background: var(--games-surface-2);
    border: 1px solid var(--games-line);
}

.coming-card h2 {
    margin: 0 0 6px;
    color: var(--games-ink);
    font-size: 1.05rem;
}

.coming-card p {
    margin: 0;
    font-size: .9rem;
    line-height: 1.65;
}

.games-footer {
    width: min(1120px, 100%);
    margin: 0 auto;
    padding: 26px 24px 42px;
    border-top: 1px solid var(--games-line);
    display: flex;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    color: var(--games-muted);
    font-size: 13px;
}

.games-footer a {
    text-decoration: none;
    border-bottom: 1px solid color-mix(in srgb, var(--games-muted) 35%, transparent);
}

.games-footer a:hover {
    color: var(--games-ink);
}

/* ============ game page ============ */

.game-shell {
    width: min(1040px, 100%);
    margin: 0 auto;
    padding: 6px 22px 64px;
}

.game-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 22px;
    flex-wrap: wrap;
    padding: 8px 0 18px;
}

.game-head h1 {
    margin: 0;
    font-size: clamp(1.9rem, 4.4vw, 3rem);
    letter-spacing: -.045em;
    line-height: 1.05;
}

.level-name {
    margin: 8px 0 0;
    color: var(--games-muted);
    font-size: .95rem;
    font-weight: 600;
}

.hud {
    display: flex;
    gap: 9px;
    flex-wrap: wrap;
}

.stat {
    min-width: 74px;
    padding: 9px 12px;
    border-radius: 15px;
    background: var(--games-surface);
    border: 1px solid var(--games-line);
    text-align: center;
    box-shadow: 0 2px 8px rgba(30, 41, 59, .04);
}

.stat-label {
    display: block;
    margin-bottom: 3px;
    color: var(--games-muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.stat strong {
    font-size: 1.12rem;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
}

.board-row {
    display: flex;
    justify-content: center;
    padding: 10px 0 8px;
}

.board-frame {
    position: relative;
    max-width: 100%;
    padding: 16px 16px 18px;
    border-radius: 28px;
    background: linear-gradient(155deg, #43526c 0%, #1c2638 68%, #141c2b 100%);
    box-shadow:
        0 26px 60px rgba(20, 30, 50, .34),
        inset 0 1px 0 rgba(255, 255, 255, .24);
}

.board-frame::before {
    content: "";
    position: absolute;
    left: 50%;
    top: -14px;
    width: 70px;
    height: 22px;
    transform: translateX(-50%);
    border: 8px solid #43526c;
    border-bottom: 0;
    border-radius: 12px 12px 0 0;
}

.board {
    --cell: 40px;
    position: relative;
    width: min(92vw, calc(var(--cols) * 96px), 440px, 42vh);
    max-width: 100%;
    aspect-ratio: var(--cols) / var(--rows);
    border-radius: 16px;
    overflow: hidden;
    background: #eef2f7;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

[data-theme="dark"] .board {
    background: #dce4ee;
}

.board-grid {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: repeat(var(--cols), 1fr);
    grid-template-rows: repeat(var(--rows), 1fr);
}

.cell {
    border-right: 1px solid rgba(100, 116, 139, .16);
    border-bottom: 1px solid rgba(100, 116, 139, .16);
}

.pieces-layer {
    position: absolute;
    inset: 0;
}

.drag-layer {
    position: fixed;
    inset: 0;
    z-index: 1000;
    pointer-events: none;
}

.drop-target {
    position: absolute;
    z-index: 1;
    border-radius: 8px;
    background: rgba(34, 197, 94, .18);
    pointer-events: none;
    transition: left .06s linear, top .06s linear, width .06s linear, height .06s linear;
}

.drop-target.bad {
    background: rgba(239, 68, 68, .18);
}

.piece {
    --piece-color: #94a3b8;
    position: absolute;
    display: grid;
    grid-template-columns: repeat(var(--w), 1fr);
    grid-template-rows: repeat(var(--h), 1fr);
    width: calc(var(--w) * var(--cell));
    height: calc(var(--h) * var(--cell));
    left: calc(var(--x) * var(--cell));
    top: calc(var(--y) * var(--cell));
    padding: 2px;
    cursor: grab;
    touch-action: none;
    filter: drop-shadow(0 4px 5px rgba(15, 23, 42, .16));
    transition: left .11s ease, top .11s ease, width .11s ease, height .11s ease;
    z-index: 2;
}

.piece:active {
    cursor: grabbing;
}

.piece,
.tray-chip {
    -webkit-user-drag: none;
    user-select: none;
    -webkit-user-select: none;
}

.piece-cell {
    margin: 2px;
    border-radius: 7px;
    background: var(--piece-color);
    box-shadow:
        inset 0 -3px 0 rgba(0, 0, 0, .14),
        inset 0 1px 0 rgba(255, 255, 255, .28);
    pointer-events: none;
}

/* Rectangular items read as one object, not four separate tiles. */
.piece.solid {
    background: var(--piece-color);
    border-radius: 11px;
    box-shadow:
        inset 0 -3px 0 rgba(0, 0, 0, .14),
        inset 0 1px 0 rgba(255, 255, 255, .28);
}

.piece.solid .piece-cell {
    margin: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.piece-cell.empty {
    visibility: hidden;
}

.piece-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--cell) * .8);
    line-height: 1;
    pointer-events: none;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .24));
    user-select: none;
}

.piece.ghost {
    z-index: 9999;
    opacity: 1;
    transform: scale(1.035);
    transform-origin: center;
    transition: transform .12s ease;
    cursor: grabbing;
    filter: none;
    will-change: left, top, transform;
    animation: drag-lift .12s ease-out;
}

.piece.ghost,
.piece.ghost .piece-cell,
.piece.ghost.solid {
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
}

.piece.ghost .piece-icon {
    filter: none;
}

@keyframes drag-lift {
    from { transform: scale(1); opacity: .8; }
    to { transform: scale(1.035); opacity: 1; }
}

.piece.ghost.bad {
    filter: none;
}

.piece.ghost.bad .piece-cell {
    background: var(--games-bad) !important;
}

.piece.ghost.bad.solid {
    background: var(--games-bad) !important;
}

.piece:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 2px;
    filter: drop-shadow(0 0 0 #fff) drop-shadow(0 4px 8px rgba(15, 23, 42, .3));
}

.game-actions {
    display: flex;
    justify-content: center;
    gap: 9px;
    flex-wrap: wrap;
    padding: 8px 0 12px;
}

.g-btn {
    min-height: 40px;
    padding: 8px 14px;
    border: 1px solid var(--games-line);
    border-radius: 12px;
    background: var(--games-surface);
    color: var(--games-ink);
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 2px 7px rgba(30, 41, 59, .04);
    transition: transform .12s ease, background .12s ease, border-color .12s ease;
}

.g-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    background: var(--games-surface-2);
    border-color: color-mix(in srgb, var(--games-brand) 45%, var(--games-line));
}

.g-btn:disabled {
    opacity: 1;
    color: var(--games-muted);
    cursor: not-allowed;
}

.g-btn.primary {
    color: #fff;
    border-color: transparent;
    background: linear-gradient(135deg, var(--games-brand), var(--games-brand-2));
    box-shadow: 0 8px 18px rgba(102, 126, 234, .26);
}

.g-btn.primary:hover:not(:disabled) {
    color: #fff;
    border-color: transparent;
    background: linear-gradient(135deg, var(--games-brand), var(--games-brand-2));
    box-shadow: 0 8px 18px rgba(102, 126, 234, .3);
}

.g-btn.primary:disabled {
    background-color: var(--games-surface-2) !important;
    background-image: none !important;
    color: var(--games-ink) !important;
    border-color: var(--games-line);
    box-shadow: none;
}

.tray {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 9px;
    padding: 4px 0 18px;
    min-height: 76px;
}

.tray-empty {
    align-self: center;
    color: var(--games-muted);
    font-size: .92rem;
}

.tray-chip {
    --piece-color: #94a3b8;
    appearance: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    min-width: 80px;
    padding: 10px 11px 8px;
    border: 1px solid var(--games-line);
    border-radius: 15px;
    background: var(--games-surface);
    color: var(--games-ink);
    cursor: grab;
    touch-action: none;
    box-shadow: var(--games-shadow-sm);
    transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}

.tray-chip:active {
    transform: scale(.97);
}

.tray-chip:hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--games-brand) 40%, var(--games-line));
    box-shadow: 0 12px 26px rgba(30, 41, 59, .12);
}

.tray-chip.hidden-source {
    opacity: 0;
    pointer-events: none;
}

.mini {
    display: grid;
    gap: 2px;
}

.mini i {
    width: 9px;
    height: 9px;
    border-radius: 2px;
    background: var(--piece-color);
}

.mini i.empty {
    visibility: hidden;
}

.tray-name {
    max-width: 92px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--games-muted);
    font-size: 11px;
    font-weight: 700;
}

.section-label {
    margin: 0 0 8px;
    text-align: center;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--games-muted);
}

.level-select {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    padding: 0 0 18px;
}

.level-dot {
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--games-line);
    border-radius: 14px;
    background: var(--games-surface);
    color: var(--games-muted);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    font-size: 13px;
    font-weight: 800;
    transition: transform .12s ease, border-color .12s ease, background .12s ease;
}

.level-dot:hover {
    transform: translateY(-2px);
    border-color: var(--games-brand);
}

.level-dot.locked {
    opacity: .5;
    cursor: not-allowed;
    border-style: dashed;
}

.level-dot.locked .dot-stars {
    color: var(--games-muted);
}

.level-dot.active {
    color: #fff;
    border-color: transparent;
    background: linear-gradient(135deg, var(--games-brand), var(--games-brand-2));
    box-shadow: 0 8px 18px rgba(102, 126, 234, .28);
}

.level-dot .dot-stars {
    font-size: 9px;
    line-height: 1;
    letter-spacing: .04em;
    color: var(--games-accent);
}

.level-dot.active .dot-stars {
    color: #ffe9a9;
}

.play-hint {
    margin: 0 auto;
    max-width: 660px;
    text-align: center;
    color: var(--games-muted);
    font-size: .9rem;
    line-height: 1.7;
}

.game-message {
    min-height: 1.35em;
    margin: -2px 0 9px;
    text-align: center;
    color: var(--games-muted);
    font-size: .86rem;
    font-weight: 600;
    line-height: 1.5;
}

.game-notes {
    max-width: 680px;
    margin: 30px auto 0;
    padding: 22px 24px;
    border: 1px solid var(--games-line);
    border-radius: 20px;
    background: var(--games-surface);
    box-shadow: var(--games-shadow-sm);
}

.game-notes h2 {
    margin: 0 0 8px;
    font-size: 1.12rem;
    letter-spacing: -.02em;
}

.game-notes p {
    margin: 0;
    color: var(--games-muted);
    font-size: .9rem;
    line-height: 1.75;
}

.game-notes p + p {
    margin-top: 8px;
}

/* ============ win modal / toast ============ */

.modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(15, 23, 42, .56);
    backdrop-filter: blur(7px);
    -webkit-backdrop-filter: blur(7px);
}

.modal-card:focus {
    outline: none;
}

.modal-card {
    width: min(430px, 100%);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    padding: 30px 28px 26px;
    border-radius: 28px;
    background: var(--games-surface);
    border: 1px solid var(--games-line);
    box-shadow: 0 30px 90px rgba(0, 0, 0, .32);
    text-align: center;
    animation: pop-in .22s cubic-bezier(.2, .8, .2, 1);
}

@keyframes pop-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-card h2 {
    margin: 2px 0 4px;
    font-size: 2rem;
    letter-spacing: -.04em;
}

.win-level {
    margin: 0;
    color: var(--games-muted);
    font-size: .92rem;
}

.stars-big {
    display: flex;
    justify-content: center;
    gap: 7px;
    margin: 16px 0 4px;
    font-size: 2.7rem;
    line-height: 1;
    color: var(--games-accent);
}

.stars-big .star-off {
    color: color-mix(in srgb, var(--games-muted) 30%, transparent);
}

.stars-big .star-on {
    animation: star-pop .45s cubic-bezier(.2, .9, .2, 1) both;
}

.stars-big .star-on:nth-child(2) { animation-delay: .1s; }
.stars-big .star-on:nth-child(3) { animation-delay: .2s; }

@keyframes star-pop {
    from { opacity: 0; transform: scale(.4) rotate(-18deg); }
    to { opacity: 1; transform: scale(1) rotate(0); }
}

.win-sub {
    margin: 0 0 16px;
    color: var(--games-muted);
    font-size: .9rem;
}

.win-stats {
    display: flex;
    justify-content: center;
    gap: 24px;
    padding: 13px 0;
    border-top: 1px solid var(--games-line);
    border-bottom: 1px solid var(--games-line);
}

.win-stats div {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.win-stats span {
    color: var(--games-muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .09em;
    text-transform: uppercase;
}

.win-stats strong {
    font-size: 1.1rem;
    font-variant-numeric: tabular-nums;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 18px;
}

.modal-actions .btn {
    width: 100%;
}

.modal-close {
    margin-top: 10px;
    padding: 6px;
    border: 0;
    background: transparent;
    color: var(--games-muted);
    font-size: 12px;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 26px;
    z-index: 60;
    max-width: min(90vw, 440px);
    padding: 10px 15px;
    border-radius: 12px;
    background: rgba(15, 23, 42, .92);
    color: #fff;
    font-size: 13px;
    line-height: 1.45;
    transform: translate(-50%, 18px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease;
    box-shadow: 0 14px 32px rgba(0, 0, 0, .3);
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ============ responsive ============ */

@media (max-width: 640px) {
    .g-topbar {
        padding: 16px 16px 8px;
    }

    .g-nav {
        gap: 8px;
        font-size: 12px;
    }

    .g-nav > a {
        display: none;
    }

    .games-hero {
        padding: 34px 18px 24px;
    }

    .game-grid {
        padding: 6px 16px 36px;
        grid-template-columns: 1fr;
    }

    .game-cover {
        height: 214px;
    }

    .game-body {
        padding: 21px 22px 23px;
    }

    .game-shell {
        padding: 2px 14px 48px;
    }

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

    .hud {
        width: 100%;
        justify-content: space-between;
    }

    .stat {
        flex: 1;
        min-width: 0;
    }

    .board-frame {
        padding: 12px 12px 14px;
        border-radius: 23px;
    }

    .board-frame::before {
        top: -11px;
        border-width: 7px;
        width: 58px;
        height: 18px;
    }

    .board {
        width: min(90vw, calc(var(--cols) * 74px), 420px, 52vh);
    }

    .game-actions {
        gap: 7px;
    }

    .g-btn {
        flex: 1;
        min-width: 82px;
        padding: 8px 10px;
    }

    .tray-chip {
        min-width: 70px;
        padding: 8px 9px 7px;
    }

    .level-dot {
        width: 40px;
        height: 40px;
    }

    .modal-card {
        padding: 26px 22px 22px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}
