:root {
    /* Palette - Soft Pastels */
    --bg-lvl1: linear-gradient(180deg, #A2D2FF 0%, #CDB4DB 100%);
    /* Sky */
    --bg-lvl2: linear-gradient(180deg, #FFC8DD 0%, #FFAFCC 100%);
    /* Candy */
    --bg-lvl3: linear-gradient(180deg, #D4A373 0%, #FEFAE0 100%);
    /* Lofi/Cozy */

    --primary: #FF9AA2;
    --secondary: #B5EAD7;
    --accent: #FFDAC1;
    --text: #5D5D5D;

    --white-trans: rgba(255, 255, 255, 0.85);
    --glass: rgba(255, 255, 255, 0.4);

    --font-heading: 'Fredoka', sans-serif;
    --font-body: 'Quicksand', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

body {
    font-family: var(--font-body);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    background: white;
    /* Background for the content part */
    /* Default */
}

#app {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    justify-content: center;
}

/* Common UI */
button {
    font-family: var(--font-heading);
    border: none;
    cursor: pointer;
    transition: transform 0.1s;
}

button:active {
    transform: scale(0.95);
}

.screen {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s;
    padding: 20px;
    padding-top: 80px;
    /* Nav space */
}

.screen.active {
    opacity: 1;
    pointer-events: all;
    z-index: 10;
}

/* Top Nav */
.top-nav {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px 20px;
    z-index: 50;
    gap: 20px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(5px);
}

.home-logo {
    height: 50px;
    transition: transform 0.2s;
}

.home-logo:hover {
    transform: scale(1.1) rotate(-5deg);
}

.nav-controls {
    display: flex;
    gap: 10px;
}

.lang-btn,
.sound-toggle-mini {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--white-trans);
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.lang-btn img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 4px;
}

.lang-btn.active {
    border: 2px solid var(--primary);
    transform: scale(1.1);
}

/* Menu Screen */
.logo-container {
    text-align: center;
    margin-bottom: 30px;
    animation: float 3s infinite ease-in-out;
}

.game-title {
    font-family: var(--font-heading);
    font-size: 3rem;
    line-height: 1;
    color: white;
    text-shadow: 3px 3px 0 var(--primary);
}

.game-title .highlight {
    color: #FFF;
    text-shadow: 3px 3px 0 #FF9AA2;
}

.subtitle {
    font-size: 1.2rem;
    background: var(--white-trans);
    padding: 5px 15px;
    border-radius: 20px;
    margin-top: 10px;
    display: inline-block;
    font-weight: 700;
}

.level-selector {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    max-width: 350px;
}

.level-btn {
    display: flex;
    align-items: center;
    background: var(--white-trans);
    padding: 15px;
    border-radius: 20px;
    text-align: left;
    gap: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    border: 3px solid transparent;
}

.level-btn:hover {
    background: white;
    transform: translateY(-3px);
}

.lvl-icon {
    font-size: 2rem;
}

.lvl-info {
    display: flex;
    flex-direction: column;
}

.lvl-name {
    font-weight: bold;
    font-size: 1.1rem;
    color: var(--text);
}

.lvl-desc {
    font-size: 0.8rem;
    opacity: 0.8;
}

.lvl-1 {
    border-color: #A2D2FF;
}

/* Easy color */
.lvl-2 {
    border-color: #FFB7B2;
}

/* Medium color */
.lvl-3 {
    border-color: #E2F0CB;
}

/* Hard color */

.rules-btn {
    margin-top: 25px;
    background: white;
    color: var(--text);
    font-size: 1.1rem;
    padding: 12px 30px;
    border-radius: 50px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    font-weight: bold;
    text-decoration: none;
    transition: transform 0.2s, box-shadow 0.2s;
    width: 100%;
    max-width: 350px;
}

.rules-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);
}

/* Decorations */
.decorations {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

.cloud,
.star {
    position: absolute;
    opacity: 0.6;
}

.c1 {
    top: 20%;
    left: 10%;
    font-size: 4rem;
    animation: floatLeft 20s infinite;
}

.c2 {
    top: 40%;
    right: 10%;
    font-size: 3rem;
    animation: floatRight 25s infinite;
}

.s1 {
    top: 15%;
    right: 20%;
    font-size: 2rem;
    animation: twinkle 2s infinite;
}

.s2 {
    top: 60%;
    left: 15%;
    font-size: 1.5rem;
    animation: twinkle 3s infinite alternate;
}

/* Game Screen */
.game-ui-header {
    width: 100%;
    max-width: 500px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--white-trans);
    padding: 10px 20px;
    border-radius: 25px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 10px;
    position: relative;
    z-index: 20;
}

.score-container,
.lives-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-weight: bold;
}

.label {
    font-size: 0.7rem;
    text-transform: uppercase;
    opacity: 0.6;
    letter-spacing: 1px;
}

#score-val {
    font-size: 1.5rem;
    color: var(--primary);
}

#lives-display {
    letter-spacing: -3px;
}

.target-container {
    position: absolute;
    left: 50%;
    top: -10px;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.target-fruit {
    font-size: 3.5rem;
    filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.1));
    z-index: 2;
}

.target-val-wrapper {
    position: absolute;
    top: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 3;
    pointer-events: none;
}

.target-label {
    font-size: 0.5rem;
    font-weight: 900;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

#target-val {
    font-size: 1.4rem;
    font-weight: 900;
    color: white;
    text-shadow: 1px 1px 0 #000;
    line-height: 1;
    margin-top: -2px;
}

.game-area {
    position: relative;
    width: 100%;
    max-width: 500px;
    flex: 1;
    border-radius: 20px;
    overflow: hidden;
    /* Canvas background is transparent so body bg shows through */
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.1);
}

#game-canvas {
    width: 100%;
    height: 100%;
    touch-action: none;
}

#current-sum-display {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--white-trans);
    padding: 10px 25px;
    border-radius: 30px;
    font-size: 1.2rem;
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    pointer-events: none;
    border: 2px solid var(--primary);
}

.mascot-container {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 120px;
    height: 120px;
    pointer-events: none;
    z-index: 10;
    /* Center crop */
    display: flex;
    justify-content: center;
    align-items: center;
}

#mascot-img {
    width: 90%;
    height: 90%;
    object-fit: cover;
    transition: transform 0.2s;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.2));
    border-radius: 50%;
    /* Make it circular */
    border: 4px solid white;
    /* Sticker effect */
    background: white;
    /* Ensure background is white if transparent part fails */
}

.mascot-dance {
    animation: dance 0.5s ease-in-out infinite alternate;
}

.game-controls {
    display: flex;
    gap: 15px;
    margin-top: 10px;
}

.mini-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: white;
    font-size: 1.5rem;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 25px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    position: relative;
    border: 4px solid var(--secondary);
}

.rules-body {
    text-align: left;
    margin-top: 20px;
    line-height: 1.6;
}

.close-modal {
    position: absolute;
    top: -15px;
    right: -15px;
    background: var(--primary);
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    font-size: 1.2rem;
}

.primary-btn {
    background: var(--primary);
    color: white;
    padding: 12px 25px;
    border-radius: 30px;
    font-size: 1.1rem;
}

.secondary-btn {
    background: #eee;
    color: var(--text);
    padding: 12px 25px;
    border-radius: 30px;
    font-size: 1.1rem;
}

.modal-actions {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    gap: 15px;
}

/* Keyframes */
@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

@keyframes floatLeft {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(20px);
    }
}

@keyframes floatRight {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-20px);
    }
}

@keyframes twinkle {

    0%,
    100% {
        opacity: 0.6;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

@keyframes dance {
    0% {
        transform: rotate(-10deg) translateY(0);
    }

    100% {
        transform: rotate(10deg) translateY(-5px);
    }
}
