/* ── Base ── */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    background:
        radial-gradient(
            ellipse 80% 50% at 0% -20%,
            #f0e6d8,
            transparent 60%
        ),
        radial-gradient(
            ellipse 80% 50% at 100% 120%,
            #e4d5c8,
            transparent 60%
        ),
        #faf7f4;
    min-height: 100vh;
    overflow-x: hidden;
    font-feature-settings: "cv02", "cv03", "cv04", "cv11";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.dark body {
    background:
        radial-gradient(
            ellipse 80% 50% at 0% -20%,
            #2a2533,
            transparent 60%
        ),
        radial-gradient(
            ellipse 80% 50% at 100% 120%,
            #1e1a2a,
            transparent 60%
        ),
        #13111a;
}

/* ── Glassmorphism ── */
.glass {
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.04);
}

.dark .glass {
    background: rgba(22, 19, 32, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.2);
}

.glass-strong {
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: 0 4px 32px rgba(0, 0, 0, 0.05);
}

.dark .glass-strong {
    background: rgba(22, 19, 32, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.07);
    box-shadow: 0 4px 32px rgba(0, 0, 0, 0.3);
}

/* ── Animations ── */
.fade-in {
    animation: fadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.fade-in-up {
    animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.slide-up {
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes countUp {
    from {
        opacity: 0;
        transform: scale(1.2);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(-12px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(-12px) scale(0.96);
    }
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

@keyframes pulseDot {
    0%,
    100% {
        opacity: 0.4;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.15);
    }
}

.animate-fade-in {
    animation: fadeIn 0.3s ease;
}

.animate-toast-in {
    animation: toastIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-toast-out {
    animation: toastOut 0.25s ease forwards;
}

/* ── Overlay ── */
.modal-overlay {
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    display: none;
}

.modal-overlay:not(.hidden) {
    opacity: 1;
}

/* ── Score ── */
.score-value {
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.score-value.bump {
    animation: countUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Bar ── */
.bar {
    transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Progress bar inner animation on mount ── */
.bar-animate {
    animation: barGrow 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    width: 0% !important;
}

@keyframes barGrow {
    to {
        width: var(--bar-width);
    }
}

/* ── Stagger children ── */
.stagger > * {
    opacity: 0;
    animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.stagger > *:nth-child(1) {
    animation-delay: 0.02s;
}
.stagger > *:nth-child(2) {
    animation-delay: 0.06s;
}
.stagger > *:nth-child(3) {
    animation-delay: 0.1s;
}
.stagger > *:nth-child(4) {
    animation-delay: 0.14s;
}
.stagger > *:nth-child(5) {
    animation-delay: 0.18s;
}
.stagger > *:nth-child(6) {
    animation-delay: 0.22s;
}
.stagger > *:nth-child(7) {
    animation-delay: 0.26s;
}
.stagger > *:nth-child(8) {
    animation-delay: 0.3s;
}

/* ── Scrollbar ── */
.scrollbar-thin::-webkit-scrollbar {
    width: 4px;
}
.scrollbar-thin::-webkit-scrollbar-track {
    background: transparent;
}
.scrollbar-thin::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 99px;
}
.dark .scrollbar-thin::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
}

/* ── Input ── */
.input-elegant {
    transition: all 0.2s ease;
}
.input-elegant:focus {
    box-shadow:
        0 0 0 2px rgba(139, 119, 101, 0.15),
        0 0 0 4px rgba(139, 119, 101, 0.06);
    border-color: #8b7765;
}
.dark .input-elegant:focus {
    box-shadow:
        0 0 0 2px rgba(180, 160, 140, 0.2),
        0 0 0 4px rgba(180, 160, 140, 0.08);
    border-color: #b4a08c;
}

/* ── Button ── */
.btn-primary {
    background: linear-gradient(135deg, #8b7765, #7a6757);
    transition: all 0.25s ease;
}
.btn-primary:hover {
    background: linear-gradient(135deg, #7a6757, #6a5849);
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(120, 100, 80, 0.25);
}
.btn-primary:active {
    transform: translateY(0px);
}
.dark .btn-primary {
    background: linear-gradient(135deg, #c4b4a4, #b4a08c);
    color: #1a1723;
}
.dark .btn-primary:hover {
    background: linear-gradient(135deg, #d4c4b4, #c4b4a4);
    box-shadow: 0 6px 24px rgba(200, 180, 160, 0.15);
}

/* ── Active game dot ── */
.live-dot {
    animation: pulseDot 1.8s ease-in-out infinite;
}

/* ── History card staggered appearance ── */
.history-card {
    opacity: 0;
    animation: slideUp 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.history-card:nth-child(1) {
    animation-delay: 0.04s;
}
.history-card:nth-child(2) {
    animation-delay: 0.1s;
}
.history-card:nth-child(3) {
    animation-delay: 0.16s;
}
.history-card:nth-child(4) {
    animation-delay: 0.22s;
}
.history-card:nth-child(5) {
    animation-delay: 0.28s;
}
.history-card:nth-child(6) {
    animation-delay: 0.34s;
}
