/**
 * Random Number Generator Styles (SIP Tool Matching Design System)
 * Minimal, high-contrast, theme-adaptive fullscreen, emerald & slate palette
 */

/* Design Tokens & Theme Variables (Exact SIP alignment) */
:root {
    --rng-brand-primary: #10b981;
    --rng-brand-primary-hover: #059669;
    --rng-brand-primary-light: rgba(16, 185, 129, 0.12);
    --rng-surface-card: #ffffff;
    --rng-surface-soft: #f8fafc;
    --rng-border: #e2e8f0;
    --rng-border-strong: #cbd5e1;
    --rng-text: #0f172a;
    --rng-text-muted: #64748b;
    --rng-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --rng-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
}

.dark {
    --rng-brand-primary: #10b981;
    --rng-brand-primary-hover: #059669;
    --rng-brand-primary-light: rgba(16, 185, 129, 0.15);
    --rng-surface-card: #18181b;
    --rng-surface-soft: #121215;
    --rng-border: rgba(255, 255, 255, 0.08);
    --rng-border-strong: rgba(255, 255, 255, 0.16);
    --rng-text: #f8fafc;
    --rng-text-muted: #a1a1aa;
    --rng-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
    --rng-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
}

/* Glassmorphism & Reusable Cards (SIP fin-glass-card style) */
.rng-glass-card {
    background: var(--rng-surface-card);
    border: 1px solid var(--rng-border);
    border-radius: 1.25rem;
    box-shadow: var(--rng-shadow-md);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.dark .rng-glass-card {
    background: rgba(24, 24, 27, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.rng-glass-card:hover {
    border-color: var(--rng-border-strong);
}

/* Result Highlight Card (SIP fin-result-card style) */
.rng-result-card {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(99, 102, 241, 0.03) 100%), var(--rng-surface-card);
    border: 1px solid rgba(16, 185, 129, 0.22);
    border-radius: 1.25rem;
    position: relative;
    overflow: hidden;
}

.dark .rng-result-card {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.12) 0%, rgba(99, 102, 241, 0.05) 100%), #121215;
    border-color: rgba(16, 185, 129, 0.3);
}

/* Hero Number Typography */
.rng-hero-number {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.04em;
    line-height: 1;
}

/* Number Pop Animation */
@keyframes rngPopBounce {
    0% {
        transform: scale(0.75);
        opacity: 0.4;
    }
    60% {
        transform: scale(1.06);
        opacity: 1;
    }
    100% {
        transform: scale(1);
    }
}

.rng-animate-roll {
    animation: rngPopBounce 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* Multi-number Winner Cards (Clean, Minimal, High Contrast) */
.rng-winner-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem 0.75rem;
    border-radius: 1rem;
    background: #ffffff;
    border: 1px solid var(--rng-border);
    box-shadow: var(--rng-shadow-sm);
    transition: all 0.2s ease;
    animation: rngPopBounce 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.dark .rng-winner-card {
    background: rgba(39, 39, 42, 0.6);
    border-color: rgba(255, 255, 255, 0.08);
}

.rng-winner-card:hover {
    transform: translateY(-2px);
    border-color: rgba(16, 185, 129, 0.4);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.12);
}

/* Compact Chips for larger multi-draws */
.rng-ball {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 3rem;
    height: 3rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.875rem;
    font-size: 1.125rem;
    font-weight: 800;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    color: #064e3b;
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    border: 1px solid rgba(16, 185, 129, 0.35);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.15);
    animation: rngPopBounce 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.dark .rng-ball {
    color: #ffffff;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.3) 0%, rgba(5, 150, 105, 0.45) 100%);
    border-color: rgba(16, 185, 129, 0.4);
}

/* Quantity Selection Buttons (SIP auto-term-btn tactile style) */
.rng-qty-btn {
    padding: 0.45rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 0.75rem;
    border: 1px solid rgba(228, 228, 231, 0.9);
    background: rgba(244, 244, 245, 0.75);
    color: #3f3f46;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    user-select: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    outline: none;
}

.dark .rng-qty-btn,
html.dark .rng-qty-btn {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.08);
    color: #d4d4d8;
}

.rng-qty-btn:hover:not(.active) {
    color: #059669;
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.08);
}

.dark .rng-qty-btn:hover:not(.active) {
    color: #34d399;
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.12);
}

.rng-qty-btn.active {
    background: #10b981 !important;
    color: #ffffff !important;
    border-color: #10b981 !important;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

/* Preset Chips */
.rng-chip {
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 0.75rem;
    border: 1px solid var(--rng-border);
    background: var(--rng-surface-card);
    color: var(--rng-text-muted);
    transition: all 0.15s ease;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    outline: none;
}

.rng-chip:hover {
    border-color: #10b981;
    color: #10b981;
    background: rgba(16, 185, 129, 0.08);
}

.rng-chip:focus {
    outline: none;
}

/* Toolbar Mode Preset Buttons (Matching SIP Mode Switcher) */
.rng-mode-btn {
    padding: 0.4rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 0.75rem;
    transition: all 0.2s ease;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    outline: none;
    border: 1px solid transparent;
    color: var(--rng-text-muted);
    min-width: 0;
}

@media (max-width: 639px) {
    .rng-mode-btn {
        padding: 0.35rem 0.25rem;
        font-size: 0.6875rem;
        gap: 0.25rem;
    }
}

.rng-mode-btn:hover {
    color: var(--rng-text);
    background: rgba(0, 0, 0, 0.04);
}

.dark .rng-mode-btn:hover {
    background: rgba(255, 255, 255, 0.06);
}

.rng-mode-btn:focus,
.rng-mode-btn:focus-visible {
    outline: none !important;
    box-shadow: none;
}

.rng-mode-btn.active {
    background: #10b981 !important;
    color: #ffffff !important;
    font-weight: 700;
    border-color: #10b981 !important;
    box-shadow: 0 1px 4px rgba(16, 185, 129, 0.3);
}

/* Fullscreen Immersive Classroom / Projector Overlay (100% Theme Adaptive) */
#rng-fullscreen-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1.5rem;
    overflow: hidden;
    animation: rngFadeIn 0.2s ease-out;
}

#rng-fullscreen-overlay.hidden {
    display: none !important;
}

/* Light Theme Fullscreen */
html:not(.dark) #rng-fullscreen-overlay {
    background: #f8fafc;
    color: #0f172a;
}

html:not(.dark) #rng-fullscreen-overlay .rng-fs-ambient-glow {
    background: radial-gradient(circle, rgba(16, 185, 129, 0.12) 0%, transparent 70%);
}

html:not(.dark) #rng-fullscreen-overlay .rng-fs-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08);
    color: #0f172a;
}

html:not(.dark) #rng-fullscreen-overlay .rng-fs-card-num {
    color: #0f172a;
}

html:not(.dark) #rng-fullscreen-overlay .rng-fs-single-num {
    color: #059669;
    text-shadow: 0 4px 20px rgba(16, 185, 129, 0.25);
}

html:not(.dark) #rng-fullscreen-overlay .rng-fs-btn-secondary {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    color: #334155;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

html:not(.dark) #rng-fullscreen-overlay .rng-fs-btn-secondary:hover {
    background: #f1f5f9;
    color: #0f172a;
}

/* Dark Theme Fullscreen */
html.dark #rng-fullscreen-overlay {
    background: #09090b;
    color: #f8fafc;
}

html.dark #rng-fullscreen-overlay .rng-fs-ambient-glow {
    background: radial-gradient(circle, rgba(16, 185, 129, 0.22) 0%, transparent 70%);
}

html.dark #rng-fullscreen-overlay .rng-fs-card {
    background: rgba(24, 24, 27, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
    color: #ffffff;
}

html.dark #rng-fullscreen-overlay .rng-fs-card-num {
    color: #ffffff;
}

html.dark #rng-fullscreen-overlay .rng-fs-single-num {
    color: #34d399;
    text-shadow: 0 0 50px rgba(16, 185, 129, 0.5);
}

html.dark #rng-fullscreen-overlay .rng-fs-btn-secondary {
    background: #18181b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
}

html.dark #rng-fullscreen-overlay .rng-fs-btn-secondary:hover {
    background: #27272a;
    color: #ffffff;
}

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

.rng-fs-ambient-glow {
    position: absolute;
    width: 650px;
    height: 650px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    filter: blur(80px);
}

/* Responsive adjustment */
@media (max-width: 640px) {
    .rng-hero-number {
        font-size: 4.5rem;
    }
}
