:root {
    --transition-fast: 150ms;
    --transition-normal: 300ms;
    --ease-out: cubic-bezier(0.0, 0, 0.2, 1);
    --ease-bounce: cubic-bezier(0.68, -0.6, 0.32, 1.6);
    --space-xs: 8px;
    --space-sm: 16px;
    --space-md: 24px;
    --space-lg: 32px;
    --space-xl: 48px;
    --color-wood: #7A5230;
    --color-wood-light: #C49A6C;
    --color-wood-dark: #4A2E1A;
    --color-amber: #E8A028;
    --color-amber-dark: #B87A10;
    --color-bg: #4A7C4E;
    --color-panel-bg: #3D2814;
    --color-panel-border: #6B4424;
    --color-btn-disabled: #4A4A4A;
    --color-nail: #8A8A8A;
}

@font-face {
    font-family: 'Fredoka';
    src: url('assets/fonts/Fredoka-VariableFont.ttf') format('truetype');
    font-weight: 300 700;
    font-display: swap;
}

/* When the platform pauses the game, freeze all CSS animations/transitions so the
   frame stays completely still (the render loop is stopped separately in JS). */
.game-paused *,
.game-paused *::before,
.game-paused *::after {
    animation-play-state: paused !important;
    transition: none !important;
}

body,
html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: none;
    -ms-touch-action: none;
    font-family: 'Inter', sans-serif;
    background: #2a2a2a;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
}

#game-world {
    position: relative;
    width: 100%;
    height: 100%;
    background: #4A7C4E;
}

#bg-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 50%;
    z-index: 0;
}

#game-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    touch-action: none;
    outline: none;
}

.ui-overlay {
    z-index: 2;
}

.ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}


.ui-overlay>* {
    pointer-events: auto;
}

/* HUD - Separate Panel Style */
.hud-panel {
    position: absolute;
    top: calc(4px + env(safe-area-inset-top) + 12px * var(--ui-scale, 1));
    left: calc(16px + env(safe-area-inset-left));
    display: flex;
    gap: 14px;
    align-items: flex-start;
    transform: scale(var(--ui-scale, 1));
    transform-origin: left top;
}

.hud-card {
    background: linear-gradient(180deg, #D4A96A 0%, #B8894A 100%);
    border-radius: 14px;
    padding: 10px 13px;
    border: 3px solid #8B6B3A;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 88px;
    max-width: 132px;
    box-sizing: border-box;
    position: relative;
}

.hud-card-label {
    font-family: 'Fredoka', sans-serif;
    font-size: 24px;
    color: #5C3A1E;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.hud-card-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.7));
}

.hud-card-icon.cash {
    background: #FFD700;
    color: #8B6B00;
    font-weight: bold;
}

.hud-card-icon.income {
    background: #4CAF50;
    color: white;
    font-weight: bold;
}

.hud-item {
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.hud-label {
    font-family: 'Inter', sans-serif;
    font-size: 22px;
    color: #5C3A1E;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.hud-value {
    font-family: 'Fredoka', sans-serif;
    font-size: 38px;
    color: #FFFFFF;
    font-weight: 700;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6), 0 1px 2px rgba(0, 0, 0, 0.8);
    width: 100%;
    min-width: 106px;
    max-width: 106px;
    text-align: center;
    box-sizing: border-box;
}

.hud-value.small-font {
    font-size: 32px;
}

/* Bottom Controls */
.controls-panel {
    position: absolute;
    bottom: calc(18px + env(safe-area-inset-bottom));
    left: calc(16px + env(safe-area-inset-left));
    right: calc(16px + env(safe-area-inset-right));
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 8px;
    z-index: 60;
    transform: scale(var(--ui-scale, 1));
    transform-origin: center bottom;
}

.game-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 92px;
    min-height: 92px;
    padding: 16px 20px;
    border: 3px solid;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Fredoka', sans-serif;
    font-size: 31px;
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    transition: transform var(--transition-fast) var(--ease-out),
        opacity var(--transition-fast) var(--ease-out);
    position: relative;
    letter-spacing: 0.5px;
    will-change: transform;
    transform-origin: center bottom;
}

.game-btn:active {
    transform: translateY(2px) scale(0.97);
}

.game-btn::after {
    content: '';
    position: absolute;
    top: -20px;
    left: -10px;
    right: -10px;
    bottom: -20px;
}

.game-btn:disabled {
    background: #4A4A4A !important;
    border-color: #666 !important;
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 0 #333 !important;
}

.btn-buy:disabled {
    box-shadow: 0 5px 0 #555 !important;
}

.game-btn:disabled .btn-cost {
    color: #999 !important;
}

.btn-buy {
    background: linear-gradient(180deg, #FFD54F 0%, #FFC107 40%, #F9A825 100%);
    border-color: #E6A000;
    min-width: 214px;
    min-height: 126px;
    font-size: 37px;
    color: #5C3A00;
    box-shadow: 0 5px 0 #B07A00, 0 8px 16px rgba(0, 0, 0, 0.5);
    text-shadow: none;
    position: relative;
    z-index: 57;
    border-radius: 24px;
    padding: 10px 8px 32px;
    transition: transform 75ms ease, filter 75ms ease;
}

.btn-buy:hover:not(:disabled) {
    transform: scale(1.02);
    filter: brightness(1.06);
}

.btn-buy::before {
    content: '';
    position: absolute;
    top: -12px;
    left: -12px;
    right: -12px;
    bottom: -12px;
}

.btn-buy::after {
    content: '';
    position: absolute;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    height: 22px;
    border-radius: 0 0 24px 24px;
    background: repeating-linear-gradient(45deg,
            #F9A825 0px,
            #F9A825 10px,
            #2a2a2a 10px,
            #2a2a2a 20px);
}

.btn-buy:active::after {
    height: 22px;
}

.btn-buy:active:not(:disabled) {
    transform: scale(1.02);
    transition: none;
    box-shadow: 0 2px 0 #C68A00, 0 3px 6px rgba(0, 0, 0, 0.4);
}

.btn-buy .btn-hammer {
    font-size: 44px;
    line-height: 1;
    margin-bottom: 2px;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.75));
}

.btn-buy .btn-label {
    color: #FFFFFF;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.45);
}

.btn-buy .btn-cost {
    color: #5C3A00;
    opacity: 0.9;
}

.btn-upgrade {
    background: linear-gradient(180deg, #6A4FA0 0%, #4E3580 50%, #3A2660 100%);
    border-color: #9A7FD0;
    font-size: 25px;
    min-width: 138px;
    min-height: 106px;
    padding: 14px 16px;
    margin: 15px 26px;
    box-shadow: 0 4px 0 #2A1850, 0 6px 12px rgba(0, 0, 0, 0.4);
    transition: transform 75ms ease, filter 75ms ease;
}

.btn-upgrade:hover:not(:disabled) {
    transform: scale(1.02);
    filter: brightness(1.06);
}

.btn-upgrade:active:not(:disabled) {
    transform: scale(1.02);
    transition: none;
    box-shadow: 0 1px 0 #2A1850, 0 2px 4px rgba(0, 0, 0, 0.4);
    border-color: #C8A0FF;
}

.btn-upgrade .btn-cost {
    color: #B2FFB2;
}

.btn-upgrade.clicked {
    animation: btnSpring 0.65s ease forwards;
}

.btn-upgrade:not(:disabled) {
    animation: btnReadyPulse 1.8s ease-in-out infinite;
}

.btn-upgrade.clicked:not(:disabled) {
    animation: btnSpring 0.65s ease forwards;
}

.btn-expand {
    background: linear-gradient(180deg, #2A7A5A 0%, #1E5A40 50%, #144030 100%);
    border-color: #50C090;
    font-size: 25px;
    min-width: 138px;
    min-height: 106px;
    padding: 14px 16px;
    margin: 15px 26px;
    box-shadow: 0 4px 0 #0E3020, 0 6px 12px rgba(0, 0, 0, 0.4);
    transition: transform 75ms ease, filter 75ms ease;
}

.btn-expand:hover:not(:disabled) {
    transform: scale(1.02);
    filter: brightness(1.06);
}

.btn-expand:active:not(:disabled) {
    transform: scale(1.02);
    transition: none;
    box-shadow: 0 1px 0 #0E3020, 0 2px 4px rgba(0, 0, 0, 0.4);
    border-color: #80FFB0;
}

.btn-expand .btn-cost {
    color: #B2FFB2;
}

.btn-expand.clicked {
    animation: btnSpring 0.65s ease forwards;
}

.btn-expand:not(:disabled) {
    animation: btnReadyPulse 1.8s ease-in-out infinite;
}

.btn-expand.clicked:not(:disabled) {
    animation: btnSpring 0.65s ease forwards;
}

@keyframes btnReadyPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.08);
    }
}

/* Celebration confetti thrown by a button (free expand / free upgrade).
   Positioned from the button's centre; direction, spin and duration come from
   per-piece custom properties set in Game.burstConfetti. */
.confetti-piece {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 10px;
    height: 15px;
    border-radius: 2px;
    pointer-events: none;
    opacity: 0;
    z-index: 70;
    animation: confettiFly var(--fly-dur, 900ms) cubic-bezier(0.12, 0.62, 0.36, 1) forwards;
}

@keyframes confettiFly {
    0% {
        transform: translate(-50%, -50%) rotate(0deg) scale(0.5);
        opacity: 1;
    }

    70% {
        opacity: 1;
    }

    100% {
        transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, 0px))) rotate(var(--rot, 180deg)) scale(1);
        opacity: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .confetti-piece {
        display: none;
    }
}

.btn-flash {
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border-radius: 12px;
    border: 4px solid white;
    opacity: 0;
    pointer-events: none;
    animation: btnFlashAnim 0.6s ease-out forwards;
}

@keyframes btnFlashAnim {
    0% {
        opacity: 1;
        transform: scale(0.95);
    }

    50% {
        opacity: 0.8;
        transform: scale(1.06);
    }

    100% {
        opacity: 0;
        transform: scale(1.1);
    }
}

@keyframes btnSpring {
    0% {
        transform: scale(1);
    }

    8% {
        transform: scale(0.91);
    }

    20% {
        transform: scale(1.13);
    }

    34% {
        transform: scale(0.96);
    }

    48% {
        transform: scale(1.06);
    }

    62% {
        transform: scale(0.985);
    }

    76% {
        transform: scale(1.025);
    }

    88% {
        transform: scale(0.996);
    }

    100% {
        transform: scale(1);
    }
}


@keyframes btnParticleX {
    0% {
        margin-left: 0;
    }

    100% {
        margin-left: var(--px);
    }
}

@keyframes btnParticleY {
    0% {
        margin-top: 0;
    }

    40% {
        margin-top: var(--rise);
    }

    100% {
        margin-top: var(--py);
    }
}

@keyframes btnParticleFade {
    0% {
        opacity: 1;
        transform: scale(1);
    }

    60% {
        opacity: 0.9;
        transform: scale(0.85);
    }

    100% {
        opacity: 0;
        transform: scale(0.3);
    }
}

.btn-cost {
    font-size: 28px;
    opacity: 0.85;
    margin-top: 3px;
    font-weight: 400;
}

.btn-label {
    font-size: inherit;
    font-weight: 600;
}

/* Item info tooltip */
.item-info {
    position: absolute;
    top: 110px;
    left: 50%;
    transform: translateX(-50%) scale(var(--ui-scale, 1));
    background: linear-gradient(180deg, #2C3E50 0%, #1A2A3A 100%);
    border: 2px solid #3A5068;
    border-radius: 8px;
    padding: 8px 16px;
    font-family: 'Fredoka', sans-serif;
    font-size: 30px;
    color: #FFFFFF;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    display: none;
    white-space: nowrap;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
}

/* Victory Screen */
.victory-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, rgba(40, 25, 10, 0.92) 0%, rgba(10, 5, 0, 0.96) 100%);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.victory-overlay.show {
    display: flex;
}

.victory-content {
    transform: scale(var(--ui-scale, 1));
    transform-origin: center center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Loading Screen */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(175deg, #1A2A3A 0%, #2C3E50 25%, #1E3A4A 50%, #2C3E50 75%, #1A2A3A 100%);
    background-size: 400% 400%;
    animation: loadingGradientShift 8s ease infinite;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 200;
    transition: opacity 0.6s ease;
    overflow: hidden;
}

.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transform: scale(var(--ui-scale, 1));
    transform-origin: center center;
}

@keyframes loadingGradientShift {
    0% {
        background-position: 0% 0%;
    }

    25% {
        background-position: 100% 50%;
    }

    50% {
        background-position: 50% 100%;
    }

    75% {
        background-position: 0% 50%;
    }

    100% {
        background-position: 0% 0%;
    }
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 80px;
    font-weight: 700;
    color: #FFD54F;
    text-shadow: 0 3px 12px rgba(255, 213, 79, 0.3), 0 2px 4px rgba(0, 0, 0, 0.5);
    margin-bottom: 10px;
    letter-spacing: 1.5px;
    text-align: center;
}

.loading-subtitle {
    font-family: 'Inter', sans-serif;
    font-size: 35px;
    color: #B8C8D8;
    margin-bottom: 50px;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    min-height: 42px;
}

.loading-subtitle .typewriter-cursor {
    display: inline-block;
    width: 2px;
    height: 28px;
    background: #B8C8D8;
    margin-left: 2px;
    vertical-align: middle;
    animation: cursorBlink 0.7s step-end infinite;
}

@keyframes cursorBlink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

.loading-bar-bg {
    width: 450px;
    height: 20px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid #3A5068;
}

.loading-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #F9A825, #FFD54F);
    border-radius: 8px;
    transition: width 0.2s ease;
}

.loading-hint {
    font-family: 'Inter', sans-serif;
    font-size: 32px;
    color: #8A9AB0;
    margin-top: 35px;
    text-align: center;
    max-width: 550px;
    min-height: 78px;
    transition: opacity 0.4s ease;
}

.loading-hint.fade-out {
    opacity: 0;
}

/* Construction Tape Borders */
.loading-tape {
    position: absolute;
    left: 0;
    right: 0;
    height: 26px;
    background: repeating-linear-gradient(-45deg,
            #FFD54F 0px, #FFD54F 18px,
            #1a1a1a 18px, #1a1a1a 36px);
    background-size: 50.91px 100%;
    animation: tapeScroll 1.5s linear infinite;
    opacity: 0.85;
    z-index: 1;
}

.loading-tape.top {
    top: 0;
}

.loading-tape.bottom {
    bottom: 0;
}

@keyframes tapeScroll {
    0% {
        background-position: 0 0;
    }

    100% {
        background-position: 50.91px 0;
    }
}

/* Morphing SVG Shapes */
.loading-morph-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.loading-morph {
    position: absolute;
    opacity: 0.12;
}

.loading-morph.shape1 {
    top: 12%;
    left: 8%;
    width: 100px;
    height: 100px;
}

.loading-morph.shape2 {
    top: 18%;
    right: 10%;
    width: 80px;
    height: 80px;
}

.loading-morph.shape3 {
    bottom: 14%;
    left: 12%;
    width: 90px;
    height: 90px;
}

.loading-morph.shape4 {
    bottom: 20%;
    right: 8%;
    width: 70px;
    height: 70px;
}

/* Blueprint line animation */
#blueprint-house line,
#blueprint-house rect,
#blueprint-house polyline,
#blueprint-house circle,
#blueprint-house path,
#blueprint-house polygon,
#blueprint-house text,
#blueprint-house g {
    opacity: 0;
    transform: translate(var(--bp-dx, 0px), var(--bp-dy, 0px));
}

#blueprint-house g>* {
    opacity: 1 !important;
    transform: none !important;
}

/* Intro Animation */
.hud-panel,
.controls-panel,
.progress-panel,
.buy-tooltip,
.btn-cheat,
.trash-bin-zone.unlocked {
    transition: opacity 0.5s ease, transform var(--transition-fast) var(--ease-out);
}

.intro-hidden {
    opacity: 0 !important;
    transform: translateY(40px) !important;
    pointer-events: none !important;
}

.intro-hidden-top {
    opacity: 0 !important;
    transform: translateY(-30px) !important;
    pointer-events: none !important;
}

/* Trash Bin */
.trash-bin-zone {
    position: absolute;
    top: calc(12% + env(safe-area-inset-top));
    left: calc(22px + env(safe-area-inset-left));
    width: 90px;
    height: 90px;
    background: rgba(128, 128, 128, 0.5);
    border: 3px dotted rgba(255, 255, 255, 0.85);
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 55;
    transition: opacity 0.4s ease, transform 0.4s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    pointer-events: none;
    opacity: 0;
    transform: scale(var(--ui-scale, 1));
    transform-origin: left top;
}

/* Hard-edged flash — cheap attention nudge hinting that lower-level pieces on
   the field can be trashed after an upgrade. Solid fill + opacity-only
   animation (no gradient/layout cost) so it's compositor-only and cheap. */
.trash-bin-zone::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: #FFFFFF;
    opacity: 0;
    pointer-events: none;
}

.trash-bin-zone.shine-sweep::after {
    animation: trashFlash 0.455s steps(1, end) 1;
}

@keyframes trashFlash {

    0%,
    50% {
        opacity: 0.8;
    }

    25%,
    75% {
        opacity: 0;
    }
}

/* Trash Tooltip */
.trash-tooltip {
    position: absolute;
    top: 110px;
    left: 0;
    background: linear-gradient(180deg, #FFD54F 0%, #F57F17 100%);
    border: 3px solid #FFB300;
    color: #1A2A3A;
    padding: 12px 24px;
    border-radius: 20px;
    font-family: 'Fredoka', sans-serif;
    font-size: 26px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    z-index: 100;
    pointer-events: none;
    animation: trashTooltipBounce 1.5s infinite ease-in-out;
}

.trash-tooltip::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 45px;
    transform: translateX(-50%);
    border-width: 12px;
    border-style: solid;
    border-color: transparent transparent #FFB300 transparent;
}

@keyframes trashTooltipBounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(8px);
    }
}

.trash-bin-zone.unlocked {
    opacity: 1;
    animation: trashBounceIn 0.52s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes trashBounceIn {
    0% {
        opacity: 0;
        transform: scale(0);
    }

    60% {
        opacity: 1;
        transform: scale(calc(var(--ui-scale, 1) * 1.15));
    }

    80% {
        transform: scale(calc(var(--ui-scale, 1) * 0.93));
    }

    100% {
        opacity: 1;
        transform: scale(var(--ui-scale, 1));
    }
}

.trash-bin-zone img {
    width: 32px;
    height: 32px;
    opacity: 1;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
    transition: filter 0.2s ease, transform 0.2s ease;
}

.trash-bin-zone span {
    font-family: 'Fredoka', sans-serif;
    color: #FFFFFF;
    font-size: 22px;
    margin-top: 2px;
    font-weight: 600;
    letter-spacing: 1px;
    opacity: 1;
}

/* unlocked class handles visibility */
.trash-bin-zone.hover {
    transform: scale(calc(var(--ui-scale, 1) * 1.15));
    background: rgba(211, 47, 47, 0.7);
    border-color: #FF5252;
    box-shadow: 0 0 20px rgba(255, 60, 60, 0.6), inset 0 0 15px rgba(255, 60, 60, 0.3);
}

.trash-bin-zone.hover img {
    filter: drop-shadow(0 2px 6px rgba(255, 100, 100, 0.7));
    transform: scale(1.15);
}

.trash-bin-zone.hover span {
    color: #FFFFFF;
}

/* Confirmation Popup */
.confirm-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 150;
}

.confirm-overlay.show {
    display: flex;
}

.confirm-box {
    background: linear-gradient(175deg, #2C3E50 0%, #1A2A3A 100%);
    border: 3px solid #3A5068;
    border-radius: 12px;
    padding: 24px 32px;
    text-align: center;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
    max-width: 400px;
    transform: scale(var(--ui-scale, 1));
    transform-origin: center center;
}

.confirm-box h3 {
    font-family: 'Fredoka', sans-serif;
    font-size: 36px;
    color: #FFD54F;
    margin: 0 0 12px;
}

.confirm-box p {
    font-family: 'Inter', sans-serif;
    font-size: 26px;
    color: #B8C8D8;
    margin: 0 0 24px;
}

.confirm-btns {
    display: flex;
    gap: 16px;
    justify-content: center;
}

.confirm-btn {
    font-family: 'Fredoka', sans-serif;
    font-size: 28px;
    font-weight: 600;
    padding: 12px 28px;
    border-radius: 6px;
    border: 2px solid;
    cursor: pointer;
    min-width: 100px;
}

.confirm-btn.yes {
    background: linear-gradient(180deg, #8B3030 0%, #5C1A1A 100%);
    border-color: #A04040;
    color: white;
}

.confirm-btn.no {
    background: linear-gradient(180deg, #5C5C5C 0%, #3A3A3A 100%);
    border-color: #7A7A7A;
    color: #DDD;
}

/* Tutorial Hand */
.tutorial-hand {
    position: absolute;
    font-size: 120px;
    pointer-events: none;
    z-index: 80;
    opacity: 0;
    transition: none;
    will-change: transform, opacity;
    filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.8)) drop-shadow(0 0 9px rgba(0, 0, 0, 0.95)) drop-shadow(0 0 18px rgba(0, 0, 0, 0.7));
    transform-origin: center center;
}

.tutorial-hand.phase-appear {
    opacity: 1;
    transition: opacity 0.3s ease;
}

.tutorial-hand.phase-grab {
    opacity: 1;
    transition: transform 0.2s ease;
    transform: scale(0.9);
}

.tutorial-hand.phase-slide {
    opacity: 1;
    transform: scale(0.9);
    transition: left 0.7s cubic-bezier(0.4, 0, 0.2, 1), top 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

.tutorial-hand.phase-fade {
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.3s ease;
}

/* Buy Tooltip */
/* Cheat Button */
.btn-cheat {
    position: absolute;
    bottom: 238px;
    right: calc(16px + env(safe-area-inset-right));
    background: linear-gradient(180deg, #FF4081 0%, #C2185B 100%);
    border: 3px solid #FF80AB;
    border-radius: 14px;
    padding: 10px 18px;
    font-family: 'Fredoka', sans-serif;
    font-size: 26px;
    font-weight: 700;
    color: white;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    box-shadow: 0 4px 0 #880E4F, 0 6px 12px rgba(0, 0, 0, 0.4);
    z-index: 50;
    min-width: 96px;
    text-align: center;
    transition: transform 150ms, box-shadow 150ms;
    display: none;
    /* cheat buttons (+$10k / +Level) hidden for production */
    pointer-events: auto;
}

.btn-cheat:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #880E4F, 0 3px 6px rgba(0, 0, 0, 0.4);
}

.buy-tooltip {
    position: absolute;
    bottom: 105%;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(180deg, #8B6B3A 0%, #6B4E28 100%);
    border: 3px solid #A0804A;
    padding: 12px 24px;
    font-family: 'Fredoka', sans-serif;
    font-size: 30px;
    color: #FFFFFF;
    white-space: nowrap;
    z-index: 57;
    animation: tooltipCenterBounceIn 0.52s cubic-bezier(0.68, -0.6, 0.32, 1.6) forwards, tooltipBounce 1.8s ease-in-out 0.52s infinite;
    transition: opacity 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.buy-tooltip::before {
    content: '🔨';
    font-size: 26px;
}

.buy-tooltip::after {
    content: '';
    position: absolute;
    bottom: -12px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 12px solid #6B4E28;
}

.buy-tooltip.hidden {
    opacity: 0;
    pointer-events: none;
}

@keyframes tooltipBounce {

    0%,
    100% {
        transform: translateX(-50%) translateY(0);
    }

    50% {
        transform: translateX(-50%) translateY(-6px);
    }
}

@keyframes upgradeTooltipBounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-6px);
    }
}

@keyframes tooltipCenterBounceIn {
    0% {
        transform: translateX(-50%) scale(0);
        opacity: 0;
    }

    55% {
        transform: translateX(-50%) scale(1.22);
        opacity: 1;
    }

    72% {
        transform: translateX(-50%) scale(0.91);
    }

    86% {
        transform: translateX(-50%) scale(1.07);
    }

    100% {
        transform: translateX(-50%) scale(1);
    }
}

@keyframes tooltipLeftBounceIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    55% {
        transform: scale(1.22);
        opacity: 1;
    }

    72% {
        transform: scale(0.91);
    }

    86% {
        transform: scale(1.07);
    }

    100% {
        transform: scale(1);
    }
}

.dim-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: black;
    opacity: 0;
    z-index: 53;
    transition: opacity 0.5s ease;
    pointer-events: auto;
}

.dim-screen.active {
    opacity: 0.5;
}

.dim-screen.hidden {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.375s ease;
}

/* Build Button Pulse */
.build-pulse {
    position: absolute;
    bottom: 0;
    left: 51%;
    transform: translateX(-50%);
    width: 225px;
    /* matching .btn-buy min-width */
    height: 185px;
    /* matching .btn-buy min-height */
    border: 8px solid #FFD54F;
    border-radius: 24px;
    pointer-events: none;
    z-index: 52;
    opacity: 0;
    display: none;
    box-sizing: border-box;
}

.build-pulse.animate {
    display: block;
    animation: buildPulseOut 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes buildPulseOut {
    0% {
        transform: translateX(-50%) scale(1);
        opacity: 0.9;
        border-width: 14px;
    }

    100% {
        transform: translateX(-50%) scale(1.75);
        opacity: 0;
        border-width: 6px;
    }
}

/* Progress Bar */
.progress-panel {
    position: absolute;
    top: calc(4px + env(safe-area-inset-top) + 12px * var(--ui-scale, 1));
    left: 50%;
    transform: translateX(-50%) scale(var(--ui-scale, 1));
    transform-origin: center top;
    background: linear-gradient(180deg, #2D505F 0%, #243f4e 100%);
    border-radius: 14px;
    padding: 10px 18px;
    border: 3px solid #3A5068;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
    /* Divide by --ui-scale so the panel's scale() transform cancels out on the
       width axis — the rendered width stays constant regardless of UI scale,
       while height/padding/font still scale. */
    width: calc((30vw + 42px) / var(--ui-scale, 1));
    min-width: 260px;
}

.progress-panel.intro-hidden-top {
    transform: translate(-50%, -30px) scale(var(--ui-scale, 1)) !important;
}

/* Options Button */
.options-btn {
    position: absolute;
    top: calc(4px + env(safe-area-inset-top) + 12px * var(--ui-scale, 1));
    right: calc(16px + env(safe-area-inset-right));
    background: linear-gradient(180deg, #D4A96A 0%, #B8894A 100%);
    border: 3px solid #8B6B3A;
    border-radius: 14px;
    width: 96px;
    height: 96px;
    font-size: 62px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    color: #5C3A1E;
    z-index: 54;
    transform: scale(var(--ui-scale, 1));
    transform-origin: right top;
    transition: transform 75ms ease, filter 75ms ease, opacity var(--transition-fast) var(--ease-out);
}

.options-btn:hover {
    transform: scale(calc(var(--ui-scale, 1) * 1.04));
    filter: brightness(1.18);
}

.options-btn:active {
    transform: scale(calc(var(--ui-scale, 1) * 1.04));
    filter: brightness(0.85);
    transition: none;
}

.options-btn::after {
    content: '';
    position: absolute;
    top: -24px;
    left: -24px;
    right: -24px;
    bottom: -24px;
}

.options-btn.intro-hidden-top {
    opacity: 0 !important;
    transform: translateY(-30px) !important;
    pointer-events: none !important;
}

/* Zoom Controls */
.zoom-controls {
    position: absolute;
    top: calc(8px + 116px * var(--ui-scale, 1) + env(safe-area-inset-top));
    right: calc(16px + env(safe-area-inset-right));
    display: flex;
    flex-direction: column;
    gap: calc(10px * var(--ui-scale, 1));
    z-index: 53;
    transform: scale(var(--ui-scale, 1));
    transform-origin: right top;
}

.zoom-btn {
    width: 54px;
    height: 54px;
    background: linear-gradient(180deg, #C49A5A 0%, #A67A3A 100%);
    border: 2px solid #7A5A2A;
    border-radius: 13px;
    font-size: 34px;
    font-weight: bold;
    color: #4A2A0A;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    transition: transform 75ms ease, filter 75ms ease, opacity var(--transition-fast) var(--ease-out);
    user-select: none;
    -webkit-user-select: none;
    padding: 0;
    line-height: 1;
}

.zoom-btn:hover:not(:disabled) {
    transform: scale(1.04);
    filter: brightness(1.18);
}

.zoom-btn:active:not(:disabled) {
    transform: scale(1.04);
    filter: brightness(0.85);
    transition: none;
}

.zoom-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.zoom-btn:disabled:active {
    transform: none;
}

.zoom-btn.intro-hidden-top {
    opacity: 0 !important;
    transform: translateY(-30px) !important;
    pointer-events: none !important;
}

/* Options Overlay */
.options-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 170;
}

.options-overlay.show {
    display: flex;
}

.options-box {
    position: relative;
    background: linear-gradient(175deg, #2C3E50 0%, #1A2A3A 100%);
    border: 3px solid #FFD54F;
    border-radius: 16px;
    padding: 24px 20px;
    /* Divide by --ui-scale so the box's scale() transform cancels out on the
       width axis (same trick as .progress-panel): the box RENDERS at 90% of the
       screen instead of 90% x ui-scale, which on a narrow portrait phone
       (ui-scale ~0.66) was leaving it at only ~59%. Padding, font size and
       height still scale normally, so the contents stay proportional. */
    width: calc(90% / var(--ui-scale, 1));
    max-width: calc(440px / var(--ui-scale, 1));
    /* Required: this is a flex item, so without it flexbox shrinks the
       deliberately-oversized layout box back down to the overlay width and the
       division above is undone. */
    flex-shrink: 0;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
    text-align: center;
    box-sizing: border-box;

    transform: scale(var(--ui-scale, 1));
}

.options-close-x {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid #FFD54F;
    background: rgba(0, 0, 0, 0.4);
    color: #FFD54F;
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    transition: background 150ms;
}

.options-close-x:hover {
    background: rgba(255, 213, 79, 0.2);
}

.options-close-x:active {
    background: rgba(255, 213, 79, 0.35);
}

.options-box h3 {
    font-family: 'Fredoka', sans-serif;
    font-size: calc(40px + var(--ofb, 4px));
    color: #FFD54F;
    margin: 0 0 24px;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

.options-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 20px;
}

.options-row-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.options-row label {
    font-family: 'Fredoka', sans-serif;
    font-size: calc(24px + var(--ofb, 4px));
    color: #FFFFFF;
}

.options-row-toggle {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 56px;
    height: 28px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #4A4A4A;
    border-radius: 28px;
    transition: background 0.2s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}

.toggle-switch input:checked+.toggle-slider {
    background: #4CAF50;
}

.toggle-switch input:checked+.toggle-slider::before {
    transform: translateX(28px);
}

.options-row input[type="range"] {
    width: 100%;
    height: 10px;
    border-radius: 5px;
    outline: none;
    -webkit-appearance: none;
    background: #1A2A3A;
    border: 2px solid #3A5068;
}

.options-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #FFD54F;
    cursor: pointer;
    border: 2px solid #E6A000;
}

.options-row input[type="range"]:hover {
    border-color: #FFD54F;
}

.options-row input[type="range"]:hover::-webkit-slider-thumb {
    transform: scale(1.15);
    box-shadow: 0 0 8px rgba(255, 213, 79, 0.5);
}

.options-row span {
    font-family: 'Inter', sans-serif;
    font-size: calc(20px + var(--ofb, 4px));
    color: #B8C8D8;
}

.options-close-btn {
    background: linear-gradient(180deg, #66BB6A 0%, #43A047 100%);
    border: 3px solid #2E7D32;
    color: white;
    border-radius: 10px;
    padding: 12px 32px;
    font-family: 'Fredoka', sans-serif;
    font-size: calc(28px + var(--ofb, 4px));
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    margin-top: 10px;
    box-shadow: 0 4px 0 #1B5E20, 0 6px 12px rgba(0, 0, 0, 0.4);
    transition: transform var(--transition-fast) var(--ease-out);
}

.options-close-btn:active {
    transform: translateY(2px);
}

.options-close-btn:hover {
    filter: brightness(1.3);
}

.options-reset-btn {
    background: linear-gradient(180deg, #8A6D6D 0%, #5E4848 100%);
    border: 3px solid #9E7D7D;
    color: white;
    border-radius: 10px;
    padding: 6px;
    font-family: 'Fredoka', sans-serif;
    font-size: calc(28px + var(--ofb, 4px));
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    margin-bottom: 15px;
    margin-top: 14px;
    box-shadow: 0 4px 0 #4A3434, 0 6px 12px rgba(0, 0, 0, 0.4);
    transition: transform var(--transition-fast) var(--ease-out), background var(--transition-fast) var(--ease-out), border-color var(--transition-fast) var(--ease-out), box-shadow var(--transition-fast) var(--ease-out);
    box-sizing: border-box;
}

.options-reset-btn:hover {
    background: linear-gradient(180deg, #E53935 0%, #B71C1C 100%);
    border-color: #FF5252;
    box-shadow: 0 4px 0 #7F0000, 0 6px 12px rgba(0, 0, 0, 0.4);
    filter: brightness(1.1);
}

.options-reset-btn:active {
    transform: translateY(2px);
}

.options-select:hover {
    border-color: #FFD54F;
}

.options-select:focus {
    border-color: #FFD54F;
}

.options-select {
    width: 100%;
    height: 48px;
    border-radius: 8px;
    outline: none;
    background: #1A2A3A;
    border: 2px solid #3A5068;
    color: #FFFFFF;
    font-family: 'Fredoka', sans-serif;
    font-size: calc(22px + var(--ofb, 4px));
    padding: 0 12px;
    cursor: pointer;
    box-sizing: border-box;
}

.options-select option {
    background: #1A2A3A;
    color: #FFFFFF;
    font-family: 'Inter', sans-serif;
    font-size: 20px;
}

@media (orientation: portrait) {
    :root {
        --ofb: 6px;
    }

    .hud-panel {
        left: calc(12px + env(safe-area-inset-left));
    }

    .options-btn,
    .zoom-controls {
        right: calc(12px + env(safe-area-inset-right));
    }

    .progress-panel {
        left: calc(50% + 16px * var(--ui-scale, 1));
        width: calc((37vw + 6px) / var(--ui-scale, 1));
        min-width: 230px;
    }

    .hud-card {
        min-width: 82px;
        max-width: 126px;
    }

    .hud-value {
        font-size: 37px;
        min-width: 100px;
        max-width: 100px;
    }

    .hud-value.small-font {
        font-size: 30px;
    }

    .controls-panel {
        gap: 0;
    }

    .free-upgrade-btn {
        padding: 9px 14px 9px;
    }

    .zoom-btn {
        width: 60px;
        height: 60px;
        font-size: 38px;
        border-radius: 14px;
    }

    /* Nudge the results button slightly lower in portrait (ui-scaled 10px). */
    .btn-show-results {
        top: calc(4px + 260px * var(--ui-scale, 1) + env(safe-area-inset-top));
    }
}

@media (orientation: landscape) {
    .trash-bin-zone {
        top: calc(12% + 20px + env(safe-area-inset-top));
    }
}

.progress-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.progress-label {
    font-family: 'Fredoka', sans-serif;
    font-size: 24px;
    font-weight: 600;
    color: #FFFFFF;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.progress-bar-bg {
    width: 100%;
    height: 14px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 7px;
    overflow: hidden;
    position: relative;
    border: 1px solid #3A5068;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #F9A825, #FFD54F);
    border-radius: 6px;
    transition: width 0.4s ease;
    min-width: 0%;
    position: relative;
    overflow: hidden;
}

.progress-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.7) 50%, transparent 100%);
    border-radius: 6px;
    opacity: 0;
    pointer-events: none;
}

.progress-bar-fill.shimmer::after {
    animation: progressShimmer 0.7s ease-out forwards;
}

@keyframes progressShimmer {
    0% {
        left: -60%;
        opacity: 1;
    }

    100% {
        left: 110%;
        opacity: 1;
    }
}

.progress-text {
    font-family: 'Inter', sans-serif;
    font-size: 22px;
    color: #FFFFFF;
    white-space: nowrap;
    font-weight: 600;
}

.progress-level-badge {
    background: #8B6B3A;
    border-radius: 4px;
    padding: 2px 8px;
    font-family: 'Fredoka', sans-serif;
    font-size: 22px;
    color: white;
    font-weight: 600;
}

/* Bottom Toast Notifications */
.bottom-toast-container {
    position: absolute;
    bottom: 227px;
    left: 50%;
    transform: translateX(-50%) scale(var(--ui-scale, 1));
    transform-origin: center bottom;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    z-index: 60;
    pointer-events: none;
}

@keyframes toastInBottom {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.8);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Toast Notifications */
.toast-container {
    position: absolute;
    top: calc(135px * var(--ui-scale, 1));
    left: 50%;
    transform: translateX(-50%) scale(var(--ui-scale, 1));
    transform-origin: center top;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    z-index: 60;
    pointer-events: none;
}

/* Landscape: move combo/milestone toasts to the right side, right-aligned,
   clearing the zoom buttons (54px wide + gap, scaled with --ui-scale) so a
   long toast grows further left instead of crossing into button space.
   Placed AFTER the base .toast-container rule above — equal-specificity CSS
   rules resolve by source order, so a media-query override earlier in the
   file gets silently overridden by a later plain rule for any shared
   properties (top/left/transform/align-items here). */
@media (orientation: landscape) {
    .toast-container {
        top: calc(135px * var(--ui-scale, 1));
        left: auto;
        right: calc(16px + env(safe-area-inset-right) + 66px * var(--ui-scale, 1));
        transform: scale(var(--ui-scale, 1));
        transform-origin: right top;
        align-items: flex-end;
    }
}

.toast {
    background: linear-gradient(180deg, #2C3E50 0%, #1A2A3A 100%);
    border: 1px solid #3A5068;
    border-left: 3px solid #FFD54F;
    border-radius: 5px;
    padding: 5px 12px;
    font-family: 'Inter', sans-serif;
    font-size: 26px;
    font-weight: 600;
    color: #FFFFFF;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 1.7s forwards;
    white-space: nowrap;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
}

.toast.combo {
    border-left-color: #FF6D00;
    background: linear-gradient(180deg, #3E2723 0%, #2C1A12 100%);
}

.toast.milestone {
    border-left-color: #AB47BC;
    background: linear-gradient(180deg, #1A1030 0%, #0E0820 100%);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.8);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    to {
        opacity: 0;
        transform: translateY(-10px) scale(0.9);
    }
}

.victory-content {
    background: linear-gradient(175deg, #2C3E50 0%, #1A2A3A 100%);
    border: 3px solid #FFD54F;
    border-radius: 16px;
    padding: 32px;
    width: calc(90% / var(--ui-scale, 1));
    max-width: calc(520px / var(--ui-scale, 1));
    flex-shrink: 0;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
    text-align: center;
    box-sizing: border-box;
    transform: scale(var(--ui-scale, 1));
}

.victory-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 76px;
    font-weight: 700;
    color: #FFD54F;
    text-shadow: 0 3px 12px rgba(255, 213, 79, 0.3), 0 2px 4px rgba(0, 0, 0, 0.5);
    text-align: center;
    margin-bottom: 16px;
    animation: victoryPulse 2s ease-in-out infinite;
    letter-spacing: 2px;
}

.victory-subtitle {
    font-family: 'Inter', sans-serif;
    font-size: 30px;
    color: #B8C8D8;
    text-align: center;
    max-width: 540px;
    line-height: 1.3;
}

@keyframes victoryPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

.victory-time {
    font-family: 'Fredoka', sans-serif;
    font-size: 32px;
    color: #FFD54F;
    margin: 12px 0 24px;
}

.victory-buttons {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 20px;
    align-items: center;
}

.victory-btn {
    font-family: 'Fredoka', sans-serif;
    font-size: 26px;
    font-weight: 600;
    padding: 14px 36px;
    border-radius: 10px;
    border: 3px solid;
    cursor: pointer;
    min-width: 280px;
    text-align: center;
    transition: transform 75ms ease, filter 75ms ease, box-shadow 75ms ease;
    position: relative;
    overflow: hidden;
}

.victory-btn:hover {
    transform: scale(1.04);
    filter: brightness(1.18);
}

.victory-btn:active {
    transform: scale(1.04);
    filter: brightness(0.85);
    transition: none;
}

.victory-btn.shine-flash::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -150%;
    width: 200%;
    height: 200%;
    background: linear-gradient(115deg,
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 0.4) 30%,
            rgba(255, 255, 255, 0.7) 40%,
            rgba(255, 255, 255, 0.4) 50%,
            rgba(255, 255, 255, 0) 80%);
    transform: rotate(25deg);
    animation: slowShine 2.5s ease-out 1s forwards;
}

@keyframes slowShine {
    0% {
        left: -150%;
    }

    100% {
        left: 150%;
    }
}

.btn-leaderboard {
    background: linear-gradient(180deg, #FFD54F 0%, #F9A825 100%);
    border-color: #E6A000;
    color: #5C3A00;
    box-shadow: 0 4px 0 #C68A00, 0 6px 12px rgba(0, 0, 0, 0.4);
}

.btn-leaderboard:active {
    box-shadow: 0 2px 0 #C68A00, 0 3px 6px rgba(0, 0, 0, 0.4);
}

.btn-replay {
    background: linear-gradient(180deg, #66BB6A 0%, #43A047 100%);
    border-color: #2E7D32;
    color: white;
    padding: 10px 36px;
    box-shadow: 0 4px 0 #1B5E20, 0 6px 12px rgba(0, 0, 0, 0.4);
}

.btn-replay:active {
    box-shadow: 0 2px 0 #1B5E20, 0 3px 6px rgba(0, 0, 0, 0.4);
}

.btn-view-board {
    background: linear-gradient(180deg, #42A5F5 0%, #1E88E5 100%);
    border-color: #1565C0;
    color: white;
    box-shadow: 0 4px 0 #0D47A1, 0 6px 12px rgba(0, 0, 0, 0.4);
}

.btn-view-board:active {
    box-shadow: 0 2px 0 #0D47A1, 0 3px 6px rgba(0, 0, 0, 0.4);
}

.btn-show-results {
    position: absolute;
    top: calc(4px + 260px * var(--ui-scale, 1) + env(safe-area-inset-top));
    right: calc(16px + env(safe-area-inset-right));
    background: linear-gradient(180deg, #FFD54F 0%, #F9A825 100%);
    border: 3px solid #E6A000;
    border-radius: 12px;
    padding: 10px 24px;
    font-family: 'Fredoka', sans-serif;
    font-size: 28px;
    font-weight: 600;
    color: #5C3A00;
    cursor: pointer;
    box-shadow: 0 4px 0 #C68A00, 0 6px 12px rgba(0, 0, 0, 0.4);
    z-index: 90;
    display: none;
    transform: scale(var(--ui-scale, 1));
    transform-origin: right top;
    transition: transform 75ms ease, filter 75ms ease;
}

.btn-show-results:hover {
    transform: scale(calc(var(--ui-scale, 1) * 1.04));
    filter: brightness(1.18);
}

.btn-show-results:active {
    transform: scale(calc(var(--ui-scale, 1) * 1.04));
    filter: brightness(0.85);
    transition: none;
}

/* Live Timer Display */
/* Personal best above, current run below. Stacking them in one positioned
   column means only the column needs placing — if either line is hidden the
   other closes the gap on its own, with no extra position classes. */
.hud-time-stack {
    position: absolute;
    /* Sits just under the zoom stack: .zoom-controls starts at 116 and is two
       54px buttons plus a gap (~116 tall in the same units), so it ends around
       232 — 244 clears it by roughly 9px at any --ui-scale. */
    top: calc(8px + 244px * var(--ui-scale, 1) + env(safe-area-inset-top));
    right: calc(16px + env(safe-area-inset-right));
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    z-index: 85;
    pointer-events: none;
    transform: scale(var(--ui-scale, 1));
    transform-origin: right top;
    transition: top 0.3s ease;
}

/* While the Results button is up it occupies 260 → ~323 in these units, so the
   stack drops below it rather than overlapping. */
.hud-time-stack.pushed-below {
    top: calc(4px + 337px * var(--ui-scale, 1) + env(safe-area-inset-top));
}

.timer-display {
    font-family: 'Fredoka', sans-serif;
    font-size: 28px;
    font-weight: 700;
    color: #FFD54F;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.7);
    transition: color 0.3s ease, opacity 0.3s ease;
}

.timer-display.paused {
    color: #B0C0D0;
    opacity: 0.92;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
}

/* Secondary to the running clock — smaller and cooler so the live timer stays
   the thing your eye lands on. */
.best-time-display {
    font-family: 'Fredoka', sans-serif;
    font-size: 22px;
    font-weight: 600;
    color: #CFE8FF;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.7);
    white-space: nowrap;
}

/* Portrait makes the zoom buttons 60px instead of 54px, so the stack ends about
   12 units lower and this has to follow. Must come after the base rule above —
   a media query adds no specificity, so it only wins on source order. */
@media (orientation: portrait) {
    .hud-time-stack {
        top: calc(8px + 262px * var(--ui-scale, 1) + env(safe-area-inset-top));
    }

    .timer-display {
        font-size: 30px;
    }

    .best-time-display {
        font-size: 24px;
    }
}

/* Leaderboard Display */
.leaderboard-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 160;
}

.leaderboard-overlay.show {
    display: flex;
}

.leaderboard-box {
    position: relative;
    background: linear-gradient(175deg, #2C3E50 0%, #1A2A3A 100%);
    border: 3px solid #FFD54F;
    border-radius: 16px;
    padding: 32px;
    width: calc(90% / var(--ui-scale, 1));
    max-width: calc(520px / var(--ui-scale, 1));
    max-height: calc(100vh / var(--ui-scale, 1) - 12vh);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
    transform: scale(var(--ui-scale, 1));
    transform-origin: center center;
    box-sizing: border-box;
}

.leaderboard-close-x {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid #FFD54F;
    background: rgba(0, 0, 0, 0.4);
    color: #FFD54F;
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    transition: background 150ms;
}

.leaderboard-close-x:hover {
    background: rgba(255, 213, 79, 0.2);
}

.leaderboard-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 40px;
    font-weight: 700;
    color: #FFD54F;
    text-align: center;
    margin-bottom: 4px;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

.leaderboard-subtitle {
    font-family: 'Inter', sans-serif;
    font-size: 20px;
    color: #B8C8D8;
    text-align: center;
    margin-bottom: 16px;
    min-height: 24px;
}

.leaderboard-entries {
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    min-height: 0;
    margin-bottom: 0;
}

.leaderboard-entry {
    background: linear-gradient(90deg, rgba(255, 213, 79, 0.12) 0%, rgba(26, 42, 58, 0.5) 100%);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    padding: 6px 14px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-sizing: border-box;
    max-width: 100%;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.leaderboard-entry:hover {
    border-color: rgba(255, 213, 79, 0.5);
    background: linear-gradient(90deg, rgba(255, 213, 79, 0.22) 0%, rgba(26, 42, 58, 0.65) 100%);
}

.leaderboard-entry.current-user {
    background: linear-gradient(90deg, rgba(76, 175, 80, 0.25) 0%, rgba(26, 42, 58, 0.6) 100%);
    border-color: #4CAF50;
}

.leaderboard-rank {
    font-family: 'Fredoka', sans-serif;
    font-size: 28px;
    font-weight: 700;
    color: #FFD54F;
    min-width: 42px;
    text-align: center;
}

.leaderboard-rank.gold {
    color: #FFD700;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.6);
}

.leaderboard-rank.silver {
    color: #C0C0C0;
    text-shadow: 0 0 8px rgba(192, 192, 192, 0.6);
}

.leaderboard-rank.bronze {
    color: #CD7F32;
    text-shadow: 0 0 8px rgba(205, 127, 50, 0.6);
}

.leaderboard-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.35);
    object-fit: cover;
    background: linear-gradient(135deg, #3A5068 0%, #1F2A38 100%);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    box-sizing: border-box;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Rivals (and signed-out players) get an emoji badge inside the avatar backing circle */
.leaderboard-avatar-emoji {
    font-size: 24px;
    line-height: 1;
}

.leaderboard-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.leaderboard-username {
    font-family: 'Inter', sans-serif;
    font-size: 22px;
    font-weight: 600;
    color: #FFFFFF;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-time {
    font-family: 'Fredoka', sans-serif;
    font-size: 26px;
    font-weight: 700;
    color: #4CAF50;
    text-align: right;
}

.leaderboard-close {
    background: linear-gradient(180deg, #5C5C5C 0%, #3A3A3A 100%);
    border: 2px solid #7A7A7A;
    border-radius: 8px;
    padding: 12px 32px;
    font-family: 'Fredoka', sans-serif;
    font-size: 28px;
    font-weight: 600;
    color: #DDD;
    cursor: pointer;
    width: 100%;
    margin-top: 8px;
    transition: transform 0.15s ease;
}

.leaderboard-close:active {
    transform: translateY(2px);
}

.leaderboard-loading {
    font-family: 'Inter', sans-serif;
    font-size: 24px;
    color: #B8C8D8;
    text-align: center;
    padding: 40px 20px;
}

.leaderboard-error {
    font-family: 'Inter', sans-serif;
    font-size: 22px;
    color: #FF6B6B;
    text-align: center;
    padding: 20px;
    line-height: 1.5;
}



@keyframes incomePopupBounce {
    0% {
        opacity: 0;
        transform: scale(calc(var(--ui-scale, 1) * 0.4));
    }

    60% {
        opacity: 1;
        transform: scale(calc(var(--ui-scale, 1) * 1.12));
    }

    80% {
        transform: scale(calc(var(--ui-scale, 1) * 0.94));
    }

    100% {
        opacity: 1;
        transform: scale(var(--ui-scale, 1));
    }
}

.options-close-btn,
.options-reset-btn {
    position: relative;
}

.options-close-x::after,
.options-close-btn::after,
.options-reset-btn::after {
    content: '';
    position: absolute;
    top: -20px;
    left: -20px;
    right: -20px;
    bottom: -20px;
}

@media (prefers-reduced-motion: reduce) {
    .victory-title {
        animation: none;
    }

    .game-btn {
        transition: none;
    }
}

/* Pause CSS animations when the platform or game pauses */
body.game-paused *,
body.game-paused *::before,
body.game-paused *::after {
    animation-play-state: paused !important;
}

/* Free Upgrade Button Style */
.free-upgrade-btn {
    position: absolute;
    bottom: calc(100% + 12px);
    /* Space for the triangle pointing down */
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(185deg, #FFB300 0%, #FF8F00 50%, #FF6F00 100%);
    border: 3px solid #FFE082;
    border-radius: 16px;
    padding: 9px 20px 9px;
    /* Reduced by another 3px vertically */
    cursor: pointer;
    font-family: 'Fredoka', sans-serif;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
    box-shadow: inset 0 2px 3px rgba(255, 255, 255, 0.4),
        0 0 15px rgba(255, 179, 0, 0.45),
        0 6px 0 #D84315,
        0 8px 16px rgba(0, 0, 0, 0.55);
    z-index: 70;
    transition: transform 75ms ease, filter 75ms ease;
    white-space: nowrap;
    will-change: transform;
    overflow: hidden;
    /* Important for the timer track to stay inside rounded corners */
    animation: freeUpgradePulse 2s ease-in-out infinite;
}

.free-upgrade-btn:hover {
    transform: translateX(-50%) scale(1.02);
    filter: brightness(1.06);
}

.free-upgrade-btn:active {
    transform: translateX(-50%) scale(1.02);
    transition: none;
    box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.3),
        0 0 10px rgba(255, 179, 0, 0.4),
        0 2px 0 #D84315,
        0 3px 6px rgba(0, 0, 0, 0.4);
}

.free-upgrade-btn .free-upgrade-text {
    font-size: 18px;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

/* Ad play icon styling - rounded square with purple border and pink play arrow */
.free-upgrade-btn .ad-play-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background-color: white;
    border: 3px solid #5E2214;
    border-radius: 10px;
    color: #E91E63;
    font-size: 26px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    margin-bottom: 8px;
    padding-left: 3px;
    /* Center-align the play triangle better */
    box-sizing: border-box;
}

/* Triangle arrow pointing down */
.free-upgrade-btn::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 10px solid #FFE082;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.4));
}

/* Track container for the visual timer */
.free-upgrade-timer-track {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 7px;
    background-color: rgba(0, 0, 0, 0.35);
    border-top: 1.5px solid rgba(0, 0, 0, 0.45);
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
    overflow: hidden;
    box-sizing: border-box;
}

/* Visual Timer Progress Bar with Gradient and Glow */
.free-upgrade-timer-bar {
    height: 100%;
    background: linear-gradient(90deg, #00FF87 0%, #60EFFF 100%);
    width: 100%;
    box-shadow: 0 0 8px rgba(0, 255, 135, 0.8);
    transition: width 0.1s linear, background 0.25s ease, box-shadow 0.25s ease;
}

@keyframes freeUpgradePulse {

    0%,
    100% {
        transform: translateX(-50%) scale(1);
    }

    50% {
        transform: translateX(-50%) scale(1.05);
    }
}

/* Bounce Shrink Out animation when ad button expires */
.free-upgrade-btn.shrink-out {
    animation: freeUpgradeShrinkOut 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards !important;
}

@keyframes freeUpgradeShrinkOut {
    0% {
        transform: translateX(-50%) scale(1);
    }

    30% {
        transform: translateX(-50%) scale(1.15);
        /* bounce up */
    }

    100% {
        transform: translateX(-50%) scale(0);
    }
}

/* Entrance Bounce In animation for free upgrade button */
.free-upgrade-btn.bounce-in {
    animation: freeUpgradeBounceIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards !important;
}

@keyframes freeUpgradeBounceIn {
    0% {
        transform: translateX(-50%) scale(0);
    }

    70% {
        transform: translateX(-50%) scale(1.15);
    }

    100% {
        transform: translateX(-50%) scale(1);
    }
}

/* Fast fading animation for critical alert */
.free-upgrade-timer-bar.critical-alert {
    animation: freeUpgradeTimerFlash 0.3s ease-in-out infinite alternate !important;
}

@keyframes freeUpgradeTimerFlash {
    0% {
        opacity: 0.15;
    }

    100% {
        opacity: 1;
    }
}

/* Expand Button Wrapper & Contract Elements */
.expand-btn-wrapper {
    position: relative;
    display: inline-block;
}

.contract-notify-btn {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: linear-gradient(180deg, #FFD54F 0%, #FF8F00 100%);
    border: 3.5px solid #FFF;
    color: #5C3A00;
    font-family: 'Fredoka', sans-serif;
    font-size: 34px;
    font-weight: 700;
    cursor: pointer;
    z-index: 70;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
    animation: contractPopIn 0.55s cubic-bezier(0.68, -0.6, 0.32, 1.6) forwards, contractBounce 1.8s ease-in-out 0.55s infinite;
    transition: transform 0.35s cubic-bezier(0.68, -0.6, 0.32, 1.6), box-shadow 0.35s ease, background 0.35s ease;
    transform-origin: center bottom;
}

.contract-notify-btn.anim-pop {
    animation: contractPopIn 0.55s cubic-bezier(0.68, -0.6, 0.32, 1.6) forwards, contractBounce 1.8s ease-in-out 0.55s infinite;
}

.contract-notify-btn.seen {
    animation: contractPopIn 0.55s cubic-bezier(0.68, -0.6, 0.32, 1.6) forwards;
}

.contract-notify-btn:hover {
    transform: translateX(-50%) scale(1.2) translateY(-4px);
    box-shadow: 0 8px 22px rgba(255, 143, 0, 0.65);
    background: linear-gradient(180deg, #FFE082 0%, #FF9800 100%);
    animation-play-state: paused;
}

.contract-notify-btn:active {
    transform: translateX(-50%) scale(0.92);
    transition: transform 0.1s ease;
}

.contract-dropoff {
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    z-index: 70;
    pointer-events: none;
    animation: contractDropoffIn 0.55s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.contract-tooltip {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%) scale(0.9);
    background: linear-gradient(180deg, #FFD54F 0%, #F57F17 100%);
    border: 3px solid #FFB300;
    color: #1A2A3A;
    padding: 8px 18px;
    border-radius: 18px;
    font-family: 'Fredoka', sans-serif;
    font-size: 22px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
    z-index: 100;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s cubic-bezier(0.68, -0.6, 0.32, 1.6);
    text-shadow: none;
}

.contract-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 8px;
    border-style: solid;
    border-color: #FFB300 transparent transparent transparent;
}

.contract-tooltip.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) scale(1);
}

.contract-dropoff-name {
    font-family: 'Fredoka', sans-serif;
    font-size: 19px;
    font-weight: 600;
    color: #FFE0B2;
    max-width: 110px;
    white-space: normal;
    text-align: center;
    line-height: 1.15;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.93);
}

.contract-dropoff-box {
    position: relative;
    width: 104px;
    height: 104px;
    border: 3px dashed #FFB300;
    border-radius: 16px;
    background: rgba(20, 14, 4, 0.32);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.contract-dropoff-box.hover {
    background: rgba(255, 179, 0, 0.3);
    border-color: #FFE082;
    transform: scale(1.06);
}

.contract-dropoff-box.warning-pulse {
    animation: contractBoxWarningPulse 0.7s ease-in-out infinite alternate;
}

@keyframes contractBoxWarningPulse {
    from {
        background: rgba(244, 67, 54, 0.28);
        border-color: #FF5252;
        box-shadow: 0 0 10px rgba(255, 23, 68, 0.45);
    }

    to {
        background: rgba(255, 23, 68, 0.48);
        border-color: #FF1744;
        box-shadow: 0 0 18px rgba(255, 23, 68, 0.85);
    }
}

.contract-dropoff-box.flash-error {
    animation: contractErrorFlash 0.55s ease-in-out;
}

@keyframes contractErrorFlash {
    0% {
        background: rgba(244, 67, 54, 0.65);
        border-color: #FF5252;
        box-shadow: 0 0 20px rgba(244, 67, 54, 0.9);
        transform: scale(1.12);
    }

    40% {
        background: rgba(211, 47, 47, 0.85);
        border-color: #FF1744;
        box-shadow: 0 0 28px rgba(255, 23, 68, 1);
        transform: scale(0.94);
    }

    70% {
        background: rgba(244, 67, 54, 0.5);
        border-color: #FF5252;
        box-shadow: 0 0 16px rgba(244, 67, 54, 0.6);
        transform: scale(1.04);
    }

    100% {
        background: rgba(20, 14, 4, 0.32);
        border-color: #FFB300;
        box-shadow: none;
        transform: scale(1);
    }
}

.contract-dropoff-img {
    max-width: 76%;
    max-height: 76%;
    filter: brightness(0);
    opacity: 0.7;
}

.contract-dropoff-tier-badge {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid #FFFFFF;
    background: rgba(0, 0, 0, 0.45);
    color: #FFFFFF;
    font-family: 'Fredoka', sans-serif;
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    pointer-events: none;
    opacity: 0.7;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.contract-dropoff-timer-track {
    width: 104px;
    height: 12px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.15);
    overflow: hidden;
    box-sizing: border-box;
}

.contract-dropoff-timer-bar {
    height: 100%;
    width: 100%;
    border-radius: 5px;
    background: linear-gradient(90deg, #FFB300 0%, #FFE082 100%);
    box-shadow: 0 0 8px rgba(255, 179, 0, 0.7);
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

/* Contract Warning Pulse Bar (< 5 seconds remaining) */
.contract-dropoff-timer-bar.warning-pulse {
    background: linear-gradient(90deg, #FF5252 0%, #FF1744 100%) !important;
    box-shadow: 0 0 10px rgba(255, 23, 68, 0.9) !important;
    animation: contractWarningPulse 0.5s ease-in-out infinite alternate;
}

@keyframes contractWarningPulse {
    from {
        opacity: 1;
        filter: brightness(1);
    }

    to {
        opacity: 0.7;
        filter: brightness(1.3);
    }
}

/* Rebirth Boost HUD Badge */
.rebirth-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(180deg, #2E1F4D 0%, #170F28 100%);
    border: 2px solid #9C27B0;
    border-radius: 12px;
    padding: 6px 14px;
    color: #E1BEE7;
    font-family: 'Fredoka', sans-serif;
    font-size: 18px;
    font-weight: 600;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
    pointer-events: none;
}

.rebirth-badge-icon {
    font-size: 20px;
}

/* Victory Screen Active Perk Badge */
.victory-perk-badge {
    background: linear-gradient(180deg, rgba(156, 39, 176, 0.35) 0%, rgba(103, 58, 183, 0.35) 100%);
    border: 2px solid #BA68C8;
    border-radius: 12px;
    padding: 6px 18px;
    color: #F3E5F5;
    font-family: 'Fredoka', sans-serif;
    font-size: 22px;
    font-weight: 600;
    margin-top: 8px;
    margin-bottom: 16px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

@keyframes contractDropoffIn {
    0% {
        transform: translateX(-50%) scale(0);
        opacity: 0;
    }

    60% {
        transform: translateX(-50%) scale(1.18);
        opacity: 1;
    }

    80% {
        transform: translateX(-50%) scale(0.92);
    }

    100% {
        transform: translateX(-50%) scale(1);
        opacity: 1;
    }
}

/* Bounce Shrink Out animation when contract timer expires */
.contract-dropoff.shrink-out {
    animation: contractDropoffShrinkOut 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards !important;
}

@keyframes contractDropoffShrinkOut {
    0% {
        transform: translateX(-50%) scale(1);
        opacity: 1;
    }

    30% {
        transform: translateX(-50%) scale(1.15);
        opacity: 1;
    }

    100% {
        transform: translateX(-50%) scale(0);
        opacity: 0;
    }
}

@keyframes contractPopIn {
    0% {
        transform: translateX(-50%) scale(0);
        opacity: 0;
    }

    60% {
        transform: translateX(-50%) scale(1.22);
        opacity: 1;
    }

    80% {
        transform: translateX(-50%) scale(0.92);
    }

    100% {
        transform: translateX(-50%) scale(1);
        opacity: 1;
    }
}

@keyframes contractBounce {

    0%,
    100% {
        transform: translateX(-50%) translateY(0);
    }

    50% {
        transform: translateX(-50%) translateY(-8px);
    }
}

/* Rebirth Perk Selection Modal */
.rebirth-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 160;
    backdrop-filter: blur(4px);
}

.rebirth-modal-box {
    background: linear-gradient(175deg, #1F2A38 0%, #0F1722 100%);
    border: 3px solid #FFB300;
    border-radius: 20px;
    padding: 28px 24px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
    width: calc(92% / var(--ui-scale, 1));
    max-width: calc(640px / var(--ui-scale, 1));
    flex-shrink: 0;
    box-sizing: border-box;
    animation: incomePopupBounce 0.55s cubic-bezier(0.68, -0.6, 0.32, 1.6) forwards;
}

.rebirth-modal-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 36px;
    font-weight: 700;
    color: #FFD54F;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
    margin-bottom: 6px;
}

.rebirth-modal-subtitle {
    font-family: 'Inter', sans-serif;
    font-size: 22px;
    color: #B8C8D8;
    margin-bottom: 24px;
}

.rebirth-card-container {
    display: flex;
    flex-direction: row;
    gap: 16px;
    justify-content: center;
    align-items: stretch;
}

.rebirth-card {
    flex: 1;
    position: relative;
    background: rgba(255, 255, 255, 0.06);
    border: 2.5px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 24px 12px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
    user-select: none;
}

.rebirth-card-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.rebirth-card-level-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: linear-gradient(180deg, #FFD54F 0%, #F57F17 100%);
    border: 1.5px solid #FFF8E1;
    border-radius: 8px;
    padding: 3px 10px;
    color: #3E2723;
    font-family: 'Fredoka', sans-serif;
    font-size: 17px;
    font-weight: 700;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
    letter-spacing: 0.5px;
}

.rebirth-card-level-badge.is-max-badge {
    background: linear-gradient(180deg, #FFE082 0%, #FF8F00 100%) !important;
    color: #211200 !important;
    border-color: #FFF !important;
    box-shadow: 0 2px 8px rgba(255, 179, 0, 0.6) !important;
}

.rebirth-card.card-seed {
    border-color: rgba(255, 213, 79, 0.3);
}

.rebirth-card.card-seed:hover {
    transform: translateY(-2px) scale(1.04);
    border-color: #FFD54F;
    background: rgba(255, 213, 79, 0.14);
    box-shadow: 0 4px 16px rgba(255, 213, 79, 0.35);
}

.rebirth-card.card-merge {
    border-color: rgba(0, 229, 255, 0.3);
}

.rebirth-card.card-merge:hover {
    transform: translateY(-2px) scale(1.04);
    border-color: #00E5FF;
    background: rgba(0, 229, 255, 0.14);
    box-shadow: 0 4px 16px rgba(0, 229, 255, 0.35);
}

.rebirth-card.card-income {
    border-color: rgba(171, 71, 188, 0.3);
}

.rebirth-card.card-income:hover {
    transform: translateY(-2px) scale(1.04);
    border-color: #AB47BC;
    background: rgba(171, 71, 188, 0.14);
    box-shadow: 0 4px 16px rgba(171, 71, 188, 0.35);
}

.rebirth-card.is-max {
    border-color: #FFD54F !important;
    background: rgba(255, 213, 79, 0.08) !important;
    box-shadow: 0 0 15px rgba(255, 213, 79, 0.3);
}

.rebirth-card:active {
    transform: translateY(0px) scale(0.98);
}

.rebirth-card-subdesc {
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    color: #8A9BAE;
    margin-top: 4px;
    font-weight: 500;
}

.rebirth-card-icon {
    font-size: 42px;
    margin-bottom: 8px;
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.4));
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.rebirth-card:hover .rebirth-card-icon {
    transform: translateY(-2px) scale(1.08);
}

.rebirth-card-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 24px;
    font-weight: 700;
    color: #FFFFFF;
    margin-bottom: 8px;
}

.rebirth-card-desc {
    font-family: 'Inter', sans-serif;
    font-size: 18px;
    font-weight: 600;
    color: #4CAF50;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    line-height: 1.3;
}

/* Deliberately understated and below the cards — declining the bonus should
   read as the quiet option, not a fourth perk. */
.rebirth-skip-btn {
    display: block;
    position: relative;
    margin: 20px auto 0;
    padding: 10px 28px;
    background: rgba(255, 255, 255, 0.07);
    border: 2px solid rgba(255, 255, 255, 0.22);
    border-radius: 10px;
    font-family: 'Fredoka', sans-serif;
    font-size: 22px;
    font-weight: 600;
    color: #B8C8D8;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.rebirth-skip-btn:hover {
    background: rgba(255, 255, 255, 0.13);
    border-color: rgba(255, 255, 255, 0.4);
    color: #E4EDF5;
}

.rebirth-skip-btn:active {
    transform: translateY(2px);
}

/* Starting Boost Panel - Selection Animation */
.rebirth-modal-box.selecting-disabled .rebirth-card,
.rebirth-modal-box.selecting-disabled .rebirth-skip-btn {
    pointer-events: none !important;
    cursor: default !important;
}

.rebirth-card.selected-shine,
.rebirth-skip-btn.selected-shine {
    position: relative !important;
    border-color: #FFD54F !important;
    box-shadow: 0 0 30px rgba(255, 213, 79, 0.95), 0 4px 20px rgba(0, 0, 0, 0.5) !important;
    transform: scale(1.05) translateY(-2px) !important;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease, border-color 0.2s ease !important;
    z-index: 10;
}

.rebirth-shine-wrap {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: inherit;
    pointer-events: none;
    z-index: 15;
}

.rebirth-shine-beam {
    position: absolute;
    top: -20%;
    left: 0;
    width: 55%;
    height: 140%;
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 0.3) 20%,
            rgba(255, 255, 255, 0.95) 50%,
            rgba(255, 255, 255, 0.3) 80%,
            rgba(255, 255, 255, 0) 100%);
    transform: translateX(-160%) skewX(-25deg);
    animation: rebirthBeamSweep 0.7s cubic-bezier(0.2, 0.8, 0.3, 1) forwards;
    pointer-events: none;
}

@keyframes rebirthBeamSweep {
    0% {
        transform: translateX(-160%) skewX(-25deg);
        opacity: 0;
    }

    15% {
        opacity: 1;
    }

    85% {
        opacity: 1;
    }

    100% {
        transform: translateX(260%) skewX(-25deg);
        opacity: 0;
    }
}

/* Confirmation stacked over the picker. */
.rebirth-skip-confirm-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.rebirth-skip-confirm-box {
    background: linear-gradient(175deg, #2C3E50 0%, #1A2A3A 100%);
    border: 3px solid #7A8A9A;
    border-radius: 12px;
    padding: 26px 32px;
    text-align: center;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
    width: calc(86% / var(--ui-scale, 1));
    max-width: calc(380px / var(--ui-scale, 1));
    box-sizing: border-box;
    animation: incomePopupBounce 0.45s cubic-bezier(0.68, -0.6, 0.32, 1.6) forwards;
}

.rebirth-skip-confirm-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 34px;
    font-weight: 700;
    color: #FFD54F;
    margin-bottom: 10px;
}

.rebirth-skip-confirm-msg {
    font-family: 'Inter', sans-serif;
    font-size: 22px;
    color: #B8C8D8;
    line-height: 1.45;
    margin-bottom: 20px;
}

.rebirth-skip-confirm-buttons {
    display: flex;
    gap: 14px;
    justify-content: center;
}

.rebirth-skip-confirm-no,
.rebirth-skip-confirm-yes {
    font-family: 'Fredoka', sans-serif;
    font-size: 24px;
    font-weight: 600;
    padding: 10px 28px;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid;
}

/* Cancel is the safe default, so it carries the emphasis. */
.rebirth-skip-confirm-no {
    background: linear-gradient(180deg, #66BB6A 0%, #43A047 100%);
    border-color: #2E7D32;
    color: #fff;
}

.rebirth-skip-confirm-yes {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.25);
    color: #C8D4E0;
}

@media (max-width: 520px) {
    .rebirth-modal-title {
        font-size: 40px;
    }

    .rebirth-modal-subtitle {
        font-size: 26px;
    }

    .rebirth-card-container {
        flex-direction: column;
        gap: 12px;
    }

    .rebirth-card {
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        padding: 16px 95px 16px 16px;
        gap: 14px;
        text-align: left;
        position: relative;
    }

    .rebirth-card-info {
        align-items: flex-start;
        text-align: left;
    }

    .rebirth-card-title {
        font-size: 28px;
    }

    .rebirth-card-desc {
        font-size: 22px;
    }

    .rebirth-card-subdesc {
        font-size: 19px;
    }

    .rebirth-card-level-badge {
        top: 50% !important;
        right: 12px !important;
        transform: translateY(-50%) !important;
        font-size: 21px !important;
        padding: 4px 12px !important;
    }

    .rebirth-card-icon {
        font-size: 42px;
        margin-bottom: 0;
        flex-shrink: 0;
    }

    .rebirth-skip-btn {
        font-size: 24px;
    }
}