html,
body {
    margin: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #020308;
    font-family: Inter, Segoe UI, system-ui, sans-serif;
    color: white;
}

/* The renderer deliberately uses a sub-1.0 internal pixel ratio for speed.
   Its CSS size must stay at the full viewport size or the reduced drawing
   buffer appears as black strips on the right and bottom. */
#game-container {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: #020308;
}

#game-container > canvas {
    position: absolute;
    inset: 0;
    z-index: 0;
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    touch-action: none;
}

#ui-layer {
    position: fixed;
    inset: 0;
    z-index: 10;
    width: auto;
    height: auto;
    pointer-events: none; /* Let clicks pass through to canvas when exploring */
}

/* Start screen */
#start-screen {
    position: absolute;
    inset: 0;
    z-index: 20;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 24% 16%, rgba(76, 201, 255, 0.24), transparent 34%),
        radial-gradient(circle at 82% 74%, rgba(255, 79, 216, 0.16), transparent 34%),
        linear-gradient(135deg, #050913, #140c21 54%, #03070d);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    transition: opacity 0.45s ease, filter 0.45s ease;
    isolation: isolate;
    overflow: hidden;
}

#start-screen.hidden {
    opacity: 0;
    filter: blur(10px);
    pointer-events: none;
}

.start-panorama {
    position: absolute;
    inset: 0;
    overflow: hidden;
    opacity: 0.92;
    z-index: -2;
}

.start-panorama::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px),
        linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px);
    background-size: 72px 72px;
    mask-image: linear-gradient(to bottom, transparent, #000 18%, #000 82%, transparent);
}

.panorama-strip {
    position: absolute;
    left: 50%;
    top: 50%;
    width: min(1420px, 120vw);
    height: min(660px, 78vh);
    transform: translate(-50%, -50%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 28px;
    overflow: hidden;
    background:
        linear-gradient(180deg, rgba(36, 33, 46, 0.94) 0 48%, rgba(42, 46, 51, 0.98) 48% 100%);
    box-shadow: 0 40px 140px rgba(0, 0, 0, 0.72), inset 0 1px 0 rgba(255,255,255,0.14);
    animation: panoDrift 18s ease-in-out infinite alternate;
}

.panorama-strip span {
    position: absolute;
    display: block;
}

.pano-wall {
    inset: 0;
    background:
        repeating-linear-gradient(90deg, rgba(255,255,255,0.045) 0 2px, transparent 2px 54px),
        radial-gradient(circle at 18% 32%, rgba(76, 201, 255, 0.16), transparent 24%),
        radial-gradient(circle at 78% 28%, rgba(255, 79, 216, 0.13), transparent 26%);
}

.pano-floor {
    left: -6%;
    right: -6%;
    bottom: 0;
    height: 38%;
    background:
        linear-gradient(90deg, rgba(255,255,255,0.13) 1px, transparent 1px),
        linear-gradient(rgba(255,255,255,0.13) 1px, transparent 1px),
        linear-gradient(135deg, rgba(42, 46, 51, 0.96), rgba(18, 20, 24, 0.98));
    background-size: 82px 82px;
    transform: perspective(500px) rotateX(56deg);
    transform-origin: bottom;
}

.pano-window {
    right: 14%;
    top: 14%;
    width: 18%;
    height: 24%;
    border: 10px solid rgba(71, 65, 49, 0.9);
    background: linear-gradient(135deg, #21334e, #0e1727);
    box-shadow: 0 0 42px rgba(255, 210, 110, 0.18);
}

.pano-window::before,
.pano-window::after {
    content: "";
    position: absolute;
    background: rgba(255,255,255,0.16);
}

.pano-window::before {
    left: 50%;
    top: 0;
    width: 3px;
    height: 100%;
}

.pano-window::after {
    width: 8px;
    height: 8px;
    right: 22%;
    top: 28%;
    border-radius: 50%;
    background: #ffe299;
    box-shadow: 0 0 18px #ffe299;
}

.pano-bed {
    right: 4%;
    bottom: 17%;
    width: 30%;
    height: 18%;
    border-radius: 8px;
    background: linear-gradient(90deg, #243341 0 42%, #101b24 42% 100%);
    box-shadow: inset 0 -16px 0 rgba(63, 36, 27, 0.78);
}

.pano-bed::before {
    content: "";
    position: absolute;
    right: 9%;
    top: -24%;
    width: 24%;
    height: 34%;
    border-radius: 7px;
    background: #ececec;
}

.pano-pc {
    left: 58%;
    top: 27%;
    width: 15%;
    height: 15%;
    border-radius: 10px;
    background: linear-gradient(135deg, #05070c, #141723);
    box-shadow: 0 0 0 5px #080a10, 0 0 38px rgba(76,201,255,0.48);
}

.pano-pc::after {
    content: "";
    position: absolute;
    right: -28%;
    bottom: -62%;
    width: 26%;
    height: 96%;
    border-radius: 10px;
    background: linear-gradient(180deg, rgba(76,201,255,0.8), rgba(255,79,216,0.82));
}

.pano-piano {
    left: 21%;
    bottom: 30%;
    width: 28%;
    height: 8%;
    background: #030304;
    box-shadow: 0 12px 0 rgba(0,0,0,0.45), inset 0 -10px 0 #f4f4ee;
}

.pano-piano::before {
    content: "";
    position: absolute;
    left: 12%;
    right: 12%;
    top: -92%;
    height: 86%;
    transform: skewX(-10deg);
    background: #f5f1e8;
    box-shadow: 0 0 24px rgba(245, 241, 232, 0.22);
}

.pano-fridge {
    left: 6%;
    bottom: 26%;
    width: 9%;
    height: 34%;
    border-radius: 6px;
    background: linear-gradient(90deg, #e6eef4, #a8b8c3);
    box-shadow: inset -12px 0 0 rgba(0,0,0,0.12);
}

.pano-fridge::after {
    content: "";
    position: absolute;
    right: 10%;
    top: 34%;
    width: 8%;
    height: 24%;
    border-radius: 4px;
    background: rgba(0,0,0,0.38);
}

.start-panel {
    width: min(620px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    overflow: auto;
    padding: 34px;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(5, 8, 16, 0.76);
    box-shadow: 0 30px 110px rgba(0, 0, 0, 0.62), inset 0 1px 0 rgba(255,255,255,0.14);
    backdrop-filter: blur(26px) saturate(145%);
}

.start-kicker {
    margin: 0 0 10px;
    color: #4cc9ff;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 12px;
    font-weight: 900;
}

.start-panel h1 {
    margin: 0;
    font-size: clamp(42px, 8vw, 78px);
    line-height: 0.9;
    letter-spacing: 0;
}

.start-copy {
    max-width: 52ch;
    margin: 18px 0 0;
    color: rgba(245, 248, 255, 0.74);
    font-size: 16px;
    line-height: 1.55;
}

.start-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.start-actions span {
    color: rgba(245, 248, 255, 0.58);
    font-size: 13px;
}

.start-actions kbd {
    padding: 2px 7px;
    border-radius: 7px;
    background: rgba(255,255,255,0.12);
    color: #f5f8ff;
    border: 1px solid rgba(255,255,255,0.14);
    font-weight: 800;
}

button,
select,
input {
    font: inherit;
}

button {
    margin-top: 20px;
    padding: 10px 20px;
    font-size: 1.2rem;
    cursor: pointer;
    background: #333;
    color: white;
    border: 1px solid #555;
    border-radius: 4px;
}

#enter-btn {
    margin: 0;
    padding: 13px 22px;
    border: 0;
    border-radius: 14px;
    color: #041018;
    background: linear-gradient(135deg, #4cc9ff, #fff06b);
    font-size: 16px;
    font-weight: 900;
    box-shadow: 0 18px 52px rgba(76, 201, 255, 0.25);
}

#enter-btn:hover {
    background: linear-gradient(135deg, #6dd7ff, #fff48f);
}

.start-settings {
    margin-top: 26px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.settings-head {
    grid-column: 1 / -1;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 14px;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.12);
}

.settings-head strong {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.settings-head span {
    color: rgba(245, 248, 255, 0.5);
    font-size: 12px;
}

.start-settings label {
    display: grid;
    gap: 7px;
    color: rgba(245, 248, 255, 0.7);
    font-size: 13px;
}

.start-settings select,
.start-settings input[type="range"] {
    width: 100%;
}

.start-settings select {
    min-height: 38px;
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: 11px;
    color: #f5f8ff;
    background: rgba(255,255,255,0.09);
    padding: 0 10px;
}

.range-setting,
.check-setting {
    grid-column: 1 / -1;
}

.range-setting b {
    color: #fff06b;
}

.check-setting {
    display: flex !important;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 10px;
}

.check-setting input {
    width: 18px;
    height: 18px;
    accent-color: #4cc9ff;
}

@keyframes panoDrift {
    from { transform: translate(-52%, -50%) scale(1.02); }
    to { transform: translate(-48%, -50%) scale(1.02); }
}

body.menu-reduced-motion .panorama-strip {
    animation: none;
}

@media (max-width: 640px) {
    .start-panel {
        padding: 24px;
        border-radius: 18px;
    }

    .start-settings {
        grid-template-columns: 1fr;
    }
}

button:hover {
    background: #444;
}

#enter-btn:hover {
    background: linear-gradient(135deg, #6dd7ff, #fff48f);
}

/* HUD */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
}

#hud.active {
    display: block;
}

#crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 6px;
    height: 6px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

#interaction-prompt {
    position: absolute;
    top: calc(50% + 20px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.9rem;
    display: none;
}

#interaction-prompt.visible {
    display: block;
}

#message-overlay {
    position: absolute;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 15px 25px;
    border-radius: 8px;
    font-size: 1.1rem;
    font-style: italic;
    text-align: center;
    opacity: 0;
    transition: opacity 0.5s;
    pointer-events: none;
}

#message-overlay.visible {
    opacity: 1;
}

/* Pause overlay */
#pause-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto; /* Catch clicks */
    font-size: 1.5rem;
    cursor: pointer;
}

#pause-overlay.hidden {
    display: none;
}

/* Wake overlay */
#fade-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: black;
    opacity: 0;
    pointer-events: none;
    transition: opacity 3s ease-in-out;
}

#fade-overlay.blackout {
    opacity: 1;
    transition: none; /* instant blackout */
}

body.pc-open > #game-container > canvas {
    visibility: hidden;
}

/* Hotfix: cleaner launch screen */
#start-screen {
    background:
        radial-gradient(circle at 18% 14%, rgba(76, 201, 255, 0.12), transparent 28%),
        radial-gradient(circle at 82% 18%, rgba(139, 92, 246, 0.10), transparent 28%),
        linear-gradient(180deg, #07101b 0%, #0a1220 58%, #060c14 100%);
}

.start-panorama {
    opacity: 0.72;
}

.start-panorama::before {
    opacity: 0.45;
    background:
        linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px),
        linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px);
    background-size: 84px 84px;
}

.panorama-strip {
    width: min(1520px, 132vw);
    height: min(680px, 82vh);
    border-radius: 0;
    border: none;
    box-shadow: none;
    opacity: 0.94;
    filter: saturate(0.92);
    animation: panoDrift 8s linear infinite alternate;
}

.start-panel {
    width: min(720px, calc(100vw - 40px));
    max-height: min(760px, calc(100vh - 40px));
    padding: 30px 32px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.10);
    background: rgba(8, 12, 18, 0.88);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
    backdrop-filter: blur(12px);
}

.start-kicker {
    margin-bottom: 12px;
    color: #76d8ff;
    letter-spacing: 0.18em;
    font-size: 11px;
}

.start-panel h1 {
    font-size: clamp(38px, 6vw, 68px);
    letter-spacing: -0.04em;
}

.start-copy {
    margin-top: 14px;
    max-width: 46ch;
    color: rgba(245, 248, 255, 0.78);
    font-size: 15px;
    line-height: 1.6;
}

.start-actions {
    gap: 16px;
    margin-top: 22px;
}

#enter-btn {
    padding: 12px 18px;
    border-radius: 12px;
    background: linear-gradient(135deg, #5ac8fa, #d8f06f);
    font-size: 15px;
    box-shadow: 0 12px 32px rgba(90, 200, 250, 0.22);
}

.start-settings {
    margin-top: 24px;
    padding-top: 20px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 14px;
}

.settings-head {
    padding-top: 0;
    padding-bottom: 6px;
    border-top: 0;
    border-bottom: 1px solid rgba(255,255,255,0.10);
}

.start-settings label {
    gap: 8px;
    color: rgba(245, 248, 255, 0.76);
    font-size: 12px;
}

.start-settings select,
.start-settings input[type="range"] {
    width: 100%;
}

.start-settings select {
    appearance: none;
    min-height: 42px;
    padding: 0 40px 0 12px;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 12px;
    color: #f5f8ff;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.04)),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Cpath fill='white' d='M3.2 5.2 7 9l3.8-3.8.9.9L7 10.8 2.3 6.1z'/%3E%3C/svg%3E") no-repeat right 12px center / 14px 14px,
        rgba(255,255,255,0.05);
    color-scheme: dark;
}

.start-settings select option {
    background: #0d1420;
    color: #f5f8ff;
}

.start-settings input[type="range"] {
    accent-color: #76d8ff;
}

.check-setting {
    margin-top: 2px;
}

@keyframes panoDrift {
    from { transform: translate(-53%, -50%) scale(1.03); }
    to { transform: translate(-47%, -50%) scale(1.03); }
}

@media (max-width: 760px) {
    .panorama-strip {
        width: 140vw;
        height: 74vh;
    }

    .start-panel {
        width: min(720px, calc(100vw - 24px));
        max-height: calc(100vh - 24px);
        padding: 24px 20px;
    }
}

/* Hotfix v45: compact original launch menu */
#start-screen {
    background:
        radial-gradient(circle at 20% 18%, rgba(87, 166, 255, 0.10), transparent 30%),
        linear-gradient(180deg, #08111d 0%, #0b111b 48%, #060912 100%);
}

.start-panorama {
    opacity: 0.86;
}

.start-panorama::before {
    opacity: 0.32;
    background-size: 96px 96px;
}

.panorama-strip {
    width: min(1540px, 136vw);
    height: min(690px, 84vh);
    opacity: 0.72;
    filter: saturate(0.82) contrast(0.95) brightness(0.72);
    animation: panoDrift 5.8s linear infinite alternate;
}

#start-screen::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 46%, transparent 0 24%, rgba(2, 4, 8, 0.46) 72%);
    pointer-events: none;
    z-index: -1;
}

.start-panel {
    width: min(420px, calc(100vw - 34px));
    max-height: calc(100vh - 34px);
    padding: 22px 20px 20px;
    border-radius: 10px;
    border: 2px solid rgba(236, 218, 176, 0.24);
    background:
        linear-gradient(180deg, rgba(33, 25, 18, 0.96), rgba(16, 14, 15, 0.98)),
        repeating-linear-gradient(90deg, rgba(255,255,255,0.035) 0 1px, transparent 1px 9px);
    box-shadow:
        0 24px 80px rgba(0, 0, 0, 0.62),
        inset 0 1px 0 rgba(255,255,255,0.16),
        inset 0 -2px 0 rgba(0,0,0,0.35);
    backdrop-filter: none;
    text-align: center;
}

.start-kicker {
    margin: 0 auto 8px;
    color: #ffe7a3;
    text-shadow: 0 2px 0 rgba(0,0,0,0.55);
    letter-spacing: 0.16em;
    font-size: 10px;
}

.start-panel h1 {
    margin: 0 auto 14px;
    color: #f9f2dc;
    font-size: clamp(36px, 8vw, 58px);
    line-height: 0.95;
    letter-spacing: -0.055em;
    text-shadow: 0 5px 0 rgba(0,0,0,0.42), 0 0 22px rgba(255, 232, 163, 0.10);
}

.start-copy {
    display: none;
}

.start-actions {
    justify-content: center;
    margin: 8px 0 14px;
}

.start-actions span {
    display: none;
}

#enter-btn {
    min-width: 220px;
    min-height: 42px;
    padding: 9px 18px;
    border: 2px solid rgba(42, 28, 18, 0.78);
    border-radius: 5px;
    color: #2a1710;
    background:
        linear-gradient(180deg, #f5e7bd, #b98655 52%, #7d4c2e 100%);
    box-shadow:
        0 5px 0 #342013,
        0 12px 24px rgba(0,0,0,0.28),
        inset 0 1px 0 rgba(255,255,255,0.72);
    font-size: 15px;
    text-shadow: 0 1px 0 rgba(255,255,255,0.45);
}

#enter-btn:hover {
    transform: translateY(-1px);
    background: linear-gradient(180deg, #fff1c8, #c8925f 52%, #87522f 100%);
}

#enter-btn:active {
    transform: translateY(3px);
    box-shadow: 0 2px 0 #342013, 0 6px 16px rgba(0,0,0,0.24), inset 0 1px 0 rgba(255,255,255,0.55);
}

.start-settings {
    margin-top: 16px;
    padding-top: 14px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
    text-align: left;
}

.settings-head {
    padding: 0 0 8px;
    border-bottom: 1px solid rgba(236, 218, 176, 0.20);
}

.settings-head strong {
    color: #f9f2dc;
    font-size: 11px;
    letter-spacing: 0.14em;
}

.settings-head span {
    font-size: 10px;
    color: rgba(249, 242, 220, 0.48);
}

.start-settings label {
    gap: 5px;
    color: rgba(249, 242, 220, 0.72);
    font-size: 11px;
}

.start-settings select {
    min-height: 34px;
    border-radius: 5px;
    border-color: rgba(236, 218, 176, 0.22);
    background:
        linear-gradient(180deg, rgba(255,255,255,0.10), rgba(255,255,255,0.04)),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Cpath fill='%23f9f2dc' d='M3.2 5.2 7 9l3.8-3.8.9.9L7 10.8 2.3 6.1z'/%3E%3C/svg%3E") no-repeat right 10px center / 12px 12px,
        rgba(0,0,0,0.18);
    color: #f9f2dc;
}

.start-settings select option {
    background: #211912;
    color: #f9f2dc;
}

.check-setting {
    grid-column: 1 / -1;
    justify-content: center;
    margin-top: 2px;
    color: rgba(249, 242, 220, 0.72) !important;
}

.check-setting input {
    accent-color: #d8a45e;
}

@media (max-width: 640px) {
    .start-panel {
        width: min(390px, calc(100vw - 24px));
        padding: 18px 16px;
    }

    .start-settings {
        grid-template-columns: 1fr;
    }
}

/* v46: compact tips and arcade chaos overlays */
.start-tips {
    display: grid;
    grid-template-columns: auto 1fr 1fr;
    gap: 8px;
    align-items: center;
    margin: 18px 0 0;
    padding: 10px;
    border: 1px solid rgba(249, 242, 220, 0.14);
    border-radius: 12px;
    background: rgba(249, 242, 220, 0.045);
    color: rgba(249, 242, 220, 0.76);
    font-size: 12px;
}

.start-tips span {
    align-self: stretch;
    display: grid;
    place-items: center;
    padding: 0 10px;
    border-radius: 9px;
    color: #14100c;
    background: #f9f2dc;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.start-tips b {
    font-weight: 700;
    line-height: 1.25;
}

#chaos-overlay {
    position: fixed;
    inset: 0;
    z-index: 5000;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    overflow: hidden;
    transition: opacity 0.16s ease, visibility 0.16s ease;
    font-family: Inter, Segoe UI, system-ui, sans-serif;
}

#chaos-overlay.show {
    opacity: 1;
    visibility: visible;
}

.chaos-overlay::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 48%, rgba(255,255,255,0.18), transparent 18%), rgba(5, 8, 16, 0.35);
    animation: chaosFlash 0.52s steps(2, end) infinite;
}

.chaos-overlay.rgb-pop::before {
    background:
        radial-gradient(circle at 42% 48%, rgba(54, 214, 255, 0.42), transparent 18%),
        radial-gradient(circle at 58% 52%, rgba(255, 79, 216, 0.36), transparent 22%),
        rgba(4, 6, 12, 0.28);
}

.chaos-overlay.snack-pop::before,
.chaos-overlay.window-fall::before {
    background:
        radial-gradient(circle at 50% 52%, rgba(255, 42, 66, 0.34), transparent 18%),
        radial-gradient(circle at 42% 48%, rgba(255, 240, 107, 0.22), transparent 16%),
        rgba(4, 6, 12, 0.44);
}

.chaos-card {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) rotate(-2deg);
    min-width: min(520px, calc(100vw - 34px));
    padding: 22px 26px;
    border: 3px solid #f9f2dc;
    border-radius: 10px;
    color: #f9f2dc;
    background: #111014;
    box-shadow: 10px 10px 0 #ff2b54, 0 24px 80px rgba(0, 0, 0, 0.42);
    text-align: center;
}

.chaos-card strong {
    display: block;
    font-size: clamp(34px, 8vw, 76px);
    line-height: 0.88;
    letter-spacing: -0.06em;
    text-transform: uppercase;
    text-shadow: 3px 3px 0 #ff2b54;
}

.chaos-card em {
    display: block;
    margin-top: 10px;
    color: rgba(249, 242, 220, 0.78);
    font-style: normal;
    font-size: 13px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.chaos-bits i {
    position: absolute;
    left: var(--x);
    top: var(--y);
    width: calc(6px * var(--s));
    height: calc(6px * var(--s));
    background: #f9f2dc;
    box-shadow: 0 0 0 2px rgba(0,0,0,0.18);
    animation: chaosBit 1.2s var(--d) ease-out forwards;
}

.rgb-pop .chaos-bits i:nth-child(3n) { background: #36d6ff; }
.rgb-pop .chaos-bits i:nth-child(3n + 1) { background: #ff4fd8; }
.rgb-pop .chaos-bits i:nth-child(3n + 2) { background: #fff06b; }
.snack-pop .chaos-bits i:nth-child(3n) { background: #ff2b54; }
.snack-pop .chaos-bits i:nth-child(3n + 1) { background: #fff06b; }
.window-fall .chaos-bits i:nth-child(2n) { background: #ff2b54; }
.window-fall .chaos-bits i:nth-child(2n + 1) { background: #f9f2dc; }

.chaos-city {
    display: none;
}

.window-fall .chaos-city {
    display: block;
    position: absolute;
    inset: -20vh 0 -20vh;
    transform: translateY(-20vh);
    animation: cityFall 2.6s cubic-bezier(.2,.8,.2,1) forwards;
}

.window-fall .chaos-city span {
    position: absolute;
    bottom: -10vh;
    width: 13vw;
    background:
        linear-gradient(90deg, rgba(255,255,255,0.2) 1px, transparent 1px),
        linear-gradient(rgba(255,255,255,0.18) 1px, transparent 1px),
        #1a2030;
    background-size: 24px 24px;
    border-top: 5px solid #313b55;
}

.window-fall .chaos-city span:nth-child(1) { left: 4vw; height: 72vh; }
.window-fall .chaos-city span:nth-child(2) { left: 24vw; height: 92vh; }
.window-fall .chaos-city span:nth-child(3) { left: 45vw; height: 76vh; }
.window-fall .chaos-city span:nth-child(4) { left: 66vw; height: 105vh; }
.window-fall .chaos-city span:nth-child(5) { left: 84vw; height: 82vh; }

@keyframes chaosFlash {
    0%, 100% { filter: saturate(1); }
    50% { filter: saturate(1.8) contrast(1.25); }
}

@keyframes chaosBit {
    from { transform: translate(0, 0) rotate(0deg); opacity: 1; }
    to { transform: translate(calc((50vw - var(--x)) * -0.35), 42vh) rotate(420deg); opacity: 0; }
}

@keyframes cityFall {
    from { transform: translateY(-38vh) scale(1.18); filter: blur(0); }
    to { transform: translateY(28vh) scale(1.45); filter: blur(2px); }
}

@media (max-width: 760px) {
    .start-tips {
        grid-template-columns: 1fr;
    }

    .start-tips span {
        padding: 7px 10px;
    }
}

/* v49: longer arcade cutscenes */
.chaos-fall-scene,
.chaos-wall-scene,
.chaos-speedlines,
.chaos-street {
    display: none;
}

.window-fall .chaos-card,
.fan-smash .chaos-card {
    top: 14%;
    transform: translateX(-50%) rotate(-1deg) scale(0.82);
    min-width: min(430px, calc(100vw - 42px));
    padding: 16px 20px;
    z-index: 4;
}

.window-fall .chaos-card {
    animation: cutsceneCardFall 5.4s ease-in-out forwards;
}

.fan-smash .chaos-card {
    animation: cutsceneCardSmash 3.3s ease-in-out forwards;
}

.window-fall .chaos-fall-scene {
    display: block;
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 50% 4%, rgba(119, 198, 255, 0.32), transparent 21%),
        linear-gradient(180deg, #08111f 0%, #172745 42%, #100e18 82%, #08070d 100%);
    perspective: 520px;
    overflow: hidden;
}

.window-fall .chaos-fall-scene::before {
    content: "";
    position: absolute;
    left: 50%;
    top: -18vh;
    width: 34vw;
    height: 155vh;
    transform: translateX(-50%) rotateX(68deg);
    background:
        linear-gradient(90deg, transparent 0 45%, rgba(255,255,255,0.18) 45% 46%, transparent 46% 54%, rgba(255,255,255,0.18) 54% 55%, transparent 55%),
        repeating-linear-gradient(180deg, rgba(255,255,255,0.12) 0 2px, transparent 2px 56px),
        linear-gradient(180deg, #111621, #05060a);
    filter: blur(0.2px);
    animation: roadRush 5.2s cubic-bezier(.18,.72,.2,1) forwards;
}

.chaos-skyline {
    position: absolute;
    inset: -120vh -10vw -80vh;
    transform-origin: center;
}

.window-fall .chaos-skyline {
    display: block;
    animation: buildingFall 5.2s cubic-bezier(.12,.72,.14,1) forwards;
}

.window-fall .chaos-skyline-b {
    transform: scaleX(-1) translateY(-90vh);
    opacity: 0.68;
    animation-duration: 4.8s;
}

.chaos-skyline span {
    position: absolute;
    bottom: -50vh;
    width: 10vw;
    min-width: 82px;
    height: calc(64vh + (var(--i) * 5vh));
    left: calc((var(--i) * 8vw) - 8vw);
    background:
        linear-gradient(90deg, rgba(255, 237, 174, 0.34) 1px, transparent 1px),
        linear-gradient(rgba(255, 237, 174, 0.22) 1px, transparent 1px),
        linear-gradient(180deg, #1b2540, #0c1020);
    background-size: 20px 24px;
    border-top: 4px solid rgba(176, 208, 255, 0.35);
    box-shadow: 0 0 0 1px rgba(255,255,255,0.06), inset 0 0 32px rgba(0,0,0,0.24);
}

.window-fall .chaos-speedlines,
.fan-smash .chaos-speedlines {
    display: block;
    position: absolute;
    inset: 0;
    z-index: 2;
    background:
        repeating-linear-gradient(100deg, transparent 0 22px, rgba(255,255,255,0.16) 23px 25px, transparent 26px 46px);
    opacity: 0.35;
    mix-blend-mode: screen;
}

.window-fall .chaos-speedlines {
    animation: speedlineFall 0.2s linear infinite;
}

.window-fall .chaos-street {
    display: block;
    position: absolute;
    left: 50%;
    bottom: -34vh;
    width: 140vw;
    height: 45vh;
    transform: translateX(-50%) scale(0.15);
    border-radius: 50% 50% 0 0;
    background:
        radial-gradient(circle at 50% 50%, rgba(255, 43, 84, 0.70), transparent 0 5%, rgba(255, 240, 107, 0.50) 5% 8%, transparent 8% 100%),
        repeating-linear-gradient(90deg, #111 0 80px, #151515 80px 160px);
    opacity: 0;
    animation: streetImpact 5.2s cubic-bezier(.08,.9,.1,1) forwards;
}

.fan-smash::before {
    background:
        radial-gradient(circle at 78% 52%, rgba(255, 43, 84, 0.42), transparent 18%),
        radial-gradient(circle at 48% 52%, rgba(255, 240, 107, 0.18), transparent 16%),
        linear-gradient(90deg, rgba(5, 8, 16, 0.18), rgba(5, 8, 16, 0.82));
}

.fan-smash .chaos-wall-scene {
    display: block;
    position: absolute;
    inset: 0;
    overflow: hidden;
    background:
        linear-gradient(90deg, #0b1018 0 42%, #2b2028 42% 100%),
        repeating-linear-gradient(0deg, rgba(255,255,255,0.055) 0 2px, transparent 2px 62px),
        repeating-linear-gradient(90deg, rgba(255,255,255,0.055) 0 2px, transparent 2px 62px);
}

.fan-smash .chaos-wall-scene::before {
    content: "";
    position: absolute;
    left: -18vw;
    top: 50%;
    width: 20vw;
    height: 20vw;
    min-width: 160px;
    min-height: 160px;
    transform: translateY(-50%);
    border-radius: 50%;
    background:
        radial-gradient(circle, #f9f2dc 0 18%, #ff2b54 19% 21%, transparent 22%),
        conic-gradient(from 0deg, transparent 0 10%, rgba(255,255,255,0.42) 10% 12%, transparent 12% 26%, rgba(255,43,84,0.36) 26% 29%, transparent 29% 100%);
    filter: drop-shadow(0 0 22px rgba(255,43,84,0.72));
    animation: fanLaunchBody 3.2s cubic-bezier(.12,.8,.14,1) forwards;
}

.fan-smash .chaos-wall-scene span {
    position: absolute;
    right: 9vw;
    top: 50%;
    width: 9vw;
    height: 9vw;
    min-width: 78px;
    min-height: 78px;
    transform: translateY(-50%) scale(0);
    border-radius: 50%;
    border: 4px solid rgba(255, 43, 84, 0.86);
    background: radial-gradient(circle, rgba(255, 43, 84, 0.52), transparent 62%);
    animation: wallCrackPop 3.2s ease-out forwards;
}

.fan-smash .chaos-wall-scene span:nth-child(2) { width: 14vw; height: 14vw; animation-delay: 0.08s; opacity: 0.72; }
.fan-smash .chaos-wall-scene span:nth-child(3) { width: 19vw; height: 19vw; animation-delay: 0.13s; opacity: 0.44; }
.fan-smash .chaos-wall-scene span:nth-child(4) { right: 6vw; width: 26vw; height: 26vw; animation-delay: 0.19s; opacity: 0.22; }
.fan-smash .chaos-wall-scene span:nth-child(5) { right: 14vw; width: 4vw; height: 4vw; animation-delay: 0.28s; opacity: 0.95; }

.fan-smash .chaos-speedlines {
    animation: fanSpeedline 0.13s linear infinite;
    opacity: 0.5;
}

.fan-smash .chaos-bits i:nth-child(2n),
.window-fall .chaos-bits i:nth-child(2n) { background: #ff2b54; }
.fan-smash .chaos-bits i:nth-child(2n + 1),
.window-fall .chaos-bits i:nth-child(2n + 1) { background: #f9f2dc; }
.fan-smash .chaos-bits i,
.window-fall .chaos-bits i {
    animation-duration: 1.85s;
    animation-delay: calc(var(--d) + 2.1s);
}
.window-fall .chaos-bits i { animation-delay: calc(var(--d) + 4.05s); }

@keyframes buildingFall {
    0% { transform: translateY(-120vh) scale(1.24); filter: blur(1px); }
    40% { transform: translateY(-38vh) scale(1.42); filter: blur(1.5px); }
    78% { transform: translateY(25vh) scale(1.7); filter: blur(2.4px); }
    100% { transform: translateY(105vh) scale(2.35); filter: blur(5px); }
}

@keyframes roadRush {
    0% { transform: translateX(-50%) rotateX(68deg) translateY(-120vh) scale(0.7); opacity: 0.15; }
    55% { opacity: 0.65; }
    100% { transform: translateX(-50%) rotateX(68deg) translateY(54vh) scale(2.1); opacity: 0.95; }
}

@keyframes speedlineFall {
    from { background-position: 0 0; }
    to { background-position: 0 110px; }
}

@keyframes streetImpact {
    0%, 72% { opacity: 0; transform: translateX(-50%) scale(0.12); }
    86% { opacity: 1; transform: translateX(-50%) scale(0.78); }
    100% { opacity: 1; transform: translateX(-50%) scale(1.3); }
}

@keyframes cutsceneCardFall {
    0%, 60% { opacity: 1; transform: translateX(-50%) rotate(-1deg) scale(0.82); }
    72% { opacity: 0; transform: translateX(-50%) translateY(-40px) rotate(2deg) scale(0.7); }
    100% { opacity: 0; }
}

@keyframes fanLaunchBody {
    0% { transform: translate(-10vw, -50%) rotate(0) scale(0.55); opacity: 0; }
    15% { opacity: 1; }
    68% { transform: translate(80vw, -50%) rotate(840deg) scale(1.0); opacity: 1; }
    76% { transform: translate(88vw, -50%) rotate(980deg) scale(1.18); opacity: 1; }
    100% { transform: translate(90vw, -50%) rotate(980deg) scale(0); opacity: 0; }
}

@keyframes wallCrackPop {
    0%, 62% { transform: translateY(-50%) scale(0); opacity: 0; }
    76% { transform: translateY(-50%) scale(1); opacity: 1; }
    100% { transform: translateY(-50%) scale(1.7); opacity: 0; }
}

@keyframes fanSpeedline {
    from { background-position: 0 0; }
    to { background-position: 90px 0; }
}

@keyframes cutsceneCardSmash {
    0%, 52% { opacity: 1; transform: translateX(-50%) rotate(-1deg) scale(0.82); }
    70%, 100% { opacity: 0; transform: translateX(-50%) translateY(-30px) rotate(2deg) scale(0.72); }
}


/* v52: mobile and tablet support */
html,
body,
#game-container,
#ui-layer {
    overscroll-behavior: none;
}

body {
    touch-action: none;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

button,
select,
input {
    touch-action: manipulation;
}

body.mobile-input #pause-overlay {
    display: none !important;
}

#mobile-controls {
    position: absolute;
    inset: 0;
    z-index: 40;
    pointer-events: none;
    display: none;
}

body.mobile-input #mobile-controls:not(.hidden) {
    display: block;
}

body.pc-open #mobile-controls,
body.mobile-input #mobile-controls.hidden {
    display: none !important;
}

.mobile-look-zone {
    position: absolute;
    inset: 0;
    pointer-events: auto;
    touch-action: none;
}

.mobile-look-zone span {
    position: absolute;
    right: max(14px, env(safe-area-inset-right));
    top: calc(12px + env(safe-area-inset-top));
    padding: 7px 10px;
    border: 1px solid rgba(255,255,255,0.16);
    border-radius: 999px;
    color: rgba(245, 248, 255, 0.64);
    background: rgba(3, 7, 14, 0.36);
    backdrop-filter: blur(12px);
    font-size: 11px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.mobile-stick {
    position: absolute;
    left: max(22px, env(safe-area-inset-left));
    bottom: calc(28px + env(safe-area-inset-bottom));
    width: 134px;
    height: 134px;
    pointer-events: auto;
    touch-action: none;
}

.mobile-stick-ring,
.mobile-stick-knob {
    position: absolute;
    border-radius: 999px;
}

.mobile-stick-ring {
    inset: 0;
    border: 1px solid rgba(255,255,255,0.18);
    background:
        radial-gradient(circle, rgba(255,255,255,0.09), rgba(255,255,255,0.02) 56%, rgba(0,0,0,0.15));
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.16),
        0 18px 60px rgba(0,0,0,0.32);
    backdrop-filter: blur(16px);
}

.mobile-stick-knob {
    left: 42px;
    top: 42px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, rgba(118,216,255,0.92), rgba(216,240,111,0.92));
    box-shadow: 0 12px 38px rgba(76,201,255,0.32);
    transform: translate3d(0, 0, 0);
}

.mobile-actions {
    position: absolute;
    right: max(18px, env(safe-area-inset-right));
    bottom: calc(28px + env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    pointer-events: auto;
}

.mobile-actions button,
.mobile-piano button {
    min-width: 92px;
    min-height: 44px;
    margin: 0;
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 14px;
    color: #f5f8ff;
    background: rgba(5, 10, 18, 0.62);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.13),
        0 14px 42px rgba(0,0,0,0.28);
    backdrop-filter: blur(18px);
    font-size: 13px;
    font-weight: 900;
}

.mobile-actions button:active,
.mobile-piano button:active {
    transform: translateY(1px) scale(0.98);
    background: rgba(76,201,255,0.28);
}

#mobile-interact {
    color: #041018;
    background: linear-gradient(135deg, #76d8ff, #d8f06f);
}

#mobile-secondary {
    display: none;
}

body.mobile-special #mobile-secondary {
    display: block;
}

#mobile-fullscreen {
    min-height: 38px;
    opacity: 0.75;
    font-size: 12px;
}

.mobile-piano {
    position: absolute;
    left: 50%;
    bottom: calc(18px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    width: min(560px, calc(100vw - 210px));
    display: grid;
    grid-template-columns: repeat(6, minmax(34px, 1fr));
    gap: 7px;
    pointer-events: auto;
}

.mobile-piano.hidden {
    display: none;
}

.mobile-piano button {
    min-width: 0;
    min-height: 42px;
    border-radius: 10px;
    background: rgba(245, 248, 255, 0.84);
    color: #101522;
}

body.mobile-piano-mode .mobile-stick,
body.mobile-piano-mode .mobile-look-zone span {
    opacity: 0.42;
}

@media (pointer: coarse), (max-width: 900px) {
    #start-screen {
        justify-content: center;
        padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
        box-sizing: border-box;
    }

    .start-panel {
        width: min(560px, calc(100vw - 24px));
        max-height: calc(100dvh - 24px);
        padding: 18px;
        border-radius: 16px;
    }

    .start-panel h1 {
        font-size: clamp(34px, 11vw, 54px);
    }

    .start-copy {
        font-size: 14px;
        line-height: 1.45;
    }

    .start-tips {
        grid-template-columns: 1fr;
        gap: 6px;
        margin-top: 14px;
    }

    .start-settings {
        grid-template-columns: 1fr;
        margin-top: 16px;
        gap: 10px;
    }

    .settings-head {
        gap: 8px;
    }

    .panorama-strip {
        width: 150vw;
        height: 78vh;
    }

    #interaction-prompt {
        top: auto;
        bottom: calc(186px + env(safe-area-inset-bottom));
        max-width: min(420px, calc(100vw - 32px));
        white-space: normal;
        text-align: center;
    }

    #message-overlay {
        top: calc(70px + env(safe-area-inset-top));
        width: min(460px, calc(100vw - 36px));
        box-sizing: border-box;
    }
}

@media (max-width: 700px), (max-height: 520px) {
    .mobile-stick {
        width: 112px;
        height: 112px;
        left: max(14px, env(safe-area-inset-left));
        bottom: calc(18px + env(safe-area-inset-bottom));
    }

    .mobile-stick-knob {
        left: 36px;
        top: 36px;
        width: 40px;
        height: 40px;
    }

    .mobile-actions {
        right: max(12px, env(safe-area-inset-right));
        bottom: calc(18px + env(safe-area-inset-bottom));
        gap: 8px;
    }

    .mobile-actions button {
        min-width: 78px;
        min-height: 40px;
        padding: 8px 10px;
        font-size: 12px;
    }

    .mobile-piano {
        bottom: calc(10px + env(safe-area-inset-bottom));
        width: min(440px, calc(100vw - 176px));
        grid-template-columns: repeat(6, minmax(28px, 1fr));
        gap: 5px;
    }

    .mobile-piano button {
        min-height: 36px;
        font-size: 12px;
    }
}

@media (orientation: portrait) and (max-width: 700px) {
    .mobile-piano {
        left: max(12px, env(safe-area-inset-left));
        right: max(12px, env(safe-area-inset-right));
        transform: none;
        width: auto;
        bottom: calc(150px + env(safe-area-inset-bottom));
        grid-template-columns: repeat(4, minmax(42px, 1fr));
    }

    .mobile-look-zone span {
        display: none;
    }
}

.start-panel { touch-action: pan-y; -webkit-overflow-scrolling: touch; }

/* v61: responsive quality pass */
*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    --safe-top: max(10px, env(safe-area-inset-top));
    --safe-right: max(10px, env(safe-area-inset-right));
    --safe-bottom: max(10px, env(safe-area-inset-bottom));
    --safe-left: max(10px, env(safe-area-inset-left));
    color-scheme: dark;
}

button,
select,
input {
    min-height: 44px;
}

button {
    transition: transform 140ms ease, border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

button:focus-visible,
select:focus-visible,
input:focus-visible {
    outline: 3px solid rgba(118, 216, 255, 0.48);
    outline-offset: 3px;
}

@media (hover: hover) {
    #enter-btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 22px 60px rgba(76, 201, 255, 0.36);
    }
}

button:active,
#enter-btn:active {
    transform: translateY(1px) scale(0.98);
}

.start-panel {
    scrollbar-width: thin;
    scrollbar-color: rgba(118, 216, 255, 0.48) transparent;
}

.start-copy {
    text-wrap: pretty;
}

.start-tips b {
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.045);
    font-size: 12px;
    line-height: 1.35;
}

.start-settings label {
    min-width: 0;
}

.start-settings select {
    width: 100%;
    min-width: 0;
}

#interaction-prompt,
#message-overlay {
    margin-inline: var(--safe-left) var(--safe-right);
}

.mobile-actions button {
    margin: 0;
    min-height: 48px;
    border-radius: 16px;
    text-shadow: 0 1px 12px rgba(0, 0, 0, 0.24);
}

.mobile-stick-ring {
    border-width: 2px;
}

@media (pointer: coarse), (max-width: 900px) {
    .start-panel {
        width: min(600px, calc(100vw - var(--safe-left) - var(--safe-right)));
        max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom));
        padding: clamp(18px, 4.5vw, 28px);
        border-radius: clamp(18px, 5vw, 26px);
        overscroll-behavior: contain;
    }

    .start-actions {
        align-items: stretch;
    }

    #enter-btn {
        min-height: 50px;
    }

    .start-settings select,
    .start-settings input {
        font-size: 16px;
    }

    .mobile-look-zone span {
        right: var(--safe-right);
        top: var(--safe-top);
    }

    .mobile-stick {
        left: calc(var(--safe-left) + 4px);
        bottom: calc(var(--safe-bottom) + 8px);
        width: clamp(104px, 26vw, 132px);
        height: clamp(104px, 26vw, 132px);
    }

    .mobile-stick-knob {
        left: 50%;
        top: 50%;
        width: clamp(42px, 10vw, 50px);
        height: clamp(42px, 10vw, 50px);
        margin: calc(clamp(42px, 10vw, 50px) / -2) 0 0 calc(clamp(42px, 10vw, 50px) / -2);
    }

    .mobile-actions {
        right: calc(var(--safe-right) + 2px);
        bottom: calc(var(--safe-bottom) + 8px);
    }

    #interaction-prompt {
        bottom: calc(clamp(132px, 31vw, 172px) + var(--safe-bottom));
        width: max-content;
        max-width: calc(100vw - var(--safe-left) - var(--safe-right) - 16px);
        font-size: clamp(12px, 3vw, 14px);
    }
}

@media (max-width: 520px) {
    .start-panel h1 {
        font-size: clamp(38px, 15vw, 58px);
    }

    .start-copy {
        margin-top: 13px;
    }

    .start-actions {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
        margin-top: 18px;
    }

    .start-actions span {
        text-align: center;
    }

    .settings-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .start-tips {
        max-height: 116px;
        overflow: auto;
        padding-right: 2px;
    }

    .mobile-actions button {
        min-width: clamp(76px, 23vw, 96px);
        padding-inline: 9px;
    }

    #mobile-fullscreen {
        min-height: 44px;
    }
}

@media (max-height: 600px) {
    .start-panel {
        padding-block: 16px;
    }

    .start-panel h1 {
        font-size: clamp(34px, 9vh, 54px);
    }

    .start-copy {
        margin-top: 10px;
        line-height: 1.4;
    }

    .start-actions,
    .start-settings {
        margin-top: 12px;
    }

    .start-tips {
        display: none;
    }
}

@media (orientation: landscape) and (pointer: coarse) and (max-height: 560px) {
    .mobile-stick {
        width: min(25vh, 104px);
        height: min(25vh, 104px);
    }

    .mobile-actions {
        grid-template-columns: repeat(2, minmax(76px, auto));
        align-items: end;
    }

    #mobile-fullscreen {
        grid-column: 2;
    }

    #interaction-prompt {
        bottom: calc(min(25vh, 104px) + var(--safe-bottom) + 20px);
    }

    .mobile-piano {
        left: 50%;
        bottom: var(--safe-bottom);
        width: min(58vw, 520px);
        transform: translateX(-50%);
    }
}

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

/* Kingdom audience overlay */
.audience-panel { position:fixed; inset:0; z-index:900; display:grid; place-items:center; padding:max(16px,env(safe-area-inset-top)) max(16px,env(safe-area-inset-right)) max(16px,env(safe-area-inset-bottom)) max(16px,env(safe-area-inset-left)); pointer-events:auto; background:radial-gradient(circle at 50% 26%,rgba(163,8,30,.24),transparent 30rem),rgba(2,1,3,.78); backdrop-filter:blur(14px) saturate(120%); }
.audience-panel.hidden { display:none; }
.audience-card { width:min(620px,100%); max-height:calc(100dvh - 32px); overflow:auto; padding:clamp(22px,5vw,38px); border:1px solid rgba(211,29,57,.52); border-radius:6px; color:#eee4d2; background:linear-gradient(145deg,rgba(110,5,22,.16),transparent 42%),rgba(10,6,10,.96); box-shadow:0 36px 120px rgba(0,0,0,.72),inset 0 1px rgba(255,255,255,.08),0 0 55px rgba(185,9,35,.18); clip-path:polygon(0 0,calc(100% - 18px) 0,100% 18px,100% 100%,18px 100%,0 calc(100% - 18px)); }
.audience-kicker { margin:0 0 12px; color:#df2743; font:800 11px/1.2 ui-monospace,monospace; letter-spacing:.18em; text-transform:uppercase; }
.audience-status-row { display:flex; align-items:center; gap:9px; color:rgba(238,228,210,.7); text-transform:uppercase; letter-spacing:.1em; font-size:12px; }
.audience-presence-dot { width:10px; height:10px; border-radius:50%; background:#887e70; box-shadow:0 0 14px rgba(136,126,112,.5); }
.audience-panel.online .audience-presence-dot { background:#ff163c; box-shadow:0 0 20px #ff163c; }
.audience-card h2 { margin:18px 0 10px; font-family:Georgia,'Times New Roman',serif; font-size:clamp(34px,7vw,58px); line-height:.96; letter-spacing:-.04em; }
.audience-decree,.audience-rule { color:rgba(238,228,210,.74); line-height:1.6; text-wrap:pretty; }
.audience-rule { padding:13px 15px; border-left:3px solid #a80b27; background:rgba(255,255,255,.04); font-size:13px; }
.audience-form { display:grid; gap:10px; margin-top:16px; }
.audience-form textarea { width:100%; min-height:132px; resize:vertical; padding:14px 15px; border:1px solid rgba(255,255,255,.16); border-radius:8px; color:#f7eddb; background:rgba(0,0,0,.28); font:500 15px/1.45 system-ui,sans-serif; outline:none; }
.audience-form textarea:focus { border-color:rgba(227,34,69,.72); box-shadow:0 0 0 3px rgba(227,34,69,.14); }
.audience-file { display:flex; align-items:center; justify-content:space-between; gap:12px; min-height:48px; padding:10px 12px; border:1px dashed rgba(255,255,255,.18); border-radius:8px; color:rgba(238,228,210,.8); background:rgba(255,255,255,.045); font-size:13px; }
.audience-file input { width:min(100%,230px); color:rgba(238,228,210,.68); font-size:12px; }
.audience-form-note { margin:0; color:rgba(238,228,210,.56); font-size:12px; line-height:1.45; }
.audience-actions { display:flex; gap:10px; margin-top:22px; flex-wrap:wrap; }
.audience-actions button { min-height:48px; display:inline-flex; align-items:center; justify-content:center; margin:0; padding:0 18px; border:1px solid rgba(255,255,255,.17); border-radius:10px; color:#f7eddb; background:rgba(255,255,255,.07); font:800 13px/1 system-ui,sans-serif; text-decoration:none; }
.audience-actions button[type="submit"] { color:#170308; border-color:transparent; background:linear-gradient(135deg,#f5e5c6,#c91c38); }
.audience-actions button:disabled { opacity:.55; cursor:wait; }
@media (max-width:520px) { .audience-actions { display:grid; grid-template-columns:1fr; } }

/* v63: restore a true desktop-scale launch menu.
   The earlier v45 hotfix capped the panel at 420px on every device, so desktop
   screens inherited a phone-width layout even when no mobile media query ran. */
@media (min-width: 901px) {
    .start-panel {
        width: min(900px, calc(100vw - 96px));
        max-height: calc(100dvh - 48px);
        padding: 28px 34px 30px;
        border-radius: 14px;
        text-align: left;
    }

    .start-kicker {
        margin: 0 0 8px;
        font-size: 11px;
    }

    .start-panel h1 {
        margin: 0;
        font-size: clamp(58px, 6vw, 82px);
        line-height: 0.88;
    }

    .start-copy {
        display: block;
        max-width: 72ch;
        margin: 14px 0 0;
        font-size: 14px;
        line-height: 1.5;
        color: rgba(249, 242, 220, 0.7);
    }

    .start-actions {
        justify-content: flex-start;
        margin: 18px 0 0;
    }

    .start-actions span {
        display: inline;
    }

    #enter-btn {
        min-width: 250px;
    }

    .start-tips {
        grid-template-columns: 92px repeat(4, minmax(0, 1fr));
        gap: 10px;
        margin-top: 20px;
        padding: 10px;
    }

    .start-tips span {
        padding-inline: 12px;
    }

    .start-tips b {
        display: flex;
        align-items: center;
        min-height: 48px;
        padding: 10px 12px;
        font-size: 11px;
        line-height: 1.35;
    }

    .start-settings {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 12px 14px;
        margin-top: 20px;
        padding-top: 16px;
    }

    .settings-head,
    .check-setting {
        grid-column: 1 / -1;
    }

    .check-setting {
        justify-content: flex-start;
    }
}

/* v66: temporary Royal Mail sidebar and stable visitor identity */
.royal-mail-toggle {
    position: fixed;
    top: max(18px, env(safe-area-inset-top));
    right: max(18px, env(safe-area-inset-right));
    z-index: 640;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 0 13px;
    border: 1px solid rgba(225, 185, 116, .35);
    border-radius: 999px;
    color: #f3e7d1;
    background: rgba(12, 7, 10, .9);
    box-shadow: 0 12px 34px rgba(0, 0, 0, .42), inset 0 1px rgba(255,255,255,.06);
    font: 800 12px/1 ui-monospace, monospace;
    letter-spacing: .08em;
    text-transform: uppercase;
    backdrop-filter: blur(12px);
    pointer-events: auto;
}
.royal-mail-toggle b {
    display: grid;
    place-items: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    color: #190309;
    background: #e9c27d;
    font-size: 11px;
}
.royal-mail-toggle.has-mail b {
    color: #fff4e6;
    background: #d31638;
    box-shadow: 0 0 18px rgba(211,22,56,.55);
}
.royal-mail-panel {
    position: fixed;
    top: max(16px, env(safe-area-inset-top));
    right: max(16px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
    z-index: 650;
    width: min(390px, calc(100vw - 32px));
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 18px;
    overflow: hidden;
    border: 1px solid rgba(225, 185, 116, .34);
    border-radius: 18px;
    color: #efe4d0;
    background: linear-gradient(160deg, rgba(100, 9, 27, .12), transparent 38%), rgba(8, 5, 8, .96);
    box-shadow: 0 30px 100px rgba(0,0,0,.68), inset 0 1px rgba(255,255,255,.07);
    backdrop-filter: blur(18px) saturate(120%);
    pointer-events: auto;
}
.royal-mail-panel.hidden,
.royal-mail-toggle.hidden { display: none; }
.royal-mail-panel header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}
.royal-mail-panel header p {
    margin: 0 0 4px;
    color: #c79c57;
    font: 800 10px/1.2 ui-monospace, monospace;
    letter-spacing: .16em;
    text-transform: uppercase;
}
.royal-mail-panel h2 {
    margin: 0;
    font: 700 34px/.95 Georgia, serif;
    letter-spacing: -.03em;
}
#royal-mail-close {
    width: 38px;
    min-width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid rgba(255,255,255,.14);
    border-radius: 10px;
    color: #eadfcd;
    background: rgba(255,255,255,.055);
    font: 500 25px/1 system-ui, sans-serif;
}
.royal-name-field {
    display: grid;
    gap: 6px;
    color: rgba(239,228,208,.7);
    font-size: 12px;
}
.royal-name-field input {
    width: 100%;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid rgba(255,255,255,.14);
    border-radius: 10px;
    outline: none;
    color: #f4ead8;
    background: rgba(255,255,255,.055);
    font: 700 14px/1 system-ui, sans-serif;
}
.royal-name-field input:focus {
    border-color: rgba(225,185,116,.65);
    box-shadow: 0 0 0 3px rgba(225,185,116,.11);
}
.royal-code-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 7px 9px;
    align-items: center;
    padding: 12px;
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 12px;
    background: rgba(255,255,255,.035);
}
.royal-code-row > span {
    grid-column: 1 / -1;
    color: rgba(239,228,208,.62);
    font-size: 11px;
}
.royal-code-row code {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #f0c77e;
    font: 700 12px/1.3 ui-monospace, monospace;
}
.royal-code-row button,
.royal-open-veil {
    min-height: 38px;
    border: 0;
    border-radius: 9px;
    color: #170408;
    background: linear-gradient(135deg, #f2ddb5, #d59a45);
    font: 900 12px/1 system-ui, sans-serif;
}
.royal-code-row button { padding: 0 12px; }
.royal-identity-note {
    margin: -5px 0 0;
    color: rgba(239,228,208,.46);
    font-size: 11px;
    line-height: 1.45;
}
.royal-mail-list {
    flex: 1;
    min-height: 120px;
    display: grid;
    align-content: start;
    gap: 10px;
    overflow: auto;
    padding-right: 3px;
}
.royal-message {
    display: grid;
    gap: 7px;
    padding: 12px;
    border: 1px solid rgba(211,22,56,.24);
    border-radius: 12px;
    background: rgba(116, 9, 28, .12);
}
.royal-message time {
    color: #d9ad63;
    font: 800 10px/1.2 ui-monospace, monospace;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.royal-message p {
    margin: 0;
    color: #f4ead8;
    font-size: 13px;
    line-height: 1.48;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.royal-message small {
    color: rgba(239,228,208,.48);
    font-size: 10px;
}
.royal-empty {
    margin: 0;
    padding: 18px 12px;
    border: 1px dashed rgba(255,255,255,.12);
    border-radius: 12px;
    color: rgba(239,228,208,.5);
    text-align: center;
    font-size: 12px;
}
.royal-open-veil {
    min-height: 46px;
    width: 100%;
}

@media (max-width: 700px) {
    .royal-mail-toggle {
        top: max(10px, env(safe-area-inset-top));
        right: max(10px, env(safe-area-inset-right));
        min-height: 38px;
    }
    .royal-mail-panel {
        inset: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
        width: auto;
        border-radius: 14px;
    }
}


/* Native-resolution DOM plaque projected onto the throne sign.
   Keeping status text out of the low-resolution WebGL buffer makes it readable
   even while adaptive rendering lowers the 3D scene resolution. */
.throne-status-plaque {
    --plaque-width: 420px;
    position: absolute;
    left: 50%;
    top: 18%;
    z-index: 35;
    width: var(--plaque-width);
    box-sizing: border-box;
    padding: calc(var(--plaque-width) * 0.035) calc(var(--plaque-width) * 0.055);
    border: max(2px, calc(var(--plaque-width) * 0.007)) solid #b8aa90;
    border-radius: calc(var(--plaque-width) * 0.018);
    background:
        linear-gradient(180deg, rgba(24, 10, 13, 0.97), rgba(5, 2, 5, 0.98)),
        #070205;
    box-shadow:
        0 0 0 2px rgba(0, 0, 0, 0.82),
        0 12px 30px rgba(0, 0, 0, 0.72),
        inset 0 0 24px rgba(117, 11, 35, 0.16);
    color: #fff1d2;
    text-align: center;
    text-transform: uppercase;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, -50%);
    transform-origin: center;
    transition: opacity 90ms linear;
    contain: layout style paint;
}

.throne-status-plaque.visible {
    opacity: 1;
    visibility: visible;
}

.throne-status-plaque[data-status="online"] {
    border-color: #ff3155;
    box-shadow: 0 0 0 2px rgba(0,0,0,.82), 0 0 28px rgba(255,49,85,.28), inset 0 0 24px rgba(255,49,85,.12);
}

.throne-status-plaque[data-status="busy"] { border-color: #ff8a32; }
.throne-status-plaque[data-status="sleeping"] { border-color: #8d5fc7; }

.throne-status-title {
    display: block;
    margin-bottom: calc(var(--plaque-width) * 0.008);
    font-family: Georgia, "Times New Roman", serif;
    font-size: calc(var(--plaque-width) * 0.058);
    font-weight: 900;
    letter-spacing: 0.13em;
    line-height: 1;
    text-shadow: 0 2px 0 #000, 0 0 8px rgba(255,241,210,.18);
}

#throne-status-value {
    display: block;
    font-family: ui-monospace, Consolas, "Courier New", monospace;
    font-size: calc(var(--plaque-width) * 0.085);
    font-weight: 1000;
    letter-spacing: 0.16em;
    line-height: 1.05;
    color: #d8c7a8;
    text-shadow: 0 3px 0 #000;
}

.throne-status-plaque[data-status="online"] #throne-status-value { color: #ff4162; }
.throne-status-plaque[data-status="busy"] #throne-status-value { color: #ff9b4f; }
.throne-status-plaque[data-status="sleeping"] #throne-status-value { color: #c69aff; }

#throne-status-message {
    margin: calc(var(--plaque-width) * 0.018) 0 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: calc(var(--plaque-width) * 0.043);
    font-weight: 700;
    letter-spacing: 0.018em;
    line-height: 1.18;
    text-transform: none;
    color: #efe4cf;
    text-wrap: balance;
    text-shadow: 0 2px 0 #000;
}

body.pc-open .throne-status-plaque,
body.audience-open .throne-status-plaque {
    display: none;
}

@media (max-width: 700px) {
    .throne-status-plaque {
        border-radius: 7px;
        padding-inline: calc(var(--plaque-width) * 0.045);
    }
    .throne-status-title { letter-spacing: 0.08em; }
    #throne-status-value { letter-spacing: 0.11em; }
}
