:root {
    --bg-main: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.5);
    --bg-keypad: #0f172a;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-ui: #1e293b;
    --color-score: #16a34a;
    --color-danger: #dc2626;
}

body.light-theme {
    --bg-main: #ffffff;
    --bg-card: #f3f4f6;
    --bg-keypad: #f9fafb;
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --border-ui: #e5e7eb;
    --color-score: #15803d;
    --color-danger: #b91c1c;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    transition: background-color 0.3s ease;
    font-family: system-ui, -apple-system, sans-serif;
    margin: 0;
}

/* --- Fixed Onboarding Layout --- */
#onboarding-container {
    position: fixed;
    inset: 0;
    z-index: 3000;
    background-color: #0f172a; /* Solid background matches splash */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.onboarding-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 2rem;
    width: 100%;
    height: 100%;
}

/* --- Improved Slide Animations --- */
.slide-in-right {
    animation: slideInRight 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.slide-out-left {
    animation: slideOutLeft 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

@keyframes slideOutLeft {
    from { transform: translateX(0); }
    to { transform: translateX(-100%); }
}

/* --- General Animations --- */
.animate-fadeIn { 
    animation: fadeIn 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) forwards; 
    opacity: 0;
}

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

/* --- Screen Layout --- */
.scroll-area { height: 65%; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.keypad-area { height: 35%; position: relative; z-index: 50; background-color: var(--bg-keypad); border-top: 1px solid var(--border-ui); }

.dice-row { background-color: var(--bg-card); transition: all 0.2s ease; border-left-width: 8px; }

/* --- Navigation & UI --- */
.nav-btn {
    width: 44px; height: 44px; border-radius: 50%;
    background-color: rgba(0,0,0,0.05);
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s ease; color: #3b82f6;
}
.nav-btn:active { transform: scale(0.9); background-color: rgba(0,0,0,0.1); }
.nav-btn.disabled { opacity: 0; pointer-events: none; }

.section-title h3 {
    font-size: 10px; font-weight: 900; text-transform: uppercase;
    letter-spacing: 0.2em; opacity: 0.4; display: flex;
    align-items: center; justify-content: center; gap: 15px;
}
.section-title h3::before, .section-title h3::after {
    content: ""; height: 1px; width: 40px; background-color: var(--border-ui);
}

.expansion-gradient {
    background: linear-gradient(to bottom right, #a855f7, #ef4444, #a855f7);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    display: inline-block; line-height: 1.1;
}

.prev-round-box {
    background-color: #fbbf24; color: #000; border-radius: 16px;
    padding: 12px 16px; font-weight: 900; font-size: 0.75rem; margin-bottom: 12px;
    display: flex; justify-content: space-between; align-items: center;
}

.prev-total-box {
    background-color: #1e293b; color: #f1f5f9; border-radius: 16px;
    padding: 12px 16px; font-weight: 900; font-size: 0.75rem; margin-bottom: 12px;
    display: flex; justify-content: space-between; align-items: center;
    border: 1px solid var(--border-ui);
}

body.light-theme .prev-total-box { background-color: #e2e8f0; color: #0f172a; border-color: #cbd5e1; }

.wild-section-container { margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--border-ui); }

.wild-counter-inline {
    background-color: #ffffff; border: 1px solid #d1d5db;
    border-radius: 20px; padding: 12px 16px; margin-bottom: 16px;
    display: flex; align-items: center; justify-content: space-between;
    color: #000000; box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.wild-btn-minus, .wild-btn-plus {
    width: 38px; height: 38px; color: white; border-radius: 12px; 
    display: flex; align-items: center; justify-content: center; 
    font-size: 1.5rem; font-weight: 900;
}
.wild-btn-minus { background-color: #ef4444; }
.wild-btn-plus { background-color: #000000; }

.wild-card {
    background-color: white; color: #000; border-radius: 20px; padding: 16px;
    border: 3px solid transparent; transition: all 0.2s ease;
    display: flex; flex-direction: column; gap: 12px;
}
.wild-card.active-input { background-color: #000 !important; color: #fff !important; border-color: #16a34a; }
.wild-stack { 
    display: flex; 
    flex-direction: column; 
    gap: 12px; /* This provides the cushion between wild dice cards */
    margin-top: 1rem;
}

.color-picker-wheel { display: flex; justify-content: center; gap: 10px; padding-top: 10px; border-top: 1px solid rgba(0,0,0,0.05); }
.wheel-item { flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%; border: 2px solid #ddd; }
.wheel-item.selected { transform: scale(1.3); border-color: #000; }
.wild-card.active-input .wheel-item.selected { border-color: #fff; }

.sparkle-btn-full { width: 100%; padding: 14px; border-radius: 14px; font-size: 0.85rem; font-weight: 900; text-transform: uppercase; margin-top: 12px; transition: all 0.2s ease; border: 2px solid transparent; }
.sparkle-on { background-color: #3b82f6; color: white; border-color: #60a5fa; }
.sparkle-off { background-color: rgba(0,0,0,0.2); color: var(--text-secondary); border-color: rgba(255,255,255,0.05); }

.kp-btn { transition: all 0.1s ease; border-radius: 18px; font-weight: 900; display: flex; align-items: center; justify-content: center; }
#add-btn { font-size: 1.8rem; writing-mode: vertical-rl; text-orientation: upright; letter-spacing: 0.1em; }

.modal-overlay {
    position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    z-index: 1000; display: flex; align-items: center; justify-content: center;
}
.action-popup {
    width: 85%; max-width: 320px; background-color: var(--bg-main);
    border: 1px solid var(--border-ui); border-radius: 32px; padding: 2rem; text-align: center;
}
.menu-panel { width: 280px; height: 100%; background: var(--bg-main); border-left: 1px solid var(--border-ui); padding: 2rem; }
.grand-total-footer { background-color: white; color: #0f172a; border-radius: 24px; padding: 24px; text-align: center; margin: 2rem 0; }
