/* Main Entry Point */
/* CSS Variables - Theme Definition */
:root {
    --native-banner-height: 0px;
    --native-status-bar-height: 0px;
    --native-status-bar-fallback: 0px;
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-right: env(safe-area-inset-right, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-left: env(safe-area-inset-left, 0px);
    --app-edge-gap: clamp(0.42rem, 1.8vw, 0.72rem);
    --app-top-gap: clamp(0.42rem, 1.25vh, 0.7rem);
    --app-bottom-gap: clamp(0.34rem, 1.15vh, 0.62rem);
    --safe-top-header-gap: clamp(0.46rem, 1.6vh, 0.74rem);
    --banner-dead-zone: clamp(0.18rem, 0.85vh, 0.46rem);
    --top-system-intrusion-height: 0px;
    --app-chrome-top: max(
        var(--safe-area-top),
        var(--native-status-bar-height, 0px),
        var(--native-status-bar-fallback, 0px),
        var(--top-system-intrusion-height, 0px)
    );
    --app-chrome-right: var(--safe-area-right);
    --app-chrome-bottom: calc(
        var(--safe-area-bottom) +
            var(--native-banner-height, 0px) +
            var(--banner-dead-zone)
    );
    --app-chrome-left: var(--safe-area-left);
    --app-canvas-height: calc(
        100dvh -
            var(--app-top-gap) -
            var(--app-bottom-gap) -
            var(--app-chrome-top) -
            var(--app-chrome-bottom)
    );
    --surface-top-padding: var(--safe-top-header-gap);
    --surface-bottom-padding: clamp(0.58rem, 1.55vh, 0.86rem);
    --fixed-overlay-top-padding: calc(var(--app-chrome-top) + var(--safe-top-header-gap));
    --fixed-overlay-bottom-padding: calc(1.22rem + var(--app-chrome-bottom));
    --fixed-overlay-available-height: calc(
        100dvh -
            var(--fixed-overlay-top-padding) -
            var(--fixed-overlay-bottom-padding)
    );
    --transient-notice-bottom: calc(16px + var(--app-chrome-bottom));
    --dev-panel-bottom: calc(48px + var(--app-chrome-bottom));
    --dev-toggle-bottom: calc(8px + var(--app-chrome-bottom));
    --utility-top-safe-offset: clamp(1.6rem, 4.8vh, 2.1rem);
    --utility-right-safe-offset: clamp(1.02rem, 3.9vw, 1.4rem);
    --utility-status-cluster-top-reserve: clamp(1rem, 3.4vh, 1.58rem);
    --utility-status-cluster-right-reserve: clamp(0.62rem, 2.4vw, 0.94rem);
    --utility-result-safe-bump-top: clamp(0.48rem, 1.8vh, 0.88rem);
    --utility-result-safe-bump-right: clamp(0.24rem, 1.1vw, 0.4rem);
    --fixed-control-top: calc(
        var(--app-chrome-top) +
            var(--utility-top-safe-offset) +
            var(--utility-status-cluster-top-reserve) +
            var(--utility-modal-status-bump-top, 0px)
    );
    --fixed-control-right: calc(
        var(--app-chrome-right) +
            var(--utility-right-safe-offset) +
            var(--utility-status-cluster-right-reserve) +
            var(--utility-modal-status-bump-right, 0px)
    );
    --game-screen-top-padding: var(--surface-top-padding);
    --game-screen-bottom-padding: clamp(0.34rem, 1vh, 0.48rem);
    --meta-top-intrusion-buffer: clamp(0.86rem, 2.8vh, 1.46rem);
    --meta-cta-safety-gap: clamp(0.54rem, 1.85vh, 1.06rem);
    --meta-top-dead-zone: calc(var(--surface-top-padding) + var(--meta-top-intrusion-buffer));
    --meta-title-size: clamp(1.04rem, 3.2vw, 1.2rem);
    --meta-subtitle-size: clamp(0.62rem, 1.8vw, 0.7rem);

    /* Slate Palette */
    --color-slate-50: #f8fafc;
    --color-slate-100: #f1f5f9;
    --color-slate-200: #e2e8f0;
    --color-slate-300: #cbd5e1;
    --color-slate-400: #94a3b8;
    --color-slate-500: #64748b;
    --color-slate-600: #475569;
    --color-slate-700: #334155;
    --color-slate-800: #1e293b;
    --color-slate-900: #0f172a;

    /* Brand Colors */
    --color-primary: #3b82f6;
    /* Blue 500 */
    --color-primary-hover: #2563eb;
    /* Blue 600 */
    --color-success: #22c55e;
    /* Green 500 */
    --color-success-hover: #16a34a;
    /* Green 600 */
    --color-danger: #ef4444;
    /* Red 500 */
    --color-warning: #f59e0b;
    /* Amber 500 */
    --color-orange-400: #fb923c;
    /* Orange 400 */
    --color-accent: #facc15;
    /* Yellow 400 */
    --color-purple: #8b5cf6;
    /* Violet 500 */
    --color-purple-hover: #7c3aed;
    /* Violet 600 */

    /* Semantic Colors */
    --bg-app: var(--color-slate-800);
    --bg-card: var(--color-slate-700);
    --bg-overlay: rgba(0, 0, 0, 0.6);

    --text-main: var(--color-slate-100);
    --text-muted: var(--color-slate-300);
    --text-subtle: var(--color-slate-400);
    --text-soft: var(--color-slate-200);

    /* Shared Surface Tokens */
    --surface-radius-sm: 8px;
    --surface-radius-md: 10px;
    --surface-radius-lg: 12px;
    --surface-border-subtle: rgba(148, 163, 184, 0.25);
    --surface-border-default: rgba(148, 163, 184, 0.3);
    --surface-border-strong: rgba(148, 163, 184, 0.35);
    --surface-bg-soft: rgba(15, 23, 42, 0.45);
    --surface-bg-muted: rgba(15, 23, 42, 0.32);
    --surface-bg-raised: rgba(30, 41, 59, 0.6);
    --shadow-card-soft: 0 4px 8px -2px rgb(0 0 0 / 0.22);
    --shadow-card-strong: 0 8px 14px -3px rgba(0, 0, 0, 0.3);
    --shadow-modal: 0 16px 34px rgba(2, 6, 23, 0.52);
    --focus-ring: 2px solid rgba(125, 211, 252, 0.95);

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;

    /* Borders */
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
    --radius-full: 9999px;
}
/* Gameplay Readability Tokens */
:root {
    --gameplay-empty-fill: #f8fafc;
    --gameplay-empty-stroke: #64748b;
    --gameplay-empty-glow: rgba(14, 165, 233, 0.2);

    --gameplay-occupied-fill: #cbd5e1;
    --gameplay-occupied-stroke: #475569;
    --gameplay-occupied-shadow: rgba(15, 23, 42, 0.28);

    --gameplay-hazard-dirty: #a16207;
    --gameplay-hazard-messy: #ca8a04;
    --gameplay-hazard-broken: #dc2626;
    --gameplay-hazard-chatty: #9333ea;
    --gameplay-hazard-janitor: #0f766e;

    --gameplay-highlight-correct: #22c55e;
    --gameplay-highlight-incorrect: #ef4444;
    --gameplay-highlight-solution: #fde047;
    --gameplay-highlight-pending: #3b82f6;

    --gameplay-queue-chip-bg: rgba(15, 23, 42, 0.72);
    --gameplay-queue-light: rgba(59, 130, 246, 0.2);
    --gameplay-queue-busy: rgba(245, 158, 11, 0.26);
    --gameplay-queue-crunch: rgba(239, 68, 68, 0.28);
}
/* Base / Global Styles */
* {
    box-sizing: border-box;
}
body {
    font-family: "Nunito", sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 100vh;
    min-height: 100dvh;
    padding: calc(var(--app-top-gap) + var(--app-chrome-top))
        calc(var(--app-edge-gap) + var(--app-chrome-right))
        calc(var(--app-bottom-gap) + var(--app-chrome-bottom))
        calc(var(--app-edge-gap) + var(--app-chrome-left));
    overscroll-behavior: none;
    overflow: hidden;
    width: 100%;
    margin: 0;
}
body.top-intrusion-simulated::before {
    content: "";
    position: fixed;
    left: 50%;
    top: calc(var(--safe-area-top) + 0.08rem);
    width: min(82vw, 340px);
    height: calc(var(--top-system-intrusion-height, 0px) + 0.82rem);
    transform: translateX(-50%);
    background: radial-gradient(
        ellipse at center,
        rgba(15, 23, 42, 0.46) 0%,
        rgba(15, 23, 42, 0.12) 58%,
        rgba(15, 23, 42, 0) 78%
    );
    filter: blur(0.5px);
    pointer-events: none;
    z-index: 12000;
}
body.top-intrusion-simulated::after {
    content: "";
    position: fixed;
    left: 50%;
    top: calc(var(--safe-area-top) + 0.14rem);
    width: clamp(168px, 50vw, 244px);
    height: var(--top-system-intrusion-height, 0px);
    transform: translateX(-50%);
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.96) 0%, rgba(30, 41, 59, 0.94) 100%);
    border: 1px solid rgba(148, 163, 184, 0.42);
    box-shadow: 0 10px 24px -12px rgba(2, 6, 23, 0.88),
        inset 0 1px 0 rgba(248, 250, 252, 0.16);
    pointer-events: none;
    z-index: 12001;
}
body.is-native-app.platform-ios.orientation-portrait {
    --native-status-bar-fallback: clamp(2.4rem, 5.5vh, 3.25rem);
}
body.is-native-app.platform-android.orientation-portrait {
    --native-status-bar-fallback: clamp(1.28rem, 3.4vh, 1.85rem);
}
body.is-native-app.orientation-landscape {
    --native-status-bar-fallback: clamp(0.42rem, 2.2vh, 1.05rem);
}
/* Typography Defaults */
h1,
h2,
h3,
h4,
h5,
h6 {
    margin: 0;
    font-weight: 700;
}
p {
    margin: 0;
}
/* Utilities */
.hidden {
    display: none !important;
}
/* Animations that don't belong to specific components logic yet, or shared ones */
@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}
.opacity-0 {
    opacity: 0 !important;
    transition: opacity 0.3s ease;
}
.pointer-events-none {
    pointer-events: none !important;
}
.bg-transparent {
    background-color: transparent !important;
}
/* Components */
/* Button Components */
/* --- Start Screen Buttons --- */
.start-screen-button {
    color: white;
    font-weight: 700;
    width: 100%;
    min-height: 2.82rem;
    padding: 0.5rem 0.64rem;
    border-radius: var(--surface-radius-lg);
    font-size: 0.92rem;
    line-height: 1.12;
    box-shadow: 0 3px 7px -2px rgba(2, 6, 23, 0.28);
    transition: background-color 0.2s ease, transform 0.16s ease, box-shadow 0.2s ease;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.08rem;
    text-align: left;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}
.start-screen-button:hover {
    transform: translateY(-1px);
}
.start-screen-button:active {
    transform: translateY(0);
}
.start-screen-button:focus-visible {
    outline: var(--focus-ring);
    outline-offset: 2px;
}
.mode-button-title {
    font-size: 0.87rem;
    font-weight: 800;
    letter-spacing: 0.01em;
    line-height: 1.02;
}
.mode-button-subtitle {
    font-size: 0.66rem;
    font-weight: 600;
    line-height: 1.1;
    color: var(--text-soft);
    opacity: 0.95;
}
.mission-claim-button {
    margin-top: 0;
    border: 2px solid rgba(74, 222, 128, 0.5);
    border-radius: var(--surface-radius-md);
    background-color: rgba(21, 128, 61, 0.15);
    color: #4ade80;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 800;
    min-height: 1.8rem;
    min-width: 4rem;
    padding: 0.2rem 0.6rem;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 2px 4px -1px rgba(2, 6, 23, 0.4);
}
.mission-claim-button.featured {
    border-color: #4ade80;
    background-color: rgba(34, 197, 94, 0.2);
    color: #86efac;
    box-shadow: 0 0 10px rgba(74, 222, 128, 0.2);
}
.mission-claim-button.secondary {
    border-color: rgba(74, 222, 128, 0.3);
    background-color: rgba(15, 23, 42, 0.4);
    color: rgba(74, 222, 128, 0.9);
    box-shadow: none;
}
.mission-claim-button:hover {
    background-color: rgba(34, 197, 94, 0.3);
    border-color: #86efac;
    color: #ffffff;
    transform: scale(1.04) translateY(-1px);
    box-shadow: 0 4px 8px -2px rgba(2, 6, 23, 0.6);
}
.mission-claim-button:disabled {
    opacity: 0.62;
    cursor: default;
}
.home-mission-share-button {
    margin-bottom: 0.35rem;
    border: 1px solid var(--surface-border-strong);
    border-radius: var(--surface-radius-sm);
    background-color: rgba(15, 23, 42, 0.38);
    color: var(--text-soft);
    font-size: 0.76rem;
    font-weight: 700;
    min-height: 2.2rem;
    padding: 0.26rem 0.56rem;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.home-mission-share-button:hover {
    background-color: rgba(30, 41, 59, 0.72);
    color: #fff;
}
.home-mission-share-button:disabled {
    opacity: 0.7;
    cursor: default;
}
#start-progression-button {
    background-color: var(--color-primary);
    /* #0ea5e9 was slightly different but let's standardize on blue */
}
#start-progression-button:hover {
    background-color: var(--color-primary-hover);
}
#start-endless-button {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    box-shadow: 0 4px 15px -3px rgba(37, 99, 235, 0.5), inset 0 2px 0 rgba(255, 255, 255, 0.15);
    border: 1px solid #60a5fa;
}
#start-endless-button:hover {
    background: linear-gradient(135deg, #60a5fa 0%, #2563eb 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px -3px rgba(37, 99, 235, 0.7), inset 0 2px 0 rgba(255, 255, 255, 0.25);
}
#start-endless-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 5px -2px rgba(37, 99, 235, 0.8);
}
#start-daily-challenge-button {
    background: linear-gradient(135deg, #b45309 0%, #78350f 100%);
    border: 1px solid #f59e0b;
    box-shadow: 0 4px 12px -3px rgba(180, 83, 9, 0.6), inset 0 2px 0 rgba(255, 255, 255, 0.15);
}
#start-daily-challenge-button .mode-button-title {
    color: #fef3c7;
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}
#start-daily-challenge-button .mode-button-subtitle {
    color: #fbbf24;
    opacity: 0.9;
}
#start-daily-challenge-button:hover {
    background: linear-gradient(135deg, #d97706 0%, #92400e 100%);
    border-color: #fbbf24;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px -3px rgba(217, 119, 6, 0.7), inset 0 2px 0 rgba(255, 255, 255, 0.25);
}
#start-daily-challenge-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 5px -2px rgba(180, 83, 9, 0.8);
}
#start-daily-challenge-button:disabled {
    opacity: 0.72;
    cursor: not-allowed;
    filter: saturate(0.55);
}
#start-daily-challenge-button.attention-pulse {
    animation: daily-cta-pulse 620ms ease-out 2;
}
@keyframes daily-cta-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.55);
    }

    100% {
        box-shadow: 0 0 0 9px rgba(245, 158, 11, 0);
    }
}
#character-select-start-button {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    align-items: center;
    text-align: center;
    justify-content: center;
    min-height: 2.66rem;
    box-shadow: 0 6px 12px -4px rgba(37, 99, 235, 0.45);
}
#character-select-start-button .mode-button-subtitle {
    display: none;
}
#character-select-start-button:disabled {
    opacity: 0.58;
    cursor: not-allowed;
    transform: none;
}
/* --- Control Buttons (Modal Hierarchy) --- */
.control-button {
    width: 100%;
    min-height: 3rem;
    padding: 0.75rem 1rem;
    border-radius: var(--surface-radius-md);
    font-weight: 700;
    font-size: 1.05rem;
    transition: all 0.2s ease-in-out;
    cursor: pointer;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}
.control-button:active {
    transform: translateY(1px) scale(0.995);
}
.control-button:focus-visible {
    outline: var(--focus-ring);
    outline-offset: 2px;
}
/* Primary */
.btn-primary {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    box-shadow: 0 4px 8px -2px rgba(37, 99, 235, 0.5);
    font-size: 1.18rem;
    padding: 0.95rem;
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 12px -4px rgba(37, 99, 235, 0.56);
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}
#play-again-button.btn-primary {
    font-size: 1.28rem;
    letter-spacing: 0.01em;
}
/* Secondary */
.btn-secondary {
    background: linear-gradient(135deg, rgba(8, 145, 178, 0.88) 0%, rgba(14, 116, 144, 0.9) 100%);
    color: white;
    box-shadow: 0 3px 6px -2px rgba(8, 47, 73, 0.38);
    border: 1px solid rgba(125, 211, 252, 0.36);
    font-size: 1rem;
    padding: 0.82rem 0.95rem;
}
.btn-secondary:hover {
    background: linear-gradient(135deg, rgba(6, 95, 111, 0.92) 0%, rgba(12, 74, 110, 0.94) 100%);
}
/* Tertiary */
.btn-tertiary {
    background-color: rgba(15, 23, 42, 0.45);
    color: var(--text-soft);
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0.58rem 0.8rem;
    box-shadow: none;
    border: 1px solid var(--surface-border-default);
    margin-top: 0;
}
.btn-tertiary:hover {
    color: white;
    background-color: rgba(30, 41, 59, 0.72);
    border-color: rgba(148, 163, 184, 0.5);
}
.btn-tertiary:active {
    background-color: rgba(30, 41, 59, 0.82);
}
#share-button.btn-tertiary {
    margin-top: 0.1rem;
}
#revive-button.btn-secondary {
    margin-top: 0.12rem;
}
/* --- Peek & Restore Buttons --- */
#peek-modal-button,
#restore-modal-button {
    position: absolute;
    top: var(--fixed-control-top);
    right: var(--fixed-control-right);
    min-height: 2.2rem;
    min-width: 2.2rem;
    max-width: min(48vw, 10.6rem);
    padding: 0.38rem 0.66rem;
    border-radius: var(--radius-full);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    font-size: 0.74rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--surface-border-default);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
body.result-modal-visible {
    --utility-modal-status-bump-top: var(--utility-result-safe-bump-top);
    --utility-modal-status-bump-right: var(--utility-result-safe-bump-right);
}
body.modal-peek-active #restore-modal-button {
    top: calc(var(--fixed-control-top) + 0.3rem);
}
#peek-modal-button {
    background-color: rgba(15, 23, 42, 0.4);
    color: var(--text-soft);
}
#peek-modal-button:hover {
    color: white;
    background-color: rgba(30, 41, 59, 0.72);
    border-color: rgba(148, 163, 184, 0.48);
}
#restore-modal-button {
    background-color: rgba(14, 116, 144, 0.92);
    color: white;
    border: 1px solid rgba(125, 211, 252, 0.56);
    box-shadow: 0 2px 5px rgba(8, 47, 73, 0.32);
}
#restore-modal-button:hover {
    background-color: rgba(12, 74, 110, 0.95);
    transform: translateY(-1px);
}
#peek-modal-button svg,
#restore-modal-button svg {
    width: 15px;
    height: 15px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}
/* Mute Toggle */
#mute-toggle.icon-button {
    background-color: var(--surface-bg-soft);
    border: 1px solid var(--surface-border-strong);
    border-radius: 9999px;
    color: var(--color-slate-100);
    font-size: 1.05rem;
    line-height: 1;
    min-width: 2.4rem;
    min-height: 2.4rem;
    padding: 0.2rem 0.45rem;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
#mute-toggle.icon-button:focus-visible,
#peek-modal-button:focus-visible,
#restore-modal-button:focus-visible {
    outline: var(--focus-ring);
    outline-offset: 2px;
}
@media (pointer: coarse) {
    .start-screen-button,
    .control-button,
    #character-select-start-button {
        min-height: 3.3rem;
    }

    #mute-toggle.icon-button {
        min-width: 2.55rem;
        min-height: 2.55rem;
    }
}
/* Modal Components */
.custom-modal {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    padding: var(--fixed-overlay-top-padding) 0.7rem var(--fixed-overlay-bottom-padding);
    background-color: var(--bg-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    z-index: 1000;
}
body.has-native-banner .custom-modal {
    padding-bottom: calc(var(--fixed-overlay-bottom-padding) + clamp(0.24rem, 0.8vh, 0.42rem));
}
.custom-modal-content {
    background-color: var(--bg-card);
    background-image: linear-gradient(180deg, rgba(51, 65, 85, 0.98) 0%, rgba(30, 41, 59, 0.98) 100%);
    padding: 1.34rem 1.08rem 1.08rem;
    border-radius: 12px;
    text-align: left;
    box-shadow: var(--shadow-modal);
    border: 1px solid rgba(148, 163, 184, 0.28);
    max-width: calc(100vw - 1.12rem);
    width: min(430px, calc(100vw - 1.12rem));
    max-height: var(--fixed-overlay-available-height);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
    position: relative;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(1.5px);
}
body.has-native-banner .custom-modal-content {
    margin-bottom: clamp(0.36rem, 1.25vh, 0.72rem);
}
.custom-modal:not(.hidden) .custom-modal-content {
    animation: modal-content-enter 170ms cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes modal-content-enter {
    from {
        opacity: 0;
        transform: translateY(7px) scale(0.99);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}
/* Override for Peek Mode transparency */
.custom-modal.bg-transparent {
    background-color: transparent !important;
}
#custom-modal-message {
    font-size: 0.98rem;
    line-height: 1.32;
    color: var(--text-main);
    margin-bottom: 0.78rem;
    font-weight: 500;
}
#custom-modal-message .result-modal-body {
    display: flex;
    flex-direction: column;
    gap: 0.34rem;
}
#custom-modal-message .loss-reason {
    color: var(--color-orange-400);
    display: block;
    font-size: 1.14rem;
    margin-bottom: 0;
    line-height: 1.25;
    font-weight: 800;
}
#custom-modal-message .result-support-line {
    color: var(--text-main);
    display: block;
    font-size: 0.88rem;
    line-height: 1.3;
    margin: 0;
}
#custom-modal-message .result-summary-line {
    color: var(--text-soft);
    display: block;
    font-size: 0.84rem;
    line-height: 1.26;
    font-weight: 700;
}
#custom-modal-message .result-earned-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.32rem;
    margin-top: 0.08rem;
}
#custom-modal-message .result-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.18rem 0.42rem;
    border-radius: var(--radius-full);
    border: 1px solid rgba(125, 211, 252, 0.28);
    background: rgba(15, 23, 42, 0.56);
    color: #dbeafe;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1.2;
}
#custom-modal-message .result-meta-line {
    font-size: 0.76rem;
    line-height: 1.25;
    margin-top: 0.2rem;
}
#custom-modal-message .social-fallback-note {
    color: var(--text-muted);
}
#modal-controls-area {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.36rem;
    margin-top: 0.62rem;
    padding-bottom: max(0.16rem, var(--safe-area-bottom));
    width: 100%;
}
#modal-controls-area.result-actions-compact {
    gap: 0.3rem;
    margin-top: 0.5rem;
}
#modal-controls-area.result-actions-compact .control-button {
    min-height: 2.78rem;
}
#modal-controls-area.result-actions-expanded {
    gap: 0.4rem;
}
#modal-controls-area.result-actions-replay-focused .btn-primary {
    min-height: 2.9rem;
}
#modal-controls-area.result-actions-footer-minimal .modal-footer-row {
    margin-top: 0.26rem;
    padding-top: 0;
    border-top: none;
}
.modal-footer-row {
    display: flex;
    flex-direction: row;
    gap: 0.42rem;
    width: 100%;
    justify-content: center;
    margin-top: 0.44rem;
    padding-top: 0.38rem;
    border-top: 1px solid var(--surface-border-default);
}
body.has-native-banner #modal-controls-area {
    margin-top: 0.7rem;
    padding-bottom: max(0.3rem, var(--safe-area-bottom));
}
body.has-native-banner #modal-controls-area.result-actions-compact {
    margin-top: 0.58rem;
    gap: 0.34rem;
}
.modal-footer-row.compact-inline {
    margin-top: 0.26rem;
    padding-top: 0;
    border-top: none;
}
.modal-footer-row.single-action {
    justify-content: stretch;
}
.modal-footer-row.single-action .control-button {
    width: 100%;
}
#custom-modal-message .near-miss-text {
    color: #facc15;
    display: block;
    font-size: 0.84rem;
    margin-bottom: 0.32rem;
}
#custom-modal-message .onboarding-tip-text {
    color: var(--text-soft);
    display: block;
    font-size: 0.82rem;
    margin-top: 0.34rem;
    line-height: 1.28;
}
@media (max-height: 700px) {
    .custom-modal {
        align-items: flex-end;
    }

    .custom-modal-content {
        width: min(430px, 94vw);
        padding: 1.08rem 0.92rem 0.9rem;
        max-height: var(--fixed-overlay-available-height);
    }

    #custom-modal-message {
        margin-bottom: 0.72rem;
    }

    #custom-modal-message .loss-reason {
        font-size: 1.08rem;
    }
}
/* Character Cards */
#character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
    gap: 0.56rem;
    align-items: stretch;
    grid-auto-rows: minmax(clamp(7.8rem, 19.5vh, 9.35rem), 1fr);
}
.character-card {
    background-color: var(--surface-bg-raised);
    border-radius: var(--surface-radius-lg);
    min-height: clamp(7.8rem, 19.5vh, 9.35rem);
    padding: clamp(0.42rem, 1.25vh, 0.54rem) 0.5rem;
    cursor: pointer;
    transition: transform 0.16s ease, border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    border: 1px solid rgba(148, 163, 184, 0.22);
    box-shadow: var(--shadow-card-soft);
    text-align: center;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}
.character-card:hover {
    transform: translateY(-2px);
    border-color: rgba(96, 165, 250, 0.65);
    box-shadow: 0 8px 14px -5px rgba(2, 6, 23, 0.45);
    background-color: rgba(30, 41, 59, 0.9);
}
.character-card:active {
    transform: translateY(0);
}
.character-card.selected,
.character-card.preselected {
    border-color: rgba(59, 130, 246, 0.88);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.34);
    background-color: rgba(30, 58, 138, 0.34);
    transform: translateY(-1px);
}
.character-card-selection {
    min-height: 1.08rem;
    font-size: 0.68rem;
    font-weight: 700;
    color: #bfdbfe;
    margin-bottom: 0.16rem;
}
.character-card:focus-visible {
    outline: var(--focus-ring);
    outline-offset: 2px;
}
.character-card.locked {
    cursor: not-allowed;
    opacity: 0.58;
    filter: grayscale(0.9);
}
.character-card.locked:hover {
    transform: none;
    border-color: transparent;
}
.character-card.locked .character-name {
    color: var(--text-soft);
}
.character-card.locked .character-unlock-info {
    color: var(--text-muted);
}
.character-card svg {
    width: 100%;
    height: clamp(52px, 8.5vh, 70px);
    flex-shrink: 0;
}
.character-name {
    font-weight: 600;
    margin-top: 0.26rem;
    color: var(--text-main);
    font-size: 0.82rem;
}
.character-unlock-info {
    font-size: 0.68rem;
    color: var(--text-soft);
    margin-top: 0.14rem;
    line-height: 1.2;
}
.character-subtitle {
    font-size: 0.72rem;
    color: var(--text-subtle);
    margin-top: 0.1rem;
    line-height: 1.2;
}
@media (max-width: 480px) {
    #character-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.5rem;
    }

    .character-card {
        min-height: clamp(7.45rem, 18.8vh, 9.1rem);
        padding: clamp(0.38rem, 1.1vh, 0.5rem) 0.44rem;
    }
}
@media (max-width: 480px) and (max-height: 700px) {
    #character-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0.42rem;
        grid-auto-rows: minmax(7rem, 1fr);
    }

    .character-card {
        min-height: 7rem;
        padding: 0.32rem 0.28rem;
    }

    .character-card-selection {
        min-height: 0.88rem;
        font-size: 0.56rem;
        margin-bottom: 0.04rem;
    }

    .character-card svg {
        height: 42px;
    }

    .character-name {
        margin-top: 0.12rem;
        font-size: 0.68rem;
    }

    .character-subtitle,
    .character-unlock-info {
        margin-top: 0.06rem;
        font-size: 0.56rem;
        line-height: 1.12;
    }
}
/* Game Specific */
/* Game Layout & HUD */
/* --- Screens Container --- */
#start-screen,
#character-select-screen {
    background-color: var(--color-slate-700);
    /* Subtle gradient for more depth */
    background: linear-gradient(to bottom, var(--color-slate-700), var(--color-slate-800));
    border-radius: clamp(16px, 4vw, 22px);
    padding: 0.78rem 0.78rem;
    padding-top: var(--meta-top-dead-zone);
    padding-bottom: var(--surface-bottom-padding);
    text-align: center;
    border: 1px solid var(--surface-border-subtle);
    box-shadow: 0 10px 34px -18px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(148, 163, 184, 0.08);
    width: 100%;
    max-width: 34rem;
    height: var(--app-canvas-height);
    min-height: min(100%, var(--app-canvas-height));
    max-height: var(--app-canvas-height);
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
    scroll-padding-top: var(--meta-top-dead-zone);
    scroll-padding-bottom: calc(var(--surface-bottom-padding) + var(--banner-dead-zone));
    position: relative;
    display: flex;
    flex-direction: column;
    /* Anchor for absolute children like privacy link */
}
#home-content-stack {
    width: 100%;
    min-height: 0;
    margin-block: auto;
    display: flex;
    flex-direction: column;
}
#home-content-stack>*+*,
#character-select-screen>*+* {
    margin-top: 0.34rem;
}
#start-screen:not(.hidden),
#character-select-screen:not(.hidden),
#game-screen:not(.hidden) {
    animation: screen-surface-enter 170ms cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes screen-surface-enter {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.995);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}
#start-screen-title,
#character-select-title {
    font-size: calc(var(--meta-title-size) * 1.35);
    line-height: 1;
    font-weight: 900;
    color: var(--color-primary);
    text-shadow: 0 4px 6px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.6);
    margin: 0;
    letter-spacing: -0.015em;
}
#home-hero {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-bottom: 0.08rem;
    flex-shrink: 0;
}
#start-screen-subtitle {
    font-size: var(--meta-subtitle-size);
    line-height: 1.08;
    color: var(--text-muted);
    font-weight: 600;
}
#home-mode-section {
    text-align: left;
    margin-top: var(--meta-cta-safety-gap);
    flex-shrink: 0;
}
#start-screen-buttons {
    display: flex;
    justify-content: flex-start;
    gap: 0.32rem;
    flex-direction: column;
}
/* Privacy Link */
.start-privacy-link {
    position: static;
    display: inline-block;
    width: auto;
    text-align: center;
    margin-top: clamp(0.36rem, 1vh, 0.62rem);
    padding-top: 0;
    font-size: 0.75rem;
    opacity: 0.6;
    text-decoration: underline;
    color: var(--text-muted);
    flex-shrink: 0;
}
.start-privacy-link:focus,
.start-privacy-link:hover {
    opacity: 1;
}
#home-onboarding-hint {
    margin-top: 0.36rem;
    font-size: 0.73rem;
    font-weight: 600;
    color: var(--text-soft);
    background: rgba(15, 23, 42, 0.28);
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: var(--surface-radius-md);
    padding: 0.28rem 0.46rem;
    min-height: 0;
}
#home-status-strip {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    background: rgba(15, 23, 42, 0.25);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: var(--surface-radius-md) var(--surface-radius-md) 0 0;
    padding: 0.43rem 0.58rem;
    border-bottom: none;
    flex-shrink: 0;
}
.home-status-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    background: transparent;
    border: none;
    padding: 0;
}
.home-status-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-subtle);
    line-height: 1;
}
.home-status-value-wrapper {
    display: flex;
    align-items: baseline;
    gap: 0.05rem;
}
#home-high-score-value,
#home-streak-value {
    font-size: 1.25rem;
    font-weight: 900;
    color: var(--color-slate-50);
    line-height: 1;
    text-shadow: 0 2px 4px rgba(15, 23, 42, 0.8);
}
.home-status-unit {
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--color-slate-300);
}
#home-progression {
    text-align: center;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-top: 1px dashed rgba(148, 163, 184, 0.3);
    border-radius: 0 0 var(--surface-radius-md) var(--surface-radius-md);
    background: rgba(15, 23, 42, 0.25);
    padding: 0.36rem 0.5rem 0.5rem;
    margin-top: 0 !important;
    flex-shrink: 0;
}
#home-progression-headline {
    color: #ffffff;
    font-weight: 800;
    text-transform: uppercase;
    font-size: 0.9rem;
    letter-spacing: 0.02em;
    text-shadow: 0 2px 4px rgba(15, 23, 42, 0.8);
}
.home-level-prefix {
    color: var(--color-primary);
    font-size: 0.75rem;
    font-weight: 800;
}
#home-level-title-value {
    margin-left: 0.15rem;
    color: var(--color-orange-400);
}
#home-progression-detail {
    margin-top: 0.25rem;
}
.home-xp-capsule {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: rgba(15, 23, 42, 0.4);
    padding: 0.15rem 0.5rem;
    border-radius: 1rem;
    font-size: 0.65rem;
    font-weight: 800;
    color: var(--color-orange-300);
}
.home-xp-icon {
    font-size: 0.75rem;
    color: var(--color-orange-400);
    text-shadow: 0 0 4px rgba(251, 146, 60, 0.5);
}
.progression-dot {
    margin: 0 0.35rem;
    opacity: 0.5;
}
#home-progression-note {
    margin-top: 0.14rem;
    font-size: 0.7rem;
    color: var(--text-muted);
}
#home-missions {
    margin-top: 0.35rem;
    text-align: left;
    border: none;
    border-radius: 0;
    padding: 0.28rem 0.12rem 0.12rem;
    background: transparent;
    flex: 0 1 auto;
    min-height: 0;
    max-height: clamp(8rem, 25vh, 12rem);
    overflow-y: auto;
    overscroll-behavior-y: contain;
}
#home-missions.onboarding-locked {
    border: 1px solid rgba(148, 163, 184, 0.15);
    background: radial-gradient(circle at center top, rgba(15, 23, 42, 0.4) 0%, rgba(15, 23, 42, 0.15) 100%);
    border-radius: var(--surface-radius-lg);
    padding: 0.6rem 0.5rem;
    text-align: center;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.1);
}
#home-missions.onboarding-locked #home-missions-title {
    color: var(--color-slate-400);
    font-size: 0.65rem;
    letter-spacing: 0.05em;
    margin-bottom: 0.2rem;
}
#home-missions.onboarding-locked #home-missions-summary {
    color: var(--color-slate-50);
    font-weight: 700;
    font-size: 0.75rem;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    margin-top: 0;
    margin-bottom: 0.25rem;
}
#home-missions.onboarding-locked .home-mission-feedback {
    /* If any text gets rendered by fallback, make it blend */
    color: var(--text-muted);
    font-size: 0.65rem;
}
#home-missions-title {
    margin: 0;
    font-size: 0.75rem;
    color: var(--text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    font-weight: 700;
}
#home-missions-summary {
    margin-top: 0.08rem;
    margin-bottom: 0.25rem;
    color: var(--text-soft);
    font-size: 0.72rem;
}
#home-mission-feedback {
    margin-bottom: 0.22rem;
    font-size: 0.72rem;
    color: var(--color-success);
    font-weight: 600;
}
#home-mission-feedback:not(.hidden) {
    animation: status-fade-slide 160ms ease-out;
}
#home-missions-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.home-mission-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.3rem;
    border: none;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 0;
    padding: 0.3rem 0;
    background: transparent;
}
.home-mission-row:last-child {
    border-bottom: none;
}
.home-mission-main {
    min-width: 0;
}
.home-mission-row.onboarding-locked {
    opacity: 0.5;
}
@keyframes reward-pulse {
    0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.2); }
    70% { box-shadow: 0 0 0 6px rgba(74, 222, 128, 0); }
    100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}
.home-mission-row.completed,
.home-mission-row.claim-featured,
.home-mission-row.claim-secondary {
    border-color: rgba(74, 222, 128, 0.3);
    background: linear-gradient(90deg, rgba(74, 222, 128, 0.08) 0%, transparent 100%);
    border-radius: var(--surface-radius-sm);
    padding-left: 0.35rem;
}
#home-missions.has-claim-ready .home-mission-row.claim-featured,
#home-missions.has-claim-ready .home-mission-row.claim-secondary {
    animation: reward-pulse 2s infinite ease-out;
}
#home-missions.multi-claim-ready .home-mission-row.claim-secondary {
    border-style: dashed;
    background: rgba(30, 41, 59, 0.34);
}
#home-missions.has-claim-ready #home-missions-summary {
    color: #bbf7d0;
}
#home-missions.multi-claim-ready .home-mission-row.deemphasized-progress {
    opacity: 0.9;
}
.home-mission-title {
    color: var(--text-soft);
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.18;
}
.home-mission-row.claim-secondary .home-mission-title,
.home-mission-row.deemphasized-progress .home-mission-title {
    font-weight: 600;
}
.home-mission-progress {
    margin-top: 0.08rem;
    color: var(--text-muted);
    font-size: 0.69rem;
}
.home-mission-status {
    margin-top: 0.2rem;
    color: var(--color-success);
    font-size: 0.73rem;
    font-weight: 700;
}
#character-select-subtitle {
    font-size: var(--meta-subtitle-size);
    color: var(--text-soft);
    line-height: 1.1;
    max-width: 24ch;
    margin-inline: auto;
    flex-shrink: 0;
}
#character-grid {
    margin-top: var(--meta-cta-safety-gap);
    flex: 1 1 auto;
    min-height: 0;
    align-content: stretch;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    padding: 0.08rem 0.1rem;
    margin-inline: -0.1rem;
}
#character-select-selection-status {
    margin-top: 0.22rem;
    min-height: 1.2rem;
    font-size: 0.78rem;
    color: var(--text-soft);
    border-radius: var(--surface-radius-md);
    border: 1px solid rgba(148, 163, 184, 0.24);
    background: rgba(15, 23, 42, 0.2);
    padding: 0.3rem 0.42rem;
    transition: color 140ms ease;
    flex-shrink: 0;
}
#character-select-start-button {
    margin: 0.18rem auto 0;
    width: 100%;
    flex-shrink: 0;
}
@keyframes status-fade-slide {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}
@media (max-width: 480px) {
    #start-screen,
    #character-select-screen {
        --meta-top-intrusion-buffer: clamp(0.74rem, 2.55vh, 1.2rem);
        --meta-cta-safety-gap: clamp(0.44rem, 1.65vh, 0.86rem);
        --meta-title-size: clamp(0.98rem, 6.1vw, 1.14rem);
        --meta-subtitle-size: clamp(0.58rem, 2.6vw, 0.66rem);
        padding: 0.68rem 0.56rem;
        padding-top: var(--meta-top-dead-zone);
        padding-bottom: clamp(0.48rem, 1.3vh, 0.68rem);
    }
}
/* --- Main Game Screen --- */
#game-screen {
    width: 100%;
    max-width: 52rem;
    text-align: center;
    background-color: rgba(15, 23, 42, 0.52);
    background-image: linear-gradient(180deg, rgba(30, 41, 59, 0.52) 0%, rgba(15, 23, 42, 0.7) 100%);
    border-radius: clamp(12px, 3.2vw, 18px);
    padding: 0.58rem 0.52rem;
    padding-top: var(--game-screen-top-padding);
    padding-bottom: var(--game-screen-bottom-padding);
    position: relative;
    border: 1px solid rgba(148, 163, 184, 0.08);
    transition: background-color 0.5s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 0.18rem;
    height: var(--app-canvas-height);
    min-height: min(100%, var(--app-canvas-height));
    max-height: var(--app-canvas-height);
    box-shadow: 0 8px 24px -18px rgba(2, 6, 23, 0.74);
}
#game-screen>*+* {
    margin-top: 0;
}
/* Theme Classes (overrides background) */
.theme-arcade {
    background-color: #334155 !important;
}
.theme-office {
    background-color: #cbd5e1 !important;
    color: #1e293b !important;
}
.theme-dive-bar {
    background-color: #1a1a1a !important;
    color: #cbd5e1 !important;
}
.theme-luxury-hotel {
    background-color: #fef3c7 !important;
    color: #78350f !important;
}
/* Theme-specific Overrides for Contrast */
.theme-office .bathroom-walls {
    background-color: white !important;
    border-color: #94a3b8 !important;
    /* slate-400 */
}
.theme-airport {
    background-color: #e5e7eb !important;
    color: #374151 !important;
}
/* --- Headers & HUD --- */
/* --- Headers & HUD --- */
#score-header,
#level-timer-header {
    width: 100%;
    padding: 0.15rem 0.25rem;
    margin-bottom: 0.1rem;
}
#score-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.86rem;
    font-weight: 700;
    color: var(--color-slate-200);
    gap: 0.55rem;
}
body.modal-peek-active #score-header {
    padding-right: calc(var(--fixed-control-right) + 4.8rem);
}
#score-area {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.4rem;
    border-radius: 9999px;
    background: rgba(15, 23, 42, 0.42);
}
#high-score-area {
    padding: 0.2rem 0.4rem;
    border-radius: 9999px;
    background: rgba(15, 23, 42, 0.42);
    font-size: 0.8rem;
}
#score-character-avatar {
    width: 20px;
    height: 27px;
}
#score-character-avatar svg {
    width: 100%;
    height: 100%;
    display: block;
}
#level-timer-header {
    display: grid;
    grid-template-areas: "mute title timer";
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.38rem;
}
#mute-toggle {
    grid-area: mute;
    justify-self: start;
    font-size: 1.05rem;
    background: none;
    border: 1px solid rgba(148, 163, 184, 0.45);
    border-radius: 9999px;
    cursor: pointer;
    padding: 0.18rem 0.42rem;
    line-height: 1;
    color: var(--color-slate-100);
    background-color: rgba(15, 23, 42, 0.45);
}
#level-title-container {
    grid-area: title;
    justify-self: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    white-space: nowrap;
    margin-bottom: 0;
    min-width: 0;
}
#level-title {
    font-size: 0.95rem;
    line-height: 1.2;
    font-weight: 800;
    color: var(--color-slate-50);
    letter-spacing: 0.01em;
}
#star-container {
    min-height: 0;
}
#timer-container {
    grid-area: timer;
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.17rem 0.38rem;
    border-radius: 9999px;
    border: 1px solid rgba(245, 158, 11, 0.35);
    background: rgba(15, 23, 42, 0.45);
}
#timer-area {
    font-size: 1.28rem;
    font-weight: 900;
    color: var(--color-warning);
    line-height: 1;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}
.time-bonus-flash {
    animation: pulse-green 0.4s ease-in-out;
    color: var(--color-success) !important;
}
@keyframes pulse-green {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.3);
    }

    100% {
        transform: scale(1);
    }
}
@media (max-width: 480px) {
    #game-screen {
        --game-screen-top-padding: clamp(0.42rem, 1.3vh, 0.62rem);
        --game-screen-bottom-padding: clamp(0.32rem, 0.9vh, 0.42rem);
        padding: 0.5rem 0.42rem;
        padding-top: var(--game-screen-top-padding);
        padding-bottom: var(--game-screen-bottom-padding);
    }

    #score-header {
        font-size: 0.78rem;
    }

    #level-title {
        font-size: 0.84rem;
        line-height: 1.08;
    }

    #timer-area {
        font-size: 1.1rem;
    }

    #score-header,
    #level-timer-header {
        gap: 0.35rem;
        padding-left: 0.05rem;
        padding-right: 0.05rem;
    }

    #timer-container {
        padding: 0.12rem 0.3rem;
    }

    #mute-toggle {
        font-size: 0.94rem;
        padding: 0.14rem 0.35rem;
    }
}
/* --- Bladder --- */
#bladder-container {
    width: 18px;
    height: 24px;
    border: 2px solid var(--color-accent);
    border-radius: 50% 50% 30% 30% / 60% 60% 40% 40%;
    position: relative;
    overflow: hidden;
    background-color: var(--color-slate-700);
}
#bladder-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--color-accent);
    transition: height 1s linear;
}
#bladder-fill.emptying {
    height: 0 !important;
    transition: height 0.5s ease-in-out !important;
}
#game-stage {
    width: 100%;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 0.12rem;
    padding-bottom: 0;
}
@media (max-height: 760px) {
    #game-screen {
        --game-screen-top-padding: clamp(0.32rem, 1vh, 0.5rem);
        --game-screen-bottom-padding: clamp(0.28rem, 0.8vh, 0.38rem);
        min-height: min(100%, var(--app-canvas-height));
        max-height: var(--app-canvas-height);
        padding-top: var(--game-screen-top-padding);
        padding-bottom: var(--game-screen-bottom-padding);
    }

    #score-header,
    #level-timer-header {
        margin-bottom: 0;
    }

    #level-title {
        font-size: 0.82rem;
    }

    #timer-area {
        font-size: 1.02rem;
    }
}
@media (max-height: 740px) {
    #start-screen,
    #character-select-screen {
        --meta-top-intrusion-buffer: clamp(0.64rem, 2.15vh, 1.04rem);
        --meta-cta-safety-gap: clamp(0.38rem, 1.35vh, 0.74rem);
    }

    #home-content-stack>*+*,
    #character-select-screen>*+* {
        margin-top: 0.28rem;
    }

    #home-content-stack {
        margin-block: 0;
    }

    #home-missions {
        max-height: clamp(5.8rem, 18vh, 8.4rem);
        overflow-y: auto;
        padding: 0.24rem 0.12rem 0.1rem;
        min-height: 0;
    }

    #home-missions-summary,
    #home-mission-feedback {
        margin-bottom: 0.18rem;
    }

    #character-select-subtitle {
        font-size: clamp(0.62rem, 1.8vw, 0.68rem);
    }
}
/* --- Overlays --- */
#flicker-overlay,
#frenzy-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 20;
}
#flicker-overlay.flicker-active {
    background-color: rgba(0, 0, 0, 0.3);
    opacity: 0.3;
}
#frenzy-overlay {
    background: radial-gradient(circle, transparent 20%, rgba(255, 215, 0, 0.3) 100%);
    animation: frenzy-pulse 0.5s infinite alternate;
}
@keyframes frenzy-pulse {
    from {
        opacity: 0.3;
    }

    to {
        opacity: 0.7;
    }
}
#wait-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.7);
    color: var(--color-slate-50);
    font-size: 3rem;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    border-radius: 8px;
    -webkit-text-stroke: 1px var(--color-warning);
    color: var(--color-accent);
    /* Override text color to yellow */
}
/* Urinals & Environment */
#bathroom-container {
    position: relative;
    margin: 0 auto;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: stretch;
    flex: 1;
    min-height: 0;
}
.bathroom-walls {
    background-color: var(--color-slate-200);
    border: 2px solid var(--color-slate-400);
    border-radius: 10px;
    padding: 5px 4px;
    margin: 0 auto;
    width: 100%;
    max-width: min(98vw, 760px);
    min-height: clamp(220px, 54vh, 560px);
    height: 100%;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transition: background-color 0.5s ease, border-color 0.5s ease;
    position: relative;
    overflow-x: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
#urinal-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 126px;
    width: 100%;
    transform-origin: center center;
    transition: transform 0.3s ease-out;
}
.urinal-row {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}
.urinal-row-divider {
    width: 80%;
    max-width: 500px;
    height: 7px;
    background-color: var(--color-slate-600);
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
/* Single Urinal Item */
.urinal {
    height: 100px;
    width: 58px;
    cursor: pointer;
    transition: transform 0.16s ease-in-out, filter 0.16s ease-in-out;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    border-radius: 12px;
    isolation: isolate;
}
.urinal::before,
.urinal::after {
    content: "";
    position: absolute;
    border-radius: 10px;
    inset: 2px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.18s ease-in-out, border-color 0.18s ease-in-out, box-shadow 0.18s ease-in-out;
    z-index: 3;
}
.urinal::before {
    border: 2px solid transparent;
}
.urinal::after {
    inset: 5px;
    border: 2px dashed transparent;
    z-index: 2;
}
.urinal-fixture-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    overflow: visible;
}
.urinal-path-main {
    stroke-width: 2;
    transition: fill 0.16s ease-in-out, stroke 0.16s ease-in-out, stroke-width 0.16s ease-in-out,
        filter 0.16s ease-in-out;
}
.urinal-state-layer {
    transition: filter 0.18s ease-in-out, opacity 0.18s ease-in-out;
}
/* Baseline Readability States */
.urinal.state-empty .urinal-path-main {
    fill: var(--gameplay-empty-fill);
    stroke: var(--gameplay-empty-stroke);
}
.urinal.state-empty .urinal-cake.playable-cake {
    fill: #67e8f9;
    stroke: #0284c7;
    stroke-width: 0.85;
}
.urinal.state-occupied .urinal-path-main,
.urinal.state-blocked .urinal-path-main {
    fill: var(--gameplay-occupied-fill);
    stroke: var(--gameplay-occupied-stroke);
}
.urinal .urinal-cake.blocked-cake {
    fill: #94a3b8;
    stroke: #64748b;
    stroke-width: 0.6;
}
.urinal.state-selectable::before {
    opacity: 0.8;
    border-color: rgba(14, 165, 233, 0.36);
}
.urinal.state-blocked::before {
    opacity: 0.85;
    border-color: rgba(71, 85, 105, 0.42);
}
/* Interaction States */
@media (hover: hover) and (pointer: fine) {
    .urinal.state-selectable:hover .urinal-path-main {
        stroke: #0284c7;
        filter: brightness(1.08);
    }

    .urinal.state-selectable:hover::before {
        opacity: 1;
        border-color: #0ea5e9;
        box-shadow: 0 0 0 2px var(--gameplay-empty-glow);
    }
}
.urinal.state-selectable:active {
    transform: scale(0.98);
}
.urinal.player-chosen-correct .urinal-path-main {
    stroke: var(--gameplay-highlight-correct);
    stroke-width: 3;
    filter: brightness(1.14);
}
.urinal.player-chosen-correct::before {
    opacity: 1;
    border-color: var(--gameplay-highlight-correct);
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.28);
}
.urinal.player-chosen-incorrect .urinal-path-main {
    stroke: var(--gameplay-highlight-incorrect);
    stroke-width: 4;
    animation: pulse-red 0.85s infinite;
}
.urinal.player-chosen-incorrect::before {
    opacity: 1;
    border-color: var(--gameplay-highlight-incorrect);
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.32);
}
.urinal.player-chosen-incorrect.player-chosen-hazard .urinal-path-main {
    animation: none;
    stroke-width: 3.2;
    filter: brightness(1.06);
}
.urinal.player-chosen-incorrect.player-chosen-hazard::before {
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.34), 0 0 0 4px rgba(15, 23, 42, 0.16);
}
.urinal.player-chosen-incorrect.player-chosen-hazard.family-dirty .urinal-path-main {
    stroke: var(--gameplay-hazard-dirty);
    fill: #fef3c7;
}
.urinal.player-chosen-incorrect.player-chosen-hazard.family-messy .urinal-path-main {
    stroke: var(--gameplay-hazard-messy);
    fill: #fef9c3;
}
.urinal.player-chosen-incorrect.player-chosen-hazard.family-broken .urinal-path-main {
    stroke: var(--gameplay-hazard-broken);
    fill: #e2e8f0;
}
.urinal.player-chosen-incorrect.player-chosen-hazard.family-janitor .urinal-path-main {
    stroke: var(--gameplay-hazard-janitor);
    fill: #ccfbf1;
}
@keyframes pulse-red {
    0% {
        stroke-opacity: 1;
    }

    50% {
        stroke-opacity: 0.5;
    }

    100% {
        stroke-opacity: 1;
    }
}
.urinal.ai-chosen .urinal-path-main {
    animation: ai-flash 0.8s ease-in-out;
}
@keyframes ai-flash {

    0%,
    100% {
        stroke: var(--color-primary);
        fill: #60a5fa;
    }

    50% {
        stroke: var(--color-success);
        fill: #dcfce7;
        stroke-width: 3px;
    }
}
.urinal.player-selection-pending .urinal-path-main {
    stroke: var(--gameplay-highlight-pending);
    stroke-width: 3;
    filter: drop-shadow(0 0 2px rgba(59, 130, 246, 0.6));
}
.urinal.player-selection-pending::before {
    opacity: 1;
    border-color: var(--gameplay-highlight-pending);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.24);
}
/* Special Urinals */
.urinal.golden .urinal-path-main {
    fill: #fef08a;
    /* yellow-200 */
    stroke: var(--color-accent);
    animation: golden-pulse 1.15s infinite;
}
.urinal.golden::before {
    opacity: 1;
    border-color: rgba(245, 158, 11, 0.76);
    box-shadow: 0 0 0 2px rgba(250, 204, 21, 0.24);
}
@keyframes golden-pulse {
    0% {
        filter: drop-shadow(0 0 3px #fde047);
    }

    50% {
        filter: drop-shadow(0 0 7px #fde047);
    }

    100% {
        filter: drop-shadow(0 0 3px #fde047);
    }
}
/* Solution Highlight (Debug/Cheat/Tutorial) */
.urinal.urinal-solution-highlight .urinal-path-main {
    stroke: #f59e0b;
    stroke-width: 2.8;
}
.urinal.urinal-solution-highlight::after {
    opacity: 1;
    border-color: var(--gameplay-highlight-solution);
}
.urinal.player-chosen-incorrect.urinal-solution-highlight::after {
    border-color: rgba(239, 68, 68, 0.82);
    border-style: solid;
}
.urinal.player-chosen-correct.urinal-solution-highlight::after {
    border-color: rgba(34, 197, 94, 0.82);
    border-style: solid;
}
@keyframes solution-pulse {
    0% {
        filter: drop-shadow(0 0 2px #fef08a);
    }

    50% {
        filter: drop-shadow(0 0 6px #fef08a);
    }

    100% {
        filter: drop-shadow(0 0 2px #fef08a);
    }
}
.urinal.family-occupied .urinal-state-layer {
    filter: drop-shadow(0 1px 1px var(--gameplay-occupied-shadow));
}
.urinal.family-chatty .urinal-path-main {
    fill: #ede9fe;
    stroke: var(--gameplay-hazard-chatty);
}
.urinal.family-chatty::after {
    opacity: 0.9;
    border-color: rgba(147, 51, 234, 0.78);
}
.urinal.family-broken .urinal-path-main {
    fill: #e2e8f0;
    stroke: var(--gameplay-hazard-broken);
}
.urinal.family-broken::after {
    opacity: 0.92;
    border-color: rgba(220, 38, 38, 0.82);
    border-style: double;
}
.urinal.family-dirty .urinal-path-main {
    fill: #fef3c7;
    stroke: var(--gameplay-hazard-dirty);
}
.urinal.family-dirty::after {
    opacity: 0.9;
    border-color: rgba(161, 98, 7, 0.8);
    border-style: dotted;
}
.urinal.family-messy .urinal-path-main {
    fill: #fef9c3;
    stroke: var(--gameplay-hazard-messy);
}
.urinal.family-messy::after {
    opacity: 0.88;
    border-color: rgba(202, 138, 4, 0.78);
}
.urinal.family-janitor .urinal-path-main {
    fill: #ccfbf1;
    stroke: var(--gameplay-hazard-janitor);
}
.urinal.family-janitor::after {
    opacity: 0.9;
    border-color: rgba(15, 118, 110, 0.82);
    border-style: solid;
}
.urinal-divider {
    width: 8px;
    height: 72px;
    background-color: var(--color-slate-400);
    border-radius: 3px;
    transition: background-color 0.5s ease;
}
/* Misc Urinal Elements */
.urinal-cake {
    fill: #7dd3fc;
    stroke: #0ea5e9;
    stroke-width: 0.8;
}
.flusher.broken {
    transform: rotate(-20deg) translate(-7px, 3px);
    opacity: 0.6;
}
/* Characters/Animations on Urinals */
.head-shake .body {
    animation: head-shake-anim 0.5s ease-in-out;
}
@keyframes head-shake-anim {

    0%,
    100% {
        transform: translateX(0) rotate(0);
    }

    20% {
        transform: translateX(-3px) rotate(-2deg);
    }

    40% {
        transform: translateX(3px) rotate(2deg);
    }

    60% {
        transform: translateX(-3px) rotate(-2deg);
    }

    80% {
        transform: translateX(3px) rotate(2deg);
    }
}
.speech-bubble {
    animation: pulse 1.5s ease-in-out infinite;
}
@media (max-width: 480px) {
    .bathroom-walls {
        min-height: clamp(208px, 50vh, 500px);
        padding: 5px 3px;
    }

    #urinal-area {
        min-height: 114px;
    }

    .urinal {
        height: 88px;
        width: 50px;
    }

    .urinal-divider {
        height: 63px;
        width: 7px;
    }
}
@media (max-height: 740px) {
    .bathroom-walls {
        min-height: clamp(184px, 43vh, 360px);
    }
}
/* Door */
#door {
    position: absolute;
    bottom: 0px;
    right: 100%;
    margin-right: 2px;
    width: 25px;
    height: 85px;
    background-color: #78350f;
    border: 2px solid #451a03;
    border-right: none;
    border-radius: 4px 0 0 4px;
    z-index: 10;
}
#door-knob {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    right: 4px;
    width: 4px;
    height: 4px;
    background-color: #facc15;
    border-radius: 50%;
}
#player-avatar {
    position: absolute;
    bottom: 10px;
    left: -40px;
    /* Initial position (off-screen or by door), JS moves it */
    width: 45px;
    height: 80px;
    z-index: 20;
    transition: left 0.5s linear, top 0.5s linear;
}
/* Note: Player Avatar styles seem to be mostly dynamic, but ensuring basic style here */
@media (max-width: 540px) {
    .bathroom-walls {
        min-height: clamp(212px, 51vh, 510px);
        padding: 5px 3px;
    }

    .urinal {
        height: 90px;
        width: 51px;
    }

    .urinal-divider {
        height: 64px;
    }

    .urinal-row-divider {
        margin-top: 0.5rem;
        margin-bottom: 0.5rem;
    }
}
@media (max-height: 760px) {
    .bathroom-walls {
        min-height: clamp(186px, 44vh, 372px);
    }
}
/* Queue Area */
#queue-area {
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    gap: 0.05rem;
    margin-right: 2px;
    min-height: 78px;
    margin-bottom: 0;
    padding: 0.14rem 0.18rem;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.26);
    background: var(--gameplay-queue-light);
    transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out;
}
#queue-label {
    font-weight: 600;
    color: var(--color-slate-200);
    margin-right: 0.35rem;
    padding-bottom: 34px;
    font-size: 0.74rem;
    letter-spacing: 0.01em;
    text-transform: uppercase;
    background: var(--gameplay-queue-chip-bg);
    border: 1px solid rgba(148, 163, 184, 0.36);
    border-radius: 999px;
    padding-left: 0.28rem;
    padding-right: 0.28rem;
}
.queue-person {
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
    position: relative;
    animation: queue-bob 2.5s ease-in-out infinite;
    filter: drop-shadow(0 2px 1px rgba(15, 23, 42, 0.28));
}
@keyframes queue-bob {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-3px);
    }
}
.queue-person.player-in-queue {
    animation: player-bob 1.5s ease-in-out infinite;
}
.queue-player-marker svg path {
    fill: #fb923c;
    stroke: #9a3412;
    stroke-width: 0.6;
}
@keyframes player-bob {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}
.queue-person-label {
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    font-weight: bold;
    background: rgba(0, 0, 0, 0.5);
    padding: 1px 4px;
    border-radius: 3px;
    color: var(--color-slate-200);
    white-space: nowrap;
}
#queue-area[data-queue-pressure="busy"] {
    background: var(--gameplay-queue-busy);
    border-color: rgba(245, 158, 11, 0.56);
}
#queue-area[data-queue-pressure="crunch"] {
    background: var(--gameplay-queue-crunch);
    border-color: rgba(239, 68, 68, 0.54);
}
@media (max-height: 760px) {
    #queue-area {
        min-height: 64px;
    }

    #queue-label {
        padding-bottom: 25px;
    }
}
@media (max-width: 390px) {
    #queue-area {
        min-height: 60px;
    }

    #queue-label {
        font-size: 0.68rem;
        padding-bottom: 22px;
    }
}
