* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Comic Neue', 'Comic Sans MS', 'Arial Rounded MT Bold', sans-serif;
    /* Kitchen / Picnic Background */
    /* HINT: Change the main background color here */
    background-color: #76c442; /* Vibrant Grass Green */
    background-image:
        /* Sunlight */
        radial-gradient(circle at 50% 0%, rgba(255, 255, 224, 0.4) 0%, transparent 70%),
        /* Picnic Checkered Pattern */
        linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.15) 75%, rgba(255, 255, 255, 0.15)),
        linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.15) 75%, rgba(255, 255, 255, 0.15));
    background-size: 100% 100%, 60px 60px, 60px 60px;
    background-position: 0 0, 0 0, 30px 30px;
    background-attachment: fixed;
    min-height: 100vh;
    height: 100dvh; /* Fix for iOS address bar sizing issues */
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow: hidden;
    position: relative;
}

/* Main Menu */
.main-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #FFE5B4 0%, #FFF4E0 30%, #FFEDCC 60%, #E8D4A0 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9998;
}

.menu-bg-decorations {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.menu-container {
    text-align: center;
    animation: menuFadeIn 0.8s ease-out;
}

@keyframes menuFadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.menu-title-wrapper {
    position: relative;
    margin-bottom: 60px;
}

.menu-title {
    font-family: 'Fredoka One', 'Comic Neue', sans-serif;
    font-size: 6em;
    color: #FF6B6B;
    text-shadow:
        0 0 20px rgba(255, 107, 107, 0.5),
        4px 4px 0 #FFB7B2,
        8px 8px 0 #E2F0CB,
        12px 12px 20px rgba(0, 0, 0, 0.2);
    animation: titleBounce 2s ease-in-out infinite, titleRainbow 3s linear infinite;
    margin: 0;
    position: relative;
    z-index: 2;
}

@keyframes titleBounce {
    0%, 100% {
        transform: translateY(0px) scale(1);
    }
    50% {
        transform: translateY(-20px) scale(1.05);
    }
}

@keyframes titleRainbow {
    0% { filter: hue-rotate(0deg); }
    100% { filter: hue-rotate(360deg); }
}

.title-emoji-left,
.title-emoji-right {
    position: absolute;
    font-size: 4em;
    animation: emojiSpin 3s linear infinite;
}

.title-emoji-left {
    left: -80px;
    top: 50%;
    transform: translateY(-50%);
}

.title-emoji-right {
    right: -80px;
    top: 50%;
    transform: translateY(-50%);
    animation-direction: reverse;
}

@keyframes emojiSpin {
    from { transform: translateY(-50%) rotate(0deg); }
    to { transform: translateY(-50%) rotate(360deg); }
}

.bouncing-fruits {
    position: absolute;
    bottom: -60px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 20px;
}

.bounce-fruit {
    font-size: 2.5em;
    animation: fruitBounce 1s ease-in-out infinite;
    filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.3));
}

@keyframes fruitBounce {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    25% {
        transform: translateY(-30px) rotate(-10deg);
    }
    50% {
        transform: translateY(0) rotate(0deg);
    }
    75% {
        transform: translateY(-15px) rotate(10deg);
    }
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 40px;
}

.menu-btn {
    font-family: 'Fredoka One', 'Comic Neue', sans-serif;
    font-size: 2em;
    padding: 20px 60px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    position: relative;
    overflow: hidden;
}

.menu-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.menu-btn:hover::before {
    width: 300px;
    height: 300px;
}

.menu-btn-play {
    background: linear-gradient(135deg, #FF6B6B, #FF8787);
    color: white;
    animation: playButtonPulse 2s ease-in-out infinite;
}

@keyframes playButtonPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 8px 20px rgba(255, 107, 107, 0.4);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 12px 30px rgba(255, 107, 107, 0.6);
    }
}

.menu-btn-settings {
    background: linear-gradient(135deg, #87CEEB, #4682B4);
    color: white;
}

.menu-btn-back {
    background: linear-gradient(135deg, #FFB347, #FFA07A);
    color: white;
    margin-top: 20px;
}

.menu-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
}

.menu-btn:active {
    transform: translateY(-2px);
}

.btn-icon {
    font-size: 1.2em;
    position: relative;
    z-index: 1;
}

.menu-btn span {
    position: relative;
    z-index: 1;
}

.settings-panel {
    background: rgba(255, 255, 255, 0.9);
    padding: 40px;
    border-radius: 30px;
    margin-top: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    animation: slideDown 0.4s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.settings-panel h3 {
    font-family: 'Fredoka One', 'Comic Neue', sans-serif;
    font-size: 2em;
    color: #FF6B6B;
    margin-bottom: 30px;
}

.setting-item {
    margin-bottom: 25px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.setting-item label {
    font-size: 1.3em;
    color: #8B6914;
    font-weight: bold;
}

.setting-item input[type="range"] {
    width: 100%;
    height: 10px;
    border-radius: 5px;
    background: linear-gradient(to right, #FF6B6B, #FFB7B2);
    outline: none;
    -webkit-appearance: none;
}

.setting-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background: #FF6B6B;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
    transition: all 0.2s;
}

.setting-item input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.setting-item input[type="range"]::-moz-range-thumb {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background: #FF6B6B;
    cursor: pointer;
    border: none;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}

#volumeValue {
    font-size: 1.2em;
    color: #FF6B6B;
    font-weight: bold;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #FFE5B4 0%, #FFF4E0 30%, #FFEDCC 60%, #E8D4A0 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-content {
    text-align: center;
    background: rgba(255, 255, 255, 0.9);
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.loading-content h2 {
    color: #FF6B6B;
    font-size: 2em;
    margin-bottom: 20px;
}

.spinner {
    border: 5px solid rgba(255, 107, 107, 0.3);
    border-top: 5px solid #FF6B6B;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-content p {
    color: #8B6914;
    font-size: 1.1em;
}

/* Animated Background Stars */
.background-stars {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    background-image:
        radial-gradient(2px 2px at 20% 30%, white, transparent),
        radial-gradient(2px 2px at 60% 70%, white, transparent),
        radial-gradient(3px 3px at 50% 50%, white, transparent),
        radial-gradient(2px 2px at 80% 10%, white, transparent),
        radial-gradient(2px 2px at 90% 60%, white, transparent);
    background-size: 200% 200%;
    animation: twinkle 3s ease-in-out infinite;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.8; }
}

/* Main Layout */
.game-layout {
    display: flex;
    gap: 30px;
    max-width: 100%;
    width: 100%;
    max-height: 95vh;
    z-index: 1;
    position: relative;
    transform: scale(0.85);
    transform-origin: center center;
}

/* Left Panel */
/* HINT: This controls the middle section where the game is */
.left-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 280px;
    min-width: 280px;
    max-width: 280px;
    align-items: center; /* Centers the score circle and other items */
}

.score-circle {
    /* HINT: Change the Score Circle colors here */
    background: linear-gradient(135deg, #FFB7B2, #FFDAC1);
    border: 5px solid #FF9AA2;
    border-radius: 50%;
    width: 180px;
    height: 180px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2), inset 0 -5px 15px rgba(0, 0, 0, 0.1);
    position: relative;
}

.circle-label {
    font-size: 1.2em;
    font-weight: bold;
    color: #FF6B6B;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
}

.circle-value {
    font-size: 2.5em;
    font-weight: bold;
    color: #FFF;
    text-shadow: 2px 2px 0px #FF9AA2, 0 0 5px rgba(0,0,0,0.1);
}

.best-score {
    position: absolute;
    bottom: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.7em;
    color: #FF6B6B;
}

.best-score span:first-child {
    font-size: 0.8em;
    opacity: 0.8;
}

.best-score span:last-child {
    font-weight: bold;
    font-size: 1.2em;
}

.stats-panel {
    background: linear-gradient(135deg, #FFF5E6, #FFE0B2);
    border: 4px solid #FFCC80;
    border-radius: 20px;
    padding: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    width: 100%; /* Ensure it fills the panel width */
}

.stats-title {
    font-size: 1.2em;
    font-weight: bold;
    color: #E67E22;
    text-align: center;
    margin-bottom: 10px;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
    text-align: center;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    font-size: 0.8em;
    color: #D35400;
    font-weight: bold;
}

.stat-value {
    font-size: 1.2em;
    font-weight: bold;
    color: #E67E22;
}

.ranking-panel {
    background: linear-gradient(135deg, #E2F0CB, #B5EAD7);
    border: 4px solid #95D1B0;
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    width: 100%; /* Ensure it fills the panel width */
}

.ranking-title {
    font-size: 1.5em;
    font-weight: bold;
    color: #558B6E;
    text-align: center;
    margin-bottom: 20px;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
}

.ranking-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.rank-item {
    background: rgba(255, 255, 255, 0.5);
    padding: 20px 20px;
    border-radius: 10px;
    display: grid;
    grid-template-columns: 45px 1fr auto; /* Rank | Name | Score */
    align-items: center;
    gap: 15px;
    font-weight: bold;
    font-size: .89em;
    min-height: 75px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.rank-name {
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.8em;
    color: rgba(0,0,0,0.6);
}

.rank-1 { background: linear-gradient(135deg, #FFD700, #FFA500); color: white; }
.rank-2 { background: linear-gradient(135deg, #C0C0C0, #A8A8A8); color: white; }
.rank-3 { background: linear-gradient(135deg, #CD7F32, #8B4513); color: white; }
.rank-you { background: linear-gradient(135deg, #87CEEB, #4682B4); color: white; }

/* Center Panel */
.center-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.game-header {
    text-align: center;
}

/* Cloud-like Arcade Title */
.game-title.cloud-title {
    font-size: 3.5em;
    color: #FFFFFF;
    font-family: 'Fredoka One', 'Comic Neue', sans-serif;
    text-shadow:
        0 0 20px rgba(135, 206, 250, 0.8),
        0 0 40px rgba(135, 206, 250, 0.6),
        4px 4px 0 #87CEEB,
        8px 8px 0 #B0E0E6,
        12px 12px 20px rgba(0, 0, 0, 0.3);
    position: relative;
    padding: 0px 20px;
    margin-top: 0px;
    animation: cloudFloat 4s ease-in-out infinite, titleShimmer 2s ease-in-out infinite;
    letter-spacing: 0.05em;
}

.game-title.cloud-title::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 110%;
    height: 120%;
    background: radial-gradient(ellipse,
        rgba(255, 255, 255, 0.4) 0%,
        rgba(227, 242, 253, 0.3) 40%,
        transparent 70%
    );
    border-radius: 50%;
    z-index: -1;
    filter: blur(20px);
    animation: cloudPulse 3s ease-in-out infinite;
}

@keyframes cloudFloat {
    0%, 100% {
        transform: translateY(0px) scale(1);
    }
    50% {
        transform: translateY(-15px) scale(1.02);
    }
}

@keyframes cloudPulse {
    0%, 100% {
        opacity: 0.6;
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        opacity: 0.9;
        transform: translate(-50%, -50%) scale(1.1);
    }
}

@keyframes titleShimmer {
    0%, 100% {
        text-shadow:
            0 0 20px rgba(135, 206, 250, 0.8),
            0 0 40px rgba(135, 206, 250, 0.6),
            4px 4px 0 #87CEEB,
            8px 8px 0 #B0E0E6,
            12px 12px 20px rgba(0, 0, 0, 0.3);
    }
    50% {
        text-shadow:
            0 0 30px rgba(135, 206, 250, 1),
            0 0 50px rgba(135, 206, 250, 0.8),
            4px 4px 0 #87CEEB,
            8px 8px 0 #B0E0E6,
            12px 12px 25px rgba(0, 0, 0, 0.4);
    }
}

.game-header {
    position: relative;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-10px); }
    20%, 40%, 60%, 80% { transform: translateX(10px); }
}

.next-fruit-display {
    background: linear-gradient(135deg, #E0BBE4, #957DAD);
    border: 4px solid #D291BC;
    border-radius: 15px;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.next-label {
    font-size: 1.2em;
    font-weight: bold;
    color: #FFFFFF;
}

.game-container {
    /* HINT: This is the box containing the game canvas */
    position: relative;
    background: transparent; /* We draw the bag in canvas now */
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    border: none;
    width: 100%;
    max-width: 700px;
    max-height: 85vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.game-container::before {
    display: none;
}

#gameCanvas {
    display: block;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    cursor: crosshair;
    max-width: 100%;
    max-height: 85vh;
    width: auto;
    height: auto;
    object-fit: contain;
    touch-action: none; /* Prevents scrolling while playing on mobile */
    position: relative;
    z-index: 2;
}

.game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 0;
    backdrop-filter: blur(10px);
    z-index: 3;
}

.game-overlay.hidden {
    display: none;
}

.game-over-box {
    background: linear-gradient(135deg, #FFF8DC, #FFE4B5);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    border: 5px solid #D4A574;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    animation: popIn 0.3s ease-out;
}

@keyframes popIn {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.game-over-box h2 {
    font-size: 2.5em;
    color: #FF6B6B;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.final-score-display {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 30px;
    font-size: 1.5em;
    color: #8B6914;
}

.final-score-display span:last-child {
    font-size: 1.8em;
    font-weight: bold;
    color: #D4A574;
}

.name-input {
    padding: 12px;
    font-size: 1.2em;
    border-radius: 15px;
    border: 3px solid #FF6B6B;
    width: 80%;
    margin-bottom: 15px;
    font-family: inherit;
    text-align: center;
    outline: none;
    background: rgba(255, 255, 255, 0.9);
}

.btn-submit {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 1.1em;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(255, 215, 0, 0.4);
    transition: all 0.3s ease;
    font-family: inherit;
    display: block;
    margin: 0 auto 15px auto;
}

.btn-submit:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(255, 215, 0, 0.6);
}

.high-score-msg {
    color: #E67E22;
    font-weight: bold;
    margin-bottom: 15px;
    font-size: 1.1em;
}

.btn-restart {
    background: linear-gradient(135deg, #FF6B6B, #FF8787);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.3em;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(255, 107, 107, 0.4);
    transition: all 0.3s ease;
    font-family: inherit;
}

.btn-restart:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(255, 107, 107, 0.6);
}

.btn-restart:active {
    transform: translateY(0);
}

.controls-hint {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.control-item {
    background: rgba(255, 255, 255, 0.8);
    padding: 8px 15px;
    border-radius: 10px;
    font-size: 0.9em;
    color: #8B6914;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* Power-ups */
.powerups-container {
    background: linear-gradient(135deg, #FFF8DC, #FFE4B5);
    border: 4px solid #D4A574;
    border-radius: 20px;
    padding: 20px;
    margin-top: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.powerups-title {
    font-size: 1.3em;
    font-weight: bold;
    color: #8B6914;
    text-align: center;
    margin-bottom: 15px;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
}

.powerups-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 15px;
}

.powerup-btn {
    background: linear-gradient(135deg, #FFF, #F0E68C);
    border: 3px solid #D4A574;
    border-radius: 15px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    font-family: inherit;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.powerup-btn:not(:disabled):hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    background: linear-gradient(135deg, #FFD700, #FFA500);
}

.powerup-btn:not(:disabled):active {
    transform: translateY(-2px);
}

.powerup-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: linear-gradient(135deg, #E0E0E0, #C0C0C0);
}

.powerup-btn.active {
    background: linear-gradient(135deg, #90EE90, #32CD32);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.powerup-icon {
    font-size: 2em;
    display: block;
    margin-bottom: 5px;
}

.powerup-count {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #FF6B6B;
    color: white;
    font-weight: bold;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 0.9em;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.next-powerup-info {
    text-align: center;
    color: #8B6914;
    font-weight: bold;
    font-size: 0.9em;
    padding: 10px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 10px;
}

.powerup-notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: white;
    padding: 20px 40px;
    border-radius: 15px;
    font-size: 2em;
    font-weight: bold;
    z-index: 10000;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    animation: popIn 0.3s ease-out;
    transition: opacity 0.3s;
}

/* Right Panel */
.right-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 280px;
    min-width: 280px;
    max-width: 280px;
}

.next-circle {
    background: linear-gradient(135deg, #B5EAD7, #C7CEEA);
    border: 5px solid #95D1B0;
    border-radius: 50%;
    width: 180px;
    height: 180px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2), inset 0 -5px 15px rgba(0, 0, 0, 0.1);
    gap: 10px;
}

.evolution-panel {
    background: linear-gradient(135deg, #FFFFD1, #FFDAC1);
    border: 4px solid #FFB7B2;
    border-radius: 20px;
    padding: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.evolution-title {
    font-size: 1em;
    font-weight: bold;
    color: #FF6B6B;
    text-align: center;
    margin-bottom: 15px;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
}

.evolution-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
}

.evolution-item {
    background: rgba(255, 255, 255, 0.5);
    border-radius: 10px;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    position: relative;
}

.evolution-item canvas {
    width: 100%;
    height: 100%;
}

.fun-fact-panel {
    /* HINT: Change the "Did You Know?" box colors here */
    background: linear-gradient(135deg, #E1F5FE, #B3E5FC);
    border: 4px solid #81D4FA;
    border-radius: 20px;
    padding: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    text-align: center;
    animation: fadeIn 0.5s ease-out;
    height: 220px;
    min-height: 220px;
    max-height: 220px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
    margin-top: 20px;
}

.fun-fact-title {
    font-size: 1.1em;
    font-weight: bold;
    color: #0288D1;
    margin-bottom: 10px;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
}

.fun-fact-content {
    font-size: 0.95em;
    color: #01579B;
    font-style: italic;
    line-height: 1.4;
    font-family: 'Comic Neue', 'Comic Sans MS', sans-serif;
    overflow-y: auto;
    max-height: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Inline SUPER button (replaces old squishy-lives-panel) */
.super-squishy-inline-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    border: 3px solid rgba(255, 255, 255, 0.8);
    border-radius: 50px;
    padding: 10px 20px;
    margin-top: 15px;
    cursor: pointer;
    font-family: 'Fredoka One', 'Comic Neue', sans-serif;
    font-size: 1.1em;
    color: white;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.2);
    animation: superRgbGlow 3s ease-in-out infinite, superPulse 2s ease-in-out infinite;
    transition: transform 0.1s;
    touch-action: manipulation;
    width: 100%;
}

.super-squishy-inline-btn:active {
    transform: scale(0.95);
}

.super-btn-label {
    white-space: nowrap;
}

.super-btn-stars {
    letter-spacing: 2px;
}

/* RGB glow cycle when super is available */
@keyframes superRgbGlow {
    0%   { box-shadow: 0 0 10px #ff0000, 0 0 20px #ff000066, 0 0 30px #ff000033; }
    16%  { box-shadow: 0 0 10px #ff8800, 0 0 20px #ff880066, 0 0 30px #ff880033; }
    33%  { box-shadow: 0 0 10px #ffff00, 0 0 20px #ffff0066, 0 0 30px #ffff0033; }
    50%  { box-shadow: 0 0 10px #00ff00, 0 0 20px #00ff0066, 0 0 30px #00ff0033; }
    66%  { box-shadow: 0 0 10px #0088ff, 0 0 20px #0088ff66, 0 0 30px #0088ff33; }
    83%  { box-shadow: 0 0 10px #aa00ff, 0 0 20px #aa00ff66, 0 0 30px #aa00ff33; }
    100% { box-shadow: 0 0 10px #ff0000, 0 0 20px #ff000066, 0 0 30px #ff000033; }
}

/* Gentle pulse */
@keyframes superPulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.04); }
}

/* Grayed out when no supers available */
.super-squishy-inline-btn.super-disabled {
    background: linear-gradient(135deg, #999, #777);
    border-color: #888;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    animation: none;
    opacity: 0.6;
    cursor: default;
}

.super-squishy-inline-btn.super-disabled .super-btn-label {
    opacity: 0.5;
}

/* Background Animated Snacks */
/* HINT: These are the floating snacks in the background */
.bg-decorations {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.bg-snack {
    position: absolute;
    font-size: 3em;
    opacity: 0.15;
    animation: floatSnack 6s ease-in-out infinite;
    filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.1));
}

.bg-snack.picnic-basket {
    font-size: 4em;
    opacity: 0.2;
    animation: picnicFloat 8s ease-in-out infinite;
}

@keyframes floatSnack {
    0%, 100% {
        transform: translateY(0px) rotate(0deg);
    }
    25% {
        transform: translateY(-20px) rotate(5deg);
    }
    50% {
        transform: translateY(0px) rotate(0deg);
    }
    75% {
        transform: translateY(-15px) rotate(-5deg);
    }
}

@keyframes picnicFloat {
    0%, 100% {
        transform: translateY(0px) scale(1);
    }
    50% {
        transform: translateY(-25px) scale(1.05);
    }
}

/* Responsive Design */
@media (max-width: 1200px) {
    .game-layout {
        flex-direction: column;
        align-items: center;
    }

    .left-panel, .right-panel {
        flex-direction: row;
        min-width: auto;
        flex-wrap: wrap;
        justify-content: center;
    }

    .evolution-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

@media (max-width: 768px) {
    .game-title {
        font-size: 2em;
    }

    .score-circle, .next-circle {
        width: 140px;
        height: 140px;
    }

    .circle-value {
        font-size: 2em;
    }

    .ranking-panel, .evolution-panel {
        width: 100%;
    }

    .evolution-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    .game-title {
        font-size: 1.5em;
    }

    .controls-hint {
        font-size: 0.8em;
    }

    .game-container {
        padding: 15px 10px 20px 10px;
    }
}

/* Tooltip for Evolution Grid */
.evolution-tooltip {
    position: fixed;
    background: rgba(255, 255, 255, 0.95);
    border: 3px solid #FF6B6B;
    border-radius: 15px;
    padding: 15px;
    width: 220px;
    pointer-events: none;
    z-index: 10000;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    font-family: 'Comic Neue', 'Comic Sans MS', sans-serif;
    text-align: center;
    animation: popIn 0.2s ease-out;
}

.tooltip-title {
    font-weight: bold;
    color: #FF6B6B;
    font-size: 1.2em;
    margin-bottom: 8px;
    text-shadow: 1px 1px 0 #FFF;
}

.tooltip-desc {
    color: #8B6914;
    font-size: 0.95em;
    line-height: 1.3;
}

/* Mobile Landscape Enforcement */
#rotate-message {
    display: none;
}

/* Show rotate message ONLY on small phones in portrait (tablets have enough room) */
@media only screen and (max-width: 920px) and (orientation: portrait) {
    #rotate-message {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: linear-gradient(135deg, #FF6B6B, #FF8E53);
        z-index: 100000;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        color: white;
        text-align: center;
        padding: 20px;
    }

    .rotate-icon {
        font-size: 5em;
        margin-bottom: 20px;
        animation: rotateIcon 2s infinite ease-in-out;
    }

    .rotate-text {
        font-family: 'Fredoka One', 'Comic Neue', sans-serif;
        font-size: 1.5em;
        text-shadow: 2px 2px 0 rgba(0,0,0,0.2);
    }

    @keyframes rotateIcon {
        0%, 20% { transform: rotate(0deg); }
        50%, 70% { transform: rotate(-90deg); }
        100% { transform: rotate(-90deg); }
    }

    .rotate-subtext {
        font-size: 0.8em;
        margin-top: 10px;
        opacity: 0.8;
    }

    .dismiss-btn {
        margin-top: 20px;
        padding: 10px 20px;
        background: rgba(255, 255, 255, 0.2);
        border: 2px solid white;
        color: white;
        border-radius: 20px;
        font-family: inherit;
        font-weight: bold;
        cursor: pointer;
    }

    /* Hide everything else so they can't play */
    body:not(.rotate-dismissed) .game-layout, body:not(.rotate-dismissed) .main-menu, body:not(.rotate-dismissed) .loading-screen, body:not(.rotate-dismissed) .bg-decorations, body:not(.rotate-dismissed) .background-stars {
        display: none !important;
    }
}

.mobile-fs-btn {
    display: none;
    position: fixed; /* Fixed to screen corner */
    top: 10px;
    right: 10px;
    width: 50px;
    height: 50px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.8);
    color: white;
    font-size: 1.5em;
    cursor: pointer;
    z-index: 100;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    backdrop-filter: blur(4px);
}

.mobile-fs-btn:active {
    transform: scale(0.9);
    background: rgba(255, 255, 255, 0.5);
}

/* Show mobile controls on touch devices or small screens */
/* Show fullscreen button on touch devices */
@media (hover: none) and (pointer: coarse), (max-width: 1366px) {
    .mobile-fs-btn {
        display: flex;
    }
}

/* Optimizations for Mobile & Tablet (landscape + small portrait tablets) */
/* Covers phones in landscape AND tablets in both orientations */
@media only screen and (max-width: 1366px) and (max-height: 1024px) {
    body {
        overflow: hidden; /* Prevent scrolling */
        position: fixed;
        width: 100%;
        height: 100%;
        padding: 0;
    }

    .game-layout {
        /* JS handles scaling now, so we remove fixed scale */
        /* transform: scale(0.42); */
        width: auto;
        height: auto;
        margin-top: 0;
        flex-direction: row !important; /* Force row layout */
        align-items: center;
        justify-content: center;
        gap: 8px;
    }

    .left-panel, .right-panel {
        width: 150px !important; /* EDIT HERE: Change width of side panels */
        min-width: 150px !important; /* EDIT HERE: Keep this same as width */
        max-width: 150px !important; /* EDIT HERE: Keep this same as width */
        display: flex !important;
        flex-direction: column !important;
        justify-content: center;
        height: auto;
        gap: 5px;
    }

    /* Compact Panels for Mobile */
    .stats-panel, .ranking-panel, .fun-fact-panel, .evolution-panel {
        display: flex !important;
        padding: 4px !important;
        margin-bottom: 4px !important;
        width: 100% !important;
        border-width: 2px !important;
        border-radius: 10px !important;
        background: rgba(255, 255, 255, 0.85);
        box-shadow: 0 2px 5px rgba(0,0,0,0.1) !important;
    }

    /* Tight stats grid */
    .stat-grid {
        gap: 2px !important;
        width: 100%;
    }

    .stats-panel {
        padding: 3px 6px !important;
    }

    /* Hide titles to save space */
    .stats-title, .ranking-title, .evolution-title, .fun-fact-title {
        display: none !important;
    }

    /* Smaller text for compact fit */
    .stat-label, .stat-value, .fun-fact-content {
        font-size: 0.75em !important;
    }

    /* Compact Rankings */
    .ranking-panel {
        padding: 4px !important;
    }

    .ranking-list {
        gap: 3px !important;
        width: 100% !important;
    }

    .rank-item {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        width: 100% !important;
        box-sizing: border-box !important;
        padding: 4px 6px !important;
        min-height: auto !important;
        gap: 4px !important;
        border-radius: 6px !important;
        font-size: 0.65em !important;
    }

    .rank-number {
        flex-shrink: 0;
        font-size: 0.9em !important;
        min-width: 18px;
        text-align: center;
    }

    .rank-name {
        flex: 1;
        font-size: 0.85em !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        text-align: left;
        opacity: 0.9;
    }

    .rank-score {
        flex-shrink: 0;
        font-size: 0.9em !important;
        text-align: right;
    }

    /* Shrink evolution panel (fruit grid) so it doesn't dominate */
    .evolution-panel {
        padding: 3px !important;
        max-height: 110px !important;
        overflow: hidden;
    }

    .evolution-grid {
        grid-template-columns: repeat(5, 1fr) !important;
        gap: 2px !important;
    }

    .evolution-item {
        padding: 1px !important;
    }

    .evolution-item canvas {
        width: 100% !important;
        height: 100% !important;
    }

    /* Compact Fun Fact - readable without scrolling */
    .fun-fact-panel {
        max-height: none !important;
        min-height: unset !important;
        height: auto !important;
        overflow: visible !important;
        padding: 5px 6px !important;
    }

    .fun-fact-content {
        font-size: 0.7em !important;
        line-height: 1.2 !important;
        overflow: visible !important;
        max-height: none !important;
    }

    /* Compact SUPER button for mobile */
    .super-squishy-inline-btn {
        padding: 4px 8px !important;
        font-size: 0.75em !important;
        border-width: 2px !important;
        margin-top: 4px !important;
        gap: 4px !important;
        border-radius: 30px !important;
    }

    .score-circle, .next-circle {
        width: 80px; /* EDIT HERE: Change size of circles */
        height: 80px; /* EDIT HERE: Keep this same as width */
        min-width: 80px; /* EDIT HERE: Keep this same as width */
        margin: 0 auto;
        border-width: 3px;
        background: rgba(255, 255, 255, 0.6);
        gap: 2px !important;
        overflow: hidden;
        align-self: center;
    }

    .circle-value {
        font-size: 1.3em;
    }

    .circle-label {
        font-size: 0.55em;
        margin-bottom: -2px;
    }

    /* Constrain next preview canvas inside the small circle */
    .next-circle canvas {
        width: 45px !important;
        height: 45px !important;
    }

    .game-title {
        display: none !important;
    }
    
    .game-container {
        margin: 0;
    }

    /* Compact Game Over screen for mobile */
    .game-over-box {
        padding: 15px 20px !important;
        border-radius: 12px !important;
        border-width: 3px !important;
        max-width: 280px;
    }

    .game-over-box h2 {
        font-size: 1.4em !important;
        margin-bottom: 8px !important;
    }

    .final-score-display {
        font-size: 1em !important;
        margin-bottom: 12px !important;
        gap: 4px !important;
    }

    .final-score-display span:last-child {
        font-size: 1.4em !important;
    }

    .high-score-msg {
        font-size: 0.85em !important;
        margin-bottom: 6px !important;
    }

    .name-input {
        padding: 8px !important;
        font-size: 1em !important;
        margin-bottom: 8px !important;
        border-width: 2px !important;
    }

    .btn-submit, #restartBtn {
        padding: 8px 20px !important;
        font-size: 0.9em !important;
        margin-bottom: 8px !important;
    }

    /* --- Main Menu Mobile Scaling --- */
    .menu-title {
        font-size: 3em; /* Smaller title */
    }

    .menu-btn {
        font-size: 1.2em; /* Smaller buttons */
        padding: 10px 30px;
    }

    .title-emoji-left, .title-emoji-right {
        font-size: 0.5em; /* Shrink emojis */
        display: none; /* Hide if still too crowded */
    }
    
    .bouncing-fruits {
        bottom: -30px;
    }
    
    .bounce-fruit {
        font-size: 1.5em;
    }
    
    .menu-title-wrapper {
        margin-bottom: 20px;
    }
    
    .menu-buttons {
        margin-top: 10px;
        gap: 10px;
    }
}
/* Super Squishy Full-Screen Effects */
@keyframes superSquishyBg {
    0%, 100% { background-color: #111; }
    50% { background-color: #220022; }
}

@keyframes superSquishyLightning {
    0%, 90%, 94%, 98%, 100% { background-color: transparent; }
    92%, 96% { background-color: rgba(255, 255, 255, 0.4); }
}

body.super-squishy-active {
    animation: superSquishyBg 0.5s infinite;
    background-image: none !important;
}

body.super-squishy-active::after {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    z-index: 9999;
    background: radial-gradient(circle at 50% 30%, transparent 10%, rgba(0,0,0,0.7) 100%);
    animation: superSquishyLightning 2s infinite;
}

body.super-squishy-active .left-panel,
body.super-squishy-active .right-panel {
    opacity: 0.3;
    transition: opacity 0.5s ease;
}

/* Keyboard Instructions Theme */
.keyboard-instructions {
    background: linear-gradient(135deg, #2b2b4d, #1a1a2e);
    border: 2px solid #FFD93D;
    color: #fff;
    border-radius: 12px;
    padding: 12px;
    font-size: 0.9em;
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3), inset 0 0 10px rgba(255,217,61,0.2);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
    width: 100%;
}

.key-hint {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
}

.key-badge {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid #FFD93D;
    padding: 3px 6px;
    border-radius: 6px;
    font-family: 'Fredoka One', monospace;
    color: #FFD93D;
    box-shadow: 0 2px 0 rgba(0,0,0,0.5);
    font-size: 0.85em;
    text-transform: uppercase;
}

.key-desc {
    color: #E0E0E0;
    font-size: 0.85em;
    font-family: 'Comic Neue', sans-serif;
}
