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

:root {
    --emerald: #059669;
    --emerald-dark: #064E3B;
    --emerald-darker: #022C22;
    --teal: #0D9488;
    --teal-dark: #134E4A;
    --gold: #D4A853;
    --gold-light: #E8C97A;
    --amber: #F59E0B;
    --cream: #FEF3C7;
    --white: #FFFFFF;
    --bg-start: #022C22;
    --bg-end: #064E3B;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(135deg, var(--bg-start) 0%, var(--bg-end) 50%, #065F46 100%);
    color: var(--cream);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* ===== ISLAMIC PATTERN OVERLAY ===== */
.pattern-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.03;
    background-image: 
        repeating-conic-gradient(
            from 0deg at 50% 50%,
            transparent 0deg 60deg,
            var(--gold) 60deg 61deg,
            transparent 61deg 120deg
        );
    background-size: 80px 80px;
}

/* ===== DECORATIONS ===== */
.decoration {
    position: fixed;
    z-index: 1;
    font-size: 2.5rem;
    animation: float 4s ease-in-out infinite;
    pointer-events: none;
    opacity: 0.6;
}

.lantern-left {
    top: 10%;
    left: 5%;
    animation-delay: 0s;
}

.lantern-right {
    top: 8%;
    right: 5%;
    animation-delay: 1.5s;
}

.crescent {
    top: 3%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 2rem;
    animation-delay: 0.8s;
    opacity: 0.4;
}

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

/* ===== CONTAINER ===== */
.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 1.5rem 1rem 2rem;
    position: relative;
    z-index: 2;
}

/* ===== HEADER ===== */
.header {
    text-align: center;
    margin-bottom: 1rem;
}

.header-ornament {
    color: var(--gold);
    font-size: 1.2rem;
    letter-spacing: 0.5rem;
    opacity: 0.7;
}

.title {
    font-size: 2.5rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold) 50%, var(--amber) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    letter-spacing: 1px;
    line-height: 1.2;
    margin: 0.3rem 0;
}

.subtitle {
    font-size: 0.95rem;
    color: var(--cream);
    opacity: 0.7;
    font-weight: 400;
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* ===== TOTAL COUNTER ===== */
.total-counter {
    background: linear-gradient(135deg, rgba(212, 168, 83, 0.15) 0%, rgba(5, 150, 105, 0.2) 100%);
    border: 1px solid rgba(212, 168, 83, 0.3);
    border-radius: 16px;
    padding: 0.8rem 1.2rem;
    text-align: center;
    margin-bottom: 1.2rem;
    backdrop-filter: blur(10px);
}

.total-label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--gold-light);
    opacity: 0.8;
    margin-bottom: 0.2rem;
}

.total-amount {
    display: block;
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--gold);
    text-shadow: 0 0 20px rgba(212, 168, 83, 0.3);
}

/* ===== NAME INPUT ===== */
.name-section {
    margin-bottom: 1.2rem;
}

.input-wrapper {
    position: relative;
}

.input-wrapper input {
    width: 100%;
    padding: 0.9rem 1.2rem;
    font-family: 'Poppins', sans-serif;
    font-size: 1rem;
    font-weight: 500;
    color: var(--white);
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(212, 168, 83, 0.3);
    border-radius: 14px;
    outline: none;
    transition: all 0.3s ease;
    text-align: center;
}

.input-wrapper input::placeholder {
    color: rgba(254, 243, 199, 0.4);
}

.input-wrapper input:focus {
    border-color: var(--gold);
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 0 20px rgba(212, 168, 83, 0.2);
}

.input-glow {
    position: absolute;
    inset: -2px;
    border-radius: 16px;
    opacity: 0;
    background: linear-gradient(135deg, var(--gold), var(--emerald));
    z-index: -1;
    transition: opacity 0.3s ease;
    filter: blur(8px);
}

.input-wrapper input:focus ~ .input-glow {
    opacity: 0.3;
}

/* ===== WHEEL ===== */
.wheel-container {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

.wheel-frame {
    position: relative;
    width: 340px;
    height: 340px;
}

.wheel-pointer {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 2rem;
    color: var(--gold);
    z-index: 10;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
    line-height: 1;
    text-shadow: 0 0 10px rgba(212, 168, 83, 0.5);
}

#wheelCanvas {
    border-radius: 50%;
    box-shadow: 
        0 0 0 8px var(--gold),
        0 0 0 12px rgba(212, 168, 83, 0.3),
        0 0 40px rgba(212, 168, 83, 0.2),
        inset 0 0 30px rgba(0,0,0,0.2);
}

.spin-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gold) 0%, var(--amber) 100%);
    border: 3px solid var(--gold-light);
    color: var(--emerald-dark);
    font-family: 'Poppins', sans-serif;
    font-size: 0.85rem;
    font-weight: 800;
    cursor: pointer;
    z-index: 5;
    box-shadow: 
        0 4px 15px rgba(212, 168, 83, 0.4),
        inset 0 1px 0 rgba(255,255,255,0.3);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spin-btn:hover:not(:disabled) {
    transform: translate(-50%, -50%) scale(1.08);
    box-shadow: 
        0 6px 25px rgba(212, 168, 83, 0.5),
        inset 0 1px 0 rgba(255,255,255,0.3);
}

.spin-btn:active:not(:disabled) {
    transform: translate(-50%, -50%) scale(0.95);
}

.spin-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== LARGE SPIN BUTTON (Mobile) ===== */
.spin-btn-large {
    width: 100%;
    padding: 1rem;
    font-family: 'Poppins', sans-serif;
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--emerald-darker);
    background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold) 50%, var(--amber) 100%);
    border: none;
    border-radius: 16px;
    cursor: pointer;
    box-shadow: 
        0 6px 25px rgba(212, 168, 83, 0.3),
        inset 0 1px 0 rgba(255,255,255,0.2);
    transition: all 0.3s ease;
    margin-bottom: 1.5rem;
    letter-spacing: 1px;
}

.spin-btn-large:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 
        0 8px 30px rgba(212, 168, 83, 0.5),
        inset 0 1px 0 rgba(255,255,255,0.2);
}

.spin-btn-large:active:not(:disabled) {
    transform: translateY(0);
}

.spin-btn-large:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* ===== HISTORY ===== */
.history-section {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(212, 168, 83, 0.2);
    border-radius: 16px;
    padding: 1.2rem;
    backdrop-filter: blur(10px);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
}

.history-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gold-light);
}

.reset-btn {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #FCA5A5;
    font-family: 'Poppins', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.reset-btn:hover {
    background: rgba(239, 68, 68, 0.25);
}

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

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.7rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    border-left: 3px solid var(--gold);
    animation: slideIn 0.4s ease;
}

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

.history-item .amount {
    font-weight: 700;
    color: var(--gold);
    font-size: 0.9rem;
}

.history-item .time {
    font-size: 0.7rem;
    opacity: 0.5;
    margin-left: 0.5rem;
}

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

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2, 44, 34, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: linear-gradient(135deg, #065F46 0%, #064E3B 100%);
    border: 2px solid var(--gold);
    border-radius: 24px;
    padding: 2.5rem 2rem;
    text-align: center;
    max-width: 380px;
    width: 90%;
    transform: scale(0.8);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    box-shadow: 
        0 0 60px rgba(212, 168, 83, 0.2),
        0 20px 60px rgba(0, 0, 0, 0.4);
    overflow: hidden;
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-confetti-left,
.modal-confetti-right {
    position: absolute;
    top: 1rem;
    font-size: 2rem;
    animation: bounce 0.6s ease infinite alternate;
}

.modal-confetti-left { left: 1.5rem; }
.modal-confetti-right { right: 1.5rem; animation-delay: 0.3s; }

.modal-star {
    position: absolute;
    top: 0.5rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.5rem;
    animation: spin-star 3s linear infinite;
}

@keyframes bounce {
    from { transform: translateY(0) rotate(-5deg); }
    to { transform: translateY(-8px) rotate(5deg); }
}

@keyframes spin-star {
    from { transform: translateX(-50%) rotate(0deg); }
    to { transform: translateX(-50%) rotate(360deg); }
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--gold);
    margin-bottom: 0.8rem;
    margin-top: 0.5rem;
}

.modal-name {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--white);
    margin-bottom: 0.3rem;
}

.modal-label {
    font-size: 0.85rem;
    color: var(--cream);
    opacity: 0.7;
    margin-bottom: 0.3rem;
}

.modal-amount {
    font-size: 2.5rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--gold-light) 0%, var(--amber) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.modal-greeting {
    font-size: 0.9rem;
    color: var(--cream);
    opacity: 0.6;
    margin-bottom: 1.2rem;
}

.modal-close {
    background: linear-gradient(135deg, var(--gold) 0%, var(--amber) 100%);
    color: var(--emerald-darker);
    border: none;
    font-family: 'Poppins', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    padding: 0.8rem 2rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(212, 168, 83, 0.3);
}

.modal-close:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(212, 168, 83, 0.5);
}

/* ===== CONFETTI CANVAS ===== */
#confettiCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
}

/* ===== FOOTER ===== */
.footer {
    text-align: center;
    padding: 1rem;
    opacity: 0.4;
    font-size: 0.8rem;
}

/* ===== SCROLLBAR ===== */
.history-list::-webkit-scrollbar {
    width: 4px;
}

.history-list::-webkit-scrollbar-track {
    background: transparent;
}

.history-list::-webkit-scrollbar-thumb {
    background: rgba(212, 168, 83, 0.3);
    border-radius: 4px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 400px) {
    .container {
        padding: 1rem 0.8rem 2rem;
    }
    
    .title {
        font-size: 2rem;
    }
    
    .wheel-frame {
        width: 300px;
        height: 300px;
    }
    
    #wheelCanvas {
        width: 300px;
        height: 300px;
    }
    
    .spin-btn {
        width: 60px;
        height: 60px;
        font-size: 0.75rem;
    }
    
    .total-amount {
        font-size: 1.5rem;
    }
    
    .modal-amount {
        font-size: 2rem;
    }
}

@media (max-width: 350px) {
    .wheel-frame {
        width: 270px;
        height: 270px;
    }
    
    #wheelCanvas {
        width: 270px;
        height: 270px;
    }
}

/* ===== CUSTOM MODAL (Password & Confirm) ===== */
.custom-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2, 44, 34, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.custom-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.custom-modal {
    background: linear-gradient(145deg, #065F46 0%, #064E3B 60%, #022C22 100%);
    border: 1.5px solid rgba(212, 168, 83, 0.5);
    border-radius: 20px;
    padding: 2rem 1.8rem;
    text-align: center;
    max-width: 380px;
    width: 90%;
    transform: scale(0.85) translateY(20px);
    transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    box-shadow:
        0 0 50px rgba(212, 168, 83, 0.15),
        0 20px 50px rgba(0, 0, 0, 0.4);
}

.custom-modal-overlay.active .custom-modal {
    transform: scale(1) translateY(0);
}

.custom-modal-icon {
    margin-bottom: 0.6rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.custom-modal-icon.warning-icon {
    filter: drop-shadow(0 0 12px rgba(245, 158, 11, 0.4));
}

.custom-modal-title {
    font-family: 'Poppins', sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--gold);
    margin-bottom: 0.4rem;
}

.custom-modal-desc {
    font-family: 'Poppins', sans-serif;
    font-size: 0.85rem;
    color: var(--cream);
    opacity: 0.65;
    line-height: 1.5;
    margin-bottom: 1.2rem;
}

/* Password Input */
.password-input-wrapper {
    position: relative;
    margin-bottom: 1.4rem;
}

.password-field {
    width: 100%;
    padding: 0.85rem 3rem 0.85rem 1.2rem;
    font-family: 'Poppins', sans-serif;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--white);
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(212, 168, 83, 0.3);
    border-radius: 12px;
    outline: none;
    transition: all 0.3s ease;
    text-align: center;
    letter-spacing: 2px;
}

.password-field::placeholder {
    color: rgba(254, 243, 199, 0.35);
    letter-spacing: 0;
}

.password-field:focus {
    border-color: var(--gold);
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 0 20px rgba(212, 168, 83, 0.15);
}

.password-toggle {
    position: absolute;
    right: 0.8rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.3rem;
    opacity: 0.6;
    transition: opacity 0.2s ease;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.password-toggle:hover {
    opacity: 1;
}

/* Modal Buttons */
.custom-modal-actions {
    display: flex;
    gap: 0.7rem;
    justify-content: center;
}

.custom-btn {
    font-family: 'Poppins', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.7rem 1.5rem;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    transition: all 0.25s ease;
    flex: 1;
    max-width: 160px;
}

.btn-cancel {
    background: rgba(255, 255, 255, 0.08);
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    color: var(--cream);
}

.btn-cancel:hover {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.25);
}

.btn-confirm {
    background: linear-gradient(135deg, var(--gold) 0%, var(--amber) 100%);
    color: var(--emerald-darker);
    box-shadow: 0 4px 12px rgba(212, 168, 83, 0.25);
}

.btn-confirm:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(212, 168, 83, 0.4);
}

.btn-destructive {
    background: linear-gradient(135deg, #DC2626 0%, #B91C1C 100%);
    color: #FFFFFF;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.25);
}

.btn-destructive:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(220, 38, 38, 0.4);
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    pointer-events: none;
    width: 90%;
    max-width: 400px;
}

.toast {
    width: 100%;
    padding: 0.85rem 1.2rem;
    border-radius: 14px;
    font-family: 'Poppins', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    pointer-events: auto;
    animation: toastSlideIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.toast.toast-removing {
    animation: toastSlideOut 0.3s ease forwards;
}

.toast-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.toast-message {
    flex: 1;
    line-height: 1.3;
}

/* Toast Types */
.toast-success {
    background: linear-gradient(135deg, rgba(5, 150, 105, 0.92) 0%, rgba(6, 95, 70, 0.92) 100%);
    border: 1px solid rgba(16, 185, 129, 0.5);
    color: #D1FAE5;
}

.toast-error {
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.92) 0%, rgba(153, 27, 27, 0.92) 100%);
    border: 1px solid rgba(248, 113, 113, 0.4);
    color: #FEE2E2;
}

.toast-info {
    background: linear-gradient(135deg, rgba(212, 168, 83, 0.92) 0%, rgba(180, 130, 50, 0.92) 100%);
    border: 1px solid rgba(232, 201, 122, 0.5);
    color: var(--emerald-darker);
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

/* ===== PULSE ANIMATION ===== */
@keyframes pulse-gold {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(212, 168, 83, 0.4);
    }
    50% {
        box-shadow: 0 0 0 12px rgba(212, 168, 83, 0);
    }
}

.spin-btn-large:not(:disabled) {
    animation: pulse-gold 2s ease-in-out infinite;
}

/* ===== SHAKE ANIMATION (for invalid input) ===== */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
    20%, 40%, 60%, 80% { transform: translateX(4px); }
}

.shake {
    animation: shake 0.5s ease;
}
