/*
 * Copyright (c) 2026 LE NGOC THUAN. All rights reserved.
 * Proprietary source. Unauthorized copying, distribution, or derivative use is prohibited.
 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #ffffff;
    --ink: #1f2937;
    --ink-soft: rgba(31, 41, 55, 0.72);
    --border: rgba(17, 24, 39, 0.08);
    --shadow: 0 12px 28px rgba(17, 24, 39, 0.12);
    --btn-shadow-soft:
        0 10px 18px rgba(15, 23, 42, 0.12),
        0 22px 34px rgba(15, 23, 42, 0.08),
        0 1px 0 rgba(255, 255, 255, 0.46) inset;
    --btn-shadow-soft-hover:
        0 12px 22px rgba(15, 23, 42, 0.15),
        0 26px 38px rgba(15, 23, 42, 0.1),
        0 1px 0 rgba(255, 255, 255, 0.38) inset;
    --btn-shadow-dark:
        0 12px 20px rgba(3, 7, 18, 0.28),
        0 24px 40px rgba(15, 23, 42, 0.18),
        0 1px 0 rgba(255, 255, 255, 0.08) inset;
    --btn-shadow-dark-hover:
        0 14px 24px rgba(3, 7, 18, 0.32),
        0 28px 42px rgba(15, 23, 42, 0.2),
        0 1px 0 rgba(255, 255, 255, 0.1) inset;

    --ui-scale: 0.94;
    --layout-pad-x: clamp(16px, 5vw, 56px);
    --layout-pad-y: clamp(14px, 3svh, 32px);
    --font-pixel: "Margarine", "Trebuchet MS", "Segoe UI", sans-serif;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --game-side-gutter: clamp(16px, 5vw, 58px);
    --home-title-size: clamp(46px, min(12vw, 12.5svh), 104px);
    --home-content-width: clamp(288px, 90vw, 460px);
    --home-picker-width: clamp(284px, 58vw, 380px);
    --room-card-width: clamp(300px, 78vw, 390px);
    --gameover-panel-width: clamp(300px, 76vw, 390px);
    --pill-height: clamp(48px, min(8vw, 7svh), 62px);
    --gameplay-score-offset: clamp(52px, 8svh, 92px);
    --icon-button-size: clamp(40px, min(9vw, 6svh), 50px);
    --modal-icon-button-size: clamp(42px, min(9vw, 6.4svh), 50px);
}

@media (min-width: 700px) and (min-height: 700px) {
    :root {
        --ui-scale: 1;
        --layout-pad-x: clamp(28px, 5vw, 72px);
        --layout-pad-y: clamp(22px, 3.6svh, 42px);
        --home-content-width: clamp(420px, 54vw, 520px);
        --home-picker-width: clamp(360px, 42vw, 430px);
        --room-card-width: clamp(380px, 48vw, 460px);
        --gameover-panel-width: clamp(380px, 48vw, 460px);
        --pill-height: clamp(56px, 6svh, 68px);
    }
}

@media (min-width: 1100px) and (min-height: 760px) {
    :root {
        --ui-scale: 1.04;
        --layout-pad-x: clamp(42px, 5vw, 96px);
        --layout-pad-y: clamp(28px, 4svh, 52px);
        --home-content-width: clamp(460px, 34vw, 560px);
        --home-picker-width: clamp(380px, 30vw, 460px);
        --room-card-width: clamp(420px, 32vw, 500px);
        --gameover-panel-width: clamp(420px, 32vw, 500px);
    }
}

html,
body {
    width: 100%;
    min-height: 100%;
    min-height: 100svh;
    min-height: 100dvh;
    overflow: hidden;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-pixel);
    font-size: calc(16px * var(--ui-scale));
    overscroll-behavior: none;
}

button {
    border: 0;
    background: transparent;
    cursor: pointer;
    font: inherit;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.72);
    outline-offset: 3px;
}

#app-shell,
#game-wrapper {
    position: relative;
    width: 100%;
    height: 100vh;
    height: 100svh;
    height: 100dvh;
    min-height: 100svh;
    min-height: 100dvh;
    overflow: hidden;
}

#game-wrapper::after {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 20vh;
    z-index: 3;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.58) 0%, rgba(15, 23, 42, 0.34) 38%, rgba(15, 23, 42, 0.14) 72%, rgba(15, 23, 42, 0) 100%);
}

.circuit-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-color: #ffffff;
    background-image:
        repeating-linear-gradient(0deg, transparent, transparent 19px, rgba(75, 85, 99, 0.08) 19px, rgba(75, 85, 99, 0.08) 20px, transparent 20px, transparent 39px, rgba(75, 85, 99, 0.08) 39px, rgba(75, 85, 99, 0.08) 40px),
        repeating-linear-gradient(90deg, transparent, transparent 19px, rgba(75, 85, 99, 0.08) 19px, rgba(75, 85, 99, 0.08) 20px, transparent 20px, transparent 39px, rgba(75, 85, 99, 0.08) 39px, rgba(75, 85, 99, 0.08) 40px),
        radial-gradient(circle at 20px 20px, rgba(55, 65, 81, 0.12) 2px, transparent 2px),
        radial-gradient(circle at 40px 40px, rgba(55, 65, 81, 0.12) 2px, transparent 2px);
    background-size: 40px 40px;
    transition: filter 0.9s ease, opacity 0.9s ease;
}

.circuit-bg.is-changing {
    animation: background-bloom 0.92s ease both;
}

.circuit-bg.is-dark + #gameCanvas {
    filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.08));
}

@keyframes background-bloom {
    0% {
        opacity: 0.78;
        filter: saturate(84%) brightness(1.06);
    }
    100% {
        opacity: 1;
        filter: saturate(100%) brightness(1);
    }
}

#gameCanvas,
.screen,
#hud,
#touchControls {
    position: absolute;
    inset: 0;
}

#gameCanvas {
    z-index: 1;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

.pet-game-layer {
    position: absolute;
    inset: 0;
    z-index: 4;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.screen {
    z-index: 5;
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
}

.screen.hidden,
#hud.hidden,
#touchControls.hidden,
.room-modal.hidden {
    display: none !important;
}

.room-view.hidden,
#hud .hidden {
    display: none !important;
}

.home-screen,
#gameOverScreen {
    display: grid;
    place-items: center;
    padding:
        max(var(--layout-pad-y), var(--safe-top))
        max(var(--layout-pad-x), var(--safe-right))
        max(var(--layout-pad-y), var(--safe-bottom))
        max(var(--layout-pad-x), var(--safe-left));
}

.home-settings-btn {
    position: absolute;
    top: calc(20px * var(--ui-scale));
    right: calc(20px * var(--ui-scale));
    z-index: 7;
    display: inline-grid;
    place-items: center;
    width: var(--icon-button-size);
    height: var(--icon-button-size);
    padding: 0;
    box-sizing: border-box;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: var(--btn-shadow-soft);
    color: #0f172a;
    pointer-events: auto;
    touch-action: manipulation;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.remove-ads-btn {
    position: absolute;
    top: calc(18px * var(--ui-scale));
    left: calc(18px * var(--ui-scale));
    z-index: 7;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-items: center;
    column-gap: 7px;
    min-width: 98px;
    min-height: 54px;
    padding: 6px 10px 7px 8px;
    border: 1px solid rgba(255, 255, 255, 0.94);
    border-radius: 17px;
    color: #182230;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(255, 255, 255, 0.82)),
        linear-gradient(135deg, rgba(250, 204, 21, 0.5), rgba(34, 197, 94, 0.22), rgba(239, 68, 68, 0.14));
    box-shadow:
        0 15px 28px rgba(15, 23, 42, 0.18),
        0 1px 0 rgba(255, 255, 255, 0.85) inset;
    font: 900 13px/1 "Margarine", system-ui, sans-serif;
    cursor: pointer;
    pointer-events: auto;
    touch-action: manipulation;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    animation: removeAdsGlow 1.9s ease-in-out infinite;
    transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.remove-ads-btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow:
        0 18px 34px rgba(15, 23, 42, 0.24),
        0 1px 0 rgba(255, 255, 255, 0.88) inset;
}

.remove-ads-btn:disabled {
    cursor: default;
    opacity: 0.72;
}

.remove-ads-icon {
    grid-row: 1 / span 2;
    width: 39px;
    height: 39px;
    display: inline-grid;
    place-items: center;
    filter: drop-shadow(0 5px 9px rgba(239, 35, 60, 0.18));
}

.remove-ads-icon svg {
    width: 39px;
    height: 39px;
    display: block;
    animation: removeAdsIconPop 1.9s ease-in-out infinite;
    transform-origin: center;
}

.remove-ads-label {
    align-self: end;
    white-space: nowrap;
    letter-spacing: 0;
}

.remove-ads-price {
    align-self: start;
    color: #b91c1c;
    font-size: 10px;
    font-weight: 900;
    line-height: 1.1;
    white-space: nowrap;
}

.remove-ads-btn.is-busy {
    animation-duration: 0.8s;
}

@keyframes removeAdsGlow {
    0%,
    100% {
        box-shadow:
            0 15px 28px rgba(15, 23, 42, 0.18),
            0 1px 0 rgba(255, 255, 255, 0.85) inset;
    }
    50% {
        box-shadow:
            0 18px 32px rgba(239, 68, 68, 0.24),
            0 1px 0 rgba(255, 255, 255, 0.9) inset;
    }
}

@keyframes removeAdsIconPop {
    0%,
    100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.08);
    }
}

.settings-panel {
    position: absolute;
    top: calc(72px * var(--ui-scale));
    right: calc(20px * var(--ui-scale));
    z-index: 8;
    display: grid;
    gap: 10px;
    width: min(calc(100vw - 32px), var(--room-card-width));
    padding: 14px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.78);
    background: rgba(15, 23, 42, 0.9);
    box-shadow: 0 18px 42px rgba(15, 23, 42, 0.22);
    color: rgba(248, 250, 252, 0.96);
    pointer-events: auto;
}

.settings-panel.hidden,
.help-panel.hidden {
    display: none;
}

.settings-title {
    margin: 0 0 2px;
    color: rgba(248, 250, 252, 0.92);
    font-size: 14px;
    line-height: 1.2;
}

.settings-action-btn {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 13px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    color: #0f172a;
    font-size: 13px;
    font-weight: 800;
    box-shadow: 0 10px 22px rgba(2, 6, 23, 0.18);
}

.settings-action-btn svg {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
    fill: currentColor;
}


.help-panel {
    padding: 10px 2px 2px;
    color: rgba(248, 250, 252, 0.96);
    pointer-events: auto;
}

.help-panel h2 {
    margin: 0 0 6px;
    font-size: 14px;
    line-height: 1.2;
}

.help-panel p {
    margin: 0;
    font-size: 13px;
    line-height: 1.42;
}

.settings-privacy-link,
.gameplay-menu-link {
    color: rgba(248, 250, 252, 0.78);
    font-size: 12px;
    line-height: 1.4;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.settings-privacy-link:hover,
.gameplay-menu-link:hover {
    color: #ffffff;
}

.home-settings-btn > *,
.settings-action-btn > * {
    pointer-events: none;
}

.home-settings-btn svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

.home-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding:
        max(var(--layout-pad-y), var(--safe-top))
        max(var(--layout-pad-x), var(--safe-right))
        max(var(--layout-pad-y), var(--safe-bottom))
        max(var(--layout-pad-x), var(--safe-left));
    background: rgba(15, 23, 42, 0.08);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

#gameOverScreen {
    align-content: center;
    justify-items: center;
    gap: 14px;
    background: rgba(15, 23, 42, 0.14);
    backdrop-filter: blur(1.5px);
    -webkit-backdrop-filter: blur(1.5px);
}

#game-wrapper.is-dark-bg #gameOverScreen {
    background: rgba(2, 6, 23, 0.3);
}

.home-center {
    display: block;
    width: 100%;
    max-width: min(100%, 620px);
    min-height: min(760px, calc(100svh - max(56px, var(--safe-top)) - max(22px, var(--safe-bottom))));
    margin: auto 0;
    padding: clamp(16px, 2.5svh, 24px) 0 clamp(12px, 2svh, 24px);
    text-align: center;
}

.home-title-stack {
    position: fixed;
    top: max(calc(var(--safe-top) + 18px), clamp(112px, 17svh, 168px));
    left: 50%;
    transform: translateX(-50%);
    z-index: 6;
    display: grid;
    justify-items: center;
    gap: clamp(8px, 1.4vh, 12px);
    width: min(calc(100vw - (var(--layout-pad-x) * 2)), 620px);
    pointer-events: none;
}

.home-best-pill {
    display: inline-grid;
    place-items: center;
    min-height: 28px;
    padding: 5px 13px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.72);
    background: rgba(255, 255, 255, 0.74);
    box-shadow:
        0 10px 20px rgba(15, 23, 42, 0.1),
        0 1px 0 rgba(255, 255, 255, 0.72) inset;
    color: rgba(15, 23, 42, 0.82);
    font-size: clamp(12px, 1.8vw, 15px);
    font-weight: 900;
    line-height: 1;
    white-space: nowrap;
}

.home-actions-wrapper {
    position: fixed;
    left: 50%;
    bottom: max(calc(var(--safe-bottom) + 72px), 25svh);
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    width: min(100%, var(--home-content-width));
    max-width: none;
    gap: calc(18px * var(--ui-scale));
    align-items: center;
    padding: 0;
    margin-top: 0;
    margin-bottom: 0;
    z-index: 6;
}

.home-pet-picker {
    position: fixed;
    left: 50%;
    bottom: calc(max(calc(var(--safe-bottom) + 72px), 25svh) + clamp(146px, 19svh, 172px));
    transform: translateX(-50%);
    display: grid;
    grid-template-columns: clamp(32px, 8vw, 38px) minmax(0, 1fr) clamp(32px, 8vw, 38px);
    align-items: center;
    justify-content: center;
    gap: clamp(6px, 1.8vw, 10px);
    width: min(100%, var(--home-picker-width));
    min-height: clamp(128px, 22svh, 192px);
    margin-top: 0;
    z-index: 5;
}

.pet-preview-stage {
    display: grid;
    justify-items: center;
    align-items: center;
    min-height: clamp(128px, 22svh, 192px);
}

.pet-preview-viewport {
    width: min(100%, clamp(190px, 38vw, 232px));
    height: clamp(126px, 20svh, 172px);
    border-radius: 50%;
    background: radial-gradient(circle at 50% 58%, rgba(203, 213, 225, 0.34) 0 34%, rgba(226, 232, 240, 0.16) 48%, rgba(255, 255, 255, 0) 70%);
}

.pet-preview-viewport canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
    filter: drop-shadow(0 22px 18px rgba(15, 23, 42, 0.18));
}

.pet-nav-btn {
    width: clamp(32px, 8vw, 38px);
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.86);
    border: 1px solid rgba(17, 24, 39, 0.1);
    color: #111827;
    box-shadow: var(--btn-shadow-soft);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.pet-nav-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--btn-shadow-soft-hover);
}

.pet-nav-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.home-online-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: calc(12px * var(--ui-scale));
    width: 100%;
    max-width: var(--home-content-width);
    align-items: stretch;
    justify-self: center;
}

.home-online-actions > * {
    width: 100%;
    min-width: 0;
    justify-self: stretch;
}

#playOfflineBtn {
    width: 100%;
    max-width: var(--home-content-width);
    justify-self: center;
}

.username-field {
    width: 100%;
    max-width: var(--home-content-width);
    display: grid;
    gap: 8px;
    justify-items: start;
    justify-self: center;
}

.username-label {
    font-size: calc(11px * var(--ui-scale));
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(71, 85, 105, 0.88);
}

.username-input {
    width: 100%;
    min-height: var(--pill-height);
    padding: 0 calc(16px * var(--ui-scale));
    border-radius: calc(20px * var(--ui-scale));
    border: 1px solid rgba(255, 255, 255, 0.82);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.66)),
        linear-gradient(135deg, rgba(255, 255, 255, 0.7), rgba(191, 219, 254, 0.28));
    box-shadow:
        0 18px 34px rgba(15, 23, 42, 0.14),
        0 12px 20px rgba(255, 255, 255, 0.62) inset,
        0 -10px 18px rgba(148, 163, 184, 0.16) inset,
        0 1px 0 rgba(255, 255, 255, 0.92) inset;
    backdrop-filter: blur(20px) saturate(155%);
    -webkit-backdrop-filter: blur(20px) saturate(155%);
    color: #0f172a;
    font-size: calc(15px * var(--ui-scale));
    outline: none;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.username-input:focus {
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.92);
    box-shadow:
        0 22px 38px rgba(15, 23, 42, 0.16),
        0 0 0 4px rgba(191, 219, 254, 0.22),
        0 10px 18px rgba(255, 255, 255, 0.52) inset,
        0 -10px 18px rgba(148, 163, 184, 0.14) inset,
        0 1px 0 rgba(255, 255, 255, 0.9) inset;
}

.username-input.invalid {
    border-color: rgba(220, 38, 38, 0.48);
    box-shadow: 0 0 0 4px rgba(248, 113, 113, 0.14);
}

.username-input::placeholder {
    color: rgba(51, 65, 85, 0.62);
}

.game-title-big {
    font-family: var(--font-pixel);
    font-size: var(--home-title-size);
    line-height: 0.9;
    letter-spacing: -0.02em;
    color: #111827;
    transform: none;
    max-width: calc(100vw - (var(--layout-pad-x) * 2));
    white-space: nowrap;
}

#game-wrapper.is-home-bg.is-dark-bg .game-title-big {
    color: rgba(248, 250, 252, 0.96);
    text-shadow:
        0 3px 18px rgba(0, 0, 0, 0.58),
        0 0 34px rgba(148, 163, 184, 0.24);
}

#game-wrapper.is-home-bg.is-dark-bg .home-best-pill {
    border-color: rgba(255, 255, 255, 0.28);
    background: rgba(15, 23, 42, 0.56);
    color: rgba(248, 250, 252, 0.94);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.34);
}

#game-wrapper.is-home-bg.is-dark-bg .username-label {
    color: rgba(226, 232, 240, 0.88);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.42);
}

#game-wrapper.is-home-bg.is-dark-bg #playOfflineBtn {
    border-color: rgba(187, 247, 208, 0.7);
    background:
        linear-gradient(180deg, rgba(74, 222, 128, 0.96), rgba(22, 163, 74, 0.94)),
        linear-gradient(135deg, rgba(255, 255, 255, 0.36), rgba(255, 255, 255, 0.08));
    color: #052e16;
    box-shadow:
        0 20px 42px rgba(15, 23, 42, 0.32),
        0 0 34px rgba(34, 197, 94, 0.22),
        0 1px 0 rgba(240, 253, 244, 0.72) inset;
}

.play-btn,
.ghost-btn {
    min-width: 0;
    min-height: var(--pill-height);
    padding: 0 calc(22px * var(--ui-scale));
    border-radius: 999px;
    border: 1px solid rgba(17, 24, 39, 0.12);
    box-shadow: var(--btn-shadow-soft);
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.play-btn:hover,
.ghost-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--btn-shadow-soft-hover);
}

.play-btn {
    background: #111827;
    color: #ffffff;
    font-size: calc(15px * var(--ui-scale));
    font-weight: 700;
    box-shadow: var(--btn-shadow-dark);
}

.ghost-btn {
    background: rgba(255, 255, 255, 0.82);
    color: rgba(30, 41, 59, 0.88);
    font-size: calc(14px * var(--ui-scale));
    font-weight: 700;
}

.hero-play {
    min-width: 0;
    width: 100%;
}

#homeBackgroundBtn,
#playOnlineBtn {
    position: relative;
    overflow: hidden;
    border-color: rgba(255, 255, 255, 0.84);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.68)),
        linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(191, 219, 254, 0.3));
    box-shadow:
        0 18px 30px rgba(15, 23, 42, 0.14),
        0 12px 20px rgba(255, 255, 255, 0.6) inset,
        0 -10px 18px rgba(148, 163, 184, 0.16) inset,
        0 1px 0 rgba(255, 255, 255, 0.92) inset;
    backdrop-filter: blur(20px) saturate(155%);
    -webkit-backdrop-filter: blur(20px) saturate(155%);
    color: rgba(15, 23, 42, 0.9);
}

#homeBackgroundBtn::before,
#playOnlineBtn::before {
    content: "";
    position: absolute;
    inset: 1px;
    border-radius: inherit;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.46), rgba(255, 255, 255, 0.14) 42%, rgba(255, 255, 255, 0.2));
    opacity: 1;
}

#homeBackgroundBtn:hover,
#playOnlineBtn:hover {
    border-color: rgba(255, 255, 255, 0.92);
    box-shadow:
        0 22px 36px rgba(15, 23, 42, 0.16),
        0 12px 20px rgba(255, 255, 255, 0.52) inset,
        0 -10px 18px rgba(148, 163, 184, 0.14) inset,
        0 1px 0 rgba(255, 255, 255, 0.92) inset;
    color: rgba(2, 6, 23, 0.96);
}

.play-btn > *,
.ghost-btn > *,
.room-btn > *,
.revive-chip > *,
.home-icon-btn > *,
.hud-settings-btn > *,
.room-head-btn > *,
.room-copy-icon-btn > * {
    pointer-events: none;
}


#hud {
    z-index: 7;
    position: absolute;
    inset: 0;
    padding: 0;
    pointer-events: none;
}

.hud-settings-btn {
    position: absolute;
    top: calc(20px * var(--ui-scale));
    right: calc(20px * var(--ui-scale));
    left: auto;
    z-index: 8;
    display: inline-grid;
    place-items: center;
    width: var(--icon-button-size);
    height: var(--icon-button-size);
    padding: 0;
    box-sizing: border-box;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: var(--btn-shadow-soft);
    color: #0f172a;
    pointer-events: auto;
    touch-action: manipulation;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.hud-settings-btn svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

.gameplay-menu-popup {
    position: absolute;
    top: calc(20px * var(--ui-scale) + var(--icon-button-size) + 10px);
    right: calc(20px * var(--ui-scale));
    z-index: 9;
    display: grid;
    gap: 9px;
    width: min(calc(100vw - 32px), 300px);
    padding: 12px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.78);
    background: rgba(15, 23, 42, 0.9);
    box-shadow: 0 18px 42px rgba(15, 23, 42, 0.22);
    pointer-events: auto;
}

.gameplay-menu-popup.hidden {
    display: none;
}

.gameover-settings-btn {
    position: fixed;
    top: calc(16px * var(--ui-scale));
    right: max(var(--game-side-gutter), calc(var(--safe-right) + 8px));
    left: auto;
}

.gameover-menu-popup {
    position: fixed;
    top: calc(16px * var(--ui-scale) + var(--icon-button-size) + 10px);
    right: max(var(--game-side-gutter), calc(var(--safe-right) + 8px));
    left: auto;
}

.gameplay-guide-panel {
    display: grid;
    gap: 7px;
}

.gameplay-menu-title {
    margin: 0;
    color: rgba(248, 250, 252, 0.96);
    font-size: 14px;
    line-height: 1.2;
    font-weight: 900;
}


.gameplay-menu-btn {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    color: #0f172a;
    font-size: 13px;
    font-weight: 800;
    box-shadow: 0 10px 22px rgba(2, 6, 23, 0.18);
}

.gameplay-menu-btn.leave-room {
    background: rgba(254, 226, 226, 0.96);
    color: #991b1b;
}

.gameplay-guide-text {
    margin: 0;
    color: rgba(248, 250, 252, 0.96);
    font-size: 13px;
    line-height: 1.42;
}

.best-score-hud,
.score-hud {
    position: absolute;
    pointer-events: none;
    white-space: nowrap;
}

.best-score-hud {
    top: auto;
    bottom: max(8svh, calc(var(--safe-bottom) + 20px));
    left: max(var(--game-side-gutter), calc(var(--safe-left) + 8px));
    min-height: calc(44px * var(--ui-scale));
    padding: calc(10px * var(--ui-scale)) calc(21px * var(--ui-scale));
    border-radius: 999px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0.38)),
        linear-gradient(135deg, rgba(255, 255, 255, 0.42), rgba(226, 232, 240, 0.16));
    border: 1px solid rgba(255, 255, 255, 0.76);
    box-shadow:
        0 12px 24px rgba(15, 23, 42, 0.08),
        0 6px 12px rgba(255, 255, 255, 0.46) inset,
        0 1px 0 rgba(255, 255, 255, 0.74) inset;
    backdrop-filter: blur(10px) saturate(130%);
    -webkit-backdrop-filter: blur(10px) saturate(130%);
    font-size: clamp(15px, 1.6vw, 20px);
    font-weight: 800;
    color: rgba(30, 41, 59, 0.88);
    text-align: center;
}

.score-hud {
    top: max(calc((64px * var(--ui-scale)) + var(--gameplay-score-offset)), calc(var(--safe-top) + 64px + var(--gameplay-score-offset)));
    left: 50%;
    transform: translateX(-50%);
    max-width: calc(100vw - 180px);
    font-size: clamp(62px, 9.7vw, 95px);
    font-weight: 900;
    line-height: 1;
    letter-spacing: -0.03em;
    color: #0f172a;
    text-align: center;
    text-shadow:
        0 3px 18px rgba(255, 255, 255, 0.72),
        0 10px 24px rgba(15, 23, 42, 0.12);
}

#game-wrapper.is-dark-bg .score-hud {
    color: rgba(248, 250, 252, 0.98);
    text-shadow:
        0 3px 18px rgba(0, 0, 0, 0.72),
        0 0 30px rgba(255, 255, 255, 0.28);
}

#game-wrapper.is-dark-bg .best-score-hud {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(226, 232, 240, 0.76)),
        linear-gradient(135deg, rgba(255, 255, 255, 0.46), rgba(148, 163, 184, 0.18));
    border-color: rgba(255, 255, 255, 0.82);
    color: rgba(15, 23, 42, 0.94);
    box-shadow:
        0 16px 30px rgba(2, 6, 23, 0.28),
        0 6px 12px rgba(255, 255, 255, 0.5) inset,
        0 1px 0 rgba(255, 255, 255, 0.86) inset;
}

.score-hud.bump {
    transform: translateX(-50%) scale(1.03);
}

.score-hud.new-record {
    color: #16a34a;
    text-shadow:
        0 0 18px rgba(134, 239, 172, 0.64),
        0 10px 24px rgba(22, 163, 74, 0.22);
}

.score-hud.record-pop {
    transform: translateX(-50%) scale(1.12);
}


.best-score-hud.new-record {
    color: #ecfdf5;
    background:
        linear-gradient(180deg, rgba(34, 197, 94, 0.94), rgba(22, 163, 74, 0.9)),
        linear-gradient(135deg, rgba(187, 247, 208, 0.42), rgba(21, 128, 61, 0.2));
    border-color: rgba(187, 247, 208, 0.78);
    box-shadow:
        0 14px 28px rgba(22, 163, 74, 0.22),
        0 7px 14px rgba(220, 252, 231, 0.34) inset,
        0 1px 0 rgba(240, 253, 244, 0.72) inset;
}

.best-score-hud.record-pop {
    transform: scale(1.06);
}

.gameover-respawn {
    display: grid;
    gap: 8px;
    justify-items: stretch;
    width: 100%;
    padding: 0;
    margin-top: 0;
}

.compact-play {
    width: 100%;
    min-width: 0;
    min-height: var(--pill-height);
}

.continue-info {
    max-width: 100%;
    margin: 0;
    color: rgba(15, 23, 42, 0.92);
    text-align: center;
    font-size: 12px;
    line-height: 1.45;
    font-weight: 900;
}

#game-wrapper.is-dark-bg .continue-info {
    color: rgba(248, 250, 252, 0.94);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.46);
}

.revive-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    min-width: 0;
    min-height: var(--pill-height);
    padding: 0 18px;
    border-radius: 999px;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    border: 0;
    box-shadow:
        0 16px 28px rgba(22, 163, 74, 0.26),
        0 1px 0 rgba(255, 255, 255, 0.24) inset;
    color: #ffffff;
    font-size: 13px;
    font-weight: 900;
    white-space: nowrap;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.revive-chip svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    flex: 0 0 auto;
}

.watch-ad-label {
    display: inline-block;
}

.revive-chip:hover {
    transform: translateY(-1px);
    box-shadow:
        0 18px 32px rgba(22, 163, 74, 0.32),
        0 1px 0 rgba(255, 255, 255, 0.24) inset;
}

.room-hud {
    position: absolute;
    top: max(calc(16px * var(--ui-scale)), calc(var(--safe-top) + 16px));
    bottom: auto;
    left: max(var(--game-side-gutter), calc(var(--safe-left) + 8px));
    pointer-events: auto;
    width: fit-content;
    min-width: 0;
    max-width: min(calc(100% - 24px), calc(18ch + 18px));
    margin-left: 0;
    margin-right: auto;
    padding: calc(5px * var(--ui-scale)) calc(7px * var(--ui-scale));
    border-radius: calc(13px * var(--ui-scale));
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.025);
    backdrop-filter: blur(4px) saturate(108%);
    -webkit-backdrop-filter: blur(4px) saturate(108%);
    transform-origin: top left;
    transition: transform 0.22s ease, box-shadow 0.22s ease, opacity 0.22s ease;
}

.room-hud-body {
    display: grid;
    gap: 4px;
    margin-top: 0;
}

.room-hud-players {
    list-style: none;
    display: grid;
    gap: 2px;
}

.room-hud-players li {
    display: grid;
    grid-template-columns: minmax(0, 13ch) minmax(2ch, max-content);
    align-items: center;
    gap: 5px;
    padding: 0;
}

.room-hud-name {
    min-width: 0;
    max-width: 13ch;
    font-size: calc(13px * var(--ui-scale));
    font-weight: 800;
    color: rgba(15, 23, 42, 0.88);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


.room-hud-score {
    font-size: calc(13px * var(--ui-scale));
    font-weight: 800;
    color: rgba(37, 99, 235, 0.9);
    min-width: 2ch;
    text-align: right;
}

.room-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.room-btn svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
    flex: 0 0 auto;
}

.home-icon-btn {
    position: absolute;
    top: 0;
    right: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--icon-button-size);
    height: var(--icon-button-size);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(17, 24, 39, 0.08);
    box-shadow: 0 10px 22px rgba(17, 24, 39, 0.08);
    color: #111827;
}

.home-icon-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.liquid-chip {
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.68);
    background:
        linear-gradient(180deg, rgba(16, 24, 40, 0.92), rgba(15, 23, 42, 0.88)),
        linear-gradient(135deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.04));
    box-shadow:
        0 20px 42px rgba(15, 23, 42, 0.24),
        0 1px 0 rgba(255, 255, 255, 0.32) inset,
        0 -10px 24px rgba(15, 23, 42, 0.18) inset;
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    color: #ffffff;
    font-size: clamp(18px, 2.8vw, 22px);
    font-weight: 800;
    letter-spacing: -0.02em;
}

#touchControls button::after {
    display: none;
}

#touchControls {
    z-index: 4;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    touch-action: none;
}

#touchControls button {
    position: relative;
    width: 100%;
    height: 100%;
    font-size: 0;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
}

#touchControls button::before {
    content: "";
    position: absolute;
    inset: 0;
    opacity: 0.28;
    transition: opacity 0.16s ease, transform 0.16s ease;
}

#touchControls button::after {
    position: absolute;
    bottom: max(26px, env(safe-area-inset-bottom));
    padding: 12px 16px;
    border: 1px solid rgba(17, 24, 39, 0.08);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.76);
    font-size: 12px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

#leftControlBtn::before {
    background:
        radial-gradient(circle at 22% 54%, rgba(31, 41, 55, 0.05), transparent 36%),
        linear-gradient(90deg, rgba(31, 41, 55, 0.04), transparent 74%);
}

#rightControlBtn::before {
    background:
        radial-gradient(circle at 78% 54%, rgba(31, 41, 55, 0.05), transparent 36%),
        linear-gradient(270deg, rgba(31, 41, 55, 0.04), transparent 74%);
}

#leftControlBtn::after {
    content: "←";
    left: 24px;
}

#rightControlBtn::after {
    content: "→";
    right: 24px;
}

#touchControls button:active::before {
    opacity: 0.52;
    transform: scale(0.985);
}


/* ── Room Modal (Popup) ── */

.room-modal {
    z-index: 9;
    display: grid;
    place-items: start center;
    justify-items: center;
    padding:
        max(24svh, calc(var(--safe-top) + 24svh))
        max(16px, var(--safe-right))
        max(16px, var(--safe-bottom))
        max(16px, var(--safe-left));
    background: rgba(15, 23, 42, 0.28);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.background-modal {
    z-index: 10;
    display: grid;
    place-items: center;
    padding:
        max(18px, var(--safe-top))
        max(12px, var(--safe-right))
        max(18px, var(--safe-bottom))
        max(12px, var(--safe-left));
    background: rgba(15, 23, 42, 0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.background-modal-card {
    width: min(calc(100vw - 24px), 430px);
    max-height: min(calc(100svh - 36px), 620px);
    max-height: min(calc(100dvh - 36px), 620px);
    overflow: hidden;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 12px;
    padding: 0 14px 14px;
    border-radius: 22px;
    border: 1px solid rgba(255, 255, 255, 0.72);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(241, 245, 249, 0.96));
    box-shadow: 0 28px 60px rgba(15, 23, 42, 0.28);
}

.background-modal-head {
    position: sticky;
    top: 0;
    z-index: 2;
    display: grid;
    grid-template-columns: var(--modal-icon-button-size) minmax(0, 1fr) var(--modal-icon-button-size);
    align-items: center;
    gap: 10px;
    margin: 0 -14px;
    padding: 14px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.96));
    box-shadow:
        0 14px 22px rgba(15, 23, 42, 0.1),
        0 1px 0 rgba(226, 232, 240, 0.8);
}

.background-title,
.room-choice-title {
    margin: 0;
    color: #0f172a;
    font-size: 18px;
    font-weight: 900;
    line-height: 1.15;
}

.background-title {
    text-align: center;
}

.room-head-btn.background-back-btn {
    flex: 0 0 auto;
    width: var(--modal-icon-button-size);
    height: var(--modal-icon-button-size);
    border: 1px solid rgba(255, 255, 255, 0.92);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.76)),
        linear-gradient(135deg, rgba(255, 255, 255, 0.85), rgba(226, 232, 240, 0.5));
    color: #0f172a;
    box-shadow:
        0 16px 30px rgba(15, 23, 42, 0.18),
        0 8px 14px rgba(15, 23, 42, 0.12),
        0 12px 18px rgba(255, 255, 255, 0.58) inset,
        0 -8px 14px rgba(148, 163, 184, 0.14) inset,
        0 1px 0 rgba(255, 255, 255, 0.94) inset;
    backdrop-filter: blur(18px) saturate(160%);
    -webkit-backdrop-filter: blur(18px) saturate(160%);
}

.room-head-btn.background-back-btn:hover {
    box-shadow:
        0 18px 34px rgba(15, 23, 42, 0.2),
        0 9px 16px rgba(15, 23, 42, 0.13),
        0 12px 18px rgba(255, 255, 255, 0.58) inset,
        0 -8px 14px rgba(148, 163, 184, 0.14) inset,
        0 1px 0 rgba(255, 255, 255, 0.94) inset;
}

.background-head-spacer {
    width: var(--modal-icon-button-size);
    height: var(--modal-icon-button-size);
}

.background-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-rows: max(84px, calc((min(calc(100vw - 24px), 430px) - 52px) / 3));
    gap: 10px;
    align-items: stretch;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 2px 2px 4px;
}

.background-swatch {
    position: relative;
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
    min-width: 0;
    box-sizing: border-box;
    overflow: hidden;
    border-radius: 12px;
    border: 2px solid rgba(148, 163, 184, 0.36);
    box-shadow: 0 8px 16px rgba(15, 23, 42, 0.08);
    background-position: center;
    cursor: pointer;
}

.background-swatch::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(0, 0, 0, 0.1));
    pointer-events: none;
}

.background-swatch span {
    position: absolute;
    inset: auto 4px 4px;
    z-index: 1;
    overflow: hidden;
    color: #ffffff;
    font-size: 9px;
    font-weight: 900;
    line-height: 1.05;
    text-align: center;
    text-shadow: 0 1px 5px rgba(0, 0, 0, 0.8);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.background-hot-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 1;
    padding: 3px 6px;
    border-radius: 999px;
    color: #ffffff;
    font-size: 9px;
    font-weight: 900;
    line-height: 1;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: linear-gradient(135deg, #ef4444, #f97316);
    box-shadow: 0 8px 14px rgba(127, 29, 29, 0.28);
    text-shadow: 0 1px 3px rgba(127, 29, 29, 0.5);
}

.background-swatch.is-selected {
    border-color: rgba(34, 197, 94, 0.92);
    box-shadow:
        0 0 0 3px rgba(34, 197, 94, 0.18),
        0 10px 18px rgba(15, 23, 42, 0.12);
}

.background-credit-link {
    justify-self: center;
    color: rgba(71, 85, 105, 0.88);
    font-size: 12px;
    font-weight: 800;
    text-decoration: none;
}

.background-credit-link:hover {
    color: #2563eb;
}

.background-reward-popup {
    position: fixed;
    inset: 0;
    z-index: 10001;
    display: grid;
    place-items: center;
    padding:
        max(18px, var(--safe-top))
        max(14px, var(--safe-right))
        max(18px, var(--safe-bottom))
        max(14px, var(--safe-left));
    background: rgba(15, 23, 42, 0.36);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.background-reward-popup.hidden {
    display: none;
}

.background-reward-card {
    position: relative;
    width: min(calc(100vw - 28px), 360px);
    display: grid;
    gap: 18px;
    padding: 26px 20px 20px;
    border-radius: 22px;
    border: 1px solid rgba(255, 255, 255, 0.74);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(241, 245, 249, 0.98));
    box-shadow: 0 30px 70px rgba(15, 23, 42, 0.32);
}

.background-reward-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 999px;
    color: #0f172a;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 10px 20px rgba(15, 23, 42, 0.12);
    cursor: pointer;
}

.background-reward-close svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.background-reward-copy {
    display: grid;
    gap: 8px;
    padding-right: 26px;
}

.background-reward-title {
    margin: 0;
    color: #0f172a;
    font-size: 20px;
    font-weight: 900;
    line-height: 1.15;
}

.background-reward-text {
    margin: 0;
    color: rgba(51, 65, 85, 0.92);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.45;
}

.background-reward-claim {
    min-height: 48px;
    border: 0;
    border-radius: 16px;
    color: #ffffff;
    font-size: 15px;
    font-weight: 900;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    box-shadow:
        0 16px 28px rgba(22, 163, 74, 0.26),
        0 1px 0 rgba(255, 255, 255, 0.24) inset;
    cursor: pointer;
}

.background-reward-claim:disabled {
    opacity: 0.68;
    cursor: wait;
}

.room-modal-card {
    position: relative;
    z-index: 1;
    width: min(100%, var(--room-card-width));
    min-height: 0;
    max-height: min(calc(100svh - 32px - var(--safe-top) - var(--safe-bottom)), 640px);
    max-height: min(calc(100dvh - 32px - var(--safe-top) - var(--safe-bottom)), 640px);
    overflow: auto;
    padding: 18px;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.72);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(241, 245, 249, 0.96));
    box-shadow: 0 28px 60px rgba(15, 23, 42, 0.28);
    display: grid;
    gap: 12px;
    align-content: start;
}

.room-head-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--modal-icon-button-size);
    min-width: var(--modal-icon-button-size);
    min-height: var(--modal-icon-button-size);
    padding: 0;
    border-radius: 999px;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.room-head-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    flex: 0 0 auto;
}

.room-exit-btn {
    position: static;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--modal-icon-button-size);
    height: var(--modal-icon-button-size);
    border-radius: 999px;
    border: 1px solid rgba(17, 24, 39, 0.08);
    background: rgba(255, 255, 255, 0.8);
    color: #111827;
    box-shadow: 0 10px 22px rgba(17, 24, 39, 0.08);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.room-exit-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.room-view {
    display: grid;
    gap: 14px;
}

.room-popup-view {
    display: grid;
    gap: 10px;
}

.room-head-btn:hover,
.room-action-btn:hover {
    box-shadow: none;
}

.room-action-btn {
    min-width: 0;
    width: 100%;
}

.room-action-btn.ghost-btn {
    box-shadow: none;
    background: rgba(226, 232, 255, 0.82);
    border-color: rgba(191, 219, 254, 0.52);
}

.room-action-btn.play-btn {
    box-shadow: none;
}

.room-action-btn.play-btn:hover,
.play-btn:hover {
    box-shadow: none;
}



/* ── Simplified Game Over Screen ── */

.gameover-simple {
    position: absolute;
    inset: 0;
    display: grid;
    width: 100%;
    padding: 0;
    text-align: center;
    pointer-events: none;
}

.gameover-scores {
    position: fixed;
    top: clamp(126px, 25svh, 220px);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 24px;
    width: min(calc(100vw - (var(--game-side-gutter) * 2)), var(--gameover-panel-width));
    padding: 8px 0;
    z-index: 7;
}

.gameover-score-main,
.gameover-score-best {
    display: grid;
    gap: 4px;
    text-align: center;
}

.gameover-label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(100, 116, 139, 0.78);
}

#game-wrapper.is-dark-bg .gameover-label {
    color: rgba(226, 232, 240, 0.88);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.48);
}

.gameover-value {
    font-size: clamp(52px, 14vw, 80px);
    line-height: 0.95;
    font-weight: 900;
    letter-spacing: -0.04em;
    color: rgba(17, 24, 39, 0.82);
}

#game-wrapper.is-dark-bg .gameover-value {
    color: rgba(248, 250, 252, 0.98);
    text-shadow: 0 4px 18px rgba(0, 0, 0, 0.6);
}

.gameover-best-value {
    font-size: clamp(28px, 7vw, 40px);
    line-height: 1;
    font-weight: 800;
    color: rgba(37, 99, 235, 0.88);
}

#game-wrapper.is-dark-bg .gameover-best-value {
    color: #bfdbfe;
    text-shadow: 0 3px 16px rgba(0, 0, 0, 0.54);
}

.drop-death-message {
    position: fixed;
    top: clamp(210px, 36svh, 315px);
    left: 50%;
    transform: translateX(-50%);
    width: min(calc(100vw - (var(--game-side-gutter) * 2)), min(360px, var(--gameover-panel-width)));
    margin: 0 auto 2px;
    padding: 6px 10px;
    border: 1px solid rgba(245, 158, 11, 0.24);
    border-radius: 8px;
    background: rgba(255, 251, 235, 0.56);
    color: rgba(146, 64, 14, 0.88);
    font-size: 11px;
    font-weight: 700;
    line-height: 1.28;
    z-index: 6;
    pointer-events: none;
}

.gameover-actions {
    --gameover-action-height: var(--pill-height);
    position: fixed;
    left: max(var(--game-side-gutter), calc(var(--safe-left) + 8px));
    right: max(var(--game-side-gutter), calc(var(--safe-right) + 8px));
    bottom: max(calc(var(--safe-bottom) + 78px), 20svh);
    display: grid;
    gap: 10px;
    width: auto;
    max-width: var(--gameover-panel-width);
    margin-top: 0;
    margin-left: auto;
    margin-right: auto;
    justify-items: center;
    z-index: 8;
    pointer-events: auto;
}

#game-wrapper.is-dark-bg .gameover-actions .play-btn {
    border-color: rgba(255, 255, 255, 0.86);
    background: rgba(248, 250, 252, 0.94);
    color: #020617;
    box-shadow:
        0 18px 36px rgba(2, 6, 23, 0.32),
        0 1px 0 rgba(255, 255, 255, 0.82) inset;
}

#game-wrapper.is-dark-bg .gameover-actions .ghost-btn {
    border-color: rgba(255, 255, 255, 0.76);
    background: rgba(255, 255, 255, 0.88);
    color: #0f172a;
}

.gameover-actions .gameover-respawn {
    margin-top: 0;
    margin-bottom: 0;
    width: 100%;
    max-width: var(--gameover-panel-width);
    justify-self: center;
}

.gameover-actions .compact-play {
    width: 100%;
    max-width: var(--gameover-panel-width);
    justify-self: center;
}

.gameover-actions .revive-chip {
    height: var(--gameover-action-height);
    min-height: var(--gameover-action-height);
}

.gameover-primary-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: var(--gameover-panel-width);
}

.gameover-primary-actions #retryBtn {
    width: 100%;
    height: var(--gameover-action-height);
    min-height: var(--gameover-action-height);
    max-width: none;
    justify-self: stretch;
}

.gameover-primary-actions .gameover-home-btn {
    position: fixed;
    top: calc(16px * var(--ui-scale));
    right: max(var(--game-side-gutter), calc(var(--safe-right) + 8px));
    left: auto;
    z-index: 8;
    width: var(--icon-button-size);
    height: var(--icon-button-size);
    min-width: var(--icon-button-size);
    min-height: var(--icon-button-size);
    background: rgba(255, 255, 255, 0.94);
    box-shadow:
        0 16px 30px rgba(15, 23, 42, 0.18),
        0 7px 14px rgba(15, 23, 42, 0.12),
        0 1px 0 rgba(255, 255, 255, 0.9) inset;
}

.gameover-primary-actions .gameover-home-btn svg {
    width: 20px;
    height: 20px;
}

/* ── Room Waiting View ── */

.room-code-section {
    display: grid;
    justify-items: center;
    gap: 8px;
    padding: 0;
}

.room-code-label-sm {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(100, 116, 139, 0.82);
    margin: 0;
}

.room-code-inline {
    display: flex;
    align-items: center;
    width: 100%;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(226, 232, 240, 0.96);
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}

.room-code-big {
    flex: 1 1 auto;
    font-size: clamp(26px, 8vw, 36px);
    line-height: 1;
    letter-spacing: 0.14em;
    text-align: left;
    color: #020617;
    font-weight: 900;
}

.room-copy-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: clamp(42px, 8.5vw, 46px);
    height: clamp(42px, 8.5vw, 46px);
    border-radius: 14px;
    background: rgba(226, 232, 255, 0.9);
    border: 1px solid rgba(191, 219, 254, 0.48);
    color: #334155;
    cursor: pointer;
    transition: background 0.16s ease;
}

.room-copy-icon-btn:active {
    background: rgba(191, 219, 254, 0.72);
}

.room-copy-icon-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.room-copy-feedback {
    min-height: 18px;
    font-size: 11px;
    font-weight: 700;
    color: rgba(59, 130, 246, 0.88);
    text-align: center;
}

.room-start-hint {
    min-height: 18px;
    margin: 0;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.35;
    text-align: left;
    color: #dc2626;
}

.room-start-hint.is-hidden {
    display: none;
}

@media (pointer: coarse) {
    .username-input,
    #homeBackgroundBtn,
    #playOnlineBtn,
    .score-hud,
    .room-hud,
    .liquid-chip {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
}

.room-join-section {
    display: grid;
    gap: 20px;
}

.room-online-choice-section {
    display: grid;
    gap: 14px;
}

.room-username-field {
    max-width: none;
}

.room-username-field .username-input {
    box-shadow:
        0 12px 24px rgba(15, 23, 42, 0.08),
        0 12px 18px rgba(255, 255, 255, 0.58) inset,
        0 -8px 14px rgba(148, 163, 184, 0.12) inset,
        0 1px 0 rgba(255, 255, 255, 0.9) inset;
}

.room-online-choice-actions {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
    align-items: center;
}

.room-online-choice-actions .room-exit-btn {
    grid-column: 1;
}

.room-online-choice-actions .room-action-btn {
    width: 100%;
    min-width: 0;
}

.room-notice-card {
    display: grid;
    place-items: center;
    gap: 16px;
    min-height: clamp(180px, 28svh, 240px);
    padding: clamp(18px, 4vw, 24px) clamp(14px, 4vw, 20px);
    border-radius: 24px;
    border: 1px solid rgba(226, 232, 240, 0.9);
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}

.room-notice-text {
    margin: 0;
    max-width: min(100%, var(--room-card-width));
    font-size: clamp(16px, 4vw, 18px);
    font-weight: 800;
    line-height: 1.45;
    text-align: center;
    color: #dc2626;
}

.room-notice-card .room-exit-btn {
    justify-self: center;
}

.room-join-label {
    display: none;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(71, 85, 105, 0.86);
}

.room-join-input {
    width: 100%;
    min-height: var(--pill-height);
    padding: 0 16px;
    border-radius: 16px;
    border: 1px solid rgba(226, 232, 240, 0.96);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
    color: #111827;
    font: inherit;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.room-join-input:focus {
    border-color: rgba(59, 130, 246, 0.42);
    box-shadow: 0 0 0 4px rgba(191, 219, 254, 0.5);
}

.room-join-feedback {
    min-height: 8px;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
    color: #dc2626;
}

.room-join-feedback:empty {
    display: none;
}

.room-join-actions {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
    align-items: center;
}

.room-join-actions .room-action-btn {
    width: 100%;
    min-width: 0;
}

.room-members-section {
    display: grid;
    gap: 12px;
}

.room-members-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.room-members-count-text {
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(71, 85, 105, 0.86);
}

.room-members-list {
    list-style: none;
    display: grid;
    gap: 0;
    min-height: 56px;
    max-height: 220px;
    margin: 0;
    padding: 0;
    border-radius: 16px;
    overflow: auto;
    border: 1px solid rgba(226, 232, 240, 0.88);
    background: #ffffff;
    box-shadow: none;
}

.room-member-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 52px;
    padding: 0 16px;
}

.room-member-item + .room-member-item {
    border-top: 1px solid rgba(226, 232, 240, 0.72);
}

.room-member-item.is-self {
    background: rgba(248, 250, 252, 0.72);
}

.room-member-item.is-inactive {
    background: rgba(248, 250, 252, 0.72);
}

.room-member-name {
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    color: #1e293b;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.room-member-item.is-inactive .room-member-name {
    color: rgba(71, 85, 105, 0.62);
}

.room-member-item.is-top-player .room-member-name {
    color: #dc2626;
}

.room-member-item.is-lobby-host .room-member-name {
    color: #0f172a;
}

.room-member-badges {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}

.room-member-host-tag {
    display: inline-flex;
    align-items: center;
    padding: 0;
    border-radius: 0;
    background: transparent;
    color: #b91c1c;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.player-self-suffix {
    color: #15803d;
}

.player-disconnected-suffix {
    color: inherit;
}

.room-member-status-tag {
    display: inline-flex;
    align-items: center;
    padding: 0;
    border-radius: 0;
    background: transparent;
    color: #b91c1c;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.room-actions-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px;
    align-items: start;
}

.room-actions-row .room-start-hint {
    grid-column: 1 / -1;
    grid-row: 1;
    text-align: center;
}

.room-actions-row .room-exit-btn {
    grid-column: 1;
    grid-row: 2;
    justify-self: start;
}

.room-actions-row .room-action-btn {
    grid-column: 2;
    grid-row: 2;
    width: 100%;
    min-width: 0;
}

.record-toast {
    position: absolute;
    top: 24px;
    left: 50%;
    z-index: 8;
    padding: calc(10px * var(--ui-scale)) calc(16px * var(--ui-scale));
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.9);
    color: #ecfdf5;
    font-size: calc(12px * var(--ui-scale));
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    transform: translateX(-50%) translateY(-8px);
    opacity: 0;
    transition: opacity 0.22s ease, transform 0.22s ease;
    pointer-events: none;
}

.record-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

@media (max-width: 768px) {
    :root {
        --home-content-width: clamp(288px, 90vw, 460px);
        --home-picker-width: clamp(292px, 62vw, 380px);
        --room-card-width: clamp(300px, 76vw, 390px);
        --gameover-panel-width: clamp(300px, 76vw, 390px);
        --pill-height: clamp(48px, min(7.5vw, 6.5svh), 60px);
        --icon-button-size: clamp(40px, min(6.5vw, 5.4svh), 46px);
        --modal-icon-button-size: clamp(42px, min(6.5vw, 5.8svh), 48px);
        --game-side-gutter: clamp(18px, 5vw, 40px);
        --layout-pad-x: clamp(18px, 5vw, 40px);
        --layout-pad-y: clamp(16px, 3svh, 30px);
    }

    .home-screen {
        padding:
            max(20px, var(--safe-top))
            max(var(--game-side-gutter), var(--safe-right))
            max(20px, var(--safe-bottom))
            max(var(--game-side-gutter), var(--safe-left));
    }

    #gameOverScreen {
        padding:
            max(20px, var(--safe-top))
            max(var(--game-side-gutter), var(--safe-right))
            max(20px, var(--safe-bottom))
            max(var(--game-side-gutter), var(--safe-left));
        gap: 12px;
    }

    .home-center {
        margin: auto 0;
        padding: clamp(16px, 2.5svh, 24px) 0 clamp(14px, 2svh, 24px);
        border: none;
        background: none;
        box-shadow: none;
    }

    .home-pet-picker {
        bottom: calc(max(calc(var(--safe-bottom) + 72px), 25svh) + clamp(146px, 18svh, 172px));
    }

    .home-icon-btn {
        width: var(--icon-button-size);
        height: var(--icon-button-size);
    }

    .home-icon-btn svg {
        width: 18px;
        height: 18px;
    }

    .compact-play {
        width: 100%;
        min-height: var(--pill-height);
    }

    .gameover-actions,
    .gameover-primary-actions {
        --gameover-action-height: 56px;
    }

    #hud {
        padding: 0;
    }

    .hud-settings-btn {
        top: calc(20px * var(--ui-scale));
        right: calc(20px * var(--ui-scale));
        left: auto;
        width: var(--icon-button-size);
        height: var(--icon-button-size);
    }

    .hud-settings-btn svg {
        width: 22px;
        height: 22px;
    }

    .gameover-primary-actions .gameover-home-btn {
        top: 16px;
        right: max(var(--game-side-gutter), calc(var(--safe-right) + 8px));
        left: auto;
        width: var(--icon-button-size);
        height: var(--icon-button-size);
    }

    .gameover-primary-actions .gameover-home-btn svg {
        width: 18px;
        height: 18px;
    }

    .gameplay-menu-popup {
        top: calc(20px * var(--ui-scale) + var(--icon-button-size) + 8px);
        right: calc(20px * var(--ui-scale));
        width: min(calc(100vw - 28px), 300px);
    }

    .room-hud {
        min-width: 0;
        width: fit-content;
        max-width: min(calc(100% - 24px), calc(17ch + 16px));
        padding: 5px;
        border-radius: 13px;
        top: max(16px, calc(var(--safe-top) + 16px));
        bottom: auto;
        left: max(var(--game-side-gutter), calc(var(--safe-left) + 8px));
    }

    .play-btn,
    .compact-play,
    .hero-play {
        width: 100%;
    }

    .home-online-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: clamp(8px, 2.2vw, 12px);
    }

    .home-online-actions .hero-play {
        min-width: 0;
        min-height: var(--pill-height);
        padding: 0 clamp(12px, 3.4vw, 16px);
        font-size: clamp(12px, 2.7vw, 14px);
    }



    .gameover-respawn {
        width: min(100%, var(--gameover-panel-width));
        padding: 0;
        gap: 8px;
    }

    .continue-info {
        max-width: 100%;
        font-size: 11px;
    }

    .revive-chip {
        min-width: 100%;
        font-size: 12px;
    }

    .room-btn {
        padding-left: 14px;
        padding-right: 14px;
        font-size: 14px;
    }

    .room-modal-card {
        width: min(100%, var(--room-card-width));
        padding: 18px;
        border-radius: 24px;
    }

    .best-score-hud {
        top: auto;
        bottom: max(8svh, calc(var(--safe-bottom) + 18px));
        left: max(var(--game-side-gutter), calc(var(--safe-left) + 8px));
        min-height: 40px;
        padding: 9px 18px;
        font-size: clamp(14px, 3.5vw, 18px);
    }

    .score-hud {
        top: max(calc(54px + var(--gameplay-score-offset)), calc(var(--safe-top) + 54px + var(--gameplay-score-offset)));
        max-width: calc(100vw - 144px);
        font-size: clamp(51px, 12.5vw, 73px);
    }

    #touchControls button::after {
        bottom: max(18px, var(--safe-bottom));
        padding: 10px 12px;
        font-size: 11px;
        letter-spacing: 0.12em;
    }

    #leftControlBtn::after {
        left: 14px;
    }

    #rightControlBtn::after {
        right: 14px;
    }
}

@media (max-width: 480px) {
    :root {
        --home-content-width: clamp(288px, 90vw, 420px);
        --home-picker-width: clamp(280px, calc(100vw - 24px), 330px);
        --room-card-width: clamp(292px, calc(100vw - 20px), 340px);
        --gameover-panel-width: clamp(292px, calc(100vw - 24px), 340px);
        --pill-height: clamp(46px, 12vw, 52px);
        --icon-button-size: clamp(38px, 10.5vw, 44px);
        --modal-icon-button-size: clamp(40px, 11vw, 46px);
        --game-side-gutter: clamp(16px, 5.5vw, 28px);
        --layout-pad-x: clamp(16px, 5.5vw, 28px);
        --layout-pad-y: clamp(12px, 3svh, 22px);
    }

    .home-screen,
    #gameOverScreen {
        padding:
            max(var(--layout-pad-y), var(--safe-top))
            max(var(--layout-pad-x), var(--safe-right))
            max(var(--layout-pad-y), var(--safe-bottom))
            max(var(--layout-pad-x), var(--safe-left));
    }

    .home-center {
        border-radius: 0;
        padding: clamp(14px, 2.4svh, 22px) 0 16px;
        margin: auto 0;
        border: none;
        background: none;
        box-shadow: none;
    }

    .home-pet-picker {
        bottom: calc(max(calc(var(--safe-bottom) + 68px), 25svh) + clamp(134px, 19svh, 158px));
    }

    .home-actions-wrapper {
        bottom: max(calc(var(--safe-bottom) + 68px), 25svh);
    }


    .username-label,
    .room-join-label,
    .room-members-count-text,
    .room-code-label-sm {
        font-size: 11px;
    }

    .username-input,
    .room-join-input {
        min-height: var(--pill-height);
        font-size: 16px;
    }

    .home-online-actions {
        gap: 8px;
    }

    .home-online-actions .hero-play {
        min-height: var(--pill-height);
        padding: 0 clamp(10px, 3vw, 14px);
        font-size: clamp(12px, 3.3vw, 13px);
    }

    .play-btn,
    .ghost-btn,
    .compact-play {
        min-height: var(--pill-height);
        padding-inline: 14px;
    }

    .gameover-actions,
    .gameover-primary-actions {
        --gameover-action-height: 48px;
    }

    .gameover-simple {
        width: min(100%, var(--gameover-panel-width));
        gap: 16px;
    }

    .gameover-scores {
        gap: 18px;
    }

    .gameover-value {
        font-size: clamp(44px, 13vw, 64px);
    }

    .gameover-best-value {
        font-size: clamp(24px, 7vw, 32px);
    }

    #hud {
        padding: 0;
    }

    .hud-settings-btn {
        top: calc(20px * var(--ui-scale));
        right: calc(20px * var(--ui-scale));
        left: auto;
        width: var(--icon-button-size);
        height: var(--icon-button-size);
    }

    .gameover-primary-actions .gameover-home-btn {
        top: 12px;
        right: max(var(--game-side-gutter), calc(var(--safe-right) + 6px));
        left: auto;
        width: var(--icon-button-size);
        height: var(--icon-button-size);
    }

    .gameplay-menu-popup {
        top: calc(20px * var(--ui-scale) + var(--icon-button-size) + 8px);
        right: calc(20px * var(--ui-scale));
        width: min(calc(100vw - 24px), 292px);
    }

    .score-hud {
        top: max(calc(48px + var(--gameplay-score-offset)), calc(var(--safe-top) + 48px + var(--gameplay-score-offset)));
        max-width: calc(100vw - 124px);
        font-size: clamp(46px, 13vw, 64px);
    }

    .best-score-hud {
        top: auto;
        bottom: max(8svh, calc(var(--safe-bottom) + 14px));
        left: max(var(--game-side-gutter), calc(var(--safe-left) + 6px));
        min-height: 38px;
        padding: 8px 16px;
        font-size: 13px;
    }

    .room-hud {
        top: max(12px, calc(var(--safe-top) + 12px));
        bottom: auto;
        left: max(var(--game-side-gutter), calc(var(--safe-left) + 6px));
        width: fit-content;
        min-width: 0;
        max-width: min(calc(100% - 24px), calc(16ch + 14px));
        padding: 5px;
    }

    .room-hud-name,
    .room-hud-score {
        font-size: 12px;
    }

    .room-modal {
        padding:
            max(20svh, calc(var(--safe-top) + 20svh))
            max(10px, var(--safe-right))
            max(10px, var(--safe-bottom))
            max(10px, var(--safe-left));
    }

    .room-modal-card {
        width: min(100%, var(--room-card-width));
        padding: 18px 14px calc(18px + var(--safe-bottom));
        border-radius: 20px;
    }

    .room-code-inline {
        gap: 10px;
        padding: 10px 12px;
    }

    .room-code-big {
        font-size: clamp(20px, 8vw, 26px);
        letter-spacing: 0.1em;
    }

    .room-copy-icon-btn {
        width: var(--modal-icon-button-size);
        height: var(--modal-icon-button-size);
    }

    .room-member-item {
        min-height: 48px;
        padding: 0 12px;
    }

    #touchControls button::after {
        bottom: max(12px, var(--safe-bottom));
        padding: 8px 10px;
        font-size: 10px;
    }

    #leftControlBtn::after {
        left: 10px;
    }

    #rightControlBtn::after {
        right: 10px;
    }
}

@media (max-height: 600px) {
    :root {
        --home-title-size: clamp(52px, min(10vw, 14svh), 92px);
        --pill-height: clamp(44px, 7.5svh, 52px);
    }

    .home-center,
    .gameover-simple {
        margin-top: max(8px, var(--safe-top));
        margin-bottom: max(8px, var(--safe-bottom));
    }

    .home-center {
        padding-top: 18px;
        padding-bottom: 18px;
    }

    .home-actions-wrapper {
        bottom: max(calc(var(--safe-bottom) + 60px), 25svh);
    }

    .home-title-stack {
        top: max(calc(var(--safe-top) + 14px), 15svh);
    }

    .gameover-scores {
        top: clamp(126px, 24svh, 156px);
    }

    .drop-death-message {
        top: clamp(174px, 31svh, 210px);
        padding: 5px 8px;
        font-size: 10px;
    }

    .gameover-actions {
        bottom: max(calc(var(--safe-bottom) + 72px), 20svh);
    }

    .home-pet-picker {
        bottom: calc(max(calc(var(--safe-bottom) + 60px), 25svh) + clamp(124px, 20svh, 148px));
    }

    .home-pet-picker,
    .pet-preview-stage {
        min-height: clamp(126px, 22svh, 174px);
    }

    .pet-preview-viewport {
        width: min(100%, clamp(190px, 38vw, 232px));
        height: clamp(116px, 19svh, 154px);
    }

}




/* Mobile fullscreen: khi browser vào fullscreen mode, fill toàn màn hình */
:fullscreen #app-shell,
:fullscreen #game-wrapper {
    height: 100vh;
    height: 100svh;
    height: 100dvh;
}

:-webkit-full-screen #app-shell,
:-webkit-full-screen #game-wrapper {
    height: 100vh;
    height: 100svh;
    height: 100dvh;
}

.room-hud-players li.is-inactive {
    opacity: 0.62;
}

.room-hud-players li.is-top-player .room-hud-name {
    color: #dc2626;
}

.system-popup {
    position: fixed;
    left: 50%;
    bottom: calc(18px + var(--safe-bottom) + 52px);
    transform: translateX(-50%);
    z-index: 10000;
    width: max-content;
    max-width: min(calc(100vw - 24px), 360px);
    pointer-events: none;
}

.system-popup.hidden {
    display: none;
}

.system-popup-card {
    width: auto;
    display: grid;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.84);
    border: 1px solid rgba(148, 163, 184, 0.22);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18);
    pointer-events: auto;
}

.system-popup-copy {
    display: grid;
    gap: 1px;
    min-width: 0;
}

.system-popup-title {
    margin: 0;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    line-height: 1.2;
    color: rgba(191, 219, 254, 0.92);
}

.system-popup-title:empty {
    display: none;
}

.system-popup-text {
    margin: 0;
    font-size: 12px;
    line-height: 1.25;
    color: rgba(248, 250, 252, 0.96);
    overflow: hidden;
    text-overflow: ellipsis;
}

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