/* === Reset & Base === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --gold: #FFD700;
    --gold-dark: #B8860B;
    --green: #00C853;
    --green-dark: #009624;
    --purple: #7C4DFF;
    --purple-dark: #651FFF;
    --red: #FF1744;
    --bg-dark: #0a0a1a;
    --bg-card: #1a1a2e;
    --bg-card-light: #25254a;
    --text: #ffffff;
    --text-muted: #a0a0c0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Poppins', sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* === Particles === */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.particle {
    position: absolute;
    border-radius: 50%;
    animation: float-particle linear infinite;
    opacity: 0.3;
}

@keyframes float-particle {
    0% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 0.3;
    }
    90% {
        opacity: 0.3;
    }
    100% {
        transform: translateY(-20px) rotate(720deg);
        opacity: 0;
    }
}

/* === Header === */
.header {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 3px solid var(--gold);
    box-shadow: 0 4px 30px rgba(255, 215, 0, 0.2);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-icon {
    font-size: 2rem;
    animation: spin-slow 3s ease-in-out infinite;
}

@keyframes spin-slow {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(15deg); }
    75% { transform: rotate(-15deg); }
}

.logo h1 {
    font-family: 'Bangers', cursive;
    font-size: 1.8rem;
    letter-spacing: 3px;
    background: linear-gradient(to right, var(--gold), #fff, var(--gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
}

.highlight {
    color: var(--red);
    -webkit-text-fill-color: var(--red);
}

.balance-bar {
    display: flex;
    gap: 1rem;
}

.balance, .tickets-count {
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: 12px;
    padding: 0.4rem 1rem;
    text-align: center;
}

.admin-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    text-decoration: none;
    font-size: 1.2rem;
    transition: all 0.2s;
}

.admin-link:hover {
    background: rgba(255, 215, 0, 0.1);
    border-color: rgba(255, 215, 0, 0.3);
}

.balance-label {
    display: block;
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.balance-amount {
    display: block;
    font-weight: 700;
    color: var(--gold);
    font-size: 1.1rem;
}

/* === Main === */
.main-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
    position: relative;
    z-index: 1;
}

.section-title {
    font-family: 'Bangers', cursive;
    font-size: 1.6rem;
    letter-spacing: 2px;
    text-align: center;
    margin-bottom: 1rem;
    color: var(--gold);
}

/* === Prize Showcase === */
.prize-showcase {
    margin-bottom: 2rem;
}

.prizes-carousel {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding: 0.5rem;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.prizes-carousel::-webkit-scrollbar {
    display: none;
}

.prize-card {
    flex: 0 0 140px;
    background: linear-gradient(145deg, var(--bg-card), var(--bg-card-light));
    border: 2px solid rgba(255, 215, 0, 0.2);
    border-radius: 16px;
    padding: 1rem;
    text-align: center;
    scroll-snap-align: start;
    transition: all 0.3s ease;
    cursor: pointer;
}

.prize-card:hover {
    border-color: var(--gold);
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(255, 215, 0, 0.2);
}

.prize-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    animation: bounce-subtle 2s ease-in-out infinite;
}

@keyframes bounce-subtle {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.prize-name {
    font-weight: 700;
    font-size: 0.8rem;
    margin-bottom: 0.3rem;
}

.prize-value {
    font-size: 0.75rem;
    color: var(--green);
    font-weight: 600;
}

/* === Scratch Card === */
.scratch-section {
    margin-bottom: 2rem;
}

.scratch-instruction {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    animation: pulse-text 2s ease-in-out infinite;
}

@keyframes pulse-text {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

.scratch-card-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.scratch-card {
    width: 320px;
    height: 220px;
    position: relative;
    border-radius: 20px;
    overflow: hidden;
    box-shadow:
        0 0 0 3px var(--gold),
        0 0 30px rgba(255, 215, 0, 0.3),
        0 20px 60px rgba(0, 0, 0, 0.5);
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32"><text y="24" font-size="24">🪙</text></svg>') 16 16, crosshair;
}

.prize-reveal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a0a2e 0%, #2d1b69 50%, #1a0a2e 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.prize-reveal-icon {
    font-size: 3.5rem;
    margin-bottom: 0.5rem;
    animation: bounce-subtle 1.5s ease-in-out infinite;
}

.prize-reveal-name {
    font-family: 'Bangers', cursive;
    font-size: 1.4rem;
    letter-spacing: 2px;
    color: var(--gold);
    text-align: center;
}

.prize-reveal-value {
    font-size: 1rem;
    color: var(--green);
    font-weight: 700;
    margin-top: 0.3rem;
}

.prize-symbols {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.prize-symbols .symbol {
    width: 40px;
    height: 40px;
    background: rgba(255, 215, 0, 0.1);
    border: 2px solid rgba(255, 215, 0, 0.3);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

#scratchCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 20px;
    touch-action: none;
}

/* === Progress Bar === */
.scratch-progress {
    width: 320px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: var(--bg-card);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(255, 215, 0, 0.2);
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--gold-dark), var(--gold));
    border-radius: 10px;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* === Buttons === */
.btn-new-card {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin: 1.5rem auto 0;
    padding: 0.8rem 2rem;
    font-family: 'Bangers', cursive;
    font-size: 1.3rem;
    letter-spacing: 2px;
    color: var(--bg-dark);
    background: linear-gradient(135deg, var(--gold), #ffec80, var(--gold));
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 20px rgba(255, 215, 0, 0.3);
}

.btn-new-card:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(255, 215, 0, 0.5);
}

.btn-new-card:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-new-card:active:not(:disabled) {
    transform: translateY(0);
}

.btn-icon {
    font-size: 1.4rem;
}

/* === History === */
.history-section {
    margin-bottom: 2rem;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
}

.history-empty {
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    padding: 2rem;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border-radius: 12px;
    border-left: 4px solid var(--gold);
    animation: slide-in 0.3s ease;
}

.history-item.loser {
    border-left-color: #666;
    opacity: 0.6;
}

@keyframes slide-in {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.history-icon {
    font-size: 1.5rem;
}

.history-info {
    flex: 1;
}

.history-name {
    font-weight: 600;
    font-size: 0.85rem;
}

.history-date {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.history-value {
    font-weight: 700;
    color: var(--green);
    font-size: 0.85rem;
}

.history-item.loser .history-value {
    color: #888;
}

/* === Modals === */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: linear-gradient(145deg, #1a1a3e, #2d1b69);
    border: 3px solid var(--gold);
    border-radius: 24px;
    padding: 2.5rem 2rem;
    text-align: center;
    max-width: 400px;
    width: 90%;
    position: relative;
    animation: modal-pop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    overflow: hidden;
}

.modal-content.loser {
    border-color: #555;
}

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

.modal-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: bounce-subtle 1s ease-in-out infinite;
}

.modal-title {
    font-family: 'Bangers', cursive;
    font-size: 2.5rem;
    letter-spacing: 3px;
    color: var(--gold);
    margin-bottom: 0.5rem;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
}

.modal-prize {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 0.3rem;
}

.modal-value {
    font-size: 1.1rem;
    color: var(--green);
    font-weight: 600;
    margin-bottom: 1.5rem;
}

.btn-claim {
    padding: 0.8rem 2.5rem;
    font-family: 'Bangers', cursive;
    font-size: 1.3rem;
    letter-spacing: 2px;
    color: var(--bg-dark);
    background: linear-gradient(135deg, var(--gold), #ffec80, var(--gold));
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 20px rgba(255, 215, 0, 0.4);
}

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

.btn-try-again {
    background: linear-gradient(135deg, #555, #888, #555);
    box-shadow: 0 5px 20px rgba(100, 100, 100, 0.3);
}

/* === Confetti === */
.confetti-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.confetti-piece {
    position: absolute;
    top: -10px;
    animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(-10px) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(500px) rotate(720deg);
        opacity: 0;
    }
}

/* === Glow effect on scratch === */
.scratch-card.scratching {
    box-shadow:
        0 0 0 3px var(--gold),
        0 0 40px rgba(255, 215, 0, 0.5),
        0 0 80px rgba(255, 215, 0, 0.2),
        0 20px 60px rgba(0, 0, 0, 0.5);
}

/* === Shimmer effect === */
.scratch-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.05),
        transparent
    );
    animation: shimmer 3s ease-in-out infinite;
    pointer-events: none;
    z-index: 5;
}

@keyframes shimmer {
    0%, 100% { left: -100%; }
    50% { left: 100%; }
}

/* === Responsive === */
@media (max-width: 480px) {
    .header {
        flex-direction: column;
        gap: 0.75rem;
        padding: 0.75rem 1rem;
    }

    .logo h1 {
        font-size: 1.4rem;
    }

    .scratch-card {
        width: 290px;
        height: 200px;
    }

    .scratch-progress {
        width: 290px;
    }

    .section-title {
        font-size: 1.3rem;
    }

    .balance-amount {
        font-size: 0.95rem;
    }
}

@media (min-width: 768px) {
    .scratch-card {
        width: 380px;
        height: 260px;
    }

    .scratch-progress {
        width: 380px;
    }

    .prize-reveal-icon {
        font-size: 4.5rem;
    }

    .prize-reveal-name {
        font-size: 1.8rem;
    }
}

/* === Screen shake on win === */
@keyframes screen-shake {
    0%, 100% { transform: translate(0); }
    10% { transform: translate(-5px, -5px); }
    20% { transform: translate(5px, -5px); }
    30% { transform: translate(-5px, 5px); }
    40% { transform: translate(5px, 5px); }
    50% { transform: translate(-3px, -3px); }
    60% { transform: translate(3px, -3px); }
    70% { transform: translate(-3px, 3px); }
    80% { transform: translate(3px, 3px); }
    90% { transform: translate(-1px, -1px); }
}

body.shake {
    animation: screen-shake 0.5s ease-in-out;
}

/* === Sparkle text === */
@keyframes sparkle {
    0%, 100% { text-shadow: 0 0 10px var(--gold), 0 0 20px var(--gold); }
    50% { text-shadow: 0 0 20px var(--gold), 0 0 40px var(--gold), 0 0 60px var(--gold); }
}

.sparkle-text {
    animation: sparkle 1s ease-in-out infinite;
}

/* === Shop === */
.shop-section {
    margin-bottom: 2rem;
}

.shop-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.shop-card {
    background: linear-gradient(145deg, var(--bg-card), var(--bg-card-light));
    border: 2px solid rgba(255, 215, 0, 0.15);
    border-radius: 18px;
    padding: 1.2rem 1rem;
    text-align: center;
    position: relative;
    transition: all 0.3s ease;
}

.shop-card:hover {
    transform: translateY(-4px);
    border-color: rgba(255, 215, 0, 0.4);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.shop-card.popular {
    border-color: var(--gold);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.15);
}

.shop-card.premium {
    border-color: var(--purple);
    box-shadow: 0 0 20px rgba(124, 77, 255, 0.15);
    background: linear-gradient(145deg, #1a1a3e, #2d1b69);
}

.shop-badge {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card-light);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    padding: 0.15rem 0.75rem;
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.shop-badge.popular-badge {
    background: linear-gradient(135deg, var(--gold-dark), var(--gold));
    color: var(--bg-dark);
    border: none;
}

.shop-badge.premium-badge {
    background: linear-gradient(135deg, var(--purple-dark), var(--purple));
    color: #fff;
    border: none;
}

.shop-icon {
    font-size: 2rem;
    margin: 0.5rem 0;
    line-height: 1.3;
}

.shop-qty {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 0.2rem;
}

.shop-price {
    font-family: 'Bangers', cursive;
    font-size: 1.5rem;
    color: var(--gold);
    letter-spacing: 1px;
}

.shop-savings {
    font-size: 0.7rem;
    color: var(--green);
    font-weight: 600;
    margin-bottom: 0.3rem;
}

.btn-buy {
    margin-top: 0.6rem;
    padding: 0.5rem 1.5rem;
    font-family: 'Poppins', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--bg-dark);
    background: linear-gradient(135deg, var(--gold), #ffec80);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
}

.btn-buy:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.4);
}

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

.btn-buy-popular {
    background: linear-gradient(135deg, #ff9100, #ffc107);
}

.btn-buy-premium {
    background: linear-gradient(135deg, var(--purple), #b388ff);
    color: #fff;
}

.btn-buy.insufficient {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Purchase success flash */
@keyframes purchase-flash {
    0% { box-shadow: 0 0 0 0 rgba(0, 200, 83, 0.6); }
    50% { box-shadow: 0 0 30px 10px rgba(0, 200, 83, 0.3); }
    100% { box-shadow: 0 0 0 0 rgba(0, 200, 83, 0); }
}

.shop-card.purchased {
    animation: purchase-flash 0.6s ease;
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    z-index: 2000;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    white-space: nowrap;
    pointer-events: none;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    background: linear-gradient(135deg, #00c853, #69f0ae);
    color: var(--bg-dark);
    box-shadow: 0 5px 20px rgba(0, 200, 83, 0.4);
}

.toast.error {
    background: linear-gradient(135deg, #ff1744, #ff8a80);
    color: #fff;
    box-shadow: 0 5px 20px rgba(255, 23, 68, 0.4);
}

@media (max-width: 480px) {
    .shop-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .shop-price {
        font-size: 1.2rem;
    }

    .shop-icon {
        font-size: 1.5rem;
    }
}
