/* Reset & Core Styling */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

body {
    background: radial-gradient(circle at center, #2d160b 0%, #110502 100%);
    color: #f7e1d7;
    font-family: 'Outfit', sans-serif;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Main Game Wrapper */
#game-container {
    position: relative;
    width: 480px;
    height: 720px;
    border-radius: 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 25px rgba(240, 160, 75, 0.15);
    overflow: hidden;
    aspect-ratio: 2 / 3;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 4px solid #3d1c0e;
}

/* Canvas Styling */
#game-canvas {
    width: 100%;
    height: 100%;
    background-color: #200f07;
    display: block;
}

/* Overlays Layer */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 10;
}

.overlay.active {
    opacity: 1;
    pointer-events: all;
}

/* HUD Overlay - Stays visible during play, transparent */
#game-hud {
    pointer-events: none;
    display: block;
    padding: 20px;
}

.hud-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    pointer-events: all;
}

.hud-btn {
    background: rgba(43, 20, 11, 0.6);
    border: 1px solid rgba(240, 160, 75, 0.3);
    color: #f7e1d7;
    font-size: 1.2rem;
    padding: 8px 12px;
    border-radius: 12px;
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: transform 0.2s, background 0.2s;
}

.hud-btn:hover {
    transform: scale(1.1);
    background: rgba(43, 20, 11, 0.8);
}

.score-display {
    font-family: 'Fredoka', sans-serif;
    font-size: 3.5rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 4px 8px rgba(0, 0, 0, 0.6), 0 0 15px rgba(240, 160, 75, 0.5);
}

.hud-food {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(43, 20, 11, 0.6);
    border: 1px solid rgba(240, 160, 75, 0.3);
    padding: 6px 14px;
    border-radius: 20px;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.currency-icon-small {
    width: 24px;
    height: 24px;
    object-fit: contain;
    animation: float-mini 2s ease-in-out infinite;
}

.hud-food span {
    font-family: 'Fredoka', sans-serif;
    font-weight: 600;
    font-size: 1.1rem;
    color: #f0a04b;
}

/* Glassmorphic UI Card */
.glass-card {
    background: rgba(29, 13, 7, 0.75);
    backdrop-filter: blur(16px) saturate(120%);
    -webkit-backdrop-filter: blur(16px) saturate(120%);
    border: 2px solid rgba(240, 160, 75, 0.25);
    border-radius: 28px;
    width: 88%;
    max-height: 90%;
    padding: 30px 24px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5), inset 0 1px 1px rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: scale-up 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* Brand & Typography */
.brand {
    margin-bottom: 15px;
}

.game-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 2.8rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -1px;
    background: linear-gradient(to bottom, #ffffff 30%, #f0a04b 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}

.game-subtitle {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.4rem;
    color: rgba(247, 225, 215, 0.8);
    font-weight: 500;
    margin-top: -2px;
}

.logo-container {
    width: 140px;
    height: 140px;
    background: radial-gradient(circle, rgba(240, 160, 75, 0.2) 0%, rgba(0,0,0,0) 70%);
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 15px;
}

.game-logo-img, .hero-logo-img {
    width: 85%;
    height: 85%;
    object-fit: contain;
    animation: float 3s ease-in-out infinite;
}

.balance-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px 18px;
    border-radius: 24px;
    margin-bottom: 25px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.currency-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
    animation: float 2.5s ease-in-out infinite;
}

.balance-display span {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.6rem;
    font-weight: 700;
    color: #f0a04b;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* General Buttons System */
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 260px;
    margin-bottom: 15px;
}

.btn {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.2rem;
    font-weight: 600;
    padding: 14px 20px;
    border-radius: 16px;
    border: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    outline: none;
}

.btn:active {
    transform: scale(0.96);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.primary-btn {
    background: linear-gradient(135deg, #f0a04b 0%, #d35400 100%);
    color: #fff;
    border-bottom: 4px solid #a04000;
}

.primary-btn:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 6px 16px rgba(240, 160, 75, 0.4);
    background: linear-gradient(135deg, #f1a95c 0%, #e67e22 100%);
}

.secondary-btn {
    background: linear-gradient(135deg, #5c2f1b 0%, #3a1c0e 100%);
    color: #f7e1d7;
    border: 1px solid rgba(240, 160, 75, 0.3);
    border-bottom: 4px solid #241007;
}

.secondary-btn:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
    background: linear-gradient(135deg, #6c3a24 0%, #442111 100%);
}

.text-btn {
    background: transparent;
    color: rgba(247, 225, 215, 0.7);
    box-shadow: none;
    font-size: 1.05rem;
    padding: 8px 15px;
}

.text-btn:hover {
    color: #fff;
    transform: scale(1.05);
}

.menu-footer {
    font-size: 0.85rem;
    color: rgba(247, 225, 215, 0.5);
    margin-top: 15px;
}

/* Game Over Styling */
.game-over-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 2.8rem;
    font-weight: 700;
    color: #e74c3c;
    text-shadow: 0 4px 10px rgba(231, 76, 60, 0.3);
    margin-bottom: 5px;
}

.death-message {
    font-size: 1rem;
    color: rgba(247, 225, 215, 0.7);
    margin-bottom: 25px;
}

.stats-container {
    display: flex;
    gap: 15px;
    width: 100%;
    justify-content: center;
    margin-bottom: 20px;
}

.stat-box {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 12px;
    flex: 1;
    max-width: 120px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label {
    font-size: 0.85rem;
    color: rgba(247, 225, 215, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    color: #fff;
}

.food-gained-box {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 25px;
    background: rgba(240, 160, 75, 0.1);
    border: 1px solid rgba(240, 160, 75, 0.2);
    padding: 8px 18px;
    border-radius: 20px;
}

.food-gained-box span {
    font-weight: 500;
    color: rgba(247, 225, 215, 0.9);
}

.food-gain {
    display: flex;
    align-items: center;
    gap: 6px;
}

.food-gain span {
    font-family: 'Fredoka', sans-serif;
    font-weight: 700;
    font-size: 1.3rem;
    color: #2ecc71;
}

/* Shop Overlay Styling */
.shop-content {
    background: rgba(24, 10, 5, 0.88);
    backdrop-filter: blur(20px);
    border-radius: 28px;
    border: 2px solid rgba(240, 160, 75, 0.35);
    width: 90%;
    height: 90%;
    display: flex;
    flex-direction: column;
    padding: 24px;
}

.shop-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 12px;
}

.shop-header h2 {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.6rem;
    font-weight: 600;
    color: #fff;
}

.balance-display-shop {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.3);
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid rgba(240, 160, 75, 0.2);
}

.balance-display-shop span {
    font-family: 'Fredoka', sans-serif;
    font-weight: 600;
    font-size: 1.1rem;
    color: #f0a04b;
}

.skins-container {
    flex: 1;
    overflow-y: auto;
    width: 100%;
    padding-right: 4px;
    margin-bottom: 20px;
}

/* Scrollbar styles for shop container */
.skins-container::-webkit-scrollbar {
    width: 6px;
}

.skins-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

.skins-container::-webkit-scrollbar-thumb {
    background: rgba(240, 160, 75, 0.4);
    border-radius: 10px;
}

.skins-container::-webkit-scrollbar-thumb:hover {
    background: rgba(240, 160, 75, 0.6);
}

.skins-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    width: 100%;
}

.skin-card {
    background: rgba(0, 0, 0, 0.25);
    border: 2px solid rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.skin-card:hover {
    transform: translateY(-3px);
    background: rgba(255, 255, 255, 0.02);
    border-color: rgba(240, 160, 75, 0.3);
}

.skin-card.selected {
    border-color: #f0a04b;
    background: rgba(240, 160, 75, 0.1);
    box-shadow: 0 0 12px rgba(240, 160, 75, 0.2);
}

.skin-preview-box {
    width: 70px;
    height: 70px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 8px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.03);
}

.skin-preview-img {
    width: 85%;
    height: 85%;
    object-fit: contain;
}

/* Custom Skin Visual filters */
.skin-filter-white {
    filter: invert(1) brightness(1.2) sepia(0.2);
}
.skin-filter-ruby {
    filter: hue-rotate(-45deg) saturate(1.5);
}
.skin-filter-mint {
    filter: hue-rotate(90deg) saturate(1.3);
}
.skin-filter-gold {
    filter: sepia(1) saturate(5) hue-rotate(10deg);
}
.skin-filter-rainbow {
    animation: rgb-pulse 4s linear infinite;
}

.skin-name {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: #fff;
}

.skin-status-btn {
    width: 100%;
    font-family: 'Fredoka', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 6px 10px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.skin-btn-locked {
    background: #e67e22;
    color: #fff;
}

.skin-btn-locked:hover {
    background: #d35400;
}

.skin-btn-unlocked {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(247, 225, 215, 0.8);
}

.skin-btn-unlocked:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
}

.skin-btn-equipped {
    background: #2ecc71;
    color: #fff;
    cursor: default;
}

.skin-cost-icon {
    width: 14px;
    height: 14px;
    object-fit: contain;
}

/* IAP Button simulation */
.iap-section {
    width: 100%;
    margin-bottom: 15px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 20px;
    border: 1px dashed rgba(240, 160, 75, 0.25);
    text-align: center;
}

.iap-section h3 {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 8px;
    color: rgba(247, 225, 215, 0.6);
}

.iap-btn {
    width: 100%;
    background: linear-gradient(135deg, #d4af37 0%, #aa7c11 100%);
    border: none;
    color: #fff;
    font-family: 'Fredoka', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    padding: 10px 15px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(170, 124, 17, 0.3);
    animation: border-glow 3s infinite alternate;
}

.iap-btn:hover {
    background: linear-gradient(135deg, #e5c158 0%, #c5931e 100%);
    transform: scale(1.02);
}

.iap-price {
    background: rgba(0, 0, 0, 0.2);
    padding: 4px 8px;
    border-radius: 8px;
}

.shop-footer {
    display: flex;
    justify-content: center;
    width: 100%;
}

/* Toast Messages */
#toast {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(43, 20, 11, 0.9);
    border: 1px solid #f0a04b;
    color: #fff;
    padding: 10px 24px;
    border-radius: 20px;
    font-family: 'Fredoka', sans-serif;
    font-size: 0.95rem;
    box-shadow: 0 6px 12px rgba(0,0,0,0.5);
    z-index: 99;
    pointer-events: none;
    transition: opacity 0.3s, bottom 0.3s;
}

.toast-hidden {
    opacity: 0;
    bottom: 15px !important;
}

/* KEYFRAMES & ANIMATIONS */
@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0px); }
}

@keyframes float-mini {
    0% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-3px) rotate(15deg); }
    100% { transform: translateY(0px) rotate(0deg); }
}

@keyframes scale-up {
    0% { transform: scale(0.9); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes rgb-pulse {
    0% { filter: hue-rotate(0deg) saturate(1.5); }
    100% { filter: hue-rotate(360deg) saturate(1.5); }
}

@keyframes border-glow {
    0% { box-shadow: 0 0 5px rgba(212, 175, 55, 0.4); }
    100% { box-shadow: 0 0 15px rgba(212, 175, 55, 0.8); }
}

/* Mobile Responsiveness for iframe/standalone */
@media (max-width: 485px) {
    #game-container {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        border: none;
    }
}
