:root {
    --bg-color: #0f111a;
    --card-bg: #1a1c2c;
    --primary-color: #ffd24d;
    /* Golden yellow for 'Renovating' */
    --secondary-color: #9ab3ff;
    /* Light blue for 'Arrows' */
    --text-color: #d1d5db;
    --text-light: #9ca3af;
    --accent-blue: #7aa2f7;
    --heart-red: #ff4d6d;
    --arrow-color: #ffffff;
    --dot-color: #1e2233;
    --btn-bg: #2a2e45;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    --transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --gradient-gold: linear-gradient(135deg, #ffd24d 0%, #f59e0b 100%);
    --gradient-blue: linear-gradient(135deg, #9ab3ff 0%, #4f46e5 100%);
    --success-green: #10b981;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

@font-face {
    font-family: 'SuperWonder';
    src: url('assets/SuperWonder.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

body {
    font-family: 'SuperWonder', 'Outfit', sans-serif;
    background-color: #05060a;
    color: var(--text-color);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    height: 100dvh;
}

#game-container {
    width: 100%;
    max-width: 450px;
    height: 100%;
    max-height: 900px;
    background: var(--bg-color);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.15s ease-in-out;
    will-change: opacity;
    z-index: 10;
}

.screen.active {
    display: flex;
    opacity: 1;
    z-index: 20;
}

.hidden {
    display: none !important;
}

/* --- Splash / Loading Screen --- */
#splash-screen {
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle, #028dfc 0%, #014c8a 100%);
    position: relative;
}

#splash-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('assets/GridDots.png') repeat;
    background-size: 35px;
    opacity: 0.18;
    pointer-events: none;
    z-index: 1;
}

.splash-logo-container {
    perspective: 1000px;
    animation: logoPulse 2s ease-in-out infinite;
    z-index: 2;
    margin-bottom: 50px;
}

.splash-logo {
    width: 160px;
    max-width: 50vw;
    height: auto;
    display: block;
    margin: 0 auto;
    filter: drop-shadow(0 0 15px rgba(2, 141, 252, 0.5));
}

@keyframes logoPulse {

    0%,
    100% {
        transform: scale(1);
        filter: drop-shadow(0 0 15px rgba(2, 141, 252, 0.5));
    }

    50% {
        transform: scale(1.05);
        filter: drop-shadow(0 0 25px rgba(2, 141, 252, 0.8));
    }
}

.splash-loader-container {
    position: absolute;
    bottom: calc(130px + env(safe-area-inset-bottom, 0px));
    width: 80%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    z-index: 2;
}

.splash-loading-text {
    font-family: 'Outfit', 'SuperWonder', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    letter-spacing: 0.5px;
    margin-left: 2px;
}

.splash-progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(1, 30, 60, 0.7);
    border-radius: 4px;
    overflow: hidden;
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.6);
}

.splash-progress-fill {
    height: 100%;
    width: 0%;
    background: #ffffff;
    border-radius: 4px;
    box-shadow: 0 0 10px #ffffff, 0 0 20px rgba(255, 255, 255, 0.5);
}

/* --- Menu Screen & Cloud Logo --- */
#menu-screen {
    justify-content: center;
    align-items: center;
    gap: 2rem;
    background: url('assets/Home_background.png') center/cover no-repeat;
    position: relative;
    padding-bottom: calc(95px + env(safe-area-inset-bottom, 0px));
}

#menu-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('assets/GridDots.png') repeat;
    background-size: 35px;
    opacity: 0.25;
    pointer-events: none;
    z-index: 1;
}

.game-logo-img {
    width: 320px;
    max-width: 90%;
    height: auto;
    display: block;
    margin: 0 auto;
    animation: logoPopIn 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    transform-origin: center;
    z-index: 2;
    position: relative;
}

@keyframes logoBounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-12px);
    }
}

@keyframes logoPopIn {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

#menu-level-info {
    font-family: 'SuperWonder', 'Outfit', sans-serif;
    font-size: 1.6rem;
    color: #ffffff;
    text-shadow: 0 4px 6px rgba(0, 0, 0, 0.4);
    letter-spacing: 1px;
    text-transform: uppercase;
    z-index: 2;
    position: relative;
}

@keyframes pulseText {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.9;
    }

    50% {
        transform: scale(1.05);
        opacity: 1;
    }
}

.btn-play-img {
    background: url('assets/Button_Play.png') no-repeat center/contain;
    width: 220px;
    height: 80px;
    border: none;
    outline: none;
    cursor: pointer;
    font-size: 0;
    /* Hide text */
    animation: playBtnPop 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0.2s both, playBtnPulse 2s infinite ease-in-out;
    box-shadow: none;
    z-index: 2;
    position: relative;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    margin-top: 35px;
}

.btn-play-img:hover {
    transform: scale(1.05);
}

.btn-play-img:active {
    transform: scale(0.95);
}

@keyframes playBtnPop {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes playBtnPulse {

    0%,
    100% {
        filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.3));
    }

    50% {
        filter: drop-shadow(0 8px 20px rgba(51, 204, 255, 0.6));
    }
}

.logo-container {
    perspective: 1000px;
    animation: logoBounce 2.5s ease-in-out infinite;
}

.cloud-logo {
    position: relative;
    width: 280px;
    height: 180px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.cloud-part {
    position: absolute;
    background: #3b4261;
    border-radius: 50%;
    filter: blur(2px);
    box-shadow: inset -10px -10px 20px rgba(0, 0, 0, 0.3), 0 15px 30px rgba(0, 0, 0, 0.4);
}

.p1 {
    width: 140px;
    height: 140px;
    top: 0;
    left: 70px;
}

.p2 {
    width: 120px;
    height: 120px;
    bottom: 10px;
    left: 20px;
}

.p3 {
    width: 110px;
    height: 110px;
    bottom: 15px;
    right: 25px;
}

.logo-text {
    position: relative;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transform: rotate(-5deg);
}

.logo-text .yellow-text {
    font-size: 2.8rem;
    font-weight: 800;
    color: #ffd24d;
    text-shadow: 0 4px 0 #b45309, 0 8px 15px rgba(0, 0, 0, 0.5);
    line-height: 1;
}

.logo-text .white-text {
    font-size: 3.5rem;
    font-weight: 800;
    color: #ffffff;
    text-shadow: 0 4px 0 #4f46e5, 0 10px 20px rgba(0, 0, 0, 0.5);
    margin-top: -5px;
}



/* --- Room Screen --- */
#room-screen {
    background: #000;
}

.room-header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    padding: 1rem;
    gap: 0.5rem;
    align-items: center;
    z-index: 100;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.4), transparent);
    border-bottom: none;
}

.stat-pill {
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(5px);
    padding: 6px 12px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.spacer {
    flex: 1;
}

.small {
    width: 36px;
    height: 36px;
}

#kitchen-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

#kitchen-bg {
    width: 100%;

    height: 100%;
    background-size: cover;
    background-position: center;
    transition: filter 0.5s ease;
}

#kitchen-bg.damaged {
    filter: sepia(0.2) brightness(0.7);
    background-image: url('assets/KitchenAssets/Damaged_Kitchen.png');
}

/* Item Selection Bar */
.item-selection-bar {
    position: absolute;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    width: 92%;
    max-width: 414px;
    height: 102px;
    background: url('assets/BlackBgForButtons.png') no-repeat center;
    background-size: 100% 100%;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 8px 12px 6px 12px;
    box-sizing: border-box;
    z-index: 100;
}

.item-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    cursor: pointer;
    position: relative;
    transition: var(--transition);
}

.item-btn.locked {
    filter: grayscale(1) brightness(0.6);
    cursor: not-allowed;
}

.item-btn.locked .item-icon-container::after {
    content: '🔒';
    position: absolute;
    top: 58%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.25rem;
    filter: grayscale(1) brightness(0.35) drop-shadow(0 0 10px rgba(0, 0, 0, 0.8));
    z-index: 10;
}

.item-btn:active:not(.locked) {
    transform: scale(0.9);
}

.item-icon-container {
    width: 70px;
    height: 70px;
    background: transparent;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    border: none;
    box-shadow: none;
    position: relative;
    overflow: visible;
}

.item-btn.unlocked .item-icon-container {
    background: transparent;
    border-color: transparent;
}

.item-icon {
    width: 100%;
    height: 100%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.fridge-icon {
    background-image: url('assets/FridgeButtonBg.png');
}

.sink-icon {
    background-image: url('assets/SinkButtonBg.png');
}

.cabinet-icon {
    background-image: url('assets/CabinetButtonBg.png');
}

.oven-icon {
    background-image: url('assets/OvenButtonBg.png');
}

.wall-icon {
    background-image: url('assets/WallButtonBg.png');
}

.window-icon {
    background-image: url('assets/KitchenAssets/WindowButtonBg.png');
}

/* Remove emoji pseudo-elements */
.fridge-icon::before,
.sink-icon::before,
.cabinet-icon::before,
.oven-icon::before,
.wall-icon::before,
.window-icon::before {
    display: none;
}

.item-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.check-mark {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #10b981;
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 12px;
    font-weight: bold;
    border: 2px solid white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.instruction-text {
    position: absolute;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 600;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
    z-index: 101;
    pointer-events: none;
    width: 100%;
}

/* --- Unlock Screen --- */
#unlock-screen {
    z-index: 200;
}

.unlock-overlay {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.8)), url('assets/KitchenAssets/Damaged_Kitchen.png') center/cover no-repeat;
    padding: 3rem 2rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.glow-effect {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, #ffd24d 0%, rgba(255, 210, 77, 0.4) 40%, transparent 80%);
    opacity: 0.8;
    z-index: 2;
    /* Still 2, but we will increase the item container's z-index */
    pointer-events: none;
    animation: pulseGlow 3s infinite ease-in-out;
}

.glow-effect::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 800px;
    height: 800px;
    transform: translate(-50%, -50%);
    background: conic-gradient(from 0deg,
            transparent 0deg,
            rgba(255, 210, 77, 0.3) 10deg,
            transparent 20deg);
    mask: radial-gradient(circle, black 30%, transparent 70%);
    -webkit-mask: radial-gradient(circle, black 30%, transparent 70%);
    filter: blur(5px);
    animation: rotateRays 25s infinite linear;
    opacity: 0.6;
}

@keyframes rotateRays {
    from {
        transform: translate(-50%, -50%) rotate(0deg);
    }

    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

@keyframes pulseGlow {

    0%,
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.4;
    }

    50% {
        transform: translate(-50%, -50%) scale(1.3);
        opacity: 0.7;
    }
}

.unlocked-item-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    /* Increased to be above the glow */
    pointer-events: none;
}

#unlocked-item-view {
    width: 100%;
    height: 100%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    filter: drop-shadow(0 0 30px #ffd24d) drop-shadow(0 0 60px rgba(255, 210, 77, 0.5));
    z-index: 5;
}

.renovated-animation {
    animation: fullScreenBounce 1.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes fullScreenBounce {
    0% {
        transform: scale(1.2);
        filter: blur(10px);
        opacity: 0;
    }

    40% {
        transform: scale(0.95);
        filter: blur(0px);
        opacity: 1;
    }

    60% {
        transform: scale(1.05);
    }

    80% {
        transform: scale(0.98);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

footer {
    padding: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.footer-buttons {
    display: flex;
    gap: 20px;
    align-items: center;
}

.hint-btn {
    position: relative;
    width: 70px !important;
    height: 70px !important;
    background: url('assets/Hints_Button.png') no-repeat center/contain !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.grid-btn {
    position: relative;
    width: 70px !important;
    height: 70px !important;
    background: url('assets/Guides_Button.png') no-repeat center/contain !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.plus-icon {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #10b981;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 16px;
    font-weight: bold;
    border: 2px solid #fff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 5;
}

#game-screen.fridge-theme .hint-btn {
    background: url('assets/Hints_Button.png') no-repeat center/contain !important;
    box-shadow: none !important;
}

#game-screen.fridge-theme .grid-btn {
    background: url('assets/Guides_Button.png') no-repeat center/contain !important;
    box-shadow: none !important;
}

.hint-badge {
    position: absolute;
    bottom: -10px;
    right: 50%;
    transform: translateX(50%);
    background: #5fb0e8;
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    display: none;
    /* Hide for now as we have the plus icon or different style */
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 0.8rem;
    border: 2px solid #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.grid-line {
    stroke: rgba(0, 0, 0, 0.7);
    stroke-width: 2;
    pointer-events: none;
}

.arrow-group.highlighted .puzzle-path,
.arrow-group.can-move .puzzle-path {
    stroke: #ffd24d !important;
    filter: drop-shadow(0 0 8px #ffd24d);
}

.arrow-group.can-move .puzzle-path {
    animation: canMovePulse 2s infinite ease-in-out;
}

.arrow-group.tapping .puzzle-path {
    stroke: #ffffff !important;
    filter: drop-shadow(0 0 15px #ffffff);
    transform: scale(1.05);
}

@keyframes canMovePulse {

    0%,
    100% {
        opacity: 0.8;
        filter: drop-shadow(0 0 4px #ffd24d);
    }

    50% {
        opacity: 1;
        filter: drop-shadow(0 0 10px #ffd24d);
    }
}

.arrow-group.highlighted .arrow-head,
.arrow-group.can-move .arrow-head {
    fill: #ffd24d !important;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-10px) rotate(-1deg);
    }

    40% {
        transform: translateX(10px) rotate(1deg);
    }

    60% {
        transform: translateX(-10px) rotate(-1deg);
    }

    80% {
        transform: translateX(10px) rotate(1deg);
    }
}

.shake {
    animation: shake 0.4s cubic-bezier(.36, .07, .19, .97) both;
}

#game-screen.fridge-theme footer {
    background: transparent;
    padding-bottom: 2.5rem;
}

#unlock-title {
    position: relative;
    z-index: 20;
    color: #fff;
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 2rem;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    animation: slideUpFade 0.6s 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

/* --- New Grid Animations --- */
.grid-dot {
    transition: r 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), fill 0.4s ease, opacity 0.4s ease;
}

.grid-dot.success {
    fill: var(--success-green) !important;
    r: 4px;
    filter: drop-shadow(0 0 5px var(--success-green));
    animation: dotPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.grid-dot.fade-out {
    opacity: 0;
    transform: scale(0);
}

@keyframes dotPop {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.8);
    }

    100% {
        transform: scale(1.2);
    }
}

.unlocked-board-image {
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 1.5s cubic-bezier(0.4, 0, 0.2, 1), transform 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.unlocked-board-image.reveal {
    opacity: 1;
    transform: scale(1);
}

.grid-success-flare {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 0;
    height: 0;
    background: radial-gradient(circle, #fff 0%, var(--primary-color) 40%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 10;
    opacity: 0;
}

.grid-success-flare.animate {
    animation: flareExplosion 1.2s cubic-bezier(0.165, 0.84, 0.44, 1) forwards;
}

@keyframes flareExplosion {
    0% {
        width: 0;
        height: 0;
        opacity: 0.8;
        transform: translate(-50%, -50%) scale(0);
    }

    100% {
        width: 800px;
        height: 800px;
        opacity: 0;
        transform: translate(-50%, -50%) scale(1.5);
    }
}

.blast-circle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 0;
    height: 0;
    border: 4px solid #fff;
    border-radius: 50%;
    pointer-events: none;
    z-index: 100;
    opacity: 0;
}

.blast-circle.animate {
    animation: blastCircleAnim 0.8s cubic-bezier(0.165, 0.84, 0.44, 1) forwards;
}

@keyframes blastCircleAnim {
    0% {
        width: 0;
        height: 0;
        opacity: 1;
        border-width: 20px;
    }

    100% {
        width: 600px;
        height: 600px;
        opacity: 0;
        border-width: 0;
    }
}

.item-reveal-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
    z-index: 50;
    filter: drop-shadow(0 0 20px rgba(255, 210, 77, 0.5));
}

.item-reveal-image.show {
    animation: itemRevealAnim 1.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes itemRevealAnim {
    0% {
        opacity: 0;
        transform: scale(0.5) rotate(-5deg);
        filter: brightness(2) blur(10px);
    }

    50% {
        opacity: 1;
        filter: brightness(1.5) blur(0px);
    }

    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
        filter: brightness(1) blur(0px);
    }
}

.grid-dot.fade-out {
    animation: dotFadeOut 0.5s ease forwards;
}

@keyframes dotFadeOut {
    0% {
        opacity: 1;
        transform: scale(1);
    }

    100% {
        opacity: 0;
        transform: scale(0) rotate(90deg);
    }
}

.item-reveal-image::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right,
            transparent,
            rgba(255, 255, 255, 0.4),
            transparent);
    transform: skewX(-25deg);
    transition: none;
}

.item-reveal-image.show::after {
    animation: shimmer 1.5s 0.5s infinite;
}

@keyframes shimmer {
    0% {
        left: -100%;
    }

    100% {
        left: 200%;
    }
}

.bg-update-flash {
    animation: bgUpdateFlash 1s ease-out;
}

@keyframes bgUpdateFlash {
    0% {
        filter: brightness(3) saturate(2);
    }

    100% {
        filter: brightness(1) saturate(1);
    }
}



.sparkle-particle {
    position: absolute;
    pointer-events: none;
    z-index: 150;
    background: var(--primary-color);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--primary-color);
    animation: particleFloat 1.2s ease-out forwards;
}

@keyframes particleFloat {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }

    100% {
        transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0);
        opacity: 0;
    }
}

@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#unlock-continue-btn {
    background: url('assets/ContinueButton.png') no-repeat center;
    background-size: contain;
    width: 240px;
    height: 80px;
    border: none;
    outline: none;
    cursor: pointer;
    background-color: transparent;
    transition: var(--transition);
    z-index: 20;
    position: relative;
    margin-top: 20px;
}

#unlock-continue-btn:hover {
    transform: scale(1.05);
}

#unlock-continue-btn:active {
    transform: scale(0.96);
}

.sparkles {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

/* Confetti-like effect */
.sparkle {
    position: absolute;
    background: var(--primary-color);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    animation: sparkleAnim 1.5s infinite linear;
}

@keyframes sparkleAnim {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }

    100% {
        transform: translateY(-100px) scale(0);
        opacity: 0;
    }
}


/* --- Game Screen Refinement --- */
#game-screen {
    padding: 0;
    background: url('assets/Gameplay_bg.png') center/cover no-repeat;
}

#game-screen.fridge-theme {
    background: url('assets/Gameplay_bg.png') center/cover no-repeat;
    padding: 0;
}

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.2rem;
    padding: 1rem 1.5rem;
    position: relative;
    z-index: 500;
    background: transparent;
    border-bottom: 2.5px solid #000000;
}

footer {
    position: relative;
    z-index: 500;
    background: transparent;
}

#game-screen.fridge-theme header {
    padding: 1.5rem 1.5rem 1rem;
    margin-bottom: 0;
    border-bottom: 2.5px solid #000000;
    background: transparent;
}

#game-screen.fridge-theme footer {
    background: transparent;
}

#game-screen.fridge-theme .progress-bar-container {
    display: none;
}

#game-screen.fridge-theme .level-display {
    display: none;
}

#game-screen.fridge-theme .icon-btn {
    background: #ffffff;
    color: #000000;
    border: 2px solid #000000;
    border-radius: 14px;
    width: 48px;
    height: 48px;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
}

.header-left {
    display: flex;
    gap: 0.8rem;
    align-items: center;
    flex: 1;
}

.header-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex: 1.5;
    font-family: 'SuperWonder', 'Outfit', sans-serif;
}

.header-center .level-title {
    font-size: 1.4rem;
    font-weight: 900;
    color: #000000;
    line-height: 1.1;
    letter-spacing: 0.5px;
}

.header-center .level-item-name {
    font-size: 1rem;
    font-weight: 800;
    color: #000000;
    text-transform: uppercase;
    line-height: 1.1;
    margin-top: 2px;
}

.header-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex: 1;
}

#game-screen.fridge-theme .header-left {
    display: flex;
    gap: 0.8rem;
    align-items: center;
    flex: 1;
}

#game-screen.fridge-theme .header-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex: 1;
}

#game-screen.fridge-theme .hearts-container {
    display: flex;
    gap: 6px;
    align-items: center;
}

.hearts-container .heart svg {
    width: 28px;
    height: 28px;
    filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.15));
}

.hearts-container .heart svg path {
    stroke: #000000;
    stroke-width: 2px;
    stroke-linejoin: round;
}

.hearts-container .heart svg[fill="currentColor"] {
    color: #ff4d4d !important;
}

.hearts-container .heart svg[fill="#2a2e45"] {
    fill: #8c8c8c !important;
}

.progress-bar-container {
    width: 100%;
    height: 6px;
    background: #1e2233;
    position: relative;
    margin: 1.5rem 0;
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: var(--gradient-blue);
    border-radius: 10px;
    transition: width 0.3s ease;
}

#board-clip-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
    width: 100%;
}

#board-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    background: transparent;
    overflow: visible;
}

#game-board {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    overflow: visible;
}



/* --- General Components --- */
.btn-primary {
    background: var(--gradient-gold);
    color: #000;
    border: none;
    padding: 1.2rem 3.5rem;
    border-radius: 50px;
    font-size: 1.4rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(245, 158, 11, 0.4);
    transition: var(--transition);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-primary:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 15px 35px rgba(245, 158, 11, 0.6);
}

.btn-primary:active {
    transform: translateY(0) scale(0.98);
}

.btn-primary.go-to-btn {
    background: url('assets/Go-To_button.png') no-repeat center/100% 100%;
    color: #000;
    box-shadow: none;
    border-radius: 0;
    width: 250px;
    height: 80px;
    padding: 0;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.1;
}

.btn-primary.go-to-btn:hover {
    box-shadow: none;
}


.icon-btn {
    background: #2a2e45;
    border: 1px solid #3b4261;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    color: white;
    transition: var(--transition);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.icon-btn:hover {
    background: #363b58;
    transform: translateY(-2px);
}

#back-btn,
#room-back-btn,
#chapter-back-btn {
    background: url('assets/backButton.png') no-repeat center/contain !important;
    background-color: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    width: 48px !important;
    height: 48px !important;
}

#back-btn:hover,
#room-back-btn:hover,
#chapter-back-btn:hover {
    background-color: transparent !important;
    transform: scale(1.08) !important;
}

#restart-btn {
    background: url('assets/Retryonce_Button.png') no-repeat center/contain !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    width: 48px !important;
    height: 48px !important;
}

#restart-btn:hover {
    background-color: transparent !important;
    transform: scale(1.08) !important;
}

#back-btn svg,
#room-back-btn svg,
#chapter-back-btn svg,
#restart-btn svg,
#hint-btn svg,
#grid-btn svg {
    display: none !important;
}

.puzzle-path {
    fill: none;
    stroke: var(--arrow-color);
    stroke-width: 9;
    stroke-linecap: round;
    stroke-linejoin: round;
    /* Removed expensive drop-shadow filter to eliminate mobile GPU rasterization lag during panning, zooming and animations */
    transition: stroke 0.2s ease;
}

.grid-dot {
    fill: #000000;
    opacity: 1;
    transition: all 0.3s ease;
}

.grid-dots-path {
    fill: #000000;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.grid-dots-path.fade-out {
    opacity: 0;
}

.arrow-head {
    fill: var(--arrow-color);
    /* Removed expensive drop-shadow filter to eliminate mobile GPU rasterization lag during panning, zooming and animations */
    transition: fill 0.2s ease;
}

.arrow-group {
    touch-action: manipulation;
}

.hidden {
    display: none !important;
}

/* Overlay & Banners */
#overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 6, 10, 0.9);
    backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.overlay-content {
    background: #1a1c2c;
    padding: 4rem 2rem 3rem;
    border-radius: 40px;
    text-align: center;
    border: 2px solid #3b4261;
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.9), inset 0 0 20px rgba(255, 255, 255, 0.05);
    max-width: 90%;
    width: 360px;
    position: relative;
    animation: slideUp 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes slideUp {
    from {
        transform: translateY(100px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.banner-container {
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    width: 120%;
    pointer-events: none;
}

.banner-ribbon {
    background: linear-gradient(to bottom, #d946ef, #a855f7);
    padding: 15px 40px;
    color: white;
    font-weight: 800;
    font-size: 1.8rem;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(168, 85, 247, 0.5);
    position: relative;
    text-transform: uppercase;
    letter-spacing: 2px;
    white-space: nowrap;
}

.banner-ribbon::before,
.banner-ribbon::after {
    content: '';
    position: absolute;
    bottom: -15px;
    border: 15px solid transparent;
    z-index: -1;
}

.banner-ribbon::before {
    left: 20px;
    border-top-color: #7e22ce;
    border-right-color: #7e22ce;
}

.banner-ribbon::after {
    right: 20px;
    border-top-color: #7e22ce;
    border-left-color: #7e22ce;
}

.overlay-message {
    color: var(--text-light);
    margin: 1.5rem 0 2rem;
    font-size: 1.1rem;
    line-height: 1.5;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 2.5rem;
}

.stat-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: #ffffff;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-light);
    text-transform: uppercase;
    margin-top: 5px;
}

.btn-secondary {
    background: #3b4261;
    color: white;
    border: none;
    padding: 1rem 2.5rem;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    margin-top: 10px;
    transition: var(--transition);
}

.btn-secondary:hover {
    background: #4a527a;
    transform: scale(1.05);
}

.hidden {
    display: none !important;
}

/* Shake Animation for Failures */
.shake {
    animation: shakeAnim 0.4s ease-in-out;
}

@keyframes shakeAnim {

    0%,
    100% {
        transform: translateX(0);
    }

    20%,
    60% {
        transform: translateX(-10px);
    }

    40%,
    80% {
        transform: translateX(10px);
    }
}

/* Success Animation for Items */
@keyframes itemUnlock {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    60% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.unlock-anim {
    animation: itemUnlock 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Congratulations Effect */
.congrats-text {
    font-size: 2.2rem;
    font-weight: 800;
    color: #ffffff;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
    margin-bottom: 1rem;
    animation: congratsAnim 1s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes congratsAnim {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.full-renovation-reveal {
    animation: fullRenovationReveal 2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes fullRenovationReveal {
    0% {
        filter: brightness(0.5) blur(10px);
    }

    100% {
        filter: brightness(1) blur(0px);
    }
}

/* --- Selection Screen --- */
#selection-screen {
    justify-content: flex-start;
    align-items: center;
    background: radial-gradient(circle at center, #1a1c2c 0%, #05060a 100%);
    gap: 1rem;
    padding-bottom: 2rem;
}

.selection-title {
    font-size: 2.2rem;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    margin-bottom: 0.5rem;
}

.selection-carousel {
    display: flex;
    gap: 1.5rem;
    padding: 1.5rem calc(50% - 140px);
    width: 100%;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -ms-overflow-style: none;
    margin-top: auto;
}

.selection-carousel::-webkit-scrollbar {
    display: none;
}

.theme-card {
    flex: 0 0 280px;
    height: 380px;
    background: #1a1c2c;
    border-radius: 35px;
    overflow: hidden;
    position: relative;
    border: 3px solid #3b4261;
    scroll-snap-align: center;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    opacity: 0.6;
    transform: scale(0.9);
}

.theme-card.active {
    border-color: #ffd24d;
    transform: scale(1);
    opacity: 1;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6), 0 0 30px rgba(255, 210, 77, 0.2);
}

.theme-image {
    width: 100%;
    height: 65%;
    background-size: cover;
    background-position: center;
}

.kitchen-preview {
    background-image: linear-gradient(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2)), url('assets/KitchenAssets/Damaged_Kitchen.png');
    background-color: #2a2e45;
}

.garden-preview {
    background-image: linear-gradient(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2)), url('assets/GardenAssets/Damaged_Garden.png');
    background-color: #1e3a2f;
}

.hall-preview {
    background-image: linear-gradient(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2)), url('assets/HallAssets/Damaged_Hall.png');
    background-color: #3b2a45;
}

.bathroom-preview {
    background-image: linear-gradient(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2)), url('assets/BathroomAssets/Damaged_Bathroom.png');
    background-color: #1e3a5f;
}

.bedroom-preview {
    background-image: linear-gradient(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2)), url('assets/BedroomAssets/Damaged_Bedroom.png');
    background-color: #4b3525;
}

.classroom-preview {
    background-image: linear-gradient(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2)), url('assets/SchoolAssets/Damaged_Classroom.png');
    background-color: #2b304c;
}

.principleroom-preview {
    background-image: linear-gradient(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2)), url('assets/PrincipleRoom/Damaged_Principleroom.png');
    background-color: #2b304c;
}

.libraryroom-preview {
    background-image: linear-gradient(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2)), url('assets/LibraryAssets/Damaged_Library.png');
    background-color: #2b304c;
}

.theme-info {
    padding: 1.5rem;
    text-align: left;
    background: linear-gradient(to top, #1a1c2c, #2a2e45);
    flex: 1;
}

.theme-info h3 {
    font-size: 1.6rem;
    color: #fff;
    margin-bottom: 5px;
}

.theme-info p {
    font-size: 0.9rem;
    color: var(--text-light);
}

.lock-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 3.5rem;
    backdrop-filter: blur(6px);
    z-index: 10;
}

.carousel-dots {
    display: flex;
    gap: 8px;
    margin-bottom: 2rem;
}

#select-confirm-btn {
    margin-top: auto;
    margin-bottom: 2rem;
}

.carousel-dots .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transition: var(--transition);
}

/* --- Video & Cinematic Renovation --- */
.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.8s ease, visibility 0.8s, background-color 0.8s ease;
}

.video-overlay.active {
    opacity: 1;
    visibility: visible;
    background: #000;
}

.cinematic-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.transformation-scene {
    position: relative;
    width: 300px;
    height: 600px;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.fridge-broken-view,
.fridge-new-view {
    position: absolute;
    width: 100%;
    height: 100%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    pointer-events: none;
    will-change: transform, opacity, filter;
}

.fridge-broken-view {
    z-index: 11;
}

.fridge-new-view {
    opacity: 0;
    z-index: 12;
}

@keyframes sweepShine {
    0% {
        left: -100%;
        opacity: 0;
    }

    50% {
        opacity: 1;
    }

    100% {
        left: 100%;
        opacity: 0;
    }
}

/* Animation Classes */
.cinematic-active .fridge-broken-view {
    animation: risingSpinBroken 2.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.cinematic-active .fridge-new-view {
    animation: risingSpinNew 2.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes risingSpinBroken {
    0% {
        transform: translateY(400px) scale(0.6) rotate(-20deg) skewX(-10deg);
        filter: brightness(0.5) blur(10px);
        opacity: 0;
    }
    25% {
        transform: translateY(0px) scale(1) rotate(0deg) skewX(0deg);
        filter: brightness(1) blur(0px);
        opacity: 1;
    }
    40% {
        transform: translateY(-20px) scale(1.05) rotate(5deg) skewX(5deg);
        filter: brightness(3) sepia(1) saturate(5) hue-rotate(-20deg) blur(2px);
        opacity: 0.9;
    }
    55% {
        transform: translateY(-50px) scale(1.15) rotate(15deg) skewX(15deg);
        filter: brightness(5) sepia(1) saturate(10) blur(15px);
        opacity: 0;
    }
    100% {
        transform: translateY(-100px) scale(1.2) rotate(25deg);
        filter: brightness(5) blur(30px);
        opacity: 0;
    }
}

@keyframes risingSpinNew {
    0% {
        transform: translateY(100px) scale(0.6) rotate(-15deg);
        filter: brightness(5) blur(20px);
        opacity: 0;
    }
    40% {
        transform: translateY(30px) scale(0.85) rotate(-5deg);
        filter: brightness(3) sepia(0.5) blur(10px);
        opacity: 0.4;
    }
    60% {
        transform: translateY(-5px) scale(1.03) rotate(1deg);
        filter: brightness(1.5) blur(2px);
        opacity: 0.9;
    }
    75% {
        transform: translateY(0px) scale(0.99) rotate(0deg);
        filter: brightness(1.1) blur(0px);
        opacity: 1;
    }
    100% {
        transform: translateY(0px) scale(1);
        filter: brightness(1) blur(0px);
        opacity: 1;
    }
}

/* Vortex & Particles */
.vortex-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
    perspective: 1200px;
}

/* 3D Volumetric Funnel Rings */
.tornado-funnel-ring {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 340px;
    height: 340px;
    margin-left: -170px;
    margin-top: -170px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, 
        transparent 0%, 
        rgba(255, 210, 77, 0.45) 15%, 
        transparent 35%, 
        rgba(51, 204, 255, 0.45) 55%, 
        transparent 75%
    );
    transform: translateY(var(--y-offset)) rotateX(75deg) scale(var(--scale));
    filter: blur(8px) drop-shadow(0 0 15px rgba(255, 210, 77, 0.35));
    opacity: 0;
    pointer-events: none;
    z-index: 6;
    will-change: transform, opacity;
}

.vortex-active .tornado-funnel-ring {
    animation: 
        funnelRingFade 2.5s ease-in-out forwards,
        spinRing var(--duration) linear infinite;
}

@keyframes funnelRingFade {
    0% {
        opacity: 0;
        transform: translateY(350px) rotateX(75deg) scale(0.1);
    }
    20% {
        opacity: var(--opacity);
    }
    80% {
        opacity: var(--opacity);
    }
    100% {
        opacity: 0;
        transform: translateY(-350px) rotateX(75deg) scale(calc(var(--scale) * 1.4));
    }
}

@keyframes spinRing {
    from {
        transform: translateY(var(--y-offset)) rotateX(75deg) scale(var(--scale)) rotateZ(0deg);
    }
    to {
        transform: translateY(var(--y-offset)) rotateX(75deg) scale(var(--scale)) rotateZ(360deg);
    }
}

/* Ground Shockwave Ring */
.shockwave-ring {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 400px;
    height: 400px;
    margin-left: -200px;
    margin-top: -200px;
    border-radius: 50%;
    border: 8px solid rgba(255, 210, 77, 0.85);
    box-shadow: 0 0 45px rgba(255, 210, 77, 0.7), inset 0 0 45px rgba(51, 204, 255, 0.7);
    transform: translateY(230px) rotateX(75deg) scale(0);
    opacity: 0;
    filter: blur(3px);
    pointer-events: none;
    z-index: 5;
    will-change: transform, opacity;
}

.vortex-active .shockwave-ring {
    animation: shockwaveAnim 1.4s cubic-bezier(0.1, 0.85, 0.25, 1) forwards;
}

@keyframes shockwaveAnim {
    0% {
        transform: translateY(230px) rotateX(75deg) scale(0.1);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    100% {
        transform: translateY(230px) rotateX(75deg) scale(2.4);
        opacity: 0;
        border-width: 1px;
    }
}

/* Skewed Flashing Energy Arcs (Lightning) */
.energy-arc {
    position: absolute;
    left: 50%;
    bottom: 20%;
    width: 2.5px;
    height: 550px;
    margin-left: var(--x-offset);
    background: linear-gradient(to top, transparent 5%, #ffffff 40%, #00d9ff 70%, transparent 95%);
    opacity: 0;
    filter: blur(1px) drop-shadow(0 0 10px rgba(0, 217, 255, 0.8));
    pointer-events: none;
    z-index: 7;
    transform-origin: bottom center;
    will-change: transform, opacity;
}

.vortex-active .energy-arc {
    animation: energyArcFlash 0.35s ease-out forwards;
}

@keyframes energyArcFlash {
    0% {
        opacity: 0;
        transform: scaleY(0.1) skewX(0deg);
    }
    15% {
        opacity: 0.9;
        transform: scaleY(1.05) skewX(var(--skew));
    }
    25% {
        opacity: 0;
    }
    45% {
        opacity: 0.95;
        transform: scaleY(1.15) skewX(calc(var(--skew) * -1.3));
    }
    60% {
        opacity: 0;
    }
    75% {
        opacity: 0.8;
        transform: scaleY(0.95) skewX(calc(var(--skew) * 0.7));
    }
    100% {
        opacity: 0;
        transform: scaleY(0.1) skewX(0deg);
    }
}

.vfx-particle {
    position: absolute;
    pointer-events: none;
    border-radius: 50%;
    transform-style: preserve-3d;
    will-change: transform, opacity, filter;
}

.vfx-particle.light-streak {
    border-radius: 2px;
    filter: blur(1.5px);
    opacity: 0.85;
}

.vfx-particle.debris {
    border-radius: 0;
    filter: brightness(0.5) contrast(1.6);
}

.vortex-active .vfx-particle {
    animation: professionalTornado var(--duration) cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes professionalTornado {
    0% {
        transform: rotateY(var(--start-angle)) translateZ(calc(var(--radius) * 0.15)) translateY(350px) scale(0.4);
        filter: blur(4px);
        opacity: 0;
    }
    15% {
        opacity: 1;
        filter: blur(0px);
    }
    50% {
        transform: rotateY(calc(var(--start-angle) + 720deg)) translateZ(calc(var(--radius) * 0.8)) translateY(40px) scale(1.15);
        opacity: 1;
    }
    75% {
        transform: rotateY(calc(var(--start-angle) + 1440deg)) translateZ(calc(var(--radius) * 1.4)) translateY(-150px) scale(0.85);
        opacity: 1;
    }
    100% {
        transform: rotateY(calc(var(--start-angle) + 2160deg)) translateZ(calc(var(--radius) * 2.6)) translateY(-450px) scale(0.2);
        filter: blur(6px);
        opacity: 0;
    }
}

.vfx-particle.burst {
    animation: burstParticle var(--duration) cubic-bezier(0.165, 0.84, 0.44, 1) forwards;
}

@keyframes burstParticle {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
    }
    30% {
        opacity: 0;
    }
    50% {
        transform: translate(-50%, -50%) scale(1) translate(var(--tx), var(--ty));
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(0.5) translate(calc(var(--tx) * 1.5), calc(var(--ty) * 1.5));
        opacity: 0;
    }
}

.vfx-star {
    position: absolute;
    pointer-events: none;
    font-size: 20px;
    z-index: 15;
}

.vortex-active .vfx-star {
    animation: starTravel var(--duration) cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes starTravel {
    0% {
        transform: translate(-50%, -50%) translate(var(--tx1), 600px) scale(0);
        opacity: 0;
    }
    20% {
        opacity: 1;
        scale: 1;
    }
    80% {
        opacity: 1;
        scale: 1;
    }
    100% {
        transform: translate(-50%, -50%) translate(var(--tx2), -800px) scale(0);
        opacity: 0;
    }
}

.energy-vortex {
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(255, 210, 77, 0.1) 0%, transparent 70%);
    border-radius: 50%;
    filter: blur(30px);
    z-index: 1;
    opacity: 0;
}

.energy-vortex::before,
.energy-vortex::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: conic-gradient(from 0deg, transparent 0%, rgba(255, 210, 77, 0.4) 10%, transparent 20%, rgba(51, 204, 255, 0.4) 40%, transparent 50%);
    mask: radial-gradient(circle, transparent 30%, black 50%, transparent 70%);
    -webkit-mask: radial-gradient(circle, transparent 30%, black 50%, transparent 70%);
    animation: rotateSpiral 3s linear infinite;
}

.energy-vortex::after {
    animation-duration: 2s;
    animation-direction: reverse;
    transform: scale(1.2);
    opacity: 0.5;
}

@keyframes rotateSpiral {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.cinematic-active .energy-vortex {
    animation: energyVortexAnim 2.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes energyVortexAnim {
    0% {
        transform: scale(0.5) rotate(0deg);
        opacity: 0;
    }
    20% {
        opacity: 1;
    }
    80% {
        opacity: 1;
    }
    100% {
        transform: scale(2) rotate(720deg);
        opacity: 0;
    }
}

/* Anamorphic Lens Flare */
.lens-flare {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 0px;
    height: 0px;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, #ffffff 10%, #ffd24d 50%, transparent 100%);
    box-shadow: 0 0 30px 10px rgba(255, 210, 77, 0.9), 0 0 60px 25px rgba(51, 204, 255, 0.55);
    border-radius: 50%;
    opacity: 0;
    z-index: 100;
    pointer-events: none;
    will-change: width, height, opacity;
}

.cinematic-active .lens-flare {
    animation: lensFlareAnim 2.5s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}

@keyframes lensFlareAnim {
    0% {
        width: 0px;
        height: 0px;
        opacity: 0;
    }
    30% {
        width: 15px;
        height: 15px;
        opacity: 0.3;
    }
    45% {
        width: 450px;
        height: 12px;
        opacity: 1;
    }
    50% {
        width: 480px;
        height: 16px;
        opacity: 1;
    }
    70% {
        width: 100px;
        height: 4px;
        opacity: 0.6;
    }
    100% {
        width: 0px;
        height: 0px;
        opacity: 0;
    }
}

/* Cinematic Camera Shake */
.cinematic-shake {
    animation: cinematicShake 1.8s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
    will-change: transform;
}

@keyframes cinematicShake {
    0% { transform: translate(0, 0) rotate(0deg); }
    10% { transform: translate(-3px, 2px) rotate(-0.5deg); }
    20% { transform: translate(3px, -2px) rotate(0.5deg); }
    30% { transform: translate(-4px, -1px) rotate(-1deg); }
    40% { transform: translate(4px, 2px) rotate(1deg); }
    45% { transform: translate(-6px, 4px) rotate(-1.5deg); }
    50% { transform: translate(6px, -4px) rotate(1.5deg); }
    55% { transform: translate(-5px, 2px) rotate(-1deg); }
    60% { transform: translate(4px, -2px) rotate(0.5deg); }
    70% { transform: translate(-2px, 1px) rotate(-0.5deg); }
    80% { transform: translate(2px, -1px) rotate(0deg); }
    90% { transform: translate(-1px, 0px) rotate(0deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}

/* Smooth fade out for unlock screen content */
.fade-out-content .unlock-overlay>*:not(.sparkles) {
    opacity: 0;
    transform: translateY(-20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

/* Realistic Renovation Reveal */
.renovation-reveal {
    animation: realisticReveal 1.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes realisticReveal {
    0% {
        filter: brightness(0.5) contrast(1.2) saturate(0.5) blur(15px);
        transform: scale(1.05);
    }

    30% {
        filter: brightness(2) contrast(1) saturate(2) blur(5px);
        transform: scale(1.02);
    }

    100% {
        filter: brightness(1) contrast(1) saturate(1) blur(0px);
        transform: scale(1);
    }
}

.cinematic-flash {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    z-index: 10000;
    pointer-events: none;
    opacity: 0;
}

.cinematic-flash.animate {
    animation: flashAnim 1s ease-out forwards;
}

@keyframes flashAnim {
    0% {
        opacity: 0;
    }

    20% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

.carousel-dots .dot.active {
    width: 24px;
    border-radius: 4px;
    background: var(--primary-color);
}

/* Backstory Video Styles */
#backstory-overlay {
    background-color: #000;
}

#backstory-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.skip-btn {
    position: absolute;
    bottom: 30px;
    right: 20px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: 1.5px solid rgba(255, 255, 255, 0.3);
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    backdrop-filter: blur(5px);
    transition: var(--transition);
    z-index: 100;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.skip-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.skip-btn:active {
    transform: scale(0.95);
}

/* Dialogue System Styles */
.dialogue-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    /* Fully transparent background to let the scene show through */
    z-index: 20000;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s;
    pointer-events: none;
}

.dialogue-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.dialogue-container {
    width: 100%;
    height: auto;
    /* Explicitly set to auto so aspect-ratio works on absolute positioning */
    position: absolute;
    bottom: 0;
    /* Anchor to the absolute bottom of the game container */
    left: 0;
    aspect-ratio: 1080 / 724;
    /* Precise aspect ratio of the 1080x724 Harry PNGs */
    background-size: 100% 100%;
    /* Stretch background exactly to full-width and full aspect height */
    background-repeat: no-repeat;
    background-position: center;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    /* Align the dialogue box to the bottom */
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    pointer-events: auto;
}

.dialogue-overlay.active .dialogue-container {
    transform: translateY(0);
}

.dialogue-box {
    background: transparent;
    /* Transparent background, utilizing the PNG's built-in bubble */
    border: none;
    box-shadow: none;
    width: 100%;
    height: 35%;
    /* Pushes the box to the lower bottom area */
    padding: 5px 6% 9px 26%;
    /* 26% left padding moves text further left for maximum space, 6% right padding keeps a clean right boundary, 9px bottom padding shifts text down */
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    /* Align the text block to the left side of the bubble region */
    justify-content: flex-end;
    /* Push both long and short text blocks to the bottom area (middle-down) */
    position: relative;
    z-index: 1;
    box-sizing: border-box;
}

.character-name-tag {
    display: none !important;
    /* Hide old tag because name is baked directly into the PNGs */
}

#dialogue-text {
    color: #4b2c20;
    /* Clean premium dark brown tone matching natural speech bubble text */
    font-family: 'SuperWonder', 'Outfit', sans-serif;
    /* Set custom premium SuperWonder font style */
    font-size: 0.95rem;
    /* Highly readable font size */
    font-weight: normal;
    line-height: 1.25;
    margin: 0;
    text-align: left;
    /* Left-align the text lines to start from the left side */
    width: 100%;
}

.tap-indicator {
    position: absolute;
    bottom: 8px;
    right: 12%;
    font-size: 0.58rem;
    color: #8c766c;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
    animation: blink 1.8s infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 0.3;
    }

    50% {
        opacity: 1;
    }
}


.selection-screen-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2rem 1.5rem 1rem;
    z-index: 100;
}

.selection-screen-header .screen-title {
    color: #ffffff;
    font-size: 1.4rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4), 0 0 10px rgba(255, 255, 255, 0.2);
}

/* --- Chapter Selection Screen --- */
#chapter-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: url('assets/Home_background.png') center/cover no-repeat;
}

#chapter-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: auto;
    aspect-ratio: 1080 / 300;
    background: url('assets/Chapter_Title_bg.png') center top no-repeat;
    background-size: 100% auto;
    z-index: 90;
    pointer-events: none;
    overflow: hidden;
}

#chapter-screen::-webkit-scrollbar,
.chapter-container::-webkit-scrollbar {
    display: none;
}

.chapter-floating-back-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.25);
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #ffffff;
    cursor: pointer;
    z-index: 100;
    transition: transform 0.2s ease, background 0.2s ease;
    backdrop-filter: blur(5px);
}

.chapter-floating-back-btn:hover {
    transform: scale(1.08);
    background: rgba(255, 255, 255, 0.35);
}

.chapter-container {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3.5rem;
    padding: 120px 0px calc(95px + env(safe-area-inset-bottom, 0px));
    position: relative;
    z-index: 1;
}

.chapter-card-v2 {
    position: relative;
    width: 390px;
    height: 460px;
    background: url('assets/Chapter1_layout_back.png') no-repeat center/100% 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: 40px 10px 15px;
    overflow: visible;
    flex-shrink: 0;
}

.chapter-card-v2.locked {
    filter: grayscale(0.8) brightness(0.65);
    cursor: not-allowed;
    pointer-events: none;
}

.chapter-badge-v2 {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 150px;
    height: 30px;
    object-fit: contain;
    z-index: 10;
    pointer-events: none;
}

.chapter-badge-v2.chapter-2-badge-v2 {
    width: 170px;
    height: 42px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #ffffff;
    font-size: 1.15rem;
    font-weight: 800;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    font-family: 'SuperWonder', 'Outfit', sans-serif;
    padding-bottom: 5px;
}

.chapter-subtitle-v2 {
    text-align: center;
    color: #000000;
    font-size: 1.25rem;
    font-weight: 700;
    margin: 8px 0 12px;
    font-family: 'SuperWonder', 'Outfit', sans-serif;
    pointer-events: none;
}

.chapter-rows-v2 {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 300px;
    justify-content: space-between;
    padding: 0 10px;
}

.chapter-row-v2 {
    display: flex;
    align-items: center;
    width: 100%;
    height: 52px;
    position: relative;
}

.chapter-row-tab-v2 {
    width: 76px;
    text-align: center;
    font-size: 0.88rem;
    font-weight: 500;
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
    text-transform: capitalize;
    font-family: 'Outfit', sans-serif;
    pointer-events: none;
    z-index: 5;
    margin-left: -5px;
    padding-right: 10px;
    transform: translateY(-2px);
}

.chapter-row-levels-v2 {
    display: flex;
    flex: 1;
    justify-content: center;
    align-items: center;
    gap: -2px;
    padding-right: 10px;
}

.chapter-level-btn-v2 {
    position: relative;
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: transparent;
    border: none;
    pointer-events: auto;
    cursor: pointer;
}

.chapter-level-btn-v2.locked {
    filter: opacity(0.55) grayscale(0.5);
    pointer-events: none;
}

.level-num-v2 {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    font-weight: 900;
    color: #000000;
    font-family: 'SuperWonder', 'Outfit', sans-serif;
    line-height: 1;
    pointer-events: none;
    white-space: nowrap;
}

.chapter-level-btn-v2.locked .level-num-v2 {
    color: #555555;
}

.tick-icon-v2,
.uncleared-icon-v2 {
    position: absolute;
    bottom: -4px;
    right: -4px;
    width: 35px;
    height: 35px;
    z-index: 20;
    pointer-events: none;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

.chapter-play-btn-v2 {
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    background: none;
    border: none;
    outline: none;
    cursor: pointer;
    transition: transform 0.2s ease;
    z-index: 10;
}

.chapter-play-btn-v2:hover {
    transform: translateX(-50%) scale(1.06);
}

.chapter-play-btn-v2:active {
    transform: translateX(-50%) scale(0.96);
}

.chapter-play-btn-v2 img {
    width: 220px;
    height: auto;
    display: block;
}

.chapter-lock-overlay-v2 {
    position: absolute;
    top: 55%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ffffff;
    font-size: 1.25rem;
    font-weight: 800;
    text-align: center;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.95);
    width: 90%;
    pointer-events: none;
    z-index: 20;
    font-family: 'SuperWonder', 'Outfit', sans-serif;
}

/* --- Bottom Navigation Bar --- */
.bottom-nav {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: calc(90px + env(safe-area-inset-bottom, 0px));
    z-index: 150;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    pointer-events: none;
    transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.3s ease;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-nav.hidden {
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
}

.bottom-nav-shadow {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: calc(min(450px, 100vw) * 300 / 1080 + env(safe-area-inset-bottom, 0px));
    background: url('assets/Bottom_back_shadow.png') no-repeat center bottom/100% 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.85;
}

.bottom-nav-base {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: calc(10px + env(safe-area-inset-bottom, 0px));
    background: url('assets/BottomUI_Home_whitebar.png') no-repeat center bottom/100% 100%;
    z-index: 1;
    pointer-events: none;
}

.nav-selector {
    position: absolute;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    /* Shift the dome slightly upward */
    left: 5%;
    width: 30%;
    /* 1/3 of the 90% nav-tabs width */
    height: 115px;
    /* Taller dome rises well above base */
    background: url('assets/BottomUI_Home_whitebar_selected.png') no-repeat center bottom/contain;
    z-index: 2;
    pointer-events: none;
    transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

.nav-tabs {
    position: absolute;
    bottom: env(safe-area-inset-bottom, 0px);
    /* Centered 90% width to reduce icon spacing */
    width: 90%;
    height: 90px;
    display: flex;
    z-index: 3;
    pointer-events: auto;
}

.nav-tab {
    flex: 1;
    height: 100%;
    background: none;
    border: none;
    outline: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    /* Non-active icons sit near base */
    position: relative;
    padding-bottom: 14px;
}

.nav-tab img {
    width: 50px;
    height: 50px;
    object-fit: contain;
    transition: transform 0.2s ease;
}

/* Active tab: only scale icon, do NOT change alignment or padding */
.nav-tab.active img {
    transform: scale(1.1);
}

/* Position translate classes for the selector */
.bottom-nav[data-active="home"] .nav-selector {
    transform: translateX(0%);
}

.bottom-nav[data-active="chapters"] .nav-selector {
    transform: translateX(100%);
}

.bottom-nav[data-active="settings"] .nav-selector {
    transform: translateX(200%);
}

/* Push contents of Screens up slightly to prevent overlap */
#selection-screen {
    padding-bottom: calc(95px + env(safe-area-inset-bottom, 0px));
}

/* --- Settings Screen Styles --- */
#settings-screen {
    justify-content: flex-start;
    align-items: center;
    background: url('assets/Home_background.png') center/cover no-repeat;
    position: relative;
    padding-top: 3.5rem;
    padding-bottom: calc(110px + env(safe-area-inset-bottom, 0px));
    /* space for bottom nav */
    overflow-y: auto;
}

#settings-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('assets/GridDots.png') repeat;
    background-size: 35px;
    opacity: 0.25;
    pointer-events: none;
    z-index: 1;
}

.settings-title-container {
    margin-bottom: 2rem;
    z-index: 2;
}

.settings-title-img {
    width: 190px;
    height: auto;
    display: block;
}

.settings-cards-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.2rem;
    width: 100%;
    max-width: 340px;
    padding: 0 10px;
    z-index: 2;
}

.settings-card {
    position: relative;
    width: 100%;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-position: center;
    border: none;
    outline: none;
}

.vibes-music-sounds-card {
    background-image: url('assets/SettingsScreen/Music_Sounds_vibs_Button.png');
    height: 172px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 10px 10px 10px 0;
    /* right padded slightly to align toggle buttons */
}

.settings-row {
    flex: 1;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    position: relative;
    padding-right: 15px;
}

.settings-toggle-btn {
    width: 50px;
    height: 28px;
    border: none;
    outline: none;
    cursor: pointer;
    background-color: transparent;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    transition: transform 0.15s ease;
}

.settings-toggle-btn:hover {
    transform: scale(1.05);
}

.settings-toggle-btn:active {
    transform: scale(0.95);
}

.settings-toggle-btn[data-active="true"] {
    background-image: url('assets/SettingsScreen/Toggle_On.png');
}

.settings-toggle-btn[data-active="false"] {
    background-image: url('assets/SettingsScreen/Toggle_Off.png');
}

.removeads-restore-card {
    background-image: url('assets/SettingsScreen/RemoveAds_Restore_Button.png');
    height: 114px;
}

.removeads-price {
    position: absolute;
    right: 25px;
    top: 18px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    color: #3b3d4f;
    pointer-events: none;
}

.settings-action-overlay-btn {
    position: absolute;
    left: 0;
    width: 100%;
    height: 50%;
    border: none;
    outline: none;
    cursor: pointer;
    background: transparent;
    transition: background-color 0.2s ease;
}

.settings-action-overlay-btn.btn-remove-ads {
    top: 0;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
}

.settings-action-overlay-btn.btn-restore-purchases {
    bottom: 0;
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
}

.settings-action-overlay-btn:active {
    background-color: rgba(0, 0, 0, 0.05);
}

.settings-card-btn {
    border: none;
    outline: none;
    cursor: pointer;
    background-color: transparent;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-position: center;
    width: 100%;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.rateus-card {
    background-image: url('assets/SettingsScreen/RateUs_Button.png');
    height: 57px;
}

.logout-card {
    background-image: url('assets/SettingsScreen/Logout_Button.png');
    height: 57px;
}

.settings-card-btn:hover {
    transform: scale(1.03);
}

.settings-card-btn:active {
    transform: scale(0.97);
}

/* --- Custom Lose Overlay Screen --- */
#lose-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('assets/Home_background.png') center/cover no-repeat;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

#lose-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

#lose-overlay.hidden {
    display: none !important;
}

.lose-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.8rem;
    width: 100%;
    height: 100%;
    padding: 2rem;
    animation: loseSlideUp 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.lose-title-img {
    width: 280px;
    max-width: 90%;
    height: auto;
    display: block;
    margin-bottom: 2rem;
    animation: logoFloat 3s ease-in-out infinite;
}

.lose-btn-img {
    width: 220px;
    height: 75px;
    border: none;
    outline: none;
    cursor: pointer;
    background-color: transparent;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), filter 0.2s ease;
}

.lose-btn-img.retry {
    background: url('assets/Retry_button.png') no-repeat center/contain;
}

.lose-btn-img.goback {
    background: url('assets/GoBack_button.png') no-repeat center/contain;
}

.lose-btn-img:hover {
    transform: scale(1.05);
    filter: brightness(1.05);
}

.lose-btn-img:active {
    transform: scale(0.95);
    filter: brightness(0.95);
}

@keyframes loseSlideUp {
    from {
        transform: translateY(60px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Completed Theme Tab Buttons */
.chapter-row-tab-v2.completed-btn {
    pointer-events: auto !important;
    cursor: pointer !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    font-size: 0.88rem !important;
    font-weight: 800 !important;
    color: #ffd24d !important;
    text-shadow: 0 0 8px #ffd24d, 0 0 15px rgba(255, 210, 77, 0.6) !important;
    animation: goldPulseText 2.5s infinite ease-in-out !important;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), text-shadow 0.2s ease !important;
    margin-left: -5px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    transform: translateY(-2px) !important;
}

.chapter-row-tab-v2.completed-btn:hover {
    transform: translateY(-4px) scale(1.1) !important;
    color: #ffffff !important;
    text-shadow: 0 0 12px #ffd24d, 0 0 25px #ffd24d !important;
}

.chapter-row-tab-v2.completed-btn:active {
    transform: translateY(0px) scale(0.96) !important;
}

@keyframes goldPulseText {

    0%,
    100% {
        text-shadow: 0 0 8px #ffd24d, 0 0 15px rgba(255, 210, 77, 0.6);
        filter: brightness(1);
    }

    50% {
        text-shadow: 0 0 15px #ffd24d, 0 0 30px #ffd24d;
        filter: brightness(1.3);
    }
}

/* --- Wrong Move Feedback Vignette --- */
.screen-danger {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 1500;
    background: radial-gradient(circle, transparent 30%, rgba(255, 59, 48, 0.45) 100%);
    opacity: 0;
    transition: none;
}

.wrong-move-flash {
    animation: wrongMoveOverlayFlash 0.5s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
}

@keyframes wrongMoveOverlayFlash {
    0% {
        opacity: 0;
    }

    20% {
        /* 100ms peak */
        opacity: 1;
    }

    100% {
        /* 400ms smooth fade out */
        opacity: 0;
    }
}

/* --- Wrong Arrow Pulse --- */
.wrong-arrow {
    transform-box: fill-box;
    transform-origin: center;
    animation: wrongArrowScalePulse 0.35s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}

.wrong-arrow .puzzle-path {
    animation: wrongPathColorPulse 0.35s ease-in-out forwards !important;
}

.wrong-arrow .arrow-head {
    animation: wrongHeadColorPulse 0.35s ease-in-out forwards !important;
}

@keyframes wrongArrowScalePulse {
    0% {
        transform: scale(1);
    }

    28.5% {
        /* 100ms peak */
        transform: scale(1.08);
    }

    57% {
        /* 200ms slightly scaled down */
        transform: scale(1.04);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes wrongPathColorPulse {
    0% {
        stroke: var(--arrow-color, #9ab3ff);
        filter: none;
    }

    28.5% {
        /* 100ms: turn bright red + red outer glow */
        stroke: #ff3b30 !important;
        filter: drop-shadow(0 0 8px #ff3b30) drop-shadow(0 0 15px #ff3b30) !important;
    }

    57.1% {
        /* 200ms: slightly darker red + smaller glow */
        stroke: #b3241d !important;
        filter: drop-shadow(0 0 5px #b3241d) !important;
    }

    100% {
        /* 350ms: return to normal color and no filter */
        stroke: var(--arrow-color, #9ab3ff);
        filter: none;
    }
}

@keyframes wrongHeadColorPulse {
    0% {
        fill: var(--arrow-color, #9ab3ff);
        filter: none;
    }

    28.5% {
        /* 100ms: turn bright red + red outer glow */
        fill: #ff3b30 !important;
        filter: drop-shadow(0 0 8px #ff3b30) !important;
    }

    57.1% {
        /* 200ms: slightly darker red + smaller glow */
        fill: #b3241d !important;
        filter: drop-shadow(0 0 5px #b3241d) !important;
    }

    100% {
        /* 350ms: return to normal color and no filter */
        fill: var(--arrow-color, #9ab3ff);
        filter: none;
    }
}

/* --- Subtle Board Shake --- */
.wrong-move-shake {
    animation: subtleShake 0.25s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes subtleShake {

    0%,
    100% {
        transform: translate(0, 0);
    }

    20%,
    60% {
        transform: translate(-5px, 2px);
    }

    40%,
    80% {
        transform: translate(5px, -2px);
    }
}

/* --- Chapter Panel Navigation Tip Box --- */
.chapter-tip-box {
    position: absolute;
    bottom: calc(105px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    width: 340px;
    background: rgba(0, 0, 0, 0.75);
    border: 1.5px dashed rgba(255, 210, 77, 0.80);
    border-radius: 14px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 120;
    pointer-events: none;
    box-sizing: border-box;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.chapter-tip-box.show {
    opacity: 1;
    visibility: visible;
}

.chapter-tip-box .tip-icon {
    font-size: 1.15rem;
    filter: drop-shadow(0 0 3px #ffd24d);
}

.chapter-tip-box .tip-text {
    font-family: 'Outfit', sans-serif;
    font-size: 0.78rem;
    color: #ffffff;
    font-weight: 500;
    line-height: 1.35;
    text-align: left;
}

/* --- Login Screen --- */
#login-screen {
    justify-content: center;
    align-items: center;
    background: url('assets/Home_background.png') center/cover no-repeat;
    position: relative;
}

#login-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('assets/GridDots.png') repeat;
    background-size: 35px;
    opacity: 0.25;
    pointer-events: none;
    z-index: 1;
}

.login-wrapper {
    width: 85%;
    max-width: 340px;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 2;
}

.login-title {
    font-family: 'Outfit', sans-serif;
    font-weight: 900;
    font-size: 3.2rem;
    color: #ffffff;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    letter-spacing: 2px;
    margin-bottom: 25px;
    text-align: center;
}

.login-tabs {
    display: flex;
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 25px;
    padding: 4px;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.login-tab {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: rgba(255, 255, 255, 0.6);
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 10px 0;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.login-tab.active {
    background: #ffffff;
    color: #014c8a;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

#login-form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.input-group {
    width: 100%;
}

.input-group input {
    width: 100%;
    padding: 14px 20px;
    background: #ffffff;
    border: 2px solid transparent;
    border-radius: 12px;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    color: #1a1c2c;
    outline: none;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
}

.input-group input:focus {
    border-color: #ffd24d;
    box-shadow: 0 0 8px rgba(255, 210, 77, 0.4), 0 4px 10px rgba(0, 0, 0, 0.15);
}

.input-group input::placeholder {
    color: #9ca3af;
    font-weight: 500;
}

.login-error-msg {
    color: #ff4d6d;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    text-align: center;
    margin: 4px 0;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    background: rgba(0, 0, 0, 0.4);
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 77, 109, 0.2);
}

.login-submit-btn {
    background: var(--gradient-gold);
    color: #000000;
    font-family: 'SuperWonder', 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 1.25rem;
    padding: 12px 20px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.4);
    transition: all 0.2s ease;
    text-shadow: none;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 5px;
    width: 100%;
}

.login-submit-btn:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.6);
}

.login-submit-btn:active {
    transform: scale(0.98);
}

.login-divider {
    font-family: 'SuperWonder', 'Outfit', sans-serif;
    font-size: 1.1rem;
    color: #000000;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.2);
    margin: 20px 0;
    position: relative;
    width: 100%;
    text-align: center;
    font-weight: 900;
}

.login-social-btns {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.social-login-btn {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    width: 100%;
    max-width: 280px;
    transition: transform 0.2s ease, filter 0.2s ease;
    outline: none;
    display: flex;
    justify-content: center;
}

.social-login-btn img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    display: block;
}

.social-login-btn:hover {
    transform: scale(1.03);
}

.social-login-btn:active {
    transform: scale(0.97);
}

/* --- Level Loading Overlay --- */
.level-loader-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 17, 26, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 20px;
    z-index: 800;
    transition: opacity 0.25s ease-in-out;
}

.level-loader-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.1);
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    animation: loaderSpin 1s linear infinite;
    box-shadow: 0 0 15px rgba(255, 210, 77, 0.4);
}

.level-loader-text {
    font-family: 'SuperWonder', 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: 1.5px;
    text-shadow: 0 0 10px rgba(255, 210, 77, 0.4);
    animation: loaderPulse 1.5s ease-in-out infinite;
}

@keyframes loaderSpin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes loaderPulse {

    0%,
    100% {
        opacity: 0.7;
        transform: scale(0.98);
    }

    50% {
        opacity: 1;
        transform: scale(1.02);
    }
}