:root {
    --primary: #FFB7CE;
    --secondary: #A2D2FF;
    --accent: #FFD1DC;
    --text: #594A4E;
    --white: #FFFFFF;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Fredoka', sans-serif;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    /* BRUTAL force disable scroll everywhere */
    -webkit-touch-callout: none;
}

body {
    background-color: #333;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
    touch-action: none;
    /* Prevent scroll/zoom on mobile */
}

#game-container {
    width: 100%;
    max-width: 480px;
    height: 100%;
    max-height: 800px;
    background: linear-gradient(to bottom, #A2D2FF 0%, #CDE7FF 100%);
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
}

header {
    position: absolute;
    top: 20px;
    left: 0;
    width: 100%;
    padding: 0 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 50;
    /* Ensure above everything */
}

.nav-left,
.nav-right {
    display: flex;
    gap: 10px;
    align-items: center;
}

.game-info-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    /* Hidden as per request */
    flex-direction: column;
    align-items: center;
}

.lang-controls {
    display: flex;
    gap: 5px;
}

.lang-btn {
    background: rgba(255, 255, 255, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 5px;
    padding: 5px;
    color: var(--text);
    font-size: 0.8rem;
    cursor: pointer;
    font-weight: bold;
}

.lang-btn.active {
    background: var(--white);
    color: var(--primary);
    border-color: var(--white);
}

.sound-btn {
    background: rgba(255, 255, 255, 0.3);
    border: none;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    font-size: 1.2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    backdrop-filter: blur(4px);
}

.home-btn {
    text-decoration: none;
    font-size: 0;
    /* Hide text emoji */
    width: 40px;
    height: 40px;
    background: url('../assets/images/logo.png') no-repeat center center;
    background-size: contain;
    border-radius: 5px;
    transition: transform 0.2s;
    display: inline-block;
}

.home-btn:hover {
    transform: scale(1.1);
}

.best-score-container {
    background: rgba(255, 255, 255, 0.5);
    padding: 5px 10px;
    border-radius: 10px;
    font-size: 0.9rem;
    color: var(--text);
    font-weight: 500;
    display: none;
    /* Hidden by default */
}

.best-score-container.visible {
    display: block;
}

#game-area {
    width: 100%;
    height: 100%;
    position: relative;
    touch-action: none !important;
    /* Force touch action none */
}

#score {
    position: absolute;
    top: 15%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 5rem;
    font-weight: 900;
    color: white;
    text-shadow: 4px 4px 0 rgba(0, 0, 0, 0.2);
    z-index: 5;
    pointer-events: none;
    font-family: 'Fredoka', sans-serif;
}


/* Parallax Backgrounds */
.parallax-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 200%;
    /* Wider for seamless scrolling */
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

.layer-sky {
    background: linear-gradient(to bottom, #A2D2FF 0%, #E0BBE4 100%);
    z-index: 0;
}

.floating-cloud {
    position: absolute;
    background: white;
    border-radius: 50%;
    opacity: 0.8;
}

.floating-cloud::after,
.floating-cloud::before {
    content: '';
    position: absolute;
    background: inherit;
    border-radius: 50%;
}

.c1 {
    width: 100px;
    height: 40px;
    top: 10%;
    left: 10%;
    animation: float 25s linear infinite;
}

.c1::after {
    width: 50px;
    height: 50px;
    top: -25px;
    left: 15px;
}

.c1::before {
    width: 40px;
    height: 40px;
    top: -15px;
    left: 50px;
}

.c2 {
    width: 80px;
    height: 35px;
    top: 25%;
    left: 60%;
    animation: float 20s linear infinite;
    opacity: 0.6;
}

.c2::after {
    width: 40px;
    height: 40px;
    top: -20px;
    left: 10px;
}

@keyframes float {
    from {
        transform: translateX(100vw);
    }

    to {
        transform: translateX(-200px);
    }
}

.floating-item {
    position: absolute;
    font-size: 1.5rem;
    animation: float 20s linear infinite;
    opacity: 0.8;
}

.star.s1 {
    top: 15%;
    animation-duration: 35s;
    animation-delay: 2s;
}

.star.s2 {
    top: 35%;
    animation-duration: 28s;
    animation-delay: 7s;
}

.hill-deco {
    position: absolute;
    bottom: 10px;
    font-size: 1.8rem;
    animation: scroll-items 20s linear infinite;
}

.layer-hills-back .t1 {
    left: 20%;
    animation-duration: 20s;
}

.layer-hills-back .t2 {
    left: 70%;
    animation-duration: 20s;
}

.layer-hills-front .b1 {
    left: 40%;
    animation-duration: 10s;
    bottom: 0;
    font-size: 2rem;
}

.layer-hills-front .b2 {
    left: 90%;
    animation-duration: 10s;
    bottom: 0;
    font-size: 2rem;
}

@keyframes scroll-items {
    0% {
        transform: translateX(100vw);
    }

    100% {
        transform: translateX(-100vw);
    }
}

.layer-mountains {
    background-image:
        radial-gradient(circle at 50% 100%, #D4A5A5 10%, transparent 12%),
        /* Candy Mountains */
        radial-gradient(circle at 80% 100%, #D4A5A5 15%, transparent 16%),
        radial-gradient(circle at 20% 100%, #D4A5A5 12%, transparent 13%);
    background-size: 50% 100%;
    background-repeat: repeat-x;
    bottom: 0;
    z-index: 1;
    animation: scroll-bg 40s linear infinite;
    opacity: 0.7;
}

.layer-hills-back {
    background-image: radial-gradient(ellipse at 50% 105%, #C1E1C1 40%, transparent 41%);
    background-size: 300px 100px;
    background-position: 0 bottom;
    background-repeat: repeat-x;
    height: 100px;
    bottom: 0px;
    top: auto;
    z-index: 2;
    animation: scroll-bg 20s linear infinite;
}

.layer-hills-front {
    background-image: radial-gradient(ellipse at 50% 110%, #FFB7CE 45%, transparent 46%);
    background-size: 400px 150px;
    background-position: 0 bottom;
    background-repeat: repeat-x;
    height: 150px;
    bottom: -20px;
    top: auto;
    z-index: 3;
    animation: scroll-bg 10s linear infinite;
}

@keyframes scroll-bg {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-50%);
    }
}

/* Custom Cupcake Character */
.character {
    position: absolute;
    width: 60px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    left: 50px;
    transition: transform 0.1s;
}

.wing {
    position: absolute;
    width: 25px;
    height: 15px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50% 50% 10% 10%;
    z-index: -1;
    animation: flap 0.3s ease-in-out infinite alternate;
    top: 25px;
}

.wing-left {
    left: -10px;
    top: 20px;
    width: 30px;
    height: 18px;
    background: #FFD;
    border: 2px solid #EEE;
    transform-origin: right center;
}

.wing-right {
    display: none;
}

@keyframes flap {
    0% {
        transform: rotate(10deg);
    }

    100% {
        transform: rotate(-30deg);
    }
}

/* Improved Kawaii Cupcake */
.character {
    /* ... positioning remains same in other block .. */
    width: 50px;
    /* Resize for better hit box match */
    height: 50px;
}

.cupcake-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 4px 5px rgba(0, 0, 0, 0.2));
    animation: bounce-idle 1s infinite alternate ease-in-out;
}

@keyframes bounce-idle {
    from {
        transform: scale(1);
    }

    to {
        transform: scale(1.05);
    }
}

.cup {
    position: absolute;
    bottom: 0;
    left: 10%;
    width: 80%;
    height: 35%;
    background: repeating-linear-gradient(90deg,
            #D2691E,
            #D2691E 6px,
            #8B4513 6px,
            #8B4513 12px);
    border-radius: 0 0 10px 10px;
    transform: perspective(30px) rotateX(5deg);
    z-index: 1;
}

/* Swirly Frosting using layered blobs */
.frosting {
    position: absolute;
    bottom: 30%;
    left: 0;
    width: 100%;
    height: 55%;
    background: #FFB7CE;
    /* Pink frosting */
    border-radius: 50% 50% 40% 40%;
    z-index: 2;
}

.frosting::before {
    /* Second layer swirl */
    content: '';
    position: absolute;
    top: -15px;
    left: 15%;
    width: 70%;
    height: 80%;
    background: #FFC0D3;
    /* Lighter pink */
    border-radius: 50%;
    z-index: 3;
}

.frosting::after {
    /* Top dollop */
    content: '';
    position: absolute;
    top: -25px;
    left: 30%;
    width: 40%;
    height: 60%;
    background: #FFE4E9;
    /* Highlight pink */
    border-radius: 50% 50% 60% 40%;
    transform: rotate(-10deg);
    z-index: 4;
}

/* Cherry on top */
.cupcake-wrapper::after {
    content: '';
    position: absolute;
    top: -20px;
    left: 45%;
    width: 12px;
    height: 12px;
    background: #FF0040;
    border-radius: 50%;
    box-shadow: -1px -1px 0 rgba(0, 0, 0, 0.1) inset;
    z-index: 5;
}

/* Cute Face */
.face {
    position: absolute;
    bottom: 35%;
    /* On the frosting */
    left: 20%;
    width: 60%;
    height: 20%;
    z-index: 6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 5px;
}

.eye {
    width: 6px;
    height: 6px;
    background: #333;
    border-radius: 50%;
    position: relative;
    animation: blink 4s infinite;
}

.eye::after {
    content: '';
    position: absolute;
    top: 1px;
    left: 1px;
    width: 2px;
    height: 2px;
    background: white;
    border-radius: 50%;
}

@keyframes blink {

    0%,
    96%,
    100% {
        transform: scaleY(1);
    }

    98% {
        transform: scaleY(0.1);
    }
}

.mouth {
    position: absolute;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: 8px;
    height: 4px;
    background: transparent;
    border-bottom: 2px solid #333;
    border-radius: 0 0 50% 50%;
}

.cheeks {
    position: absolute;
    top: 50%;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 2px;
}

.cheeks::before,
.cheeks::after {
    content: '';
    width: 5px;
    height: 3px;
    background: #FF69B4;
    border-radius: 50%;
    opacity: 0.6;
}


/* Marshmallow Obstacles */
.obstacle {
    position: absolute;
    width: 60px;
    background: repeating-linear-gradient(-45deg,
            #FFB7CE,
            #FFB7CE 15px,
            #A2D2FF 15px,
            #A2D2FF 30px,
            #FFF5A5 30px,
            #FFF5A5 45px,
            #FFFFFF 45px,
            #FFFFFF 60px);
    border: 2px solid rgba(0, 0, 0, 0.05);
    box-shadow: inset 5px 0 10px rgba(0, 0, 0, 0.1), 5px 5px 10px rgba(0, 0, 0, 0.1);
    z-index: 5;
}

.obstacle-top {
    top: 0;
    border-bottom-left-radius: 15px;
    border-bottom-right-radius: 15px;
    border-bottom: 3px solid rgba(255, 255, 255, 0.8);
}

.obstacle-bottom {
    bottom: 0;
    border-top-left-radius: 15px;
    border-top-right-radius: 15px;
    border-top: 3px solid rgba(255, 255, 255, 0.8);
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 20;
    opacity: 0;
    visibility: hidden;
    /* Hide from keyboard/screen readers */
    pointer-events: none;
    transition: opacity 0.3s, visibility 0s 0.3s;
    /* Delay visibility change */
    color: white;
    text-align: center;
}

.screen.active {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
    transition: opacity 0.3s;
}

.screen h1 {
    font-size: 3.5rem;
    color: var(--primary);
    text-shadow: 2px 2px 0 #FFF, -1px -1px 0 #FFF, 1px -1px 0 #FFF, -1px 1px 0 #FFF, 1px 1px 0 #FFF;
    margin-bottom: 20px;
}

.screen h2 {
    font-size: 2.5rem;
    margin-bottom: 20px;
}

.tutorial-icon {
    font-size: 3rem;
    margin-top: 30px;
    animation: bounce 1s infinite alternate;
}

@keyframes bounce {
    from {
        transform: translateY(0);
    }

    to {
        transform: translateY(-10px);
    }
}

#restart-btn {
    padding: 15px 30px;
    font-size: 1.2rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 25px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 0 #FF8FAB;
    transition: transform 0.1s;
    margin-top: 20px;
}

/* #start-btn replaced by difficulty settings */

.difficulty-container {
    margin-top: 30px;
    background: rgba(255, 255, 255, 0.2);
    padding: 20px;
    border-radius: 15px;
}

.difficulty-container p {
    font-size: 1.2rem;
    margin-bottom: 15px;
}

.difficulty-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    /* For logic on very small screens */
}

.diff-btn {
    padding: 10px 20px;
    font-size: 1.1rem;
    border: none;
    border-radius: 20px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
    transition: transform 0.1s, filter 0.2s;
    color: var(--text);
}

.diff-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 rgba(0, 0, 0, 0);
}

.easy {
    background: #C1E1C1;
    color: #3A5A3A;
}

.normal {
    background: #FFF5A5;
    color: #5A5A3A;
}

.hard {
    background: #FFB7CE;
    color: #5A3A3A;
}

.diff-btn:hover {
    filter: brightness(1.1);
}

#restart-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #FF8FAB;
}

.result-score {
    font-size: 1.5rem;
    margin-bottom: 5px;
}

.result-best {
    font-size: 1rem;
    opacity: 0.8;
}

@media (min-width: 481px) {
    #game-container {
        border-radius: 20px;
        margin: 20px;
    }
}

/* Rankings & Nickname UI */
.rankings-btn-menu {
    margin-top: 15px;
    padding: 10px 20px;
    font-size: 1rem;
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    color: var(--text);
    border: none;
    border-radius: 20px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
}

.rankings-content,
.nickname-content {
    background: rgba(255, 255, 255, 0.9);
    width: 90%;
    max-width: 400px;
    height: 90%;
    border-radius: 20px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    color: var(--text);
    overflow: hidden;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.nickname-content {
    height: auto;
    max-height: 90%;
    justify-content: center;
}

.rankings-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    border-bottom: 2px solid var(--primary);
    padding-bottom: 10px;
}

.rankings-header h2 {
    font-size: 1.8rem;
    margin: 0;
    color: var(--primary);
}

.mini-btn {
    background: var(--secondary);
    border: none;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    cursor: pointer;
    font-size: 1.2rem;
}

.rankings-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    flex: 1;
}

.filter-group label {
    font-size: 0.8rem;
    margin-bottom: 2px;
    color: #666;
}

select {
    width: 100%;
    padding: 8px;
    border-radius: 10px;
    border: 1px solid #CCC;
    background: white;
    font-family: 'Fredoka', sans-serif;
}

.rankings-list {
    flex: 1;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 10px;
    padding: 10px;
}

.ranking-item {
    display: flex;
    align-items: center;
    background: white;
    padding: 8px 12px;
    border-radius: 10px;
    margin-bottom: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.rank-position {
    font-weight: bold;
    font-size: 1.2rem;
    width: 30px;
    text-align: center;
}

.rank-flag {
    font-size: 1.5rem;
    margin: 0 10px;
}

.rank-info {
    flex: 1;
    text-align: left;
}

.rank-nickname {
    font-weight: bold;
    color: var(--text);
}

.rank-date {
    font-size: 0.7rem;
    color: #999;
}

.rank-score {
    font-weight: bold;
    font-size: 1.2rem;
    color: var(--primary);
}

.top-1 {
    font-size: 1.5rem;
}

.top-2 {
    font-size: 1.4rem;
}

.top-3 {
    font-size: 1.3rem;
}

#nickname-input {
    width: 100%;
    padding: 15px;
    border-radius: 10px;
    border: 2px solid var(--secondary);
    font-size: 1.2rem;
    text-align: center;
    margin: 20px 0;
    font-family: 'Fredoka', sans-serif;
}

.nickname-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.main-btn {
    padding: 10px 25px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 15px;
    font-weight: bold;
    cursor: pointer;
}

.secondary-btn {
    padding: 10px 25px;
    background: #CCC;
    color: white;
    border: none;
    border-radius: 15px;
    font-weight: bold;
    cursor: pointer;
}
