:root {
    --primary: #ff477e;
    --secondary: #fce043;
    --bg-dark: #120e1f;
    --text: #ffffff;
    --glass: rgba(0, 0, 0, 0.25);
    --glass-border: rgba(255, 255, 255, 0.3);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: linear-gradient(135deg, #1f1c2c 0%, #928DAB 100%);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden; /* Prevent scrolling on mobile */
    touch-action: none; /* Prevent default touch actions like pull-to-refresh */
}

/* Screen Shake Animation */
@keyframes shake {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    10% { transform: translate(-1px, -2px) rotate(-1deg); }
    20% { transform: translate(-3px, 0px) rotate(1deg); }
    30% { transform: translate(3px, 2px) rotate(0deg); }
    40% { transform: translate(1px, -1px) rotate(1deg); }
    50% { transform: translate(-1px, 2px) rotate(-1deg); }
    60% { transform: translate(-3px, 1px) rotate(0deg); }
    70% { transform: translate(3px, 1px) rotate(-1deg); }
    80% { transform: translate(-1px, -1px) rotate(1deg); }
    90% { transform: translate(1px, 2px) rotate(0deg); }
    100% { transform: translate(1px, -2px) rotate(-1deg); }
}

.shake {
    animation: shake 0.3s cubic-bezier(.36,.07,.19,.97) both;
}

#game-container {
    position: relative;
    width: 100%;
    max-width: 400px;
    height: 100dvh;
    max-height: 800px;
    background: url('assets/images/bg.png') no-repeat center center;
    background-size: cover;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

@media (min-width: 500px) {
    #game-container {
        height: 90vh;
        border-radius: 20px;
        border: 1px solid var(--glass-border);
    }
}

/* Background Animated Shapes */
.bg-shape {
    display: none;
}

.shape1 {
    width: 200px;
    height: 200px;
    background: var(--primary);
    top: -50px;
    left: -50px;
    animation: float 8s infinite alternate ease-in-out;
}

.shape2 {
    width: 250px;
    height: 250px;
    background: var(--secondary);
    bottom: -100px;
    right: -50px;
    animation: float 10s infinite alternate-reverse ease-in-out;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(30px, 50px) scale(1.2); }
}

/* UI Elements */
.ui-header {
    position: relative;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    padding: 20px;
    gap: 15px;
}

.glass-panel {
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 15px;
    padding: 10px 15px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
}

.score-board {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.score-board .label, .next-item-panel .label {
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 2px;
}

#score-display {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    background: linear-gradient(to right, #ffffff, #fce043);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.next-item-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 80px;
}

#next-item-display {
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
}

/* Canvas Area */
#canvas-container {
    flex: 1;
    position: relative;
    z-index: 5;
    width: 100%;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

#game-over-line {
    position: absolute;
    top: 15%; /* Threshold line */
    left: 0;
    width: 100%;
    height: 2px;
    background: repeating-linear-gradient(
        90deg,
        rgba(255, 71, 126, 0.5),
        rgba(255, 71, 126, 0.5) 10px,
        transparent 10px,
        transparent 20px
    );
    z-index: 10;
    pointer-events: none;
    opacity: 0.3;
    transition: opacity 0.3s;
}

#game-over-line.danger {
    opacity: 1;
    background: repeating-linear-gradient(
        90deg,
        #ff477e,
        #ff477e 10px,
        transparent 10px,
        transparent 20px
    );
    box-shadow: 0 0 10px #ff477e;
    animation: flash 0.5s infinite;
}

@keyframes flash {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* Modals */
.modal {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    width: 100%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 30px 20px;
    transform: scale(1);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal.hidden .modal-content {
    transform: scale(0.8);
}

.modal h2 {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 10px;
    color: var(--primary);
}

.modal p {
    font-size: 1.2rem;
    margin-bottom: 20px;
}

#final-score {
    font-weight: 800;
    color: var(--secondary);
    font-size: 1.5rem;
}

.input-group {
    width: 100%;
    margin-bottom: 15px;
}

input {
    width: 100%;
    padding: 12px 15px;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.3);
    color: white;
    font-size: 1rem;
    outline: none;
    text-align: center;
    transition: border-color 0.3s;
}

input:focus {
    border-color: var(--primary);
}

button {
    width: 100%;
    padding: 15px;
    border-radius: 10px;
    border: none;
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    margin-bottom: 10px;
    transition: transform 0.2s, box-shadow 0.2s;
}

button:active {
    transform: scale(0.95);
}

.primary-btn {
    background: linear-gradient(45deg, var(--primary), #ff7a9f);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 71, 126, 0.4);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid var(--glass-border);
}

.leaderboard {
    width: 100%;
    margin-top: 20px;
    border-top: 1px solid var(--glass-border);
    padding-top: 15px;
}

.leaderboard h3 {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 10px;
}

#leaderboard-list {
    list-style: none;
    text-align: left;
}

#leaderboard-list li {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.9rem;
}

#leaderboard-list li span:last-child {
    font-weight: bold;
    color: var(--secondary);
}

/* Meta-Game Styles */
.overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s;
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.menu-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 90%;
    max-width: 400px;
    padding: 30px;
}

/* ── STORE PANEL ─────────────────────────── */
.store-panel {
    position: relative;
    width: 92%;
    max-width: 370px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(160deg, #1a1030 0%, #0f0a1e 100%);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 25px 60px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.04);
}

/* Header */
.store-header {
    padding: 22px 20px 16px;
    background: linear-gradient(135deg, rgba(168,85,247,0.25) 0%, rgba(255,71,126,0.15) 100%);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.store-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.store-title-text {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: 2px;
    background: linear-gradient(90deg, #ff477e, #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.store-coin-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(252,224,67,0.15);
    border: 1px solid rgba(252,224,67,0.35);
    border-radius: 30px;
    padding: 5px 14px;
    font-size: 1.1rem;
    font-weight: 800;
    color: #fce043;
}

.store-coin-icon { font-size: 1rem; }

.store-subtitle {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.45);
    font-weight: 400;
    letter-spacing: 0.3px;
}

/* Scrollable items area */
.store-items-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}

.store-items-scroll::-webkit-scrollbar { width: 4px; }
.store-items-scroll::-webkit-scrollbar-track { background: transparent; }
.store-items-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

/* Card */
.store-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.09);
    border-radius: 16px;
    padding: 14px;
    transition: background 0.2s, transform 0.15s;
}

.store-card:active { transform: scale(0.98); }

/* Icon circle */
.store-card-icon-wrap {
    flex-shrink: 0;
    width: 54px;
    height: 54px;
    border-radius: 16px;
    background: color-mix(in srgb, var(--card-clr) 25%, transparent);
    border: 1.5px solid color-mix(in srgb, var(--card-clr) 50%, transparent);
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 14px color-mix(in srgb, var(--card-clr) 30%, transparent);
}

.store-card-emoji { font-size: 1.7rem; line-height: 1; }

/* Card body */
.store-card-body { flex: 1; min-width: 0; }

.store-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}

.store-card-name {
    font-size: 0.95rem;
    font-weight: 800;
    color: #fff;
}

.store-card-owned {
    font-size: 0.78rem;
    font-weight: 700;
    color: #fce043;
    background: rgba(252,224,67,0.12);
    border: 1px solid rgba(252,224,67,0.25);
    border-radius: 20px;
    padding: 1px 9px;
}

.store-card-desc {
    font-size: 0.72rem;
    color: rgba(255,255,255,0.45);
    margin-bottom: 10px;
    line-height: 1.3;
}

/* Buy buttons */
.store-card-actions {
    display: flex;
    gap: 7px;
}

.store-buy-coin,
.store-buy-ad {
    flex: 1;
    padding: 7px 6px;
    border-radius: 10px;
    border: none;
    font-size: 0.75rem;
    font-weight: 800;
    cursor: pointer;
    margin: 0;
    transition: transform 0.15s, filter 0.15s;
    letter-spacing: 0.2px;
}

.store-buy-coin:active,
.store-buy-ad:active { transform: scale(0.93); filter: brightness(0.9); }

.store-buy-coin {
    background: linear-gradient(135deg, #fce043, #f59e0b);
    color: #1a0f00;
    box-shadow: 0 3px 10px rgba(245,158,11,0.35);
}

.store-buy-ad {
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    color: #fff;
    box-shadow: 0 3px 10px rgba(99,102,241,0.35);
}

/* Footer */
.store-footer {
    padding: 12px 16px 16px;
    border-top: 1px solid rgba(255,255,255,0.07);
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.store-return-btn {
    width: 100%;
    padding: 13px;
    border-radius: 12px;
    border: none;
    font-size: 1rem;
    font-weight: 800;
    cursor: pointer;
    background: linear-gradient(135deg, #ff477e, #a855f7);
    color: #fff;
    box-shadow: 0 4px 18px rgba(255,71,126,0.35);
    transition: transform 0.15s;
    letter-spacing: 0.5px;
    margin: 0;
}

.store-return-btn:active { transform: scale(0.96); }

.store-back-btn {
    width: 100%;
    padding: 11px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.15);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.7);
    transition: background 0.2s;
    margin: 0;
}

.store-back-btn:active { background: rgba(255,255,255,0.12); }

/* Legacy selectors for JS event listeners */
.buy-coin-btn { background: linear-gradient(135deg,#fce043,#f59e0b); color:#1a0f00; }
.buy-ad-btn   { background: linear-gradient(135deg,#3b82f6,#6366f1); color:#fff; }

/* ── REWARDED AD DIALOG ──────────────────── */
.ad-dialog {
    width: 88%;
    max-width: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 32px 24px 28px;
    gap: 12px;
    background: linear-gradient(160deg, #1a1030 0%, #0f0a1e 100%);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 24px;
}

.ad-icon-ring {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(59,130,246,0.15);
    border: 2px solid rgba(59,130,246,0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 4px;
    box-shadow: 0 0 24px rgba(59,130,246,0.2);
}

.ad-ring-watching {
    background: rgba(168,85,247,0.15);
    border-color: rgba(168,85,247,0.4);
    box-shadow: 0 0 24px rgba(168,85,247,0.2);
    animation: adPulse 1.5s ease-in-out infinite;
}

.ad-ring-success {
    background: rgba(34,197,94,0.15);
    border-color: rgba(34,197,94,0.4);
    box-shadow: 0 0 24px rgba(34,197,94,0.25);
}

.ad-ring-error {
    background: rgba(239,68,68,0.15);
    border-color: rgba(239,68,68,0.4);
    box-shadow: 0 0 24px rgba(239,68,68,0.2);
}

@keyframes adPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 20px rgba(168,85,247,0.2); }
    50%       { transform: scale(1.06); box-shadow: 0 0 32px rgba(168,85,247,0.4); }
}

.ad-icon-emoji { font-size: 2rem; line-height: 1; }

.ad-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: #fff;
    margin: 0;
}

.ad-subtitle {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.5);
    margin: 0;
    line-height: 1.4;
}

/* Progress bar */
.ad-progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.1);
    border-radius: 99px;
    overflow: hidden;
    margin-top: 4px;
}

#ad-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #a855f7, #ff477e);
    border-radius: 99px;
    transition: width 0.2s linear;
}

/* Boost HUD */
#boost-hud {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 15px;
    z-index: 50;
    background: var(--glass);
    padding: 10px 20px;
    border-radius: 30px;
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
}

.boost-btn {
    position: relative;
    width: 45px;
    height: 45px;
    background: rgba(0,0,0,0.5);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    border: 2px solid rgba(255,255,255,0.2);
}

.boost-btn:active { transform: scale(0.9); }
.boost-btn.active { background: rgba(255,71,126,0.5); border-color: var(--primary); }
.boost-icon { font-size: 1.5rem; }

.boost-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--primary);
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid #120e1f;
}

/* Loader */
.loader {
    border: 4px solid rgba(255,255,255,0.1);
    border-left-color: var(--primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

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


/* Background Falling Fruits */
.falling-fruit {
    position: absolute;
    top: -100px;
    animation: fallDown linear forwards;
    opacity: 1;
}

@keyframes fallDown {
    0% { transform: translateY(0) rotate(0deg); }
    100% { transform: translateY(120vh) rotate(360deg); }
}


.hidden { display: none !important; }

