:root {
    --ink: #1f2430;
    --muted: #657080;
    --paper: #fffaf0;
    --panel: rgba(255, 250, 240, 0.94);
    --line: rgba(31, 36, 48, 0.14);
    --red: #d94b3d;
    --red-dark: #9c2c25;
    --teal: #178f88;
    --blue: #256db8;
    --gold: #e1a829;
    --green: #2f8c4c;
    --shadow: 0 18px 50px rgba(31, 36, 48, 0.24);
    --top-control-offset: calc(18px + env(safe-area-inset-top, 0px));
    --start-edge-top: calc(42px + env(safe-area-inset-top, 0px));
    --menu-ad-content-clearance: calc(var(--top-control-offset) + 184px);
    --modal-edge-top: calc(18px + env(safe-area-inset-top, 0px));
    --modal-edge-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    --modal-vertical-reserve: calc(var(--modal-edge-top) + var(--modal-edge-bottom));
    --ad-banner-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    --ad-banner-lift: calc(68px + env(safe-area-inset-bottom, 0px));
    --longshot-hud-ad-gap: 26px;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
}

body {
    margin: 0;
    overflow: hidden;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #8ed0dc;
    color: var(--ink);
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

canvas {
    display: block;
    width: 100vw;
    height: 100vh;
}

button {
    font: inherit;
}

#ui-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.hidden {
    display: none !important;
}

.premium-no-ads #menu-ad-area,
.premium-no-ads #remove-ads-btn,
.premium-no-ads #menu-remove-ads-btn {
    display: none !important;
}

#top-hud {
    position: absolute;
    top: var(--top-control-offset);
    left: 50%;
    z-index: 40;
    width: min(148px, calc(100vw - 178px));
    transform: translateX(-50%);
    display: grid;
    grid-template-columns: 1fr;
    align-items: center;
    justify-items: stretch;
    gap: 7px;
    padding: 9px 10px;
    border: 1px solid rgba(255, 255, 255, 0.48);
    border-radius: 8px;
    background: rgba(31, 36, 48, 0.66);
    color: white;
    box-shadow: 0 10px 28px rgba(31, 36, 48, 0.18);
    backdrop-filter: blur(14px);
}

#mode-label {
    display: none;
}

#timer {
    width: 100%;
    padding: 6px 9px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.16);
    font-variant-numeric: tabular-nums;
    font-size: 1rem;
    font-weight: 900;
    text-align: center;
}

.icon-btn {
    position: absolute;
    top: var(--top-control-offset);
    right: 18px;
    z-index: 200;
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.42);
    border-radius: 8px;
    background: rgba(31, 36, 48, 0.66);
    color: white;
    font-size: 1.45rem;
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 0 10px 28px rgba(31, 36, 48, 0.18);
    backdrop-filter: blur(14px);
    transition: transform 0.12s ease, background 0.16s ease;
}

.icon-btn:hover {
    background: rgba(31, 36, 48, 0.78);
}

.icon-btn:active {
    transform: translateY(1px) scale(0.97);
}

.game-home-btn {
    position: absolute;
    top: var(--top-control-offset);
    left: 18px;
    z-index: 200;
    min-width: 76px;
    height: 46px;
    display: grid;
    place-items: center;
    padding: 0 14px;
    border: 1px solid rgba(255, 255, 255, 0.42);
    border-radius: 8px;
    background: rgba(31, 36, 48, 0.66);
    color: white;
    cursor: pointer;
    font-size: 0.92rem;
    font-weight: 950;
    letter-spacing: 0;
    pointer-events: auto;
    box-shadow: 0 10px 28px rgba(31, 36, 48, 0.18);
    backdrop-filter: blur(14px);
    transition: transform 0.12s ease, background 0.16s ease;
}

.game-home-btn:hover {
    background: rgba(31, 36, 48, 0.78);
}

.game-home-btn:active {
    transform: translateY(1px) scale(0.97);
}

#ranking-btn {
    right: 74px;
}

#game-restart-btn {
    right: 74px;
}

.play-tip {
    position: absolute;
    left: 50%;
    bottom: calc(26px + env(safe-area-inset-bottom));
    z-index: 30;
    max-width: min(520px, calc(100vw - 32px));
    transform: translateX(-50%);
    padding: 10px 14px;
    border-radius: 8px;
    background: rgba(255, 250, 240, 0.86);
    color: var(--ink);
    font-size: 0.88rem;
    font-weight: 800;
    text-align: center;
    box-shadow: 0 10px 28px rgba(31, 36, 48, 0.18);
    backdrop-filter: blur(14px);
}

#archery-hud {
    position: absolute;
    left: 50%;
    bottom: calc(var(--ad-banner-lift) + var(--longshot-hud-ad-gap));
    z-index: 42;
    width: max-content;
    max-width: calc(100vw - 28px);
    display: grid;
    grid-template-columns: auto auto;
    align-items: center;
    gap: 9px;
    transform: translateX(-50%);
    pointer-events: none;
}

body.game-ad-visible #archery-hud,
body.native-banner-active #archery-hud,
body.game-ad-visible .play-tip {
    bottom: calc(var(--ad-banner-lift) + var(--longshot-hud-ad-gap));
}

.hud-pill {
    min-height: 34px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    border-radius: 50px;
    background: rgba(31, 36, 48, 0.72);
    color: white;
    font-size: 0.82rem;
    font-weight: 900;
    box-shadow: 0 8px 22px rgba(31, 36, 48, 0.24);
}

#draw-meter {
    display: none;
    height: 16px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.86);
    border-radius: 50px;
    background: rgba(31, 36, 48, 0.45);
    box-shadow: 0 8px 22px rgba(31, 36, 48, 0.24);
}

#top-hud.longshot-hud #draw-meter {
    display: block;
}

#draw-fill {
    display: block;
    width: 100%;
    height: 100%;
    transform: scaleX(0);
    transform-origin: left center;
    background: linear-gradient(90deg, #f7d557, #ff4757);
    transition: transform 0.05s linear;
}

#archery-hud.draw-cancel .hud-pill {
    background: rgba(103, 52, 34, 0.84);
}

#top-hud.draw-cancel #draw-meter {
    border-color: rgba(255, 71, 87, 0.94);
    background: rgba(66, 36, 28, 0.66);
}

#top-hud.draw-cancel #draw-fill {
    background: linear-gradient(90deg, #9da7b3, #ff4757);
}

#start-screen {
    position: absolute;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--start-edge-top) 18px calc(150px + env(safe-area-inset-bottom, 0px));
    pointer-events: auto;
    overflow-y: auto;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.04) 0 32%, transparent 32% 100%),
        linear-gradient(180deg, rgba(16, 22, 31, 0.05), rgba(31, 36, 48, 0.18));
}

body.menu-ad-visible #start-screen {
    padding-top: max(var(--start-edge-top), var(--menu-ad-content-clearance));
}

.start-shell {
    position: relative;
    z-index: 5;
    width: min(560px, 100%);
    display: grid;
    gap: 14px;
    text-align: center;
    transform: translateY(-18px);
}

body.menu-ad-visible .start-shell {
    transform: translateY(8px);
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--red-dark);
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.start-shell h1 {
    margin: 0;
    color: white;
    font-size: clamp(1.95rem, 7vw, 3.25rem);
    line-height: 0.95;
    letter-spacing: 0;
    text-transform: uppercase;
    text-shadow:
        0 3px 0 rgba(31, 36, 48, 0.16),
        0 16px 34px rgba(31, 36, 48, 0.42);
}

.main-start-btn {
    justify-self: center;
    margin-top: 20px;
    min-width: 154px;
    min-height: 52px;
    padding: 0 32px;
    font-size: 1.02rem;
    background: var(--red);
    color: #fffaf0;
    text-transform: none;
    box-shadow:
        0 12px 24px rgba(217, 75, 61, 0.3),
        0 3px 0 rgba(122, 34, 27, 0.24);
}

.menu-ad-area {
    position: absolute;
    inset: 0;
    z-index: 4;
    pointer-events: none;
}

.menu-ad-offer {
    position: absolute;
    top: calc(var(--top-control-offset) + 16px);
    left: 50%;
    width: min(270px, calc(100vw - 28px));
    display: grid;
    gap: 7px;
    transform: translateX(-50%);
    pointer-events: none;
}

.menu-ad-promo {
    padding: 5px 10px 6px;
    border-radius: 8px;
    background: rgba(255, 250, 240, 0.8);
    color: var(--red-dark);
    font-family: "Comic Sans MS", "Marker Felt", "Chalkboard SE", ui-rounded, system-ui, sans-serif;
    font-size: 0.95rem;
    font-weight: 900;
    line-height: 1.12;
    text-align: center;
    text-shadow: 0 2px 0 rgba(255, 255, 255, 0.9);
    box-shadow: 0 8px 18px rgba(31, 36, 48, 0.14);
    transform: rotate(-1.5deg);
    pointer-events: none;
}

.menu-tagline {
    justify-self: center;
    width: min(520px, calc(100vw - 28px));
    color: white;
    font-size: 1rem;
    font-weight: 950;
    line-height: 1.08;
    text-align: center;
    text-shadow:
        0 2px 0 rgba(31, 36, 48, 0.18),
        0 10px 24px rgba(31, 36, 48, 0.38);
    pointer-events: none;
}

.menu-no-ads-btn {
    position: relative;
    justify-self: center;
    width: fit-content;
    max-width: min(208px, calc(100vw - 128px));
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid rgba(31, 36, 48, 0.14);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.88);
    color: var(--ink);
    font: inherit;
    font-size: 0.86rem;
    font-weight: 900;
    line-height: 1.08;
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 0 9px 20px rgba(31, 36, 48, 0.16);
    backdrop-filter: blur(14px);
    animation: remove-ads-nudge 2.8s ease-in-out infinite;
    overflow: hidden;
    transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}

.menu-no-ads-btn::before {
    content: "";
    position: absolute;
    inset: 2px;
    border-radius: 6px;
    border: 2px solid rgba(217, 75, 61, 0.42);
    opacity: 0;
    transform: scale(0.92);
    animation: remove-ads-click-ring 2.8s ease-in-out infinite;
    pointer-events: none;
}

.menu-no-ads-btn::after {
    content: "";
    position: absolute;
    top: -35%;
    left: -44%;
    width: 34%;
    height: 170%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.82), transparent);
    transform: rotate(18deg);
    animation: remove-ads-sheen 2.8s ease-in-out infinite;
    pointer-events: none;
}

.menu-no-ads-btn:hover {
    animation: none;
    transform: translateY(-2px) scale(1.02);
    background: #fffaf0;
    box-shadow: 0 12px 24px rgba(31, 36, 48, 0.2);
}

.menu-no-ads-btn:active {
    transform: translateY(0) scale(0.99);
}

.menu-no-ads-label {
    min-width: 0;
    overflow-wrap: anywhere;
}

.menu-no-ads-price {
    flex: 0 0 auto;
    padding: 3px 8px;
    border-radius: 5px;
    background: var(--red);
    color: #fffaf0;
    font-variant-numeric: tabular-nums;
}

@keyframes remove-ads-nudge {
    0%, 72%, 100% {
        transform: translateY(0) scale(1);
    }
    78% {
        transform: translateY(-2px) scale(1.025);
    }
    84% {
        transform: translateY(0) scale(1);
    }
}

@keyframes remove-ads-click-ring {
    0%, 70%, 100% {
        opacity: 0;
        transform: scale(0.92);
    }
    78% {
        opacity: 1;
        transform: scale(1.02);
    }
    88% {
        opacity: 0;
        transform: scale(1.12);
    }
}

@keyframes remove-ads-sheen {
    0%, 62%, 100% {
        left: -44%;
    }
    82% {
        left: 112%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .menu-no-ads-btn,
    .menu-no-ads-btn::before,
    .menu-no-ads-btn::after {
        animation: none;
    }
}

.native-ad-platform .menu-ad-area {
    inset: 0;
}

.game-grid {
    --game-card-gap: 14px;
    --game-card-half-gap: 7px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--game-card-gap);
    align-items: stretch;
}

.game-card-wrap {
    position: relative;
}

.game-card-wrap:nth-child(3) {
    grid-column: 1 / -1;
    width: calc(50% - var(--game-card-half-gap));
    justify-self: center;
}

.game-card {
    position: relative;
    min-height: 158px;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto auto;
    align-items: end;
    gap: 8px;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.48);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.3);
    color: var(--ink);
    text-align: left;
    cursor: pointer;
    pointer-events: auto;
    box-shadow:
        inset 0 0 0 1px rgba(31, 36, 48, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.52),
        0 12px 30px rgba(31, 36, 48, 0.16);
    -webkit-backdrop-filter: blur(18px) saturate(1.28);
    backdrop-filter: blur(18px) saturate(1.28);
    transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
    width: 100%;
    height: 100%;
}

.game-card-wrap:nth-child(1) .game-card {
    background:
        linear-gradient(155deg, rgba(255, 255, 255, 0.36), rgba(217, 75, 61, 0.11)),
        rgba(255, 255, 255, 0.18);
}

.game-card-wrap:nth-child(2) .game-card {
    background:
        linear-gradient(155deg, rgba(255, 255, 255, 0.36), rgba(23, 143, 136, 0.12)),
        rgba(255, 255, 255, 0.18);
}

.game-card-wrap:nth-child(3) .game-card {
    background:
        linear-gradient(155deg, rgba(255, 255, 255, 0.36), rgba(225, 168, 41, 0.13)),
        rgba(255, 255, 255, 0.18);
}

.game-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.72);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.64),
        0 14px 34px rgba(31, 36, 48, 0.18);
}

.game-card:active {
    transform: translateY(0) scale(0.99);
}

.game-index {
    position: absolute;
    left: 12px;
    top: 12px;
    color: rgba(31, 36, 48, 0.44);
    font-size: 0.84rem;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
}

.game-copy {
    min-width: 0;
    display: grid;
    gap: 4px;
    align-items: end;
}

.game-name {
    min-width: 0;
    font-size: 1.08rem;
    line-height: 1.08;
    font-weight: 900;
    overflow-wrap: anywhere;
}

.game-rule {
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 900;
    text-transform: uppercase;
    white-space: nowrap;
}

.game-info {
    position: absolute;
    right: 10px;
    top: 10px;
    z-index: 2;
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(31, 36, 48, 0.78);
    color: #fffaf0;
    font-size: 0.78rem;
    font-weight: 900;
    pointer-events: auto;
    border: 0;
    cursor: pointer;
}

.game-info:focus-visible {
    outline: 3px solid rgba(255, 222, 104, 0.95);
    outline-offset: 2px;
}

.game-info:hover {
    background: rgba(31, 36, 48, 0.92);
    transform: translateY(-1px);
}

.game-info:active {
    transform: translateY(0) scale(0.96);
}

.game-thumb {
    position: relative;
    min-height: 76px;
    border-radius: 8px;
    overflow: hidden;
    background: #d7edf2;
}

.game-thumb::after {
    content: none;
}

.game-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumb-plunger {
    position: absolute;
    left: 48%;
    top: 28%;
    width: 8px;
    height: 54px;
    border-radius: 999px;
    background: #7b4b2a;
    transform: rotate(-18deg);
}

.thumb-plunger::after {
    content: "";
    position: absolute;
    left: -10px;
    bottom: -11px;
    width: 28px;
    height: 18px;
    border-radius: 50% 50% 45% 45%;
    background: var(--red);
}

[data-scene="flip"] .thumb-plunger {
    left: 44%;
    top: 22%;
    transform: rotate(72deg);
}

[data-scene="longshot"] .thumb-plunger {
    left: 18%;
    top: 36%;
    transform: rotate(-34deg);
}

.thumb-mountain {
    position: absolute;
    right: -10px;
    bottom: 22%;
    width: 78%;
    height: 60%;
    background: linear-gradient(135deg, #426d43 0 58%, #f4fbff 59% 72%, #31583c 73%);
    clip-path: polygon(0 100%, 32% 30%, 48% 58%, 68% 8%, 100% 100%);
}

.howto-scene {
    height: 150px;
    margin: 8px 0 12px;
    border-radius: 8px;
    background: linear-gradient(#a7d8ee 0 58%, #f2d7a1 59%);
    position: relative;
    overflow: hidden;
}

.howto-figure {
    margin: 8px 0 12px;
    border-radius: 8px;
    overflow: hidden;
    background: #d7edf2;
    border: 1px solid rgba(31, 36, 48, 0.1);
}

.howto-image {
    display: block;
    width: 100%;
    height: min(260px, 44vh);
    object-fit: contain;
}

#game-over,
#settings-modal,
#info-modal,
#game-select-modal,
#ranking-modal,
#restart-modal {
    position: absolute;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--modal-edge-top) 18px var(--modal-edge-bottom);
    background:
        radial-gradient(circle at 50% 18%, rgba(255, 211, 77, 0.32), transparent 28%),
        rgba(31, 36, 48, 0.64);
    pointer-events: auto;
    backdrop-filter: blur(8px);
}

#info-modal {
    z-index: 420;
}

#game-select-modal {
    z-index: 360;
    background:
        radial-gradient(circle at 48% 14%, rgba(255, 255, 255, 0.22), transparent 24%),
        radial-gradient(circle at 50% 18%, rgba(255, 211, 77, 0.12), transparent 32%),
        linear-gradient(180deg, rgba(31, 36, 48, 0.22), rgba(31, 36, 48, 0.34));
    -webkit-backdrop-filter: blur(12px) saturate(1.18);
    backdrop-filter: blur(12px) saturate(1.18);
}

.result-panel,
.modal-content {
    width: min(380px, calc(100vw - 32px));
    border: 1px solid rgba(31, 36, 48, 0.16);
    border-radius: 8px;
    background: var(--paper);
    box-shadow: var(--shadow);
}

.result-panel {
    position: relative;
    overflow: hidden;
    padding: 24px;
    text-align: center;
    animation: result-pop 0.32s cubic-bezier(0.2, 1.35, 0.35, 1);
}

.result-panel::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(135deg, rgba(217, 75, 61, 0.16), transparent 42%),
        linear-gradient(315deg, rgba(23, 143, 136, 0.15), transparent 44%);
    pointer-events: none;
}

.result-panel > * {
    position: relative;
}

#result-title {
    margin: 0 0 10px;
    color: var(--ink);
    font-size: 2.2rem;
    line-height: 0.96;
    text-transform: uppercase;
}

#result-summary {
    margin: 0;
    color: #334050;
    font-size: 1.05rem;
    font-weight: 800;
}

#final-time {
    font-variant-numeric: tabular-nums;
}

#result-detail {
    min-height: 20px;
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.4;
    font-weight: 700;
}

#rank-info {
    margin: 18px 0;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.52);
}

.current-record-card {
    position: relative;
    display: grid;
    gap: 5px;
    padding: 13px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(255, 232, 138, 0.32);
    background:
        linear-gradient(90deg, rgba(255, 222, 104, 0.2), transparent 34%),
        linear-gradient(135deg, rgba(31, 36, 48, 0.96), rgba(33, 84, 94, 0.92));
    color: white;
    text-align: left;
    box-shadow: 0 14px 30px rgba(31, 36, 48, 0.2);
}

.current-record-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 5px;
    background: linear-gradient(180deg, #ffe88a, var(--red), var(--teal));
}

.current-record-card > * {
    position: relative;
}

.current-record-card strong {
    font-size: 2rem;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.current-record-card span,
.current-record-card small {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.record-kicker {
    color: #ffe88a;
    font-size: 0.72rem;
    font-weight: 950;
    text-transform: uppercase;
}

.top10-list {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.top10-scroll {
    max-height: 190px;
    overflow-y: auto;
    display: grid;
    gap: 7px;
    padding-right: 3px;
    overscroll-behavior: contain;
}

.top10-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--ink);
    font-size: 0.76rem;
    font-weight: 900;
    letter-spacing: 0;
    text-align: left;
    text-transform: uppercase;
}

.top10-row {
    position: relative;
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) minmax(78px, auto);
    gap: 8px;
    align-items: center;
    min-height: 42px;
    padding: 8px 10px;
    border: 1px solid rgba(31, 36, 48, 0.08);
    border-radius: 8px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.66);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
    font-size: 0.82rem;
}

.top10-row span,
.top10-row strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.top10-rank {
    display: flex;
    align-items: center;
}

.top10-rank-badge {
    width: 38px;
    min-width: 38px;
    padding: 5px 0;
    border-radius: 999px;
    background: rgba(31, 36, 48, 0.08);
    color: #45505c;
    font-size: 0.78rem;
    font-weight: 950;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.top10-player {
    color: #2f3946;
    font-weight: 900;
}

.top10-row strong {
    color: var(--ink);
    font-size: 0.9rem;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.top10-row.top10-rank-1 {
    min-height: 50px;
    border-color: rgba(225, 168, 41, 0.42);
    background:
        linear-gradient(135deg, rgba(255, 232, 138, 0.9), rgba(255, 255, 255, 0.78) 58%),
        rgba(255, 255, 255, 0.7);
    box-shadow:
        0 10px 22px rgba(225, 168, 41, 0.18),
        inset 0 1px 0 rgba(255, 255, 255, 0.82);
}

.top10-row.top10-rank-1::before,
.top10-row.top10-rank-2::before,
.top10-row.top10-rank-3::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 5px;
}

.top10-row.top10-rank-1::before {
    background: var(--gold);
}

.top10-row.top10-rank-2 {
    border-color: rgba(37, 109, 184, 0.24);
    background:
        linear-gradient(135deg, rgba(215, 224, 233, 0.9), rgba(255, 255, 255, 0.76) 60%),
        rgba(255, 255, 255, 0.7);
}

.top10-row.top10-rank-2::before {
    background: var(--blue);
}

.top10-row.top10-rank-3 {
    border-color: rgba(217, 75, 61, 0.22);
    background:
        linear-gradient(135deg, rgba(246, 190, 124, 0.44), rgba(255, 255, 255, 0.76) 60%),
        rgba(255, 255, 255, 0.7);
}

.top10-row.top10-rank-3::before {
    background: var(--red);
}

.top10-row.top10-rank-1 .top10-rank-badge,
.top10-row.top10-rank-2 .top10-rank-badge,
.top10-row.top10-rank-3 .top10-rank-badge {
    color: #1f2430;
    box-shadow: 0 6px 14px rgba(31, 36, 48, 0.12);
}

.top10-row.top10-rank-1 .top10-rank-badge {
    background: linear-gradient(180deg, #fff3a6, var(--gold));
}

.top10-row.top10-rank-2 .top10-rank-badge {
    background: linear-gradient(180deg, #f5f8fb, #b9c7d6);
}

.top10-row.top10-rank-3 .top10-rank-badge {
    background: linear-gradient(180deg, #ffd29a, #d9853b);
}

.top10-row.top10-rank-1 .top10-score {
    font-size: 1rem;
}

.top10-row.current-user {
    outline: 2px solid rgba(23, 143, 136, 0.46);
    box-shadow:
        0 0 0 3px rgba(23, 143, 136, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

.top10-empty {
    padding: 13px;
    border: 1px dashed rgba(31, 36, 48, 0.18);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.42);
    color: #45505c;
    font-size: 0.84rem;
    font-weight: 850;
}

#rank-text {
    margin: 0;
    font-size: 1rem;
    line-height: 1.05;
    font-weight: 950;
}

#percentile-text {
    margin: 7px 0 0;
    color: #4f5c68;
    font-size: 0.86rem;
    font-weight: 800;
}

@keyframes result-pop {
    from {
        opacity: 0;
        transform: translateY(18px) scale(0.92);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.result-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.primary-action,
.secondary-action,
.settings-row,
.settings-home-btn,
.game-home-btn,
.footer-link,
.close-btn {
    pointer-events: auto;
}

.primary-action,
.secondary-action {
    min-height: 46px;
    border: 0;
    border-radius: 7px;
    cursor: pointer;
    font-weight: 950;
    transition: transform 0.12s ease, background 0.16s ease;
}

.primary-action {
    background: var(--red);
    color: white;
    box-shadow: 0 10px 20px rgba(217, 75, 61, 0.26);
}

.primary-action.danger-action {
    background: #b9352b;
    box-shadow: 0 10px 20px rgba(185, 53, 43, 0.28);
}

.secondary-action {
    border: 1px solid var(--line);
    background: white;
    color: var(--ink);
}

.primary-action:hover,
.secondary-action:hover {
    transform: translateY(-1px);
}

.primary-action:active,
.secondary-action:active {
    transform: translateY(1px) scale(0.98);
}

.primary-action:disabled,
.secondary-action:disabled,
.primary-action.is-disabled,
.secondary-action.is-disabled {
    cursor: wait;
    opacity: 0.62;
    transform: none;
}

.settings-redesign {
    position: relative;
    width: min(430px, calc(100vw - 32px));
    max-width: none;
    max-height: min(720px, calc(100vh - var(--modal-vertical-reserve)));
    overflow-y: auto;
    padding: 22px 18px 14px;
    text-align: center;
}

.ranking-content {
    position: relative;
    width: min(760px, calc(100vw - 32px));
    max-width: none;
    height: min(720px, calc(100vh - var(--modal-vertical-reserve)));
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    padding: 20px;
    overflow: hidden;
    border-color: rgba(255, 255, 255, 0.48);
    background:
        linear-gradient(180deg, rgba(255, 250, 240, 0.97), rgba(248, 241, 222, 0.96)),
        var(--paper);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.7),
        0 24px 70px rgba(31, 36, 48, 0.3);
}

.game-select-content {
    position: relative;
    width: min(560px, calc(100vw - 32px));
    max-width: none;
    max-height: min(720px, calc(100vh - var(--modal-vertical-reserve)));
    display: grid;
    gap: 14px;
    padding: 22px 18px 18px;
    overflow-y: auto;
    border-color: rgba(255, 255, 255, 0.52);
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.38), rgba(255, 250, 240, 0.18)),
        rgba(255, 255, 255, 0.16);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.66),
        inset 0 -1px 0 rgba(255, 255, 255, 0.14),
        0 24px 70px rgba(31, 36, 48, 0.28);
    -webkit-backdrop-filter: blur(28px) saturate(1.34);
    backdrop-filter: blur(28px) saturate(1.34);
}

.game-select-content::before {
    content: "";
    position: absolute;
    inset: 1px;
    border-radius: 7px;
    background:
        radial-gradient(circle at 24% 8%, rgba(255, 255, 255, 0.46), transparent 28%),
        linear-gradient(135deg, rgba(255, 255, 255, 0.22), transparent 42%);
    pointer-events: none;
}

.game-select-content > * {
    position: relative;
    z-index: 1;
}

.game-select-content h2 {
    margin: 0;
    padding-right: 42px;
    color: var(--ink);
    font-size: 1.35rem;
    line-height: 1;
    font-weight: 950;
    text-align: center;
    text-transform: uppercase;
}

.ranking-head {
    display: grid;
    gap: 5px;
    padding-bottom: 13px;
    padding-right: 42px;
    border-bottom: 1px solid rgba(31, 36, 48, 0.1);
}

.ranking-head h2 {
    margin: 0;
    color: var(--ink);
    font-size: 1.48rem;
    line-height: 1;
    font-weight: 950;
    text-transform: uppercase;
}

#ranking-player-id {
    min-width: 0;
    overflow: hidden;
    color: #687380;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.78rem;
    font-weight: 850;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ranking-body {
    min-height: 0;
    overflow-y: auto;
    display: grid;
    gap: 14px;
    margin-top: 14px;
    padding-right: 3px;
}

.ranking-game-panel {
    position: relative;
    display: grid;
    gap: 12px;
    padding: 14px;
    border: 1px solid rgba(31, 36, 48, 0.12);
    border-radius: 8px;
    overflow: visible;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(255, 248, 229, 0.68)),
        rgba(255, 255, 255, 0.68);
    box-shadow:
        0 14px 34px rgba(31, 36, 48, 0.09),
        inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

.ranking-game-panel::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 4px;
    border-radius: 7px 7px 0 0;
    background: linear-gradient(90deg, var(--red), var(--gold), var(--teal), var(--blue));
}

.ranking-game-panel > * {
    position: relative;
}

.ranking-game-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(150px, auto);
    gap: 10px;
    align-items: start;
}

.ranking-game-head h3 {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
    font-size: 1.04rem;
    line-height: 1.1;
    font-weight: 950;
}

.champion-pill {
    position: relative;
    display: grid;
    gap: 3px;
    min-width: 0;
    padding: 8px 10px 8px 36px;
    border-radius: 7px;
    border: 1px solid rgba(31, 36, 48, 0.08);
    background: rgba(31, 36, 48, 0.07);
    color: #45505c;
    font-size: 0.72rem;
    font-weight: 900;
    text-align: right;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.champion-pill strong {
    color: var(--ink);
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
}

.champion-pill-active {
    border-color: rgba(225, 168, 41, 0.34);
    background:
        linear-gradient(135deg, rgba(31, 36, 48, 0.94), rgba(54, 61, 74, 0.92)),
        var(--ink);
    color: rgba(255, 255, 255, 0.78);
    box-shadow:
        0 10px 22px rgba(31, 36, 48, 0.16),
        inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.champion-pill-active::before {
    content: "1";
    position: absolute;
    left: 9px;
    top: 50%;
    width: 20px;
    height: 20px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: linear-gradient(180deg, #fff3a6, var(--gold));
    color: #2c220e;
    font-size: 0.78rem;
    font-weight: 950;
    transform: translateY(-50%);
}

.champion-pill-active strong {
    color: #ffe88a;
}

.champion-pill-empty {
    padding-left: 10px;
}

.champion-pill.current-user {
    outline: 2px solid rgba(255, 222, 104, 0.62);
}

.ranking-user-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.ranking-user-stats > span {
    position: relative;
    min-width: 0;
    min-height: 76px;
    display: grid;
    align-content: center;
    gap: 3px;
    padding: 9px 10px;
    border-radius: 7px;
    border: 1px solid rgba(31, 36, 48, 0.08);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.68), rgba(255, 255, 255, 0.34)),
        rgba(31, 36, 48, 0.05);
    color: #687380;
    font-size: 0.72rem;
    font-weight: 850;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.ranking-user-stats strong {
    color: var(--ink);
    font-size: 1.02rem;
    font-variant-numeric: tabular-nums;
}

.ranking-stat-label {
    min-width: 0;
    display: block;
    line-height: 1.15;
    white-space: normal;
    color: #687380;
    font-size: 0.72rem;
    font-weight: 900;
    text-transform: uppercase;
}

.ranking-error {
    padding: 10px 11px;
    border-radius: 7px;
    background: rgba(217, 75, 61, 0.1);
    color: var(--red-dark);
    font-size: 0.82rem;
    font-weight: 850;
}

.settings-redesign h2,
.info-content h2,
.restart-confirm-content h2 {
    margin: 0 0 16px;
    color: var(--ink);
    font-size: 1.3rem;
    font-weight: 950;
}

.restart-confirm-content {
    width: min(360px, calc(100vw - 32px));
    padding: 22px 18px 18px;
    text-align: center;
}

.restart-confirm-content p {
    margin: 0 0 18px;
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 850;
    line-height: 1.35;
}

.restart-confirm-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

@media (max-width: 560px) {
    .ranking-content {
        padding: 18px 14px;
    }

    .ranking-game-head,
    .ranking-user-stats {
        grid-template-columns: 1fr;
    }

    .ranking-game-panel {
        padding-bottom: 18px;
    }

    .ranking-user-stats > span {
        min-height: 82px;
        padding-top: 11px;
        padding-bottom: 11px;
    }

    .champion-pill {
        text-align: left;
    }
}

.settings-group {
    margin-bottom: 12px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.6);
}

.settings-row {
    width: 100%;
    min-height: 50px;
    display: grid;
    grid-template-columns: 30px 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 0 14px;
    border: 0;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
}

.settings-row:hover {
    background: rgba(31, 36, 48, 0.05);
}

.settings-home-btn {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: white;
    color: var(--ink);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 950;
    line-height: 1;
}

.settings-home-btn:hover,
.close-btn:hover {
    background: #f8fafc;
}

.player-id-row {
    min-height: 74px;
    grid-template-columns: 30px minmax(0, 1fr) auto;
    grid-template-areas:
        "icon label copy"
        ". value value";
    align-items: start;
    padding-top: 10px;
    padding-bottom: 10px;
}

.player-id-row .settings-icon {
    grid-area: icon;
}

.player-id-row .settings-label {
    grid-area: label;
}

.player-id-copy {
    grid-area: copy;
    align-self: center;
    padding: 3px 7px;
    border-radius: 5px;
    background: rgba(31, 36, 48, 0.08);
    color: #4f5c68;
    font-size: 0.68rem;
    font-weight: 950;
}

.settings-icon {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: rgba(31, 36, 48, 0.08);
    font-weight: 950;
}

.settings-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #242a34;
    font-size: 0.93rem;
    font-weight: 850;
    text-align: left;
}

html[dir="rtl"] .settings-label,
html[dir="rtl"] .game-card,
html[dir="rtl"] .ranking-game-panel,
html[dir="rtl"] .settings-records,
html[dir="rtl"] .result-panel {
    text-align: right;
}

html[dir="rtl"] .game-index {
    left: auto;
    right: 12px;
}

html[dir="rtl"] .game-info {
    right: auto;
    left: 10px;
}

html[dir="rtl"] .current-record-card,
html[dir="rtl"] .top10-title {
    text-align: right;
}

html[dir="rtl"] .current-record-card::before,
html[dir="rtl"] .top10-row.top10-rank-1::before,
html[dir="rtl"] .top10-row.top10-rank-2::before,
html[dir="rtl"] .top10-row.top10-rank-3::before {
    left: auto;
    right: 0;
}

html[dir="rtl"] .champion-pill {
    padding-right: 36px;
    padding-left: 10px;
}

html[dir="rtl"] .champion-pill-active::before {
    right: 9px;
    left: auto;
}

html[dir="rtl"] .champion-pill-empty {
    padding-right: 10px;
}

.settings-value,
.settings-chevron {
    min-width: 0;
    color: #747f8d;
    font-size: 0.85rem;
    font-weight: 850;
}

.settings-select {
    margin-left: auto;
    min-width: 112px;
    max-width: 46%;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.88);
    color: var(--ink);
    padding: 7px 8px;
    font-size: 0.86rem;
    font-weight: 850;
    pointer-events: auto;
}

.language-row {
    cursor: default;
}

.player-id-value {
    grid-area: value;
    overflow-wrap: anywhere;
    white-space: normal;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.84rem;
    line-height: 1.35;
    text-align: left;
}

.settings-divider {
    height: 1px;
    margin-left: 52px;
    background: var(--line);
}

.settings-records {
    margin-bottom: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.6);
    text-align: left;
}

.settings-section-title {
    margin-bottom: 9px;
    color: #242a34;
    font-size: 0.82rem;
    font-weight: 950;
    text-transform: uppercase;
}

.settings-records-body {
    display: grid;
    gap: 8px;
}

.settings-record-row {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(78px, 0.9fr) minmax(78px, 0.9fr);
    gap: 8px;
    align-items: center;
    padding: 9px;
    border-radius: 7px;
    background: rgba(31, 36, 48, 0.06);
}

.settings-record-game {
    min-width: 0;
    overflow: hidden;
    color: var(--ink);
    font-size: 0.84rem;
    font-weight: 950;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.settings-record-stat {
    min-width: 0;
    display: grid;
    gap: 2px;
    text-align: right;
}

.settings-record-stat span {
    color: #747f8d;
    font-size: 0.64rem;
    font-weight: 850;
}

.settings-record-stat strong {
    min-width: 0;
    overflow: hidden;
    color: var(--ink);
    font-size: 0.82rem;
    font-weight: 950;
    font-variant-numeric: tabular-nums;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.settings-records-empty,
.settings-record-error {
    padding: 9px;
    border-radius: 7px;
    background: rgba(31, 36, 48, 0.06);
    color: #747f8d;
    font-size: 0.78rem;
    font-weight: 850;
    text-align: center;
}

.settings-record-error {
    grid-column: 2 / -1;
    color: var(--red-dark);
}

@media (max-width: 420px) {
    .settings-record-row {
        grid-template-columns: 1fr 1fr;
    }

    .settings-record-game {
        grid-column: 1 / -1;
    }

    .settings-record-stat {
        text-align: left;
    }
}

.settings-badge {
    padding: 3px 8px;
    border-radius: 5px;
    background: var(--gold);
    color: #36270a;
    font-size: 0.72rem;
    font-weight: 950;
}

.danger-row .settings-icon,
.danger-row .settings-label,
.danger-row .settings-chevron {
    color: var(--red-dark);
}

.settings-legal {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    flex-wrap: wrap;
}

.footer-link {
    border: 0;
    background: transparent;
    color: #687380;
    cursor: pointer;
    font-size: 0.68rem;
    font-weight: 800;
}

.footer-link:hover {
    color: var(--ink);
    text-decoration: underline;
}

.legal-dot {
    color: #a7aeb8;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: white;
    color: var(--ink);
    cursor: pointer;
    font-size: 1.25rem;
    font-weight: 800;
    line-height: 1;
}

.info-content {
    position: relative;
    max-width: 460px;
    height: min(620px, calc(100vh - var(--modal-vertical-reserve)));
    display: flex;
    flex-direction: column;
    padding: 22px 18px 18px;
}

.scrollable-content {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.72);
    color: #3e4651;
    font-size: 0.92rem;
    line-height: 1.55;
    text-align: left;
}

.scrollable-content h3,
.scrollable-content h4 {
    color: var(--ink);
}

.scrollable-content a {
    color: var(--blue);
}

.info-actions {
    display: grid;
    gap: 12px;
    padding-top: 20px;
}

.info-skip-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #4a5663;
    font-size: 0.84rem;
    font-weight: 850;
    line-height: 1.25;
    text-align: left;
}

.info-skip-row input {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--red);
}

.info-actions .primary-action {
    width: 100%;
    margin-top: 4px;
}

#ad-overlay {
    position: absolute;
    inset: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: #11151d;
    color: white;
    pointer-events: auto;
}

#ad-content {
    width: min(460px, 92vw);
    height: min(280px, 48vh);
    display: grid;
    place-items: center;
    margin: 18px 0;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    background: #1d2430;
    color: #aab3c1;
    font-size: 1.1rem;
    font-weight: 800;
}

#ad-timer {
    font-size: 2rem;
    font-weight: 950;
}

#ad-message {
    color: #c4ccd8;
    font-size: 0.9rem;
    font-weight: 750;
}

.spinner {
    width: 36px;
    height: 36px;
    margin: 4px auto 10px;
    border: 4px solid rgba(31, 36, 48, 0.12);
    border-left-color: var(--red);
    border-radius: 50%;
    animation: spin 0.85s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

#toast-container {
    position: fixed;
    left: 50%;
    bottom: calc(34px + env(safe-area-inset-bottom));
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    transform: translateX(-50%);
    pointer-events: none;
}

.toast {
    max-width: min(420px, calc(100vw - 32px));
    padding: 10px 14px;
    border-radius: 8px;
    background: rgba(31, 36, 48, 0.92);
    color: white;
    font-size: 0.9rem;
    font-weight: 800;
    box-shadow: 0 10px 28px rgba(31, 36, 48, 0.28);
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.toast-visible {
    opacity: 1;
    transform: translateY(0);
}

@media (max-width: 760px) {
    :root {
        --top-control-offset: max(52px, calc(18px + env(safe-area-inset-top, 0px)));
        --start-edge-top: max(72px, calc(42px + env(safe-area-inset-top, 0px)));
        --menu-ad-content-clearance: calc(var(--top-control-offset) + 220px);
        --modal-edge-top: max(56px, calc(20px + env(safe-area-inset-top, 0px)));
        --modal-edge-bottom: max(18px, calc(18px + env(safe-area-inset-bottom, 0px)));
    }

    body.menu-ad-visible #start-screen {
        align-items: flex-start;
    }

    .start-shell {
        width: min(430px, 100%);
        gap: 14px;
        transform: translateY(8px);
    }

    body.menu-ad-visible .start-shell {
        transform: translateY(14px);
    }

    .menu-ad-area {
        inset: 0;
    }

    .menu-ad-offer {
        top: calc(var(--top-control-offset) + 70px);
        width: min(238px, calc(100vw - 28px));
        gap: 6px;
    }

    .menu-ad-promo {
        padding: 5px 8px 6px;
        font-size: 0.82rem;
    }

    .menu-tagline {
        width: min(340px, calc(100vw - 28px));
        font-size: 0.82rem;
    }

    .menu-no-ads-btn {
        min-height: 34px;
        gap: 7px;
        padding: 7px 9px;
        font-size: 0.76rem;
        max-width: min(190px, calc(100vw - 128px));
    }

    .game-grid {
        --game-card-gap: 10px;
        --game-card-half-gap: 5px;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .game-card {
        min-height: 136px;
        grid-template-columns: none;
        grid-template-rows: minmax(0, 1fr) auto auto;
        align-items: end;
        gap: 5px;
        padding: 8px;
    }

    .start-shell h1 {
        font-size: clamp(1.75rem, 10vw, 2.7rem);
    }

    .game-thumb {
        min-height: 68px;
        height: 68px;
    }

    .game-index {
        position: absolute;
        left: 8px;
        top: 8px;
        font-size: 0.66rem;
    }

    .game-copy {
        gap: 3px;
    }

    .game-name {
        font-size: 0.72rem;
        line-height: 1.08;
    }

    .game-rule {
        font-size: 0.58rem;
    }

    .game-info {
        right: 7px;
        top: 7px;
        width: 21px;
        height: 21px;
        font-size: 0.68rem;
    }

    #top-hud {
        width: min(148px, calc(100vw - 178px));
    }

    .result-actions {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 380px) {
    .game-home-btn {
        left: 12px;
        min-width: 70px;
        height: 42px;
        padding: 0 10px;
        font-size: 0.82rem;
    }

    .icon-btn {
        right: 12px;
        width: 42px;
        height: 42px;
        font-size: 1.3rem;
    }

    #ranking-btn,
    #game-restart-btn {
        right: 64px;
    }

    #top-hud {
        width: 100px;
        padding: 8px 7px;
    }

    #timer {
        padding: 5px 4px;
        font-size: 0.86rem;
    }
}

@media (max-width: 760px) and (max-height: 680px) {
    body.menu-ad-visible .start-shell {
        transform: translateY(6px);
    }
}

@media (max-height: 680px) {
    #start-screen {
        align-items: flex-start;
        overflow-y: auto;
        padding-bottom: calc(136px + env(safe-area-inset-bottom, 0px));
    }

    .game-card {
        min-height: 104px;
    }

    .menu-ad-offer {
        top: calc(var(--top-control-offset) + 68px);
    }

    .menu-ad-promo {
        font-size: 0.76rem;
    }

    .menu-no-ads-btn {
        min-height: 32px;
        font-size: 0.72rem;
    }

}

@media (orientation: landscape) and (max-height: 480px) {
    :root {
        --modal-edge-top: max(10px, env(safe-area-inset-top, 0px));
        --modal-edge-bottom: max(10px, env(safe-area-inset-bottom, 0px));
    }

    #game-over,
    #settings-modal,
    #info-modal,
    #game-select-modal,
    #ranking-modal,
    #restart-modal {
        position: fixed;
        padding:
            var(--modal-edge-top)
            max(12px, env(safe-area-inset-right, 0px))
            var(--modal-edge-bottom)
            max(12px, env(safe-area-inset-left, 0px));
    }

    .result-panel {
        width: min(420px, calc(100vw - 28px));
        max-height: calc(100vh - var(--modal-vertical-reserve));
        padding: 14px;
        overflow-y: auto;
    }

    .eyebrow {
        margin-bottom: 5px;
        font-size: 0.66rem;
    }

    #result-title {
        margin-bottom: 5px;
        font-size: 1.5rem;
        line-height: 1;
    }

    #result-summary {
        font-size: 0.9rem;
    }

    #result-detail {
        min-height: 0;
        margin-top: 5px;
        font-size: 0.74rem;
        line-height: 1.25;
    }

    #rank-info {
        margin: 10px 0;
        padding: 10px;
    }

    #rank-text {
        font-size: 0.86rem;
    }

    #rank-text.rank-result {
        display: grid;
        grid-template-columns: minmax(116px, 0.82fr) minmax(0, 1.18fr);
        gap: 8px;
        align-items: stretch;
    }

    #percentile-text {
        margin-top: 5px;
        font-size: 0.74rem;
        line-height: 1.25;
    }

    .current-record-card {
        gap: 3px;
        padding: 9px 10px;
    }

    .current-record-card strong {
        font-size: 1.38rem;
    }

    #rank-text.rank-result .current-record-card {
        align-content: center;
        height: 100%;
    }

    .record-kicker {
        font-size: 0.62rem;
    }

    .top10-list {
        gap: 5px;
        margin-top: 8px;
    }

    #rank-text.rank-result .top10-list {
        margin-top: 0;
    }

    .top10-scroll {
        max-height: 92px;
        gap: 5px;
    }

    #rank-text.rank-result .top10-scroll {
        max-height: 74px;
    }

    .top10-title {
        font-size: 0.66rem;
    }

    .top10-row {
        grid-template-columns: 40px minmax(0, 1fr) minmax(62px, auto);
        gap: 6px;
        min-height: 32px;
        padding: 5px 7px;
        font-size: 0.72rem;
    }

    #rank-text.rank-result .top10-row {
        grid-template-columns: 34px minmax(0, 1fr) minmax(54px, auto);
        gap: 4px;
    }

    .top10-row.top10-rank-1 {
        min-height: 36px;
    }

    .top10-rank-badge {
        width: 31px;
        min-width: 31px;
        padding: 3px 0;
        font-size: 0.66rem;
    }

    #rank-text.rank-result .top10-rank-badge {
        width: 27px;
        min-width: 27px;
    }

    .top10-row strong,
    .top10-row.top10-rank-1 .top10-score {
        font-size: 0.78rem;
    }

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

    .primary-action,
    .secondary-action {
        min-height: 38px;
        font-size: 0.84rem;
    }

    .game-select-content {
        width: min(520px, calc(100vw - 28px));
        max-height: calc(100vh - var(--modal-vertical-reserve));
        gap: 9px;
        padding: 14px 14px 12px;
    }

    .game-select-content h2 {
        padding-right: 34px;
        font-size: 1rem;
    }

    .game-grid {
        --game-card-gap: 8px;
        --game-card-half-gap: 4px;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .game-card-wrap:nth-child(3) {
        grid-column: auto;
        width: auto;
        justify-self: stretch;
    }

    .game-card {
        min-height: 112px;
        gap: 4px;
        padding: 7px;
    }

    .game-thumb {
        min-height: 52px;
        height: 52px;
    }

    .game-index {
        left: 7px;
        top: 7px;
        font-size: 0.62rem;
    }

    .game-copy {
        gap: 2px;
    }

    .game-name {
        font-size: 0.66rem;
        line-height: 1.08;
    }

    .game-rule {
        font-size: 0.52rem;
    }

    .game-info {
        right: 6px;
        top: 6px;
        width: 20px;
        height: 20px;
        font-size: 0.64rem;
    }

    .close-btn {
        top: 8px;
        right: 8px;
        width: 28px;
        height: 28px;
        font-size: 1rem;
    }
}

@media (orientation: landscape) and (max-height: 340px) {
    .result-panel {
        padding: 12px;
    }

    .eyebrow {
        margin-bottom: 3px;
    }

    #result-title {
        margin-bottom: 3px;
        font-size: 1.36rem;
    }

    #result-detail {
        margin-top: 3px;
        font-size: 0.7rem;
        line-height: 1.2;
    }

    #rank-info {
        margin: 8px 0;
        padding: 8px;
    }

    .current-record-card {
        padding: 7px 8px;
    }

    .current-record-card strong {
        font-size: 1.24rem;
    }

    #rank-text.rank-result .top10-scroll {
        max-height: 62px;
    }

    .primary-action,
    .secondary-action {
        min-height: 34px;
        font-size: 0.8rem;
    }
}
