/* Казуальные игры «на одного» (/games/pyatnashki и следующие): сцена игры с панелью, полноэкранный
   режим, окно победы, таблица рекордов. Сама плитка/поле конкретной игры — в конце файла по разделам. */

.cg-wrap { padding: 0 var(--lv-pad-x) 8px; }

.cg-stage {
    position: relative;
    max-width: 720px;
    margin: 0 auto;
    padding: 16px;
    background: #f2eee6;
    border: 1px solid #e3ddd1;
    outline: none;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.cg-stage:focus-visible { box-shadow: 0 0 0 3px rgba(20, 20, 20, .25); }

.cg-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; font-family: 'Inter', sans-serif; }
.cg-modes { display: flex; gap: 6px; flex-wrap: wrap; }
.cg-stats { display: flex; gap: 18px; margin-left: auto; }
.cg-stat { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
/* Счётчики — Inter с табличными цифрами: у Playfair цифры разной ширины, и таймер с десятыми «дрожал». */
.cg-stat b { font-family: 'Inter', sans-serif; font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; color: #141414; }
.cg-stat b[data-cg-time] { min-width: 3.9em; text-align: right; }
.cg-stat small { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #7a756c; }
.cg-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.cg-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 14px; min-height: 38px;
    font: 600 14px/1.2 'Inter', sans-serif; color: #141414;
    background: #fffdf8; border: 1px solid #d8d0c0; cursor: pointer; text-decoration: none;
}
.cg-btn:hover { background: #fff; border-color: #141414; color: #141414; }
.cg-btn.is-active, .cg-btn--primary { background: #141414; border-color: #141414; color: #fff; }
.cg-btn--primary:hover { background: #33312d; color: #fff; }
.cg-btn--ghost { background: transparent; }
.cg-btn:disabled { opacity: .6; cursor: default; }
.cg-btn svg { flex-shrink: 0; }

.cg-board-wrap { display: flex; justify-content: center; }

.cg-note { margin: 0; padding: 10px 12px; font: 14px/1.45 'Inter', sans-serif; color: #33312d; background: #fffdf8; border-left: 3px solid #141414; }
.cg-note--warn { border-left-color: #c2410c; }
.cg-note--ok { border-left-color: #2f9e44; }
.cg-link { padding: 0; border: 0; background: none; font: inherit; font-weight: 600; color: #141414; text-decoration: underline; cursor: pointer; }

.cg-help { margin: 0; font: 13px/1.45 'Inter', sans-serif; color: #7a756c; text-align: center; }

/* --- полноэкранный режим: и настоящий (Fullscreen API), и «фокус-режим» для iPhone --- */
.cg-stage--max { position: fixed; inset: 0; z-index: 1000; max-width: none; margin: 0; border: 0; overflow: auto; }
html.cg-noscroll, html.cg-noscroll body { overflow: hidden; }
.cg-stage--full { max-width: none; justify-content: center; padding: 16px max(16px, 3vw); background: #f2eee6; }
.cg-stage--full .cg-bar { width: 100%; max-width: 900px; margin: 0 auto; }
.cg-stage--full .cg-help { display: none; }

/* --- окно победы поверх поля --- */
.cg-overlay {
    position: absolute; inset: 0; z-index: 5;
    display: flex; align-items: center; justify-content: center;
    padding: 16px; background: rgba(242, 238, 230, .82);
    backdrop-filter: blur(2px);
}
.cg-overlay[hidden] { display: none; }
.cg-win {
    width: 100%; max-width: 400px; max-height: 100%; overflow: auto;
    padding: 24px 22px; background: #fffdf8; border: 1px solid #141414;
    box-shadow: 0 18px 40px rgba(20, 20, 20, .18);
    display: flex; flex-direction: column; gap: 12px; text-align: center;
    font-family: 'Inter', sans-serif;
}
.cg-win-title { font-family: 'Playfair Display', Georgia, serif; font-size: 34px; font-weight: 900; color: #141414; }
.cg-win-num { font-family: 'Inter', sans-serif; font-size: 42px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; line-height: 1; }
.cg-win-sub { margin-top: 6px; font-size: 14px; color: #7a756c; }
.cg-win-local { margin: 0; font-size: 14px; color: #33312d; }
.cg-win-save { display: flex; flex-direction: column; gap: 10px; padding: 12px 0; border-top: 1px solid #e3ddd1; border-bottom: 1px solid #e3ddd1; }
.cg-win-hint { margin: 0; font-size: 13.5px; line-height: 1.45; color: #33312d; }
.cg-win-login { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.cg-win-check { display: flex; gap: 8px; align-items: flex-start; justify-content: center; font-size: 13.5px; color: #33312d; cursor: pointer; text-align: left; }
.cg-win-check input { margin-top: 2px; }
.cg-win-ok { margin: 0; font-size: 14px; font-weight: 600; color: #2f9e44; }
.cg-win-err { margin: 0; font-size: 13.5px; color: #c2410c; }

/* --- таблица рекордов --- */
.cg-records { max-width: 720px; margin: 36px auto 0; padding: 0 var(--lv-pad-x); box-sizing: content-box; }
.cg-records h2 { margin: 0 0 6px; font-family: 'Playfair Display', Georgia, serif; font-size: 28px; font-weight: 900; }
.cg-records-sub { margin: 0 0 14px; font: 14px/1.5 'PT Serif', Georgia, serif; color: #7a756c; }
.cg-tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.cg-mybest { margin: 0 0 10px; font: 600 14px/1.4 'Inter', sans-serif; color: #141414; }
.cg-top-list { margin: 0; padding: 0; list-style: none; border-top: 1px solid #e3ddd1; }
.cg-top-list li {
    display: grid; grid-template-columns: 34px 1fr auto auto; gap: 12px; align-items: baseline;
    padding: 9px 4px; border-bottom: 1px solid #e3ddd1; font: 15px/1.3 'Inter', sans-serif; color: #141414;
}
.cg-top-list li.is-me { background: #fffdf8; font-weight: 600; }
.cg-top-place { font-family: 'Playfair Display', Georgia, serif; font-weight: 800; color: #7a756c; text-align: right; }
.cg-top-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cg-top-time { font-variant-numeric: tabular-nums; font-weight: 600; }
.cg-top-moves { font-size: 13px; color: #7a756c; min-width: 70px; text-align: right; }
.cg-top-empty { margin: 0; font: 15px/1.5 'PT Serif', Georgia, serif; color: #7a756c; }

@media (max-width: 520px) {
    .cg-stage { padding: 12px 10px; }
    .cg-wrap { padding: 0 10px 8px; }
    .cg-stats { margin-left: 0; width: 100%; justify-content: space-between; }
    .cg-stat { align-items: flex-start; }
    .cg-stat b[data-cg-time] { text-align: left; }
    .cg-top-list li { grid-template-columns: 26px 1fr auto; }
    .cg-top-moves { display: none; }
}

/* ===================== Пятнашки ===================== */
.pz-board {
    --n: 4;
    position: relative;
    width: min(100%, 520px);
    aspect-ratio: 1;
    padding: 6px;
    box-sizing: border-box;
    background: #2b2925;
    container-type: inline-size;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}
.cg-stage--full .pz-board { width: min(94vw, calc(100vh - 150px), 900px); width: min(94vw, calc(100dvh - 150px), 900px); }
.pz-board::before { content: ''; position: absolute; inset: 6px; background: #3a3732; }
.pz-tile {
    position: absolute; top: 6px; left: 6px;
    width: calc((100% - 12px) / var(--n)); height: calc((100% - 12px) / var(--n));
    padding: 3px; box-sizing: border-box;
    border: 0; background: transparent; cursor: pointer;
    font-family: 'Playfair Display', Georgia, serif; font-weight: 800;
    font-size: calc(46cqw / var(--n)); font-variant-numeric: lining-nums; color: #141414;
    transition: transform .11s ease-out;
    -webkit-tap-highlight-color: transparent;
}
.pz-tile::before {
    content: ''; position: absolute; inset: 3px; z-index: -1;
    background: #fbf6ea; border-radius: 4px;
    box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .12), inset 0 1px 0 #fff;
}
.pz-tile { z-index: 1; display: flex; align-items: center; justify-content: center; isolation: isolate; }
.pz-tile.is-home { color: #9c3d13; }
.pz-tile:hover::before { background: #fffdf6; }
.pz-board.is-solved .pz-tile::before { background: #e3f1dc; }
.pz-board.is-solved .pz-tile { color: #2b6b2f; }
.pz-tile.is-shake { animation: pz-shake .25s; }
@keyframes pz-shake { 25% { margin-left: -3px; } 75% { margin-left: 3px; } }
.cg-stage.is-loading .pz-board { opacity: .55; }
@media (prefers-reduced-motion: reduce) { .pz-tile { transition: none; } }

/* ===================== Сапёр ===================== */
.cg-stage--saper.ms-wide { max-width: 1320px; }
.cg-stage--saper .cg-board-wrap { overflow-x: auto; justify-content: safe center; padding-bottom: 2px; }
.ms-board {
    --w: 9; --cell: 34px;
    display: grid;
    grid-template-columns: repeat(var(--w), var(--cell));
    grid-auto-rows: var(--cell);
    gap: 2px;
    padding: 5px;
    background: #2b2925;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    flex-shrink: 0;
}
.ms-cell {
    display: flex; align-items: center; justify-content: center;
    background: #fbf6ea; border-radius: 3px;
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .13), inset 0 1px 0 #fff;
    font: 800 calc(var(--cell) * .56)/1 'Inter', sans-serif; font-variant-numeric: tabular-nums;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.ms-cell:hover { background: #fffdf6; }
.ms-cell.is-open { background: #d9d2c4; box-shadow: none; cursor: default; }
.ms-cell.n1 { color: #1c62b9; } .ms-cell.n2 { color: #2b8a3e; } .ms-cell.n3 { color: #c92a2a; } .ms-cell.n4 { color: #5f3dc4; }
.ms-cell.n5 { color: #a61e4d; } .ms-cell.n6 { color: #0b7285; } .ms-cell.n7 { color: #141414; } .ms-cell.n8 { color: #6b6b6b; }
.ms-cell.is-flag, .ms-cell.is-wrong {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M6 3v14' stroke='%23141414' stroke-width='1.8' stroke-linecap='round'/%3E%3Cpath d='M6.8 3.5 15 7l-8.2 3.5z' fill='%23d9480f'/%3E%3Cpath d='M3.5 17h6' stroke='%23141414' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: center; background-size: 64%;
}
.ms-cell.is-wrong { background-color: #f1d9cf; position: relative; }
.ms-cell.is-wrong::after { content: ''; position: absolute; inset: 22%; background: linear-gradient(45deg, transparent 45%, #c92a2a 45%, #c92a2a 55%, transparent 55%), linear-gradient(-45deg, transparent 45%, #c92a2a 45%, #c92a2a 55%, transparent 55%); }
.ms-cell.is-mine {
    background-color: #d9d2c4; box-shadow: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cg stroke='%23141414' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='M10 2.5v15M2.5 10h15M4.7 4.7l10.6 10.6M15.3 4.7 4.7 15.3'/%3E%3C/g%3E%3Ccircle cx='10' cy='10' r='5' fill='%23141414'/%3E%3Ccircle cx='8.3' cy='8.3' r='1.3' fill='%23fff'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: center; background-size: 72%;
}
.ms-cell.is-boom { background-color: #e8590c; }
.ms-board.is-won .ms-cell.is-flag { background-color: #e3f1dc; }
.ms-board.is-lost .ms-cell, .ms-board.is-won .ms-cell { cursor: default; }
.cg-stage.is-loading .ms-board { opacity: .7; }

/* ===================== Косынка ===================== */
.cg-stage--kosynka { max-width: 900px; }
.cg-stage--kosynka .cg-board-wrap { display: block; }
.ks-board {
    --cw: 80px; --ch: 112px;
    position: relative; margin: 0 auto; isolation: isolate; z-index: 0;
    background: #2f5d46; border-radius: 6px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .25), inset 0 0 60px rgba(0, 0, 0, .25);
    touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.ks-slot, .ks-card { position: absolute; left: 0; top: 0; width: var(--cw); height: var(--ch); box-sizing: border-box; }
.ks-slot { border: 2px solid rgba(255, 255, 255, .18); border-radius: calc(var(--cw) * .08); display: flex; align-items: center; justify-content: center; color: rgba(255, 255, 255, .28); font-size: calc(var(--cw) * .42); }
.ks-slot--waste, .ks-slot--tab { border-style: dashed; }
.ks-slot--stock { cursor: pointer; }
.ks-slot--stock span { display: none; }
.ks-slot--stock.is-empty span { display: block; }
.ks-slot--stock.is-done span { opacity: .3; }
.ks-slot--found.is-red { color: rgba(255, 190, 190, .35); }
.ks-card {
    border-radius: calc(var(--cw) * .08);
    transition: transform .16s ease-out;
    cursor: pointer;
    background: #24453a repeating-linear-gradient(45deg, rgba(255, 255, 255, .09) 0 3px, transparent 3px 7px);
    border: 2px solid #fbf6ea;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .35);
    -webkit-tap-highlight-color: transparent;
}
.ks-board.is-instant .ks-card { transition: none; }
.ks-card.is-drag { transition: none; box-shadow: 0 10px 22px rgba(0, 0, 0, .4); }
.ks-face { display: none; position: absolute; inset: 0; border-radius: inherit; background: #fffdf8; color: #141414; overflow: hidden; }
.ks-card.is-up { border-color: #d8d0c0; background: #fffdf8; }
.ks-card.is-up .ks-face { display: block; }
.ks-card.is-red .ks-face { color: #c92a2a; }
.ks-corner { position: absolute; left: 5%; top: 3%; display: flex; flex-direction: column; align-items: center; font: 700 calc(var(--cw) * .26)/1 'Inter', sans-serif; letter-spacing: -.04em; }
.ks-corner i { font-style: normal; font-size: .82em; margin-top: 1px; }
.ks-corner--b { left: auto; top: auto; right: 5%; bottom: 3%; transform: rotate(180deg); }
.ks-pip { position: absolute; left: 50%; top: 56%; transform: translate(-50%, -50%); font-size: calc(var(--cw) * .5); line-height: 1; }
.ks-card.is-shake { animation: ks-shake .25s; }
@keyframes ks-shake { 25% { margin-left: -3px; } 75% { margin-left: 3px; } }
.ks-board.is-won .ks-card { cursor: default; }
.cg-stage.is-loading .ks-board { opacity: .7; }
@media (max-width: 520px) {
    .ks-corner { font-size: calc(var(--cw) * .3); }
    .ks-corner--b { display: none; }
    .ks-pip { top: 60%; font-size: calc(var(--cw) * .46); }
}
@media (prefers-reduced-motion: reduce) { .ks-card { transition: none; } }

/* ===================== Шарики ===================== */
.ln-board {
    --ln: min(100%, 468px);
    width: var(--ln); aspect-ratio: 1; margin: 0 auto; box-sizing: border-box;
    display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 3px; padding: 3px;
    background: #8f897e; border-radius: 6px; user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.cg-stage--full .ln-board { --ln: min(94vw, calc(100vh - 230px), calc(100dvh - 230px), 760px); }
.ln-cell { position: relative; background: #d9d3c7; border-radius: 3px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.ln-cell:hover { background: #e3ddd1; }
.ln-ball { position: absolute; inset: 12%; border-radius: 50%; pointer-events: none; }
.ln-ball.c1 { background: radial-gradient(circle at 34% 30%, #fff 0, #ff8787 18%, #e03131 52%, #8c1d1d 100%); }
.ln-ball.c2 { background: radial-gradient(circle at 34% 30%, #fff 0, #8ce99a 18%, #2f9e44 52%, #1b5e2b 100%); }
.ln-ball.c3 { background: radial-gradient(circle at 34% 30%, #fff 0, #74c0fc 18%, #1c7ed6 52%, #0f3f73 100%); }
.ln-ball.c4 { background: radial-gradient(circle at 34% 30%, #fff 0, #ffe066 18%, #fab005 52%, #a06a00 100%); }
.ln-ball.c5 { background: radial-gradient(circle at 34% 30%, #fff 0, #99e9f2 18%, #15aabf 52%, #0b5f6b 100%); }
.ln-ball.c6 { background: radial-gradient(circle at 34% 30%, #fff 0, #e599f7 18%, #ae3ec9 52%, #5f1f70 100%); }
.ln-ball.c7 { background: radial-gradient(circle at 34% 30%, #fff 0, #d9a679 18%, #8d5524 52%, #4a2a10 100%); }
.ln-ball[class*=" c"] { box-shadow: 0 2px 3px rgba(0, 0, 0, .3); }
.ln-ball.is-sel { animation: ln-bounce .5s ease-in-out infinite alternate; }
@keyframes ln-bounce { from { transform: translateY(6%); } to { transform: translateY(-14%); } }
.ln-ball.is-grow { animation: ln-grow .28s ease-out; }
@keyframes ln-grow { from { transform: scale(.2); } to { transform: scale(1); } }
.ln-ball.is-pop { animation: ln-pop .4s ease-in forwards; }
@keyframes ln-pop { to { transform: scale(1.35); opacity: 0; } }
.ln-ball.is-shake { animation: ks-shake .25s; }
.ln-next { display: inline-flex; gap: 4px; height: 22px; align-items: center; }
.ln-next .ln-mini { position: relative; inset: auto; display: block; width: 18px; height: 18px; }
.ln-board.is-over .ln-cell { cursor: default; }
@media (prefers-reduced-motion: reduce) { .ln-ball.is-sel, .ln-ball.is-grow, .ln-ball.is-pop { animation: none; } }

/* ===================== Маджонг ===================== */
.cg-stage--madzhong { max-width: 1040px; }
.cg-stage--madzhong .cg-board-wrap { display: block; }
.mj-board {
    --mw: 48px; --mh: 64px; --md: 6px;
    position: relative; margin: 0 auto; isolation: isolate; z-index: 0;
    background: #2f5d46; border-radius: 6px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .25), inset 0 0 70px rgba(0, 0, 0, .28);
    user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.mj-tile {
    position: absolute; left: 0; top: 0; width: var(--mw); height: var(--mh); box-sizing: border-box;
    border-radius: calc(var(--mw) * .1);
    background: linear-gradient(135deg, #fffef9 0%, #f6efdc 100%);
    border: 1px solid #cfc3a3;
    /* торец фишки: вниз-вправо на толщину --md, ниже — тень на стол */
    box-shadow:
        calc(var(--md) * .34) calc(var(--md) * .34) 0 #e9dfc4,
        calc(var(--md) * .67) calc(var(--md) * .67) 0 #d9caa3,
        var(--md) var(--md) 0 #b9a679,
        calc(var(--md) + 1px) calc(var(--md) + 1px) 0 #8d7b53,
        calc(var(--md) + 2px) calc(var(--md) + 4px) 8px rgba(0, 0, 0, .35);
    cursor: pointer; -webkit-tap-highlight-color: transparent;
    transition: opacity .22s, filter .15s;
}
/* нижние слои чуть темнее — так видно, что лежит выше */
.mj-tile[data-z="0"] { background: linear-gradient(135deg, #f4ecd8 0%, #e6dabb 100%); }
.mj-tile[data-z="1"] { background: linear-gradient(135deg, #f9f3e3 0%, #ede3c8 100%); }
.mj-tile svg { position: absolute; inset: 6% 7%; width: 86%; height: 88%; display: block; pointer-events: none; }
.mj-tile:hover { filter: brightness(1.04); }
.mj-tile.is-sel { background: linear-gradient(135deg, #fff3bf 0%, #ffe066 100%); border-color: #f08c00; }
.mj-tile.is-hint { animation: mj-hint 1.2s ease-out 1; }
@keyframes mj-hint { 0%, 60% { background: #c3fae8; border-color: #12b886; } 100% { background: linear-gradient(135deg, #fffef9 0%, #f6efdc 100%); } }
.mj-tile.is-gone { opacity: 0; pointer-events: none; }
.mj-tile.is-shake { animation: ks-shake .25s; }
.mj-board.is-won .mj-tile { cursor: default; }
.mj-toast { top: 12px; }
.cg-stage.is-loading .mj-board { opacity: .7; }
@media (prefers-reduced-motion: reduce) { .mj-tile { transition: none; } }

/* ===================== Паук (карты — общие ks-* с косынкой) ===================== */
.cg-stage--pauk { max-width: 940px; }
.cg-stage--pauk .cg-board-wrap { display: block; }
.pk-found { border-style: dashed; }
.pk-stock span { display: none; }
.ks-card.is-hint { box-shadow: 0 0 0 3px #ffd43b, 0 4px 12px rgba(0, 0, 0, .35); }
.ks-slot.is-hint { border-color: #ffd43b; }
.ks-slot.is-shake { animation: ks-shake .25s; }
.pk-toast {
    position: absolute; left: 50%; top: calc(var(--ch) + 8px); z-index: 400; transform: translate(-50%, -6px);
    max-width: 90%; padding: 8px 14px; border-radius: 8px; background: rgba(20, 20, 20, .88); color: #fff;
    font: 500 14px/1.35 'Inter', sans-serif; text-align: center; pointer-events: none;
    opacity: 0; transition: opacity .2s, transform .2s;
}
.pk-toast.is-on { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 520px) {
    /* Узкие карты наполовину закрыты соседними — масть ставим рядом с достоинством, а не под ним. */
    .cg-stage--pauk .ks-corner { flex-direction: row; align-items: baseline; font-size: calc(var(--cw) * .32); left: 3%; letter-spacing: -.06em; }
    .cg-stage--pauk .ks-corner i { font-size: .95em; margin: 0 0 0 1px; }
    .cg-stage--pauk .ks-pip { display: none; }
}

/* ===================== Судоку ===================== */
.sd-wrap { width: min(100%, 520px); display: flex; flex-direction: column; gap: 12px; }
.cg-stage--full .sd-wrap { width: min(94vw, calc(100vh - 290px), 720px); width: min(94vw, calc(100dvh - 290px), 720px); }
.sd-board {
    /* Строки и столбцы строго поровну: с «1fr» без minmax(0,…) пустая строка/столбец (ни одной цифры) сжималась вдвое */
    display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); grid-template-rows: repeat(9, minmax(0, 1fr)); aspect-ratio: 1;
    border: 2px solid #2b2925; background: #fffdf8;
    container-type: inline-size; user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.sd-cell {
    display: flex; align-items: center; justify-content: center; position: relative;
    border-right: 1px solid #d8d0c0; border-bottom: 1px solid #d8d0c0;
    font: 500 6.4cqw/1 'Inter', sans-serif; color: #1c62b9; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.sd-cell:nth-child(9n) { border-right: 0; }
.sd-cell:nth-child(n+73) { border-bottom: 0; }
.sd-cell.bR { border-right: 2px solid #2b2925; }
.sd-cell.bB { border-bottom: 2px solid #2b2925; }
.sd-cell.is-given { color: #141414; font-weight: 700; }
.sd-cell.is-peer { background: #f3ede1; }
.sd-cell.is-same { background: #e4dccb; }
.sd-cell.is-sel { background: #f6dfb8; }
.sd-cell.is-bad { color: #c92a2a; }
.sd-cell.is-bad.is-given { background: #f8e1dc; }
.sd-notes { position: absolute; inset: 6%; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); }
.sd-notes i { display: flex; align-items: center; justify-content: center; font: 500 2.2cqw/1 'Inter', sans-serif; font-style: normal; color: #6b6458; }
.sd-board.is-won .sd-cell { background: #e3f1dc; cursor: default; }
.sd-pad { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 6px; }   /* ряд цифр 1–9, ниже «заметки» (показать/спрятать) и «отменить» */
.sd-key--notes { grid-column: span 5; }
.sd-key--undo { grid-column: span 4; }
.sd-key--tool small { font-size: 11px; }
.sd-key {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 50px; padding: 4px 0;
    background: #fffdf8; border: 1px solid #d8d0c0; cursor: pointer; color: #141414;
    font: 600 22px/1 'Inter', sans-serif; -webkit-tap-highlight-color: transparent;
}
.sd-key:hover { border-color: #141414; }
.sd-key small { font-size: 10px; font-weight: 500; color: #7a756c; min-height: 10px; }
.sd-key.is-done { opacity: .35; }
.sd-key--tool { font-size: 0; }
.sd-key.is-active { background: #141414; border-color: #141414; color: #fff; }
.sd-key.is-active small { color: #d8d0c0; }
.sd-key:disabled { opacity: .4; cursor: default; }
.cg-stage.is-loading .sd-board { opacity: .6; }

/* --- «Другие игры»: короткие карточки остальных игр каталога --- */
.cg-more { max-width: 720px; margin: 36px auto 12px; padding: 0 var(--lv-pad-x); box-sizing: content-box; }
.cg-more h2 { margin: 0 0 12px; font-family: 'Playfair Display', Georgia, serif; font-size: 28px; font-weight: 900; }
.cg-more-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 10px; }
.cg-more-card {
    display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px;
    background: #fffdf8; border: 1px solid #e3ddd1; color: #141414; text-decoration: none;
    transition: border-color .15s, transform .15s;
}
.cg-more-card:hover { border-color: #141414; transform: translateY(-1px); color: #141414; }
.cg-more-icon { flex: 0 0 40px; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; background: #f2eee6; color: #2b2925; }
.cg-more-card--saper .cg-more-icon { color: #c92a2a; }
.cg-more-card--kosynka .cg-more-icon { color: #2f5d46; }
.cg-more-card--sudoku .cg-more-icon { color: #1c62b9; }
.cg-more-card--puzzlum .cg-more-icon { color: #9775fa; }
.cg-more-card--tetrum .cg-more-icon { color: #4dabf7; }
.cg-more-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cg-more-label { font: 700 10.5px/1.2 'Inter', sans-serif; letter-spacing: .1em; text-transform: uppercase; color: #e8590c; }
.cg-more-title { font: 900 18px/1.2 'Playfair Display', Georgia, serif; color: #141414; }
.cg-more-desc { font: 14px/1.4 'PT Serif', Georgia, serif; color: #4b4740; }
.cg-more a.cg-more-all, .cg-more a.cg-more-all:visited { display: inline-block; margin-top: 12px; font: 600 14px/1.4 'Inter', sans-serif; color: #141414; }
.cg-more-card:hover .cg-more-title, .cg-more-all:hover { text-decoration: underline; }

/* всплывающий выбор цифры в судоку (мышь): 3×3, «5» над выбранной клеткой */
.sd-wrap { position: relative; }
.sd-pop {
    --k: 44px;
    position: absolute; z-index: 4;
    display: flex; flex-direction: column; gap: 2px; padding: 4px;
    background: #2b2925; box-shadow: 0 12px 28px rgba(20, 20, 20, .35);
}
.sd-pop[hidden] { display: none; }
.sd-pop-grid { display: grid; grid-template-columns: repeat(3, var(--k)); gap: 2px; }
.sd-pop-row { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.sd-pop button {
    width: 100%; height: var(--k); padding: 0;
    border: 0; background: #fffdf8; color: #141414; cursor: pointer;
    font: 600 calc(var(--k) * .5)/1 'Inter', sans-serif;
}
.sd-pop button:hover { background: #f6dfb8; }
.sd-pop button.is-on { background: #141414; color: #fff; }
.sd-pop button.is-done { color: #c8c0b0; }
.sd-pop .sd-pop-tool { height: calc(var(--k) * .7); font-size: calc(var(--k) * .3); font-weight: 600; background: #f2eee6; color: #4b4740; }
.sd-pop-cap { padding: 5px 2px 2px; font: 700 calc(var(--k) * .24)/1 'Inter', sans-serif; letter-spacing: .08em; text-transform: uppercase; color: #cfc8ba; }
/* второй набор цифр — заметки: серые и пониже основных (размер потом подберём по ощущению) */
.sd-pop-grid--notes button { height: calc(var(--k) * .78); font-size: calc(var(--k) * .4); font-weight: 500; background: #ece7dc; color: #8a8478; }
.sd-pop-grid--notes button:hover { background: #f6dfb8; color: #4b4740; }
.sd-pop-grid--notes button.is-on { background: #6b6458; color: #fff; }
.sd-pop-grid--notes button:disabled { opacity: .35; cursor: default; background: #ece7dc; color: #8a8478; }

/* --- Слово дня (wd): поле 6×5, экранная клавиатура, окно результата --- */
.wd-date { font: 700 15px/1.2 'Inter', sans-serif; color: #141414; }
.wd-wrap { position: relative; width: min(100%, 500px); display: flex; flex-direction: column; align-items: center; gap: 16px; }
.wd-grid { display: grid; grid-template-rows: repeat(6, 1fr); gap: 6px; width: min(100%, 330px); }
.cg-stage--full .wd-grid { width: min(90vw, calc((100vh - 330px) * .82), 420px); width: min(90vw, calc((100dvh - 330px) * .82), 420px); }
.cg-stage--full .wd-wrap { width: min(100%, 620px); }
.wd-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.wd-tile {
    aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
    font: 700 clamp(22px, 7vw, 32px)/1 'Inter', sans-serif; text-transform: uppercase; color: #141414;
    background: #fffdf8; border: 2px solid #ddd5c6; user-select: none;
}
.wd-tile.is-filled { border-color: #8b857a; animation: wd-pop .1s ease-out; }
.wd-tile--0, .wd-tile--1, .wd-tile--2 { color: #fff; border-color: transparent; }
.wd-tile--0 { background: #8f897e; }
.wd-tile--1 { background: #d4a52c; }
.wd-tile--2 { background: #3f8f55; }
.wd-tile.is-flip { animation: wd-flip .34s ease-in-out; }
.wd-row.is-shake { animation: wd-shake .4s; }
@keyframes wd-pop { from { transform: scale(1.08); } to { transform: none; } }
@keyframes wd-flip { 0% { transform: rotateX(0); } 50% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
@keyframes wd-shake { 0%, 100% { transform: none; } 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
.wd-msg {
    position: absolute; top: 4px; left: 50%; z-index: 3; transform: translateX(-50%);
    padding: 9px 14px; font: 600 14px/1.2 'Inter', sans-serif; color: #fff; background: #141414;
    white-space: nowrap; pointer-events: none; box-shadow: 0 6px 18px rgba(20, 20, 20, .2);
}
.wd-msg[hidden] { display: none; }

.wd-kb { width: 100%; display: flex; flex-direction: column; gap: 6px; touch-action: manipulation; }
.wd-kb-row { display: flex; gap: 5px; justify-content: center; }
.wd-key {
    flex: 1 1 0; min-width: 0; max-width: 42px; height: 52px; padding: 0;
    display: flex; align-items: center; justify-content: center;
    font: 600 17px/1 'Inter', sans-serif; text-transform: uppercase; color: #141414;
    background: #e3ddd1; border: 0; border-radius: 4px; cursor: pointer; user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.wd-key:hover { background: #d8d0c0; }
.wd-key:active { transform: translateY(1px); }
.wd-key--wide { flex: 1.6 1 0; max-width: 68px; font-size: 12px; text-transform: none; }
.wd-key--0 { background: #8f897e; color: #fff; }
.wd-key--1 { background: #d4a52c; color: #fff; }
.wd-key--2 { background: #3f8f55; color: #fff; }
.wd-key--0:hover, .wd-key--1:hover, .wd-key--2:hover { filter: brightness(.95); background-image: none; }
.cg-stage--full .wd-key { height: 58px; max-width: 50px; }
.cg-stage--full .wd-key--wide { max-width: 80px; }
.wd-yesterday { color: #141414; letter-spacing: .04em; }

.wd-result { gap: 14px; }
.wd-answer { display: flex; gap: 5px; justify-content: center; }
.wd-answer span {
    width: 42px; height: 42px; display: flex; align-items: center; justify-content: center;
    font: 700 22px/1 'Inter', sans-serif; text-transform: uppercase; color: #fff; background: #3f8f55;
}
.wd-answer span.is-miss { background: #141414; }
.wd-stats { display: flex; flex-direction: column; gap: 10px; padding-top: 2px; }
.wd-stats-nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.wd-stat { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.wd-stat b { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; color: #141414; }
.wd-stat small { font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase; color: #7a756c; }
.wd-dist { display: flex; flex-direction: column; gap: 3px; }
.wd-dist-row { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.wd-dist-n { width: 10px; font-weight: 600; color: #7a756c; }
.wd-dist-bar { display: block; padding: 2px 6px; text-align: right; font-weight: 600; color: #fff; background: #8f897e; box-sizing: border-box; }
.wd-dist-bar.is-now { background: #3f8f55; }
.wd-next { margin: 0; font-size: 13.5px; color: #33312d; font-variant-numeric: tabular-nums; }
.wd-next a { color: #141414; font-weight: 600; }

@media (max-width: 520px) {
    .wd-kb-row { gap: 4px; }
    .wd-key { height: 48px; font-size: 15px; }
    .wd-key--wide { font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
    .wd-tile.is-flip, .wd-tile.is-filled, .wd-row.is-shake { animation: none; }
}

/* ===================== Филворды ===================== */
.cg-stage--filvordy { max-width: 760px; }
.cg-stage--filvordy .cg-board-wrap { display: block; }
.fw-wrap { --fw: min(100%, 520px); width: var(--fw); margin: 0 auto; }
.cg-stage--full .fw-wrap { --fw: min(94vw, calc(100vh - 300px), calc(100dvh - 300px), 720px); }
.fw-theme { margin: 0 0 10px; text-align: center; font: 500 15px/1.3 'Inter', sans-serif; color: #5c5650; }
.fw-theme b { color: #141414; font-weight: 700; }
.fw-board {
    position: relative; width: 100%; aspect-ratio: 1; box-sizing: border-box; container-type: inline-size;
    display: grid; grid-template-columns: repeat(var(--fw-n, 6), minmax(0, 1fr)); grid-template-rows: repeat(var(--fw-n, 6), minmax(0, 1fr));
    background: #fffdf7; border: 2px solid #3b3631; border-radius: 6px; overflow: hidden;
    user-select: none; -webkit-user-select: none; touch-action: none;
}
.fw-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.fw-lines polyline { fill: none; stroke-width: .72; stroke-linecap: round; stroke-linejoin: round; }
.fw-found { opacity: .85; }
.fw-sel { stroke: #4dabf7; opacity: .55; }
.fw-cell {
    position: relative; z-index: 1; display: flex; align-items: center; justify-content: center;
    border-right: 1px solid rgba(59, 54, 49, .14); border-bottom: 1px solid rgba(59, 54, 49, .14);
    font: 700 calc(52cqw / var(--fw-n, 6))/1 'Inter', sans-serif; color: #2b2723; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.fw-cell.is-sel { color: #0b4f8a; }
.fw-cell.is-done { color: rgba(43, 39, 35, .78); cursor: default; }
.fw-cell.is-hint::before {
    content: ''; position: absolute; inset: 12%; z-index: -1; border-radius: 50%;
    border: 2px solid #f08c00; animation: fw-hint 1.2s ease-out 2;
}
.fw-cell.is-hint.is-done::before { display: none; }
@keyframes fw-hint { 0% { transform: scale(1.4); opacity: 0; } 40% { transform: scale(1); opacity: 1; } }
.fw-board.is-shake { animation: ks-shake .25s; }
.fw-board.is-over .fw-found { animation: fw-glow .6s ease-out; }
@keyframes fw-glow { 50% { opacity: 1; } }
.fw-toast { top: 10px; }
.fw-words { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 8px; justify-content: center; }
.fw-word { display: flex; gap: 2px; align-items: center; padding: 3px 6px; border-radius: 6px; background: #f1ede4; font: 600 14px/1.2 'Inter', sans-serif; text-transform: uppercase; letter-spacing: .04em; }
.fw-word.is-found { background: var(--fw-c); color: #1f1c19; }
.fw-slot { width: 13px; height: 17px; border-bottom: 2px solid #b5ab9c; text-align: center; font-size: 12px; line-height: 17px; color: #e8590c; }
.cg-stage.is-loading .fw-board { opacity: .7; }
@media (max-width: 520px) {
    .fw-slot { width: 10px; }
    .fw-word { padding: 3px 5px; font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) { .fw-cell.is-hint::before, .fw-board.is-shake { animation: none; } }

/* ===================== Таблицы Шульте ===================== */
.cg-stage--tablitsy-shulte { max-width: 720px; }
.cg-stage--tablitsy-shulte .cg-board-wrap { display: block; }
.sh-board { --sh: min(100%, 480px); position: relative; width: var(--sh); aspect-ratio: 1; margin: 0 auto; container-type: inline-size; }
.cg-stage--full .sh-board { --sh: min(94vw, calc(100vh - 230px), calc(100dvh - 230px), 720px); }
.sh-start {
    position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
    border: 2px dashed #b5ab9c; border-radius: 8px; background: #fffdf7; cursor: pointer; color: #141414; padding: 20px;
}
.sh-start span { font-size: 34px; }
.sh-start small { font: 500 14px/1.35 'Inter', sans-serif; color: #5c5650; max-width: 280px; }
.sh-start:hover { border-color: #141414; }
.sh-start[hidden], .sh-grid[hidden] { display: none; }
.sh-grid {
    position: absolute; inset: 0; display: grid; gap: 0;
    grid-template-columns: repeat(var(--sh-n, 5), minmax(0, 1fr)); grid-template-rows: repeat(var(--sh-n, 5), minmax(0, 1fr));
    border: 2px solid #141414; background: #fffdf7; user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.sh-cell {
    appearance: none; margin: 0; padding: 0; border: 0; border-right: 1px solid #c9c0b1; border-bottom: 1px solid #c9c0b1; border-radius: 0;
    background: transparent; color: #141414; cursor: pointer; -webkit-tap-highlight-color: transparent;
    font: 700 calc(46cqw / var(--sh-n, 5))/1 'Inter', sans-serif; font-variant-numeric: lining-nums;
}
.sh-cell.is-red { color: #c92a2a; }
.sh-board--gorbov .sh-cell { font-size: calc(40cqw / var(--sh-n, 7)); }
.sh-cell.is-ok { animation: sh-ok .35s ease-out; }
.sh-cell.is-bad { animation: sh-bad .4s ease-out; }
@keyframes sh-ok { from { background: #b2f2bb; } }
@keyframes sh-bad { from { background: #ffa8a8; } }
.sh-dot { position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; background: #e8590c; opacity: .55; pointer-events: none; }
/* При нечётной стороне в центре стоит число — вместо точки тонкое кольцо вокруг него. */
.sh-dot.is-ring { width: calc(78% / var(--sh-n, 5)); height: auto; aspect-ratio: 1; margin: 0; transform: translate(-50%, -50%); background: none; border: 2px solid #e8590c; opacity: .4; }
.sh-grid.is-done { animation: sh-done .6s ease-out; }
@keyframes sh-done { 40% { box-shadow: 0 0 0 6px rgba(47, 158, 68, .35); } }
.sh-board.is-turn .sh-grid { animation: sh-turn .35s ease-out; }
@keyframes sh-turn { from { opacity: .2; } }
.sh-next.is-red { color: #c92a2a; }
@media (max-width: 520px) { .cg-stage--tablitsy-shulte .cg-stats { gap: 10px; } .cg-stage--tablitsy-shulte .cg-stat b { font-size: 18px; } }
.cg-stage.is-loading .sh-board { opacity: .7; }
.sh-result { text-align: left; }
.sh-chart { display: block; width: 100%; height: auto; font: 500 10px 'Inter', sans-serif; }
.sh-axis { stroke: #b5ab9c; }
.sh-mean { stroke: #e8590c; stroke-dasharray: 4 3; }
.sh-mean-l { fill: #e8590c; font-weight: 600; }
.sh-line { fill: none; stroke: #1c7ed6; stroke-width: 2.4; stroke-linejoin: round; }
.sh-pt { fill: #fffdf8; stroke: #1c7ed6; stroke-width: 2; }
.sh-val { fill: #141414; font-weight: 700; }
.sh-tick { fill: #5c5650; }
.sh-res-idx { margin: 8px 0 0; display: grid; gap: 8px; }
.sh-res-row dt { font: 600 12px/1.3 'Inter', sans-serif; color: #5c5650; }
.sh-res-row dd { margin: 2px 0 0; font: 400 13px/1.35 'Inter', sans-serif; color: #3b3631; }
.sh-res-row dd b { font-size: 16px; color: #141414; margin-right: 6px; }
.sh-print { display: none; }
@media print {
    body.sh-printing > * { display: none !important; }
    body.sh-printing > .sh-print { display: block !important; }
    .sh-print-h { margin: 0 0 6mm; font: 600 12pt 'Inter', sans-serif; }
    .sh-print-grid { display: grid; grid-template-columns: repeat(2, 78mm); justify-content: center; gap: 9mm 14mm; }
    .sh-print-t { display: grid; grid-template-columns: repeat(var(--sh-n), 1fr); aspect-ratio: 1; border: 1.5pt solid #000; break-inside: avoid; }
    .sh-print-t span { display: flex; align-items: center; justify-content: center; border-right: .5pt solid #888; border-bottom: .5pt solid #888; font: 700 16pt 'Inter', sans-serif; color: #000; }
    .sh-print-t span.is-red { color: #d00; }
}
@media (prefers-reduced-motion: reduce) { .sh-cell.is-ok, .sh-cell.is-bad, .sh-grid.is-done, .sh-board.is-turn .sh-grid { animation: none; } }
