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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    overflow: hidden;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#gameContainer {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#gameCanvas {
    background: #1a1a2e;
    border-radius: 15px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.6);
    position: absolute;
    width: 800px; /* Start with canvas size */
    height: 1200px; /* Start with canvas size */
    max-width: min(80vw, 80vh * (800/1200)); /* Limit max size based on viewport */
    max-height: min(80vh, 80vw * (1200/800)); /* Limit max size based on viewport */
    width: auto; /* Allow width to scale based on max-width */
    height: auto; /* Allow height to scale based on max-height */
    z-index: 1;
    transition: all 0.3s ease; /* Smoother transition */
}

/* When not in game, shrink the canvas */
/* This class is applied to #gameContainer when a menu is active */
#gameContainer.menu-active #gameCanvas {
     max-width: 400px; /* Smaller size when menu is active */
     max-height: 600px; /* Smaller size when menu is active */
}

#gameUI {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

#topBar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(15px);
    border-radius: 0 0 25px 25px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 10px;
    pointer-events: auto;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.currency {
    display: flex;
    gap: 25px;
    font-size: 18px;
    font-weight: 600;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.menu-currency {
    position: fixed;
    top: 25px;
    right: 25px;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(15px);
    padding: 15px 25px;
    border-radius: 25px;
    font-size: 16px;
    z-index: 11;
    pointer-events: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.level-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: white;
    font-size: 16px;
    font-weight: 600;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.lives {
    margin-top: 5px;
    font-size: 14px;
}

.stars {
    display: flex;
    align-items: center;
}

.star-objectives {
    display: flex;
    gap: 12px;
}

.star {
    font-size: 26px;
    opacity: 0.3;
    transition: all 0.3s ease;
    filter: drop-shadow(0 0 5px rgba(255, 215, 0, 0.3));
}

.star.earned {
    opacity: 1;
    animation: starGlow 2s ease-in-out infinite alternate;
}

@keyframes starGlow {
    from { filter: drop-shadow(0 0 5px rgba(255, 215, 0, 0.8)); }
    to { filter: drop-shadow(0 0 15px rgba(255, 215, 0, 1)); }
}

#gameStats {
    position: absolute;
    bottom: 120px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.stat {
    background: rgba(0, 0, 0, 0.7);
    padding: 12px 18px;
    border-radius: 25px;
    color: white;
    font-weight: 600;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

#powerupBar {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 18px;
    pointer-events: auto;
}

.powerup-slot {
    width: 65px;
    height: 65px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 26px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.powerup-slot:hover {
    transform: scale(1.15);
    box-shadow: 0 8px 25px rgba(255, 255, 255, 0.4);
    border-color: rgba(255, 255, 255, 0.4);
}

.powerup-slot span {
    font-size: 12px;
    font-weight: bold;
    margin-top: 2px;
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 6px;
    border-radius: 10px;
}

.menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, rgba(26, 26, 46, 0.95) 0%, rgba(0, 0, 0, 0.9) 100%);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    backdrop-filter: blur(25px);
    pointer-events: auto;
    overflow-y: auto;
}

.menu.active {
    display: flex;
}

/* Style specifically for the active main menu to compress its content */
#mainMenu.active {
    /* Adjust internal spacing */
}

#mainMenu.active h1 {
    margin-bottom: 20px; /* Further reduced */
    font-size: 42px; /* Also reduce font size */
}

#mainMenu.active .main-menu-stats {
     margin-bottom: 15px; /* Further reduced */
     gap: 15px; /* Further reduced */
}

#mainMenu.active .main-menu-stats > div { /* Target the hearts and preview containers */
     padding: 15px; /* Reduced padding */
     border-radius: 15px; /* Reduced border radius */
}

#mainMenu.active .hearts-info,
#mainMenu.active .recharge-timer {
    font-size: 12px; /* Reduced font size */
}

#mainMenu.active .next-chest {
    font-size: 16px; /* Reduced font size */
}

#mainMenu.active .chest-progress {
    width: 180px; /* Reduced width */
    margin: 8px auto; /* Reduced margin */
}

#mainMenu.active .menu-buttons {
    gap: 10px; /* Further reduced */
}

#mainMenu.active .btn {
    padding: 15px 35px; /* Reduced padding */
    font-size: 16px; /* Reduced font size */
    min-width: 180px; /* Reduced min width */
}

/* Adjust the refill button size slightly for consistency within hearts-info */
#mainMenu.active .hearts-info #refillHeartsBtn {
    margin-top: 8px; /* Slightly reduced margin */
    padding: 6px 12px; /* Reduced padding */
    font-size: 12px; /* Reduced font size */
    min-width: auto; /* Allow button to shrink */
}

.menu .back-btn {
    position: fixed;
    bottom: 25px;
    left: 25px;
    z-index: 12;
}

.menu h1, .menu h2 {
    color: white;
    margin-bottom: 40px;
    font-size: 52px;
    text-shadow: 0 4px 15px rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
    background: linear-gradient(45deg, #fff, #e0e0e0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.menu h2 {
    font-size: 42px;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 25px;
    align-items: center;
    flex-shrink: 0;
}

.main-menu-stats {
    display: flex;
    gap: 30px;
    margin-bottom: 30px;
    align-items: center;
}

.hearts-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.hearts-container {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.heart {
    font-size: 24px;
    transition: all 0.3s ease;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.heart.filled {
    color: #e74c3c;
    animation: heartbeat 2s ease-in-out infinite;
}

.heart.empty {
    color: #555;
    opacity: 0.5;
}

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

.hearts-info {
    font-size: 14px;
    color: #ccc;
    text-align: center;
}

.recharge-timer {
    color: #f39c12;
    font-weight: bold;
}

.level-map-preview {
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    text-align: center;
    color: white;
}

.level-map-preview h3 {
    margin-bottom: 10px;
    color: #f39c12;
}

.next-chest {
    font-size: 18px;
    margin-bottom: 10px;
}

.chest-progress {
    width: 200px;
    height: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    overflow: hidden;
    margin: 10px auto;
}

.chest-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #f39c12, #e67e22);
    transition: width 0.3s ease;
}

.btn {
    padding: 18px 45px;
    font-size: 18px;
    font-weight: 600;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    min-width: 220px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.btn:hover::before {
    left: 100%;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.4);
}

.btn.primary {
    background: linear-gradient(45deg, #ff6b6b, #ee5a24);
}

.btn.secondary {
    background: linear-gradient(45deg, #2ecc71, #27ae60);
}

.btn-with-notification {
    position: relative;
}

.notification-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    background: #e74c3c;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    color: white;
    animation: pulse 2s infinite;
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.5);
}

.back-btn {
    min-width: 120px;
    padding: 12px 25px;
    font-size: 16px;
    background: linear-gradient(45deg, #555, #333);
    color: white;
}

.back-btn:hover {
    background: linear-gradient(45deg, #666, #444);
}

.shop-items, .upgrade-tree {
    width: 90%;
    max-width: 1200px;
    color: white;
    flex-grow: 1;
    overflow-y: auto;
    padding: 30px;
    margin-top: 20px;
    margin-bottom: 80px;
    scrollbar-width: thin;
    scrollbar-color: #667eea rgba(0, 0, 0, 0.3);
}

.shop-items::-webkit-scrollbar, .upgrade-tree::-webkit-scrollbar {
    width: 10px;
}

.shop-items::-webkit-scrollbar-track, .upgrade-tree::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
}

.shop-items::-webkit-scrollbar-thumb, .upgrade-tree::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #667eea, #764ba2);
    border-radius: 5px;
    border: 2px solid rgba(0, 0, 0, 0.3);
}

.shop-section {
    margin-bottom: 50px;
}

.shop-section h3 {
    font-size: 28px;
    margin-bottom: 25px;
    text-align: center;
    color: #f39c12;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.powerup-packs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

.pack {
    background: rgba(255, 255, 255, 0.1);
    padding: 25px;
    border-radius: 20px;
    text-align: center;
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.pack:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.3);
}

.pack h4 {
    font-size: 20px;
    margin-bottom: 12px;
    color: #f39c12;
}

.pack p {
    font-size: 14px;
    margin-bottom: 18px;
    opacity: 0.9;
    line-height: 1.4;
}

.upgrade-tree {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 30px;
}

.upgrade-section h3 {
    font-size: 26px;
    margin-bottom: 25px;
    text-align: center;
    color: #f39c12;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.upgrade-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 25px;
    border-radius: 20px;
    margin-bottom: 20px;
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.upgrade-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.3);
}

.upgrade-item h4 {
    font-size: 20px;
    margin-bottom: 12px;
    color: #f39c12;
}

.upgrade-item p {
    font-size: 14px;
    margin-bottom: 18px;
    opacity: 0.9;
    line-height: 1.4;
}

.upgrade-btn {
    width: 100%;
    padding: 15px;
    font-size: 14px;
}

.upgrade-btn[disabled] {
    background: linear-gradient(45deg, #555, #444);
    cursor: not-allowed;
    color: #bbb;
    text-shadow: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.upgrade-btn[disabled]:hover {
    transform: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.upgrade-btn[disabled]::before {
    display: none;
}

.summerGalaMenu {
    justify-content: flex-start;
    padding-top: 0;
    padding-bottom: 0;
}

.summer-background {
    width: 100%;
    min-height: 100vh;
    /* background is now set dynamically in JS */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 60px 30px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
}

.summer-background::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 0;
}

.summer-background > * {
    position: relative;
    z-index: 1;
}

.summer-background h2 {
    color: #fff;
    font-size: 52px;
    text-shadow: 0 4px 15px rgba(0, 0, 0, 0.8);
    margin-bottom: 15px;
    flex-shrink: 0;
}

.summer-background p {
    color: #eee;
    font-size: 20px;
    margin-bottom: 40px;
    text-align: center;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
    flex-shrink: 0;
    line-height: 1.4;
}

.gala-progress {
    width: 100%;
    max-width: 1200px;
    flex-grow: 1;
    overflow-y: auto;
    padding-bottom: 100px;
}

.stars-count {
    text-align: center;
    font-size: 28px;
    font-weight: bold;
    color: #ffd700;
    margin-bottom: 35px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.gala-progress-bar-container {
    width: 90%;
    max-width: 800px;
    height: 35px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    overflow: hidden;
    margin: 25px auto 50px;
    position: relative;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.3);
}

.gala-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #f39c12, #e67e22);
    transition: width 0.8s ease-in-out;
    border-radius: 20px;
    box-shadow: 0 0 15px rgba(243, 156, 18, 0.5);
}

.gala-progress-text {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: bold;
    font-size: 16px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    z-index: 1;
}

.track-container {
    width: 100%;
    overflow-x: auto;
    padding: 25px 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.reward-items {
    display: flex;
    gap: 35px;
    min-width: max-content;
    align-items: center;
    position: relative;
    padding: 25px;
}

.reward-items::before {
    content: '';
    position: absolute;
    top: calc(50% - 40px);
    left: 0;
    right: 0;
    height: 10px;
    background: linear-gradient(90deg, #f39c12, #e67e22);
    z-index: 1;
    transform: translateY(-50%);
    border-radius: 5px;
    box-shadow: 0 2px 8px rgba(243, 156, 18, 0.3);
}

.reward-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    min-width: 130px;
    z-index: 2;
    background: rgba(0, 0, 0, 0.4);
    padding: 20px;
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    flex-shrink: 0;
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.reward-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
}

.reward-circle {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    border: 4px solid #f39c12;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
    margin-bottom: 12px;
    position: relative;
    z-index: 3;
    transition: all 0.3s ease;
}

.reward-circle.claimed {
    background: #2ecc71;
    border-color: #27ae60;
    box-shadow: 0 6px 15px rgba(46, 204, 113, 0.4);
}

.reward-circle.available {
    background: #f39c12;
    border-color: #e67e22;
    animation: rewardPulse 2s infinite;
    cursor: pointer;
}

@keyframes rewardPulse {
    0% { transform: scale(1); box-shadow: 0 6px 15px rgba(243, 156, 18, 0.4); }
    50% { transform: scale(1.1); box-shadow: 0 8px 25px rgba(243, 156, 18, 0.8); }
    100% { transform: scale(1); box-shadow: 0 6px 15px rgba(243, 156, 18, 0.4); }
}

.reward-label {
    text-align: center;
    font-size: 13px;
    font-weight: bold;
    color: white;
    background: rgba(0, 0, 0, 0.6);
    padding: 6px 12px;
    border-radius: 15px;
    margin-bottom: 6px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.stars-required {
    font-size: 14px;
    color: #ffd700;
    font-weight: bold;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.claim-reward-btn {
    padding: 6px 12px;
    font-size: 12px;
    margin-top: 12px;
    min-width: 80px;
}

.consolation-message {
    color: #ffd700;
    font-size: 18px;
    margin-bottom: 25px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    flex-shrink: 0;
    line-height: 1.4;
}

.game-over-content, .level-complete-content {
    text-align: center;
    color: white;
    flex-shrink: 0;
    margin-bottom: 100px;
}

.final-score p, .score-summary p {
    font-size: 26px;
    margin-bottom: 25px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.star-display {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 25px 0;
}

.star-display .star {
    font-size: 40px;
    opacity: 0.3;
    transition: all 0.3s ease;
}

.star-display .star.earned {
    opacity: 1;
    color: gold;
    animation: starGlow 2s ease-in-out infinite alternate;
}

.rewards p {
    font-size: 20px;
    color: #f39c12;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.game-over-buttons, .level-complete-buttons {
    display: flex;
    flex-direction: column;
    gap: 18px;
    align-items: center;
    flex-shrink: 0;
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 12;
    background: rgba(0, 0, 0, 0.6);
    padding: 15px 25px;
    border-radius: 15px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#snackbar {
    visibility: hidden;
    min-width: 300px;
    margin-left: -150px;
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    text-align: center;
    border-radius: 15px;
    padding: 20px;
    position: fixed;
    z-index: 100;
    left: 50%;
    bottom: 40px;
    font-size: 16px;
    font-weight: 500;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#snackbar.show {
    visibility: visible;
    -webkit-animation: snackbarFadeIn 0.5s, snackbarFadeOut 0.5s 2.5s;
    animation: snackbarFadeIn 0.5s, snackbarFadeOut 0.5s 2.5s;
}

@-webkit-keyframes snackbarFadeIn {
    from {bottom: 0; opacity: 0; transform: translateY(100%);}
    to {bottom: 40px; opacity: 1; transform: translateY(0);}
}

@keyframes snackbarFadeIn {
    from {bottom: 0; opacity: 0; transform: translateY(100%);}
    to {bottom: 40px; opacity: 1; transform: translateY(0);}
}

@-webkit-keyframes snackbarFadeOut {
    from {bottom: 40px; opacity: 1; transform: translateY(0);}
    to {bottom: 0; opacity: 0; transform: translateY(100%);}
}

@keyframes snackbarFadeOut {
    from {bottom: 40px; opacity: 1; transform: translateY(0);}
    to {bottom: 0; opacity: 0; transform: translateY(100%);}
}

.fade-in-btn {
    animation: fadeIn 0.5s ease-in-out forwards;
}

.level-map-container .level-item.pulse-border {
    /* Add pulse animation to border or box-shadow */
     animation: pulseBorderGlow 2s ease-in-out infinite alternate;
}

@keyframes pulseBorderGlow {
    from { border-color: rgba(243, 156, 18, 0.5); box-shadow: 0 0 10px rgba(243, 156, 18, 0.3); }
    to { border-color: rgba(255, 215, 0, 1); box-shadow: 0 0 25px rgba(255, 215, 0, 0.8); }
}

/* Ensure reward display items have initial opacity 0 before animation */
.reward-items-display .reward-display {
    opacity: 0;
}

@media (max-width: 768px) {
    /* Adjust font sizes and padding for smaller screens if necessary */
    .menu h1 { font-size: 32px; margin-bottom: 30px; }
    .menu h2 { font-size: 24px; margin-bottom: 20px; }
    .btn { padding: 10px 25px; font-size: 14px; min-width: 150px; }
    .back-btn { padding: 8px 15px; font-size: 14px; min-width: 80px; }
    .currency, .menu-currency { font-size: 14px; gap: 10px; }
    .level-info { font-size: 12px; }
    .lives { font-size: 12px; }
    .star { font-size: 20px; }
    #gameStats { bottom: 80px; left: 10px; gap: 5px;}
    .stat { padding: 5px 10px; font-size: 12px;}
    #powerupBar { bottom: 10px; gap: 10px;}
    .powerup-slot { width: 45px; height: 45px; font-size: 18px; }
    .powerup-slot span { font-size: 10px; }
    .shop-section h3, .upgrade-section h3 { font-size: 20px; }
    .pack h4, .upgrade-item h4 { font-size: 16px; }
    .pack p, .upgrade-item p { font-size: 12px; }
    .upgrade-btn { padding: 10px; font-size: 12px; }
    .reward-item { min-width: 90px; padding: 10px; }
    .reward-circle { width: 40px; height: 40px; font-size: 18px; }
    .reward-label, .stars-required { font-size: 10px; }
    .claim-reward-btn { padding: 4px 8px; font-size: 10px; }
    .final-score p, .score-summary p { font-size: 18px; }
    .star-display .star { font-size: 28px; }
    .rewards p { font-size: 16px; }

    /* Adjust fixed button/currency positions for smaller screens */
    .menu .back-btn {
        bottom: 10px;
        left: 10px;
    }
    .menu-currency {
        top: 10px;
        right: 10px;
        padding: 5px 10px;
    }
    .game-over-buttons, .level-complete-buttons {
        bottom: 10px;
        padding: 5px 10px;
        gap: 10px;
    }
    .game-over-content, .level-complete-content {
        margin-bottom: 60px; /* Adjust margin for smaller buttons */
    }
    .gala-progress {
        padding-bottom: 60px; /* Adjust padding for smaller back button */
    }
    .shop-items, .upgrade-tree {
        margin-bottom: 60px; /* Adjust margin for fixed back button */
    }
    /* Adjust snackbar for smaller screens */
    #snackbar {
        min-width: 150px;
        margin-left: -75px;
        font-size: 14px;
        bottom: 20px;
        padding: 12px;
    }
    @-webkit-keyframes snackbarFadeIn { from { bottom: 0; opacity: 0; } to { bottom: 20px; opacity: 1; } }
    @keyframes snackbarFadeIn { from { bottom: 0; opacity: 0; } to { bottom: 20px; opacity: 1; } }
    @-webkit-keyframes snackbarFadeOut { from { bottom: 20px; opacity: 1; } to { bottom: 0; opacity: 0; } }
    @keyframes snackbarFadeOut { from { bottom: 20px; opacity: 1; } to { bottom: 0; opacity: 0; } }

    /* Adjust main menu compression for mobile if needed */
    /* Example: Can further reduce gaps/margins on very small screens */

    /* Target elements specifically within the active main menu on small screens */
    #mainMenu.active h1 { font-size: 32px; margin-bottom: 20px; /* Reduced from 30px */ }
    #mainMenu.active .main-menu-stats { margin-bottom: 10px; /* Reduced from 15px */ gap: 10px; /* Reduced from 15px */ }
    #mainMenu.active .main-menu-stats > div { padding: 10px; /* Reduced from 15px */ border-radius: 10px; /* Reduced from 15px */ }
    #mainMenu.active .hearts-info,
    #mainMenu.active .recharge-timer { font-size: 11px; /* Further reduced */ }
    #mainMenu.active .hearts-container { gap: 5px; /* Reduced from 8px */ }
    #mainMenu.active .next-chest { font-size: 14px; /* Reduced from 16px */ }
    #mainMenu.active .chest-progress { width: 120px; /* Reduced from 180px */ margin: 6px auto; /* Reduced from 8px */ }
    #mainMenu.active .menu-buttons { gap: 8px; /* Reduced from 10px */ }
    #mainMenu.active .btn { padding: 10px 25px; /* Already smaller in base mobile style */ font-size: 14px; /* Already smaller */ min-width: 150px; /* Already smaller */ }
    #mainMenu.active .hearts-info #refillHeartsBtn {
        margin-top: 6px; /* Reduced from 8px */
        padding: 5px 10px; /* Reduced from 6px 12px */
        font-size: 11px; /* Further reduced */
    }
}