/* ============================================
   Ragnarok Landverse — Lucky Draw System
   Premium Dark / Golden / Purple Theme
   ============================================ */

:root {
    --gold-primary: #e8b930;
    --gold-light: #f5d76e;
    --gold-dark: #b8860b;
    --purple-deep: #1a0a2e;
    --purple-mid: #2d1b69;
    --purple-glow: #7b2ff7;
    --purple-light: #b57edc;
    --bg-card: rgba(20, 10, 50, 0.75);
    --bg-card-border: rgba(232, 185, 48, 0.25);
    --text-primary: #f0e6d2;
    --text-secondary: #a89ec4;
    --shadow-gold: 0 0 30px rgba(232, 185, 48, 0.3);
    --shadow-purple: 0 0 40px rgba(123, 47, 247, 0.3);
    --font-display: 'Cinzel', serif;
    --font-body: 'Inter', sans-serif;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    background: var(--purple-deep);
    position: relative;
}

/* Background */
.bg-overlay {
    position: fixed;
    inset: 0;
    background: url('public/bg.png') center center / cover no-repeat;
    z-index: -2;
}

.bg-overlay::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg,
            rgba(26, 10, 46, 0.6) 0%,
            rgba(26, 10, 46, 0.8) 50%,
            rgba(26, 10, 46, 0.95) 100%);
}

/* Particles canvas */
#particles {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
}

/* Container */
.container {
    max-width: 700px;
    margin: 0 auto;
    padding: 30px 20px 60px;
    position: relative;
    z-index: 1;
}

/* ---- Header ---- */
.header {
    text-align: center;
    margin-bottom: 30px;
}

.logo {
    width: 220px;
    height: auto;
    filter: drop-shadow(0 0 20px rgba(232, 185, 48, 0.5));
    animation: float 4s ease-in-out infinite;
    margin-bottom: 8px;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.title {
    font-family: var(--font-display);
    font-size: 2.4rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--gold-light), var(--gold-primary), var(--gold-dark));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    letter-spacing: 3px;
    text-transform: uppercase;
}

.subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-top: 6px;
    font-style: italic;
}

/* ---- Draw Section ---- */
.draw-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    margin-bottom: 36px;
}

/* Slot Wrapper */
.slot-wrapper {
    perspective: 800px;
    width: 100%;
    max-width: 460px;
}

.slot-frame {
    position: relative;
    background: linear-gradient(145deg, rgba(45, 27, 105, 0.9), rgba(20, 10, 50, 0.95));
    border: 2px solid var(--bg-card-border);
    border-radius: 16px;
    padding: 32px 24px;
    text-align: center;
    overflow: hidden;
    box-shadow: var(--shadow-gold), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(12px);
}

.slot-frame::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 20%;
    right: 20%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--gold-primary), transparent);
}

.slot-display {
    position: relative;
    z-index: 1;
}

.slot-text {
    font-family: var(--font-display);
    font-size: 2.6rem;
    font-weight: 700;
    color: var(--gold-light);
    text-shadow: 0 0 20px rgba(232, 185, 48, 0.6);
    display: block;
    min-height: 60px;
    line-height: 60px;
    transition: var(--transition);
    word-break: break-all;
}

.slot-text.spinning {
    animation: spin 0.08s steps(1) infinite;
    color: var(--purple-light);
    text-shadow: 0 0 12px rgba(181, 126, 220, 0.6);
}

@keyframes spin {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }

    100% {
        opacity: 1;
    }
}

.slot-text.reveal {
    animation: revealPop 0.5s ease-out forwards;
}

@keyframes revealPop {
    0% {
        transform: scale(1.8);
        opacity: 0;
    }

    60% {
        transform: scale(0.95);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.slot-glow {
    position: absolute;
    inset: 0;
    border-radius: 16px;
    opacity: 0;
    background: radial-gradient(ellipse at center, rgba(232, 185, 48, 0.15) 0%, transparent 70%);
    transition: opacity 0.5s;
    pointer-events: none;
}

.slot-glow.active {
    opacity: 1;
    animation: pulseGlow 1.5s ease-in-out infinite;
}

@keyframes pulseGlow {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }
}

/* Draw Button */
.draw-btn {
    position: relative;
    padding: 16px 56px;
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--purple-deep);
    background: linear-gradient(135deg, var(--gold-light), var(--gold-primary), var(--gold-dark));
    border: none;
    border-radius: 50px;
    cursor: pointer;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(232, 185, 48, 0.4), 0 0 40px rgba(232, 185, 48, 0.15);
    transition: all var(--transition);
    text-transform: uppercase;
}

.draw-btn:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 8px 35px rgba(232, 185, 48, 0.55), 0 0 60px rgba(232, 185, 48, 0.25);
}

.draw-btn:active {
    transform: translateY(0) scale(0.98);
}

.draw-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.draw-btn-shine {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: shine 3s infinite;
}

@keyframes shine {
    0% {
        left: -100%;
    }

    30% {
        left: 100%;
    }

    100% {
        left: 100%;
    }
}

.draw-btn-text {
    position: relative;
    z-index: 1;
}

/* Stats */
.stats-bar {
    display: flex;
    gap: 40px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-secondary);
}

.stat-value {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gold-primary);
    text-shadow: 0 0 8px rgba(232, 185, 48, 0.3);
}

/* ---- History Section ---- */
.history-section {
    background: var(--bg-card);
    border: 1px solid var(--bg-card-border);
    border-radius: 16px;
    padding: 24px;
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow-purple);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.history-title {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--gold-primary);
    letter-spacing: 1px;
}

.history-actions {
    display: flex;
    gap: 8px;
}

.export-btn {
    font-family: var(--font-body);
    font-size: 0.8rem;
    padding: 8px 16px;
    background: rgba(46, 204, 113, 0.15);
    border: 1px solid rgba(46, 204, 113, 0.3);
    color: #2ecc71;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition);
}

.export-btn:hover {
    background: rgba(46, 204, 113, 0.3);
    border-color: rgba(46, 204, 113, 0.6);
    transform: translateY(-1px);
}

.reset-btn {
    font-family: var(--font-body);
    font-size: 0.8rem;
    padding: 8px 16px;
    background: rgba(255, 60, 60, 0.15);
    border: 1px solid rgba(255, 60, 60, 0.3);
    color: #ff6b6b;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition);
}

.reset-btn:hover {
    background: rgba(255, 60, 60, 0.3);
    border-color: rgba(255, 60, 60, 0.6);
    transform: translateY(-1px);
}

/* Table */
.history-table-wrapper {
    max-height: 400px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--gold-dark) transparent;
}

.history-table-wrapper::-webkit-scrollbar {
    width: 6px;
}

.history-table-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

.history-table-wrapper::-webkit-scrollbar-thumb {
    background: var(--gold-dark);
    border-radius: 3px;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    display: none;
}

.history-table.visible {
    display: table;
}

.history-table th {
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--gold-primary);
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--bg-card-border);
    position: sticky;
    top: 0;
    background: rgba(20, 10, 50, 0.98);
    z-index: 2;
}

.history-table td {
    padding: 10px 12px;
    font-size: 0.9rem;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(232, 185, 48, 0.07);
}

.history-table tbody tr {
    transition: background var(--transition);
}

.history-table tbody tr:hover {
    background: rgba(123, 47, 247, 0.1);
}

.history-table tbody tr.new-row {
    animation: rowSlideIn 0.4s ease-out;
}

@keyframes rowSlideIn {
    0% {
        opacity: 0;
        transform: translateX(-20px);
        background: rgba(232, 185, 48, 0.2);
    }

    100% {
        opacity: 1;
        transform: translateX(0);
        background: transparent;
    }
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-style: italic;
    font-size: 0.9rem;
}

.empty-state.hidden {
    display: none;
}

/* ---- Navigation Bar ---- */
.nav-bar {
    display: flex;
    justify-content: center;
    margin-top: 24px;
    gap: 12px;
}

.nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 10px 24px;
    background: var(--bg-card);
    border: 1px solid var(--bg-card-border);
    color: var(--gold-primary);
    border-radius: 10px;
    cursor: pointer;
    text-decoration: none;
    backdrop-filter: blur(12px);
    transition: all var(--transition);
}

.nav-btn:hover {
    background: rgba(232, 185, 48, 0.12);
    border-color: var(--gold-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(232, 185, 48, 0.2);
}

/* ---- Responsive ---- */
@media (max-width: 600px) {
    .container {
        padding: 20px 14px 40px;
    }

    .logo {
        width: 160px;
    }

    .title {
        font-size: 1.7rem;
    }

    .slot-text {
        font-size: 1.8rem;
        min-height: 44px;
        line-height: 44px;
    }

    .slot-frame {
        padding: 24px 16px;
    }

    .draw-btn {
        padding: 14px 40px;
        font-size: 1.1rem;
    }

    .stats-bar {
        gap: 24px;
    }

    .stat-value {
        font-size: 1.2rem;
    }

    .history-section {
        padding: 16px;
    }

    .history-table-wrapper {
        max-height: 300px;
    }
}