* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Screen Reader Support */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Focus indicators for accessibility */
button:focus,
.color-option:focus,
.wheel-segment:focus {
    outline: 3px solid #ffffff;
    outline-offset: 2px;
    border-radius: 4px;
}

/* High contrast focus for better visibility */
@media (prefers-contrast: high) {
    button:focus,
    .color-option:focus,
    .wheel-segment:focus {
        outline: 4px solid #ffffff;
        outline-offset: 3px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

:root {
    --theme-night-1: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    --theme-night-2: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    --theme-day-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --theme-day-2: linear-gradient(135deg, #ff9a56 0%, #ffd93d 100%);
    
    --current-theme: var(--theme-day-1);

    --start-angle: -90deg;           /* make 0deg point to the TOP under the pointer */
    --segment-span: 45deg;           /* your wedges are 45° each */
    --segment-offset: calc(var(--segment-span) / 2); /* center of a wedge = 22.5° */
}

body {
    font-family: 'Arial', sans-serif;
    background: var(--current-theme);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: background 0.5s ease;
}

.app-container {
    text-align: center;
    position: relative;
    z-index: 10;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.color-palette {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 20px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.color-option {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
}

.color-option:hover {
    transform: scale(1.1);
    border-color: rgba(255, 255, 255, 0.6);
}

.color-option.active {
    border-color: #ffffff;
    transform: scale(1.15);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.4);
}

.color-option.active::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ffffff;
    font-size: 20px;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Smooth transitions for theme changes */
.app-container,
.timer-display {
    transition: all 0.5s ease;
}

/* Responsive design for color palette */
@media (max-width: 768px) {
    .color-palette {
        gap: 10px;
        padding: 10px;
        margin-bottom: 18px;
    }
    
    .color-option {
        width: 36px;
        height: 36px;
    }
}

@media (max-width: 480px) {
    .color-palette {
        gap: 8px;
        padding: 8px;
        margin-bottom: 15px;
    }
    
    .color-option {
        width: 32px;
        height: 32px;
    }
}

.app-container.timer-active {
    opacity: 0;
    transform: scale(0.9);
    pointer-events: none;
}

.timer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    z-index: 5;
}

.progress-fill {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0.2) 100%);
    z-index: 1;
}

.roulette-container {
    position: relative;
    margin-bottom: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.roulette-wheel {
    width: 240px;
    height: 240px;
    border-radius: 50%;
    border: 3px solid #ffffff;
    position: relative;
    background: conic-gradient(
        #ff6b6b 0deg 45deg,
        #4ecdc4 45deg 90deg,
        #ffe66d 90deg 135deg,
        #a8e6cf 135deg 180deg,
        #dda0dd 180deg 225deg,
        #87ceeb 225deg 270deg,
        #f0e68c 270deg 315deg,
        #ffa07a 315deg 360deg
    );
    transition: transform 3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.roulette-pointer {
    position: absolute;
    top: -20px;
    left: calc(50% - 12px);
    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 25px solid #ffffff;
    z-index: 10;
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.9));
    animation: pulse 2s infinite;
    /* Ensure perfect centering */
    transform-origin: center bottom;
}

@keyframes pulse {
    0%, 100% { filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.9)); }
    50% { filter: drop-shadow(0 0 15px rgba(255, 255, 255, 1)); }
}

.roulette-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    background: #ffffff;
    border-radius: 50%;
    z-index: 10;
}

.wheel-segment {
    position: absolute;
    top: 50%;
    left: 50%;
    transform-origin: 0 0;      /* rotate around the center point */
    width: 0;                   /* the radial “spoke” itself is virtual; text sits on span */
    height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    /* rotate to (start + segment + midpoint), then push outward along the radius */
    transform:
      translateY(-50%)
      rotate(calc(var(--start-angle) + var(--segment-rotation) + var(--segment-offset)))
      translateX(85px);         /* radius for label position – tweak to taste */
}

.wheel-segment > span {
    transform: rotate(calc(-1 * (var(--start-angle) + var(--segment-rotation) + var(--segment-offset))));
    display: inline-block;
    min-width: 36px;            /* prevents cramped text */
    text-align: center;
    color: #333;
    font-size: 12px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(255,255,255,0.8);
    pointer-events: none;       /* avoid capturing clicks while spinning */
}

.controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

/* Responsive design for smaller screens */
@media (max-width: 768px) {
    .controls {
        flex-direction: column;
        align-items: center;
        gap: 12px;
    }
    
    .duration-btn {
        width: 100%;
        max-width: 280px;
        padding: 12px 20px;
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .controls {
        gap: 10px;
        margin-bottom: 15px;
    }
    
    .duration-btn {
        max-width: 250px;
        padding: 10px 16px;
        font-size: 14px;
    }
}

.background-timer-control {
    margin-bottom: 20px;
    text-align: center;
}

.checkbox-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #ffffff;
    font-size: 14px;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 20px;
    height: 20px;
    border: 2px solid #ffffff;
    border-radius: 4px;
    position: relative;
    transition: all 0.3s ease;
    background: transparent;
}

.checkbox-label input[type="checkbox"]:checked + .checkmark {
    background: #ffffff;
}

.checkbox-label input[type="checkbox"]:checked + .checkmark::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #667eea;
    font-size: 14px;
    font-weight: bold;
}

.checkbox-label:hover .checkmark {
    border-color: rgba(255, 255, 255, 0.8);
    transform: scale(1.1);
}

.duration-btn {
    padding: 10px 20px;
    border: 2px solid #ffffff;
    background: transparent;
    color: #ffffff;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
}

.duration-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.duration-btn.active {
    background: #ffffff;
    color: #667eea;
}

.spin-btn {
    padding: 20px 40px;
    background: linear-gradient(45deg, #ff6b6b, #ffa07a);
    color: #ffffff;
    border: none;
    border-radius: 35px;
    font-size: 22px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
}

.spin-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.spin-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.spin-btn.charging {
    animation: pulse 0.5s infinite ease-in-out alternate;
}

@keyframes pulse {
    from { transform: translateY(-2px) scale(1); }
    to { transform: translateY(-2px) scale(1.05); }
}

.charge-indicator {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: linear-gradient(45deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.6));
    width: 0%;
    transition: width 0.1s ease;
    border-radius: 35px;
}

.timer-display {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 50%;
    padding: 40px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 15;
    transition: opacity 0.3s ease, transform 0.3s ease;
    cursor: pointer;
    width: 200px;
    height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.timer-display.pulsing {
    animation: timerPulse 4s ease-in-out infinite;
}

@keyframes timerPulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
        box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.05);
        box-shadow: 0 0 30px rgba(255, 255, 255, 0.5);
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
    }
}

.timer-display:hover {
    transform: translate(-50%, -50%) scale(1.02);
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
}

.timer-text {
    font-size: 48px;
    font-weight: bold;
    color: #ffffff;
    line-height: 1.2;
}

.timer-text small {
    font-size: 16px;
    font-weight: normal;
    opacity: 0.8;
    display: block;
    margin-top: 10px;
}

.timer-status {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 10px;
    font-style: italic;
}

.show-timer-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.3s ease;
    z-index: 15;
    backdrop-filter: blur(10px);
}

.show-timer-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.show-timer-btn.visible {
    display: flex;
}

.restart-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.3s ease;
    z-index: 15;
    backdrop-filter: blur(10px);
}

.restart-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.restart-btn.visible {
    display: flex;
}

.zen-particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    animation: float 6s infinite ease-in-out;
}

@keyframes float {
    0%, 100% { transform: translateY(0px) rotate(0deg); opacity: 0; }
    50% { transform: translateY(-100px) rotate(180deg); opacity: 1; }
}

.hidden {
    display: none !important;
}

/* Completion Overlay Styles */
.completion-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease;
}

.confetti-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.confetti-piece {
    position: absolute;
    width: 10px;
    height: 10px;
    top: -10px;
    border-radius: 2px;
    animation: confettiFall linear forwards;
}

@keyframes confettiFall {
    0% {
        transform: translateY(-10px) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

.completion-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    color: #ffffff;
    font-size: 48px;
    font-weight: bold;
    text-align: center;
    z-index: 21;
    opacity: 0;
    transition: all 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4, #ffe66d, #a8e6cf);
    background-size: 400% 400%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 3s ease-in-out infinite;
}

@keyframes gradientShift {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

/* Responsive design for completion label */
@media (max-width: 768px) {
    .completion-label {
        font-size: 36px;
    }
}

@media (max-width: 480px) {
    .completion-label {
        font-size: 28px;
    }
}

/* Footer Styles */
.app-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 5;
    padding: 15px 0;
}

.footer-content {
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
    color: rgba(255, 255, 255, 0.8);
}

.footer-links {
    margin-bottom: 8px;
}

.footer-link {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-size: 14px;
    transition: color 0.3s ease;
}

.footer-link:hover {
    color: #ffffff;
    text-decoration: underline;
}

.footer-separator {
    margin: 0 10px;
    color: rgba(255, 255, 255, 0.5);
}

.footer-copyright {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
}

/* Responsive footer */
@media (max-width: 768px) {
    .app-footer {
        padding: 12px 0;
    }
    
    .footer-content {
        padding: 0 20px;
    }
    
    .footer-link {
        font-size: 13px;
    }
    
    .footer-copyright {
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .footer-links {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
    
    .footer-separator {
        display: none;
    }
}

.disclaimer small {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.4);
    line-height: 1.3;
    display: block;
    text-align: center;
}

/* Responsive disclaimer */
@media (max-width: 768px) {
    .disclaimer small {
        font-size: 9px;
    }
}

/* Loading Overlay Styles */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    color: white;
    transition: opacity 0.5s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-overlay p {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.9);
    margin: 0;
}

/* Offline Banner */
.offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: #ff6b6b;
    color: white;
    text-align: center;
    padding: 10px;
    z-index: 999;
    font-size: 14px;
}