/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --bg-color: #0f0f23;
    --surface-color: #1a1a2e;
    --text-color: #ffffff;
    --accent-color: #ffd700;
    --shadow-heavy: 0 20px 60px rgba(0, 0, 0, 0.5);
    --shadow-medium: 0 10px 30px rgba(0, 0, 0, 0.3);
}

body {
    font-family: 'Poppins', sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow-x: hidden;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 50%, rgba(102, 126, 234, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(118, 75, 162, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 10%, rgba(255, 107, 157, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.container {
    max-width: 1200px;
    width: 100%;
    position: relative;
    z-index: 1;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 0 20px;
}

.title {
    font-family: 'Righteous', cursive;
    font-size: 2.5rem;
    background: linear-gradient(135deg, #ffd700, #ff6b9d, #4ecdc4);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gradientShift 4s ease infinite;
    letter-spacing: 2px;
    text-shadow: 0 0 40px rgba(255, 215, 0, 0.3);
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.config-toggle {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: var(--text-color);
    padding: 6px 12px;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.config-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(255, 215, 0, 0.3);
}

.gear-icon {
    font-size: 1.2rem;
    display: inline-block;
    transition: transform 0.3s ease;
}

.config-toggle:hover .gear-icon {
    transform: rotate(90deg);
}

/* Configuration Panel */
.config-panel {
    background: var(--surface-color);
    border-radius: 20px;
    padding: 0px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-heavy);
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: all 0.4s ease;
    border: 2px solid rgba(255, 215, 0, 0.2);
}

.config-panel.active {
    max-height: 800px;
    padding: 30px;
    opacity: 1;
    margin-bottom: 40px;
}

.config-title {
    font-family: 'Righteous', cursive;
    font-size: 2rem;
    margin-bottom: 25px;
    color: var(--accent-color);
}

.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.config-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.config-group.full-width {
    grid-column: 1 / -1;
}

.config-group label {
    font-weight: 600;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.9);
}

.config-group input[type="number"],
.config-group input[type="text"] {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.config-group input[type="number"]:focus,
.config-group input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-color);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.1);
}

.color-picker-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.color-picker-grid input[type="color"] {
    width: 100%;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.color-picker-grid input[type="color"]:hover {
    transform: scale(1.05);
    border-color: var(--accent-color);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-weight: 600;
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkbox-custom {
    width: 24px;
    height: 24px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    position: relative;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--bg-color);
    font-weight: bold;
    font-size: 1.1rem;
}

.help-text {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 4px;
}

.apply-button {
    width: 100%;
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    border: none;
    color: var(--bg-color);
    padding: 16px;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 5px 20px rgba(255, 215, 0, 0.4);
}

.apply-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(255, 215, 0, 0.6);
}

.apply-button:active {
    transform: translateY(0);
}

/* Spinner Container */
.spinner-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
}

.spinner-pointer {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 20px solid transparent;
    border-right: 20px solid transparent;
    border-top: 40px solid #ffffff;
    z-index: 10;
    filter: drop-shadow(0 5px 10px rgba(255, 107, 157, 0.5));
    animation: pointerPulse 2s ease-in-out infinite;
}

@keyframes pointerPulse {
    0%, 100% { transform: translateX(-50%) scale(1.5); }
    50% { transform: translateX(-50%) scale(1.25); }
}

#spinnerCanvas {
    max-width: 600px;
    max-height: 600px;
    width: 100%;
    height: auto;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.8));
    transition: transform 0.1s ease-out;
}

.spin-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff6b9d, #ffc371);
    border: 6px solid var(--bg-color);
    color: var(--text-color);
    font-size: 1.3rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0 0 4px rgba(255, 107, 157, 0.3), 0 10px 30px rgba(0, 0, 0, 0.4);
    z-index: 11;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.spin-button:hover {
    transform: translate(-50%, -50%) scale(1.1);
    box-shadow: 0 0 0 8px rgba(255, 107, 157, 0.4), 0 15px 40px rgba(0, 0, 0, 0.5);
}

.spin-button:active {
    transform: translate(-50%, -50%) scale(1.05);
}

.spin-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: translate(-50%, -50%) scale(1);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal-overlay.active {
    display: flex;
}

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

.modal {
    background: var(--surface-color);
    border-radius: 30px;
    padding: 50px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-heavy);
    border: 3px solid var(--accent-color);
    position: relative;
    overflow: hidden;
    animation: modalSlideIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes modalSlideIn {
    from {
        transform: scale(0.8) translateY(-50px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.modal-confetti {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    overflow: hidden;
}

.confetti-piece {
    position: absolute;
    width: 10px;
    height: 10px;
    top: -20px;
    opacity: 0;
}

.confetti-piece:nth-child(1) { left: 10%; background: #ffd700; animation: confettiFall1 2.8s ease-in forwards; }
.confetti-piece:nth-child(2) { left: 20%; background: #ff6b9d; animation: confettiFall2 3.2s ease-in forwards; width: 8px; height: 15px; }
.confetti-piece:nth-child(3) { left: 30%; background: #4ecdc4; animation: confettiFall3 2.5s ease-in forwards; }
.confetti-piece:nth-child(4) { left: 40%; background: #a78bfa; animation: confettiFall4 3.0s ease-in forwards; width: 12px; height: 8px; }
.confetti-piece:nth-child(5) { left: 50%; background: #ffd700; animation: confettiFall5 2.7s ease-in forwards; }
.confetti-piece:nth-child(6) { left: 60%; background: #ff6b9d; animation: confettiFall6 3.3s ease-in forwards; width: 8px; height: 12px; }
.confetti-piece:nth-child(7) { left: 70%; background: #4ecdc4; animation: confettiFall7 2.9s ease-in forwards; }
.confetti-piece:nth-child(8) { left: 80%; background: #a78bfa; animation: confettiFall8 2.6s ease-in forwards; width: 10px; height: 15px; }
.confetti-piece:nth-child(9) { left: 90%; background: #ffd700; animation: confettiFall9 3.1s ease-in forwards; }
.confetti-piece:nth-child(10) { left: 15%; background: #ff6b9d; animation: confettiFall10 2.8s ease-in forwards; }
.confetti-piece:nth-child(11) { left: 25%; background: #4ecdc4; animation: confettiFall11 3.4s ease-in forwards; width: 12px; height: 10px; }
.confetti-piece:nth-child(12) { left: 35%; background: #a78bfa; animation: confettiFall12 2.7s ease-in forwards; }
.confetti-piece:nth-child(13) { left: 45%; background: #ffd700; animation: confettiFall13 3.0s ease-in forwards; width: 8px; height: 14px; }
.confetti-piece:nth-child(14) { left: 55%; background: #ff6b9d; animation: confettiFall14 2.9s ease-in forwards; }
.confetti-piece:nth-child(15) { left: 65%; background: #4ecdc4; animation: confettiFall15 2.6s ease-in forwards; width: 10px; height: 12px; }
.confetti-piece:nth-child(16) { left: 75%; background: #a78bfa; animation: confettiFall16 3.2s ease-in forwards; }
.confetti-piece:nth-child(17) { left: 85%; background: #ffd700; animation: confettiFall17 2.8s ease-in forwards; }
.confetti-piece:nth-child(18) { left: 95%; background: #ff6b9d; animation: confettiFall18 3.1s ease-in forwards; width: 9px; height: 9px; }
.confetti-piece:nth-child(19) { left: 5%; background: #4ecdc4; animation: confettiFall19 2.7s ease-in forwards; }
.confetti-piece:nth-child(20) { left: 50%; background: #a78bfa; animation: confettiFall20 3.3s ease-in forwards; width: 11px; height: 11px; }

/* Individual keyframes with slightly different speeds */
@keyframes confettiFall1 {
    0% { top: -20px; opacity: 0; transform: rotateZ(0deg); }
    10% { opacity: 1; }
    100% { top: 110%; opacity: 0.7; transform: rotateZ(680deg); }
}

@keyframes confettiFall2 {
    0% { top: -20px; opacity: 0; transform: rotateZ(0deg); }
    10% { opacity: 1; }
    100% { top: 110%; opacity: 0.7; transform: rotateZ(760deg); }
}

@keyframes confettiFall3 {
    0% { top: -20px; opacity: 0; transform: rotateZ(0deg); }
    10% { opacity: 1; }
    100% { top: 110%; opacity: 0.7; transform: rotateZ(620deg); }
}

@keyframes confettiFall4 {
    0% { top: -20px; opacity: 0; transform: rotateZ(0deg); }
    10% { opacity: 1; }
    100% { top: 110%; opacity: 0.7; transform: rotateZ(700deg); }
}

@keyframes confettiFall5 {
    0% { top: -20px; opacity: 0; transform: rotateZ(0deg); }
    10% { opacity: 1; }
    100% { top: 110%; opacity: 0.7; transform: rotateZ(640deg); }
}

@keyframes confettiFall6 {
    0% { top: -20px; opacity: 0; transform: rotateZ(0deg); }
    10% { opacity: 1; }
    100% { top: 110%; opacity: 0.7; transform: rotateZ(780deg); }
}

@keyframes confettiFall7 {
    0% { top: -20px; opacity: 0; transform: rotateZ(0deg); }
    10% { opacity: 1; }
    100% { top: 110%; opacity: 0.7; transform: rotateZ(690deg); }
}

@keyframes confettiFall8 {
    0% { top: -20px; opacity: 0; transform: rotateZ(0deg); }
    10% { opacity: 1; }
    100% { top: 110%; opacity: 0.7; transform: rotateZ(610deg); }
}

@keyframes confettiFall9 {
    0% { top: -20px; opacity: 0; transform: rotateZ(0deg); }
    10% { opacity: 1; }
    100% { top: 110%; opacity: 0.7; transform: rotateZ(730deg); }
}

@keyframes confettiFall10 {
    0% { top: -20px; opacity: 0; transform: rotateZ(0deg); }
    10% { opacity: 1; }
    100% { top: 110%; opacity: 0.7; transform: rotateZ(670deg); }
}

@keyframes confettiFall11 {
    0% { top: -20px; opacity: 0; transform: rotateZ(0deg); }
    10% { opacity: 1; }
    100% { top: 110%; opacity: 0.7; transform: rotateZ(800deg); }
}

@keyframes confettiFall12 {
    0% { top: -20px; opacity: 0; transform: rotateZ(0deg); }
    10% { opacity: 1; }
    100% { top: 110%; opacity: 0.7; transform: rotateZ(650deg); }
}

@keyframes confettiFall13 {
    0% { top: -20px; opacity: 0; transform: rotateZ(0deg); }
    10% { opacity: 1; }
    100% { top: 110%; opacity: 0.7; transform: rotateZ(710deg); }
}

@keyframes confettiFall14 {
    0% { top: -20px; opacity: 0; transform: rotateZ(0deg); }
    10% { opacity: 1; }
    100% { top: 110%; opacity: 0.7; transform: rotateZ(695deg); }
}

@keyframes confettiFall15 {
    0% { top: -20px; opacity: 0; transform: rotateZ(0deg); }
    10% { opacity: 1; }
    100% { top: 110%; opacity: 0.7; transform: rotateZ(630deg); }
}

@keyframes confettiFall16 {
    0% { top: -20px; opacity: 0; transform: rotateZ(0deg); }
    10% { opacity: 1; }
    100% { top: 110%; opacity: 0.7; transform: rotateZ(750deg); }
}

@keyframes confettiFall17 {
    0% { top: -20px; opacity: 0; transform: rotateZ(0deg); }
    10% { opacity: 1; }
    100% { top: 110%; opacity: 0.7; transform: rotateZ(665deg); }
}

@keyframes confettiFall18 {
    0% { top: -20px; opacity: 0; transform: rotateZ(0deg); }
    10% { opacity: 1; }
    100% { top: 110%; opacity: 0.7; transform: rotateZ(720deg); }
}

@keyframes confettiFall19 {
    0% { top: -20px; opacity: 0; transform: rotateZ(0deg); }
    10% { opacity: 1; }
    100% { top: 110%; opacity: 0.7; transform: rotateZ(655deg); }
}

@keyframes confettiFall20 {
    0% { top: -20px; opacity: 0; transform: rotateZ(0deg); }
    10% { opacity: 1; }
    100% { top: 110%; opacity: 0.7; transform: rotateZ(790deg); }
}

.modal-title {
    font-family: 'Righteous', cursive;
    font-size: 1.8rem;
    margin-bottom: 20px;
    color: rgba(255, 255, 255, 0.7);
}

.modal-result {
    font-family: 'Righteous', cursive;
    font-size: 6rem;
    background: linear-gradient(135deg, #ffd700, #ff6b9d);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 30px 0;
    animation: resultPop 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) 0.3s backwards;
}

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

.modal-buttons {
    display: flex;
    gap: 15px;
    margin-top: 30px;
}

.modal-button {
    flex: 1;
    padding: 16px 24px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.modal-button-primary {
    background: linear-gradient(135deg, #ff6b9d, #c44569);
    color: var(--text-color);
    box-shadow: 0 5px 20px rgba(255, 107, 157, 0.4);
}

.modal-button-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(255, 107, 157, 0.6);
}

.modal-button-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.modal-button-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.modal-button:active {
    transform: translateY(0);
}

/* Responsive Design */
@media (max-width: 768px) {
    .title {
        font-size: 2.5rem;
    }

    .header {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }

    .config-grid {
        grid-template-columns: 1fr;
    }

    .spin-button {
        width: 100px;
        height: 100px;
        font-size: 1.1rem;
    }

    .modal {
        padding: 30px;
    }

    .modal-result {
        font-size: 4rem;
    }

    .modal-buttons {
        flex-direction: column;
    }
}
