/* ============================================================
   [ANCHOR: CSS] Mario — стили сайта (пиксельная 8-бит эстетика)
     1. Переменные и база            -> [CSS-VARS]
     2. Кнопки и пиксельные карточки -> [CSS-UI]
     3. Шапка                        -> [CSS-HEADER]
     4. Главный экран                -> [CSS-HERO]
     5. Секции главной               -> [CSS-SECTIONS]
     6. Отзывы и форма               -> [CSS-REVIEWS]
     7. Игра                         -> [CSS-GAME]
     8. Подвал                       -> [CSS-FOOTER]
     9. Анимации и адаптив           -> [CSS-ANIM]
   Картинки декора (облака, холмы, кирпичи) — SVG из tools/make_sprites.py
   ============================================================ */

/* ---------- [CSS-VARS] ---------- */
:root {
    --sky: #5c94fc;
    --sky-deep: #3a6fd8;
    --red: #e52521;
    --red-dark: #9c1210;
    --q: #fca044;
    --q-dark: #c45c00;
    --q-light: #ffd8a0;
    --pipe: #43b047;
    --pipe-dark: #1e7d32;
    --pipe-light: #9be36a;
    --brick: #c84c0c;
    --brick-dark: #7a2a00;
    --coin: #fbd000;
    --ink: #111;
    --paper: #fffaf0;
    --muted: #5a4a3a;

    --font-pixel: "Press Start 2P", "Courier New", monospace;
    --font-body: "Rubik", system-ui, -apple-system, "Segoe UI", sans-serif;

    --px: 4px; /* «пиксель» рамок */
    --container: 1160px;
    --header-h: 64px;
}

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

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 12px); }

body {
    margin: 0;
    font-family: var(--font-body);
    font-size: 17px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--sky);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

img, video { max-width: 100%; display: block; }
a { color: inherit; }
button { font: inherit; }

.container {
    width: 100%;
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 20px;
}

.sr-only, .hp-field {
    position: absolute !important;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}
.hp-field { left: -9999px; }

.is-hidden { display: none !important; }

/* ---------- [CSS-UI] Кнопки и пиксельные карточки ---------- */

/* Рамка из box-shadow даёт «срезанные» углы — как у спрайтов 8-бит. */
.pixel-card {
    position: relative;
    background: var(--paper);
    box-shadow:
        0 calc(var(--px) * -1) 0 0 var(--ink),
        0 var(--px) 0 0 var(--ink),
        calc(var(--px) * -1) 0 0 0 var(--ink),
        var(--px) 0 0 0 var(--ink),
        calc(var(--px) * 2) calc(var(--px) * 3) 0 0 rgba(0, 0, 0, 0.28);
    margin: var(--px);
}

.btn {
    --btn-bg: var(--q);
    --btn-shade: var(--q-dark);
    --btn-light: var(--q-light);
    --btn-color: var(--ink);
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 20px 16px;
    margin: var(--px);
    font-family: var(--font-pixel);
    font-size: 12px;
    line-height: 1.4;
    letter-spacing: 0.02em;
    text-decoration: none;
    text-align: center;
    color: var(--btn-color);
    background: var(--btn-bg);
    border: 0;
    cursor: pointer;
    box-shadow:
        inset calc(var(--px) * -1) calc(var(--px) * -1) 0 0 var(--btn-shade),
        inset var(--px) var(--px) 0 0 var(--btn-light),
        0 calc(var(--px) * -1) 0 0 var(--ink),
        0 var(--px) 0 0 var(--ink),
        calc(var(--px) * -1) 0 0 0 var(--ink),
        var(--px) 0 0 0 var(--ink),
        0 calc(var(--px) * 2) 0 0 rgba(0, 0, 0, 0.3);
    transition: transform 0.08s steps(2), filter 0.15s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.06); }
.btn:active { transform: translateY(3px); }
.btn:focus-visible { outline: 3px dashed var(--ink); outline-offset: 8px; }
.btn[disabled], .btn-soon { filter: grayscale(0.8); opacity: 0.7; cursor: not-allowed; transform: none; }

.btn-primary { /* «?»-блок: значения по умолчанию */ }
.btn-pipe {
    --btn-bg: var(--pipe);
    --btn-shade: var(--pipe-dark);
    --btn-light: var(--pipe-light);
    --btn-color: #fff;
    text-shadow: 2px 2px 0 var(--pipe-dark);
}
.btn-ghost {
    --btn-bg: #fff;
    --btn-shade: #c9c9c9;
    --btn-light: #fff;
}
.btn-big { font-size: 16px; padding: 18px 28px 20px; }
.btn-small { font-size: 10px; padding: 10px 14px 12px; }
.btn-wide { width: calc(100% - var(--px) * 2); }

/* ---------- [CSS-HEADER] ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--red);
    border-bottom: var(--px) solid var(--ink);
    box-shadow: 0 var(--px) 0 rgba(0, 0, 0, 0.18);
}
.header-inner {
    display: flex;
    align-items: center;
    gap: 20px;
    min-height: var(--header-h);
}
.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #fff;
    flex-shrink: 0;
}
.logo-icon { width: 32px; height: 32px; image-rendering: pixelated; }
.logo-text {
    font-family: var(--font-pixel);
    font-size: 18px;
    text-shadow: 3px 3px 0 var(--ink);
}
.nav {
    display: flex;
    gap: 4px;
    margin-left: auto;
}
.nav a {
    padding: 10px 12px;
    font-family: var(--font-pixel);
    font-size: 10px;
    color: #fff;
    text-decoration: none;
    text-shadow: 2px 2px 0 var(--red-dark);
    border-bottom: var(--px) solid transparent;
}
.nav a:hover { border-bottom-color: #fff; }
.nav a.is-active { border-bottom-color: var(--coin); color: var(--coin); }
.nav a.nav-game {
    background: var(--pipe);
    text-shadow: 2px 2px 0 var(--pipe-dark);
    box-shadow: inset -3px -3px 0 var(--pipe-dark), inset 3px 3px 0 var(--pipe-light);
}
.nav a.nav-game.is-active { color: #fff; border-bottom-color: transparent; filter: brightness(1.1); }

.player-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 4px;
    background: rgba(0, 0, 0, 0.25);
    color: #fff;
    text-decoration: none;
    font-size: 14px;
    font-weight: 700;
    max-width: 180px;
}
.player-chip img, .player-chip .avatar-fallback { width: 28px; height: 28px; flex-shrink: 0; }
.player-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav-toggle {
    display: none;
    margin-left: auto;
    width: 44px; height: 40px;
    padding: 8px;
    background: var(--q);
    border: 0;
    cursor: pointer;
    box-shadow: inset -3px -3px 0 var(--q-dark), 0 0 0 3px var(--ink);
}
.nav-toggle span { display: block; height: 4px; margin: 4px 0; background: var(--ink); }

.avatar, .avatar-fallback {
    width: 28px; height: 28px;
    object-fit: cover;
    image-rendering: auto;
    background: var(--q);
    box-shadow: 0 0 0 2px var(--ink);
}
.avatar-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-pixel);
    font-size: 11px;
    color: var(--ink);
    flex-shrink: 0;
}
.avatar-fallback--big { width: 48px; height: 48px; font-size: 18px; }

/* ---------- [CSS-HERO] ---------- */
.hero, .page-hero {
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, var(--sky-deep) 0%, var(--sky) 55%);
    color: #fff;
}
.hero { min-height: min(88vh, 760px); display: flex; align-items: center; padding: 70px 0 120px; }

.sky-clouds { position: absolute; inset: 0; pointer-events: none; }
.cloud {
    position: absolute;
    width: 168px; height: 72px;
    background: url("../img/cloud.svg") no-repeat center / contain;
    image-rendering: pixelated;
    animation: cloud-drift linear infinite;
}
.cloud-1 { top: 12%; left: -10%; animation-duration: 70s; }
.cloud-2 { top: 26%; left: -10%; width: 112px; height: 48px; animation-duration: 95s; animation-delay: -40s; }
.cloud-3 { top: 6%; left: -10%; width: 224px; height: 96px; animation-duration: 120s; animation-delay: -80s; }

.hero-hills { position: absolute; left: 0; right: 0; bottom: 64px; height: 160px; pointer-events: none; }
.hill {
    position: absolute;
    bottom: 0;
    background: url("../img/hill.svg") no-repeat bottom / 100% 100%;
    image-rendering: pixelated;
}
.hill-big { left: 4%; width: 384px; height: 160px; }
.hill-small { right: 8%; width: 240px; height: 100px; }

.ground-strip {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 64px;
    background: url("../img/brick.svg") repeat-x left top / 64px 64px;
    image-rendering: pixelated;
    border-top: var(--px) solid var(--ink);
}

.hero-content { position: relative; z-index: 2; text-align: center; }
.hero-blocks {
    display: flex;
    justify-content: center;
    gap: 0;
    margin-bottom: 40px;
}
.q-block, .brick-block {
    position: relative;
    width: 56px; height: 56px;
    image-rendering: pixelated;
}
.q-block {
    padding: 0;
    border: 0;
    cursor: pointer;
    font-family: var(--font-pixel);
    font-size: 26px;
    color: var(--q-dark);
    text-shadow: 3px 3px 0 var(--ink);
    background: var(--q);
    box-shadow:
        inset -4px -4px 0 var(--q-dark),
        inset 4px 4px 0 var(--q-light),
        0 0 0 4px var(--ink);
    animation: q-shine 1.2s steps(1) infinite;
}
.q-block.is-bumped { animation: q-bump 0.25s steps(3); }
.q-block.is-empty {
    background: #9c6b30;
    color: transparent;
    text-shadow: none;
    box-shadow: inset -4px -4px 0 #5e3a12, inset 4px 4px 0 #c08a50, 0 0 0 4px var(--ink);
    animation: none;
    cursor: default;
}
.brick-block {
    background: url("../img/brick.svg") 0 0 / 56px 56px;
    box-shadow: 0 0 0 4px var(--ink);
    z-index: 1;
}
.coin-pop {
    position: absolute;
    left: 50%; top: -8px;
    width: 32px; height: 32px;
    margin-left: -16px;
    background: url("../img/icon-coin.svg") no-repeat center / contain;
    image-rendering: pixelated;
    pointer-events: none;
    animation: coin-pop 0.7s ease-out forwards;
}

.hero-kicker {
    margin: 0 0 14px;
    font-family: var(--font-pixel);
    font-size: 14px;
    color: var(--coin);
    text-shadow: 3px 3px 0 var(--ink);
}
.hero-title {
    margin: 0 0 22px;
    font-family: var(--font-pixel);
    font-size: clamp(44px, 9vw, 104px);
    line-height: 1.05;
    color: #fff;
    text-shadow:
        5px 5px 0 var(--red),
        10px 10px 0 var(--ink);
    letter-spacing: 0.04em;
}
.hero-sub {
    max-width: 640px;
    margin: 0 auto 28px;
    font-size: 19px;
    font-weight: 500;
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.35);
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; }
.hero-hint {
    margin: 28px 0 0;
    font-family: var(--font-pixel);
    font-size: 9px;
    opacity: 0.85;
}

/* Шапка внутренних страниц (Отзывы) */
.page-hero { padding: 60px 0 110px; text-align: center; }
.page-hero-inner { position: relative; z-index: 2; }
.page-title {
    margin: 0 0 18px;
    font-family: var(--font-pixel);
    font-size: clamp(28px, 6vw, 52px);
    text-shadow: 4px 4px 0 var(--red), 8px 8px 0 var(--ink);
}
.page-sub { margin: 0 0 22px; font-size: 19px; font-weight: 500; }
.rating-big {
    font-family: var(--font-pixel);
    font-size: 1.3em;
    color: var(--coin);
    text-shadow: 3px 3px 0 var(--ink);
}

/* ---------- [CSS-SECTIONS] ---------- */
.section { padding: 80px 0; }
.section-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin: 0 0 44px;
    font-family: var(--font-pixel);
    font-size: clamp(18px, 3.4vw, 28px);
    line-height: 1.4;
    text-align: center;
}
.section-title--left { justify-content: flex-start; text-align: left; margin-bottom: 18px; }
.title-coin {
    width: 32px; height: 32px;
    flex-shrink: 0;
    background: url("../img/icon-coin.svg") no-repeat center / contain;
    image-rendering: pixelated;
    animation: coin-spin 1s steps(4) infinite;
}

/* Витрина — «подземный» уровень */
.vitrina { background: #1b1b2f; color: #fff; }
.vitrina .section-title { color: #fff; text-shadow: 3px 3px 0 var(--ink); }
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 32px;
}
.gallery-card { color: var(--ink); }
.gallery-photo { aspect-ratio: 3 / 2; overflow: hidden; background: var(--sky); }
.gallery-photo img { width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; transition: transform 0.3s; }
.gallery-card:hover .gallery-photo img { transform: scale(1.04); }
.gallery-caption { padding: 18px 20px 22px; }
.gallery-title { margin: 0 0 8px; font-family: var(--font-pixel); font-size: 14px; line-height: 1.5; }
.gallery-text { margin: 0; color: var(--muted); white-space: pre-line; }

.section-cta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    margin-top: 48px;
}
.cta-arrow {
    width: 0; height: 0;
    border-left: 14px solid transparent;
    border-right: 14px solid transparent;
    border-top: 18px solid var(--coin);
    animation: arrow-bounce 0.9s steps(2) infinite;
}

/* Блоки — «надземный» уровень с кирпичами */
.ofertas { background: var(--sky); }
.blocks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 32px;
}
.block-card-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 28px 22px 22px;
}
.block-badge {
    position: absolute;
    top: -22px; right: 18px;
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-pixel);
    font-size: 18px;
    color: var(--q-dark);
    background: var(--q);
    box-shadow: inset -3px -3px 0 var(--q-dark), inset 3px 3px 0 var(--q-light), 0 0 0 4px var(--ink);
    animation: q-shine 1.2s steps(1) infinite;
}
.block-title { margin: 0 0 12px; font-family: var(--font-pixel); font-size: 14px; line-height: 1.5; }
.block-body { margin: 0 0 22px; color: var(--muted); white-space: pre-line; flex-grow: 1; }
.btn-block { align-self: stretch; }

.empty-note {
    text-align: center;
    font-family: var(--font-pixel);
    font-size: 12px;
    line-height: 1.8;
}
.empty-note--small { font-size: 10px; }

/* Приглашение в игру */
.game-teaser {
    background:
        url("../img/bush.svg") repeat-x left bottom 64px / 216px 48px,
        url("../img/brick.svg") repeat-x left bottom / 64px 64px,
        linear-gradient(180deg, var(--sky) 0%, #8fb8ff 100%);
    image-rendering: pixelated;
    padding-bottom: 150px;
}
.teaser-inner {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 40px;
    align-items: center;
}
.teaser-text p { font-size: 18px; margin: 0 0 22px; }
.teaser-board { padding: 22px; }
.board-title { margin: 0 0 14px; font-family: var(--font-pixel); font-size: 13px; }
.mini-board { list-style: none; margin: 0; padding: 0; }
.mini-board li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 2px dashed rgba(0, 0, 0, 0.15);
}
.mini-rank { font-family: var(--font-pixel); font-size: 12px; width: 22px; color: var(--red); }
.mini-name { flex-grow: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-time { font-family: var(--font-pixel); font-size: 11px; }

/* Отзывы-призыв на главной */
.reviews-cta { background: #8fb8ff; padding-top: 40px; }
.cta-panel {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 28px 32px;
}
.cta-panel .section-title { margin-bottom: 8px; }
.cta-rating { margin: 0; font-size: 18px; }
.cta-panel .rating-big { color: var(--q-dark); text-shadow: 2px 2px 0 var(--ink); }

/* ---------- [CSS-REVIEWS] ---------- */
.reviews { background: var(--sky); }
.reviews-grid {
    columns: 3 300px;
    column-gap: 32px;
}
.review-card {
    break-inside: avoid;
    margin: var(--px) var(--px) 36px;
    display: inline-block;
    width: calc(100% - var(--px) * 2);
}
.review-photo { background: #000; }
.review-photo img, .review-photo video { width: 100%; max-height: 420px; object-fit: cover; }
.review-body { padding: 18px 20px 20px; }
.review-text { margin: 0; white-space: pre-line; }
.review-card--text .review-text::before {
    content: "“";
    display: block;
    height: 28px;
    font-family: var(--font-pixel);
    font-size: 36px;
    color: var(--red);
}
.review-author { margin: 12px 0 0; font-weight: 700; color: var(--muted); }
.review-stars { display: flex; gap: 4px; margin-bottom: 10px; }
.star {
    display: inline-block;
    width: 20px; height: 20px;
    background: url("../img/icon-star.svg") no-repeat center / contain;
    image-rendering: pixelated;
    filter: grayscale(1) opacity(0.3);
}
.star.is-on { filter: none; }

.review-form-section { background: #8fb8ff; }
.review-form {
    max-width: 680px;
    margin: 0 auto;
    padding: 30px 32px 26px;
}
.star-input {
    display: inline-flex;
    flex-direction: row-reverse;
    gap: 6px;
    margin: 0 0 18px;
    padding: 0;
    border: 0;
}
.star-input legend { float: left; width: 100%; margin-bottom: 8px; font-weight: 700; }
.star-input input { position: absolute; opacity: 0; pointer-events: none; }
.star-input label { cursor: pointer; padding: 2px; }
.star-input label .star { width: 34px; height: 34px; filter: grayscale(1) opacity(0.3); transition: transform 0.1s; }
.star-input input:checked ~ label .star,
.star-input label:hover .star,
.star-input label:hover ~ label .star { filter: none; }
.star-input label:hover .star { transform: scale(1.15); }
.star-input input:focus-visible + label { outline: 3px dashed var(--ink); }

.field { display: block; position: relative; margin-bottom: 18px; }
.field-label { display: block; margin-bottom: 6px; font-weight: 700; }
.field input, .field textarea {
    width: 100%;
    padding: 12px 14px;
    font: inherit;
    color: var(--ink);
    background: #fff;
    border: 0;
    box-shadow: 0 0 0 3px var(--ink), inset 3px 3px 0 rgba(0, 0, 0, 0.08);
    resize: vertical;
}
.field input:focus, .field textarea:focus { outline: none; box-shadow: 0 0 0 3px var(--ink), 0 0 0 7px var(--coin); }
.field-counter { position: absolute; right: 8px; bottom: 6px; font-size: 12px; color: var(--muted); }

.form-note { margin: 0 0 16px; color: var(--muted); }
.form-note--small { font-size: 14px; margin-top: 14px; margin-bottom: 0; }
.form-note--warn { padding: 10px 14px; background: #ffe2a8; color: var(--ink); }
.form-status { min-height: 1.5em; margin: 10px 0 0; font-weight: 700; }
.form-status.is-ok { color: var(--pipe-dark); }
.form-status.is-error { color: var(--red); }

/* ---------- [CSS-GAME] ---------- */
.game-section {
    background: #1b1b2f;
    padding: 36px 0 60px;
    min-height: calc(100vh - var(--header-h));
}
.game-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 28px;
    align-items: start;
}
.game-frame {
    position: relative;
    aspect-ratio: 5 / 3;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    box-shadow: 0 0 0 var(--px) var(--ink), 0 0 0 calc(var(--px) * 2) var(--q), 0 0 0 calc(var(--px) * 3) var(--ink);
    margin: calc(var(--px) * 3);
    overflow: hidden;
    touch-action: none;
}
.game-frame:has(.game-overlay--menu.is-visible) { touch-action: pan-y; }
#kart-canvas {
    display: block;
    width: 100%;
    height: auto;
    max-height: 100%;
    aspect-ratio: 5 / 3;
    flex: 0 0 auto;
    image-rendering: auto;
}
.game-overlay {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    text-align: center;
    color: #fff;
    background: rgba(10, 10, 40, 0.72);
    z-index: 3;
}
.game-overlay.is-visible { display: flex; }
.overlay-title {
    margin: 0 0 6px;
    font-family: var(--font-pixel);
    font-size: clamp(18px, 4vw, 34px);
    line-height: 1.3;
    text-shadow: 4px 4px 0 var(--red), 7px 7px 0 var(--ink);
}
.overlay-sub, .overlay-hint { margin: 0 0 8px; font-size: 15px; }
.overlay-hint { font-family: var(--font-pixel); font-size: 9px; opacity: 0.85; margin-top: 10px; }
.overlay-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.overlay-title--sm {
    font-size: clamp(12px, 2.8vw, 18px);
    text-shadow: 2px 2px 0 var(--red), 4px 4px 0 var(--ink);
    margin-bottom: 2px;
}
.game-overlay--menu {
    justify-content: flex-start;
    overflow-y: auto;
    gap: 6px;
    padding: 10px 12px 14px;
    touch-action: pan-y;
}
.overlay-actions--menu { margin-top: 4px; }
.overlay-status { margin: 0; min-height: 1.2em; font-size: 13px; }
.picker-label {
    margin: 4px 0 0;
    font-family: var(--font-pixel);
    font-size: 8px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.85;
}
.kart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    width: min(100%, 380px);
}
.kart-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    text-align: left;
    color: #fff;
    background: rgba(0, 0, 0, 0.45);
    border: 3px solid rgba(255, 255, 255, 0.35);
    cursor: pointer;
    font: inherit;
}
.kart-chip:hover { border-color: #fff; }
.kart-chip.is-on {
    border-color: #111;
    box-shadow: 0 0 0 3px var(--kart, var(--coin));
    background: rgba(0, 0, 0, 0.7);
}
.kart-chip--shroom { --kart: #e52521; }
.kart-chip--bolt { --kart: #fbd000; }
.kart-chip--drift { --kart: #43b047; }
.kart-chip--tank { --kart: #5c94fc; }
.kart-chip-art {
    width: 48px;
    height: 36px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.08);
}
.kart-chip-meta { min-width: 0; }
.kart-chip-name {
    display: block;
    font-family: var(--font-pixel);
    font-size: 8px;
    line-height: 1.3;
}
.kart-chip-tag {
    display: block;
    margin-top: 3px;
    font-size: 11px;
    opacity: 0.8;
}
.level-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    width: min(100%, 380px);
}
.level-chip {
    min-width: 72px;
    padding: 8px 10px;
    color: #fff;
    background: rgba(0, 0, 0, 0.45);
    border: 3px solid rgba(255, 255, 255, 0.35);
    cursor: pointer;
    font: inherit;
}
.level-chip strong {
    display: block;
    font-family: var(--font-pixel);
    font-size: 8px;
    line-height: 1.3;
}
.level-chip span {
    display: block;
    margin-top: 3px;
    font-size: 11px;
    opacity: 0.8;
}
.level-chip:hover { border-color: #fff; }
.level-chip.is-on {
    border-color: #111;
    box-shadow: 0 0 0 3px var(--coin);
    background: rgba(251, 208, 0, 0.18);
}
.level-chip.is-locked {
    opacity: 0.45;
    cursor: not-allowed;
}
.level-chip.is-locked:hover { border-color: rgba(255, 255, 255, 0.35); }
.online-box { width: min(100%, 380px); display: flex; flex-direction: column; gap: 8px; }
.online-note { margin: 0; font-size: 13px; line-height: 1.35; }
.online-join { display: flex; gap: 8px; }
.online-input {
    width: 100%;
    padding: 8px 10px;
    color: #fff;
    background: rgba(0, 0, 0, 0.45);
    border: 3px solid rgba(255, 255, 255, 0.45);
    font: inherit;
}
.online-join .online-input { text-transform: uppercase; letter-spacing: 0.12em; font-family: var(--font-pixel); font-size: 12px; }
.room-code {
    margin: 0;
    font-family: var(--font-pixel);
    font-size: clamp(18px, 4vw, 28px);
    letter-spacing: 0.18em;
    color: var(--coin);
    text-shadow: 3px 3px 0 var(--ink);
}
.room-list { list-style: none; margin: 0; padding: 0; width: min(100%, 380px); text-align: left; }
.room-player {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 4px;
    border-bottom: 2px dashed rgba(255, 255, 255, 0.2);
    font-size: 14px;
}
.room-player b { font-family: var(--font-pixel); font-size: 8px; color: var(--coin); }
.room-player button { margin-left: auto; }
.finish-time {
    margin: 0;
    font-family: var(--font-pixel);
    font-size: clamp(22px, 5vw, 40px);
    color: var(--coin);
    text-shadow: 4px 4px 0 var(--ink);
}
.finish-place { margin: 0; font-family: var(--font-pixel); font-size: 13px; }
.finish-laps { margin: 0; font-size: 14px; opacity: 0.85; }
.finish-save { margin: 4px 0 8px; font-weight: 700; min-height: 1.4em; }

.game-toolbar {
    position: absolute;
    top: 6px; right: 6px;
    display: flex;
    gap: 6px;
    z-index: 4;
}
.tool-btn {
    width: 34px; height: 34px;
    padding: 0;
    font-size: 15px;
    line-height: 34px;
    color: #fff;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.6);
    cursor: pointer;
}
.tool-btn:hover { background: rgba(0, 0, 0, 0.75); }

.touch-controls {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0;
    padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px));
    background: #12162a;
    box-shadow: inset 0 4px 0 #000;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: none;
}
.touch-group { display: flex; align-items: center; gap: 10px; }
.touch-btn {
    width: 78px;
    height: 78px;
    padding: 0;
    font-family: var(--font-pixel);
    font-size: 18px;
    line-height: 1;
    color: #fff;
    background: #2a3148;
    border: 3px solid #fff;
    border-radius: 16px;
    box-shadow: 0 4px 0 #000;
    -webkit-tap-highlight-color: transparent;
}
.touch-btn.is-down { background: #fbd000; color: #111; transform: translateY(2px); box-shadow: 0 2px 0 #000; }
.touch-btn--gas {
    width: 108px;
    height: 88px;
    border-radius: 44px;
    font-size: 13px;
    background: #1e7d32;
    border-color: #9be36a;
}
.touch-btn--gas.is-down { background: #9be36a; color: #111; }
.touch-btn--brake { background: #9c1210; border-color: #ff8a80; font-size: 9px; }
.touch-btn--brake.is-down { background: #ff8a80; color: #111; }

.game-side { display: flex; flex-direction: column; gap: 26px; }
.game-side .pixel-card { padding: 20px; }
.side-title { margin: 0 0 12px; font-family: var(--font-pixel); font-size: 13px; line-height: 1.4; }
.profile-card p { margin: 0 0 12px; font-size: 15px; }
.profile-row { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }
.profile-avatar img { width: 48px; height: 48px; object-fit: cover; box-shadow: 0 0 0 3px var(--ink); }
.profile-name { font-weight: 900; font-size: 18px; margin: 0 !important; }
.profile-best { font-family: var(--font-pixel); font-size: 10px; margin: 6px 0 0 !important; }
.link-wait { margin-top: 10px; padding: 12px; background: #e9f7e3; }
.link-fallback { font-weight: 700; }

.leaderboard { list-style: none; margin: 0; padding: 0; max-height: 460px; overflow-y: auto; }
.leader-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 4px;
    border-bottom: 2px dashed rgba(0, 0, 0, 0.12);
}
.leader-row.is-me { background: #fff1b8; }
.leader-row:nth-child(1) .leader-rank { color: #d4a400; }
.leader-row:nth-child(2) .leader-rank { color: #8a8a8a; }
.leader-row:nth-child(3) .leader-rank { color: #b0602a; }
.leader-rank { font-family: var(--font-pixel); font-size: 11px; width: 26px; text-align: right; color: var(--muted); }
.leader-name { flex-grow: 1; font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leader-time { font-family: var(--font-pixel); font-size: 10px; }
.leader-empty { padding: 8px 0; color: var(--muted); }

.help-list { margin: 0; padding-left: 18px; font-size: 14px; }
.help-list li { margin-bottom: 6px; }
kbd {
    display: inline-block;
    min-width: 22px;
    padding: 1px 5px;
    font-family: var(--font-pixel);
    font-size: 9px;
    text-align: center;
    background: #fff;
    box-shadow: 0 0 0 2px var(--ink), 0 3px 0 2px var(--ink);
    margin: 0 2px 4px;
}

/* ---------- [CSS-FOOTER] ---------- */
.site-footer { background: #8fb8ff; }
.page-game .site-footer, .page-home .site-footer { background: #8fb8ff; }
.footer-bushes {
    height: 48px;
    background: url("../img/bush.svg") repeat-x left bottom / 216px 48px;
    image-rendering: pixelated;
}
.footer-ground {
    background: url("../img/brick.svg") repeat left top / 64px 64px;
    image-rendering: pixelated;
    border-top: var(--px) solid var(--ink);
    color: #fff;
    padding: 28px 0 32px;
}
.footer-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.footer-inner > * { text-shadow: 2px 2px 0 var(--ink); }
.footer-brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-pixel); font-size: 14px; }
.footer-brand img { image-rendering: pixelated; }
.footer-nav { display: flex; gap: 18px; font-family: var(--font-pixel); font-size: 10px; }
.footer-nav a { text-decoration: none; }
.footer-nav a:hover { color: var(--coin); }
.footer-note { margin: 0; font-size: 14px; width: 100%; text-align: center; }

/* ---------- [CSS-ANIM] Анимации ---------- */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity 0.5s, transform 0.5s steps(6); }
.reveal.is-visible { opacity: 1; transform: none; }

@keyframes cloud-drift {
    from { transform: translateX(0); }
    to { transform: translateX(calc(100vw + 260px)); }
}
@keyframes q-shine {
    0%, 60% { color: var(--q-dark); }
    70% { color: #fff3c4; }
    85% { color: #ffb347; }
}
@keyframes q-bump {
    0% { transform: translateY(0); }
    50% { transform: translateY(-14px); }
    100% { transform: translateY(0); }
}
@keyframes coin-pop {
    0% { transform: translateY(0) scaleX(1); opacity: 1; }
    25% { transform: translateY(-50px) scaleX(0.3); }
    50% { transform: translateY(-80px) scaleX(1); }
    75% { transform: translateY(-70px) scaleX(0.3); opacity: 1; }
    100% { transform: translateY(-40px) scaleX(1); opacity: 0; }
}
@keyframes coin-spin {
    0% { transform: scaleX(1); }
    25% { transform: scaleX(0.5); }
    50% { transform: scaleX(0.15); }
    75% { transform: scaleX(0.5); }
}
@keyframes arrow-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(6px); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
    .reveal { opacity: 1; transform: none; }
    html { scroll-behavior: auto; }
}

/* ---------- Адаптив ---------- */
@media (max-width: 980px) {
    .game-layout { grid-template-columns: 1fr; }
    .game-side { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
    .teaser-inner { grid-template-columns: 1fr; }
}

@media (max-width: 1024px), (hover: none) and (pointer: coarse) {
    .hide-touch { display: none; }
    .page-game .game-section { padding: 0; }
    .page-game .game-layout { padding: 0; }
    .page-game .game-main {
        display: flex;
        flex-direction: column;
        height: calc(100dvh - var(--header-h));
    }
    .page-game .game-frame {
        flex: 1 1 auto;
        aspect-ratio: auto;
        min-height: 0;
        height: auto;
        margin: 0;
    }
    .page-game .touch-controls {
        display: flex;
        position: sticky;
        bottom: 0;
        z-index: 20;
        flex: 0 0 auto;
    }
}

html.is-cockpit,
html.is-cockpit body { overflow: hidden; height: 100%; }
html.is-cockpit .site-header,
html.is-cockpit .site-footer,
html.is-cockpit .game-side { display: none; }
html.is-cockpit .game-section {
    padding: 0;
    min-height: 100dvh;
}
html.is-cockpit .game-layout { padding: 0; }
html.is-cockpit .game-main { height: 100dvh; min-height: 100dvh; }
html.is-cockpit .game-frame {
    margin: 0;
    touch-action: none;
}
html.is-cockpit .touch-controls { display: flex; }

@media (max-width: 820px) {
    .nav-toggle { display: block; }
    .nav {
        display: none;
        position: absolute;
        top: 100%; left: 0; right: 0;
        flex-direction: column;
        gap: 0;
        padding: 8px 20px 16px;
        background: var(--red);
        border-bottom: var(--px) solid var(--ink);
    }
    .nav.is-open { display: flex; }
    .nav a { padding: 14px 8px; font-size: 12px; border-bottom: 2px solid rgba(0, 0, 0, 0.15); }
    .nav a.nav-game { margin-top: 8px; text-align: center; }
    .header-inner { position: relative; gap: 12px; }
    .player-chip { order: 2; margin-left: auto; max-width: 140px; }
    .nav-toggle { order: 3; margin-left: 0; }
    .player-chip + .nav-toggle { margin-left: 0; }
}

@media (max-width: 560px) {
    body { font-size: 16px; }
    .section { padding: 60px 0; }
    .hero { padding: 40px 0 110px; }
    .q-block, .brick-block { width: 44px; height: 44px; font-size: 20px; }
    .brick-block { background-size: 44px 44px; }
    .hero-sub { font-size: 17px; }
    .hill-big { width: 260px; height: 110px; }
    .hill-small { display: none; }
    .logo-text { font-size: 14px; }
    .player-chip-name { display: none; }
    .player-chip { padding: 4px; }
    .review-form { padding: 24px 18px 20px; }
    .cta-panel { padding: 22px 20px; }
    .touch-btn { width: 68px; height: 68px; font-size: 16px; }
    .touch-btn--gas { width: 96px; height: 78px; }
    .touch-btn--brake { font-size: 8px; }
}
