/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow-x: hidden; /* Prevent horizontal scroll */
    overflow-y: hidden; /* Prevent vertical scroll and scrollbar flicker */
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    position: fixed; /* Lock the body to prevent any scrolling */
    width: 100%;
}

body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    margin: 0;
}

/* Container */
.container {
    text-align: center;
    max-width: 500px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
    text-align: center;
    position: relative;
    overflow: hidden; /* Ensure no content overflows */
}

/* Title */
.title {
    font-size: clamp(2rem, 4vw, 3.5rem);
    color: white;
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    font-weight: bold;
    letter-spacing: 2px;
}

/* Subtitle */
h3 {
    font-size: 1.3rem;
    color: white;
    margin-bottom: 1rem;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    font-weight: 500;
    letter-spacing: 1px;
}

/* Spin Counter */
.spin-counter {
    font-size: 1.2rem;
    color: white;
    margin-bottom: 1.5rem;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    font-weight: 500;
}

/* Wheel container */
.wheel-container {
    position: relative;
    display: inline-block;
    margin: 0 auto;
}

/* Wheel canvas */
#wheel {
    width: 100%;
    max-width: 400px;
    height: auto;
    border-radius: 50%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transition: transform 4s cubic-bezier(0.25, 0.1, 0.25, 1);
    cursor: pointer;
}

/* Pointer at top */
.pointer {
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 20px solid transparent;
    border-right: 20px solid transparent;
    border-top: 30px solid #fff;
    z-index: 10;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* Spin button */
.spin-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(45deg, #ff6b6b, #ff8e53);
    color: white;
    border: none;
    border-radius: 50%;
    width: clamp(80px, 20vw, 120px);
    height: clamp(80px, 20vw, 120px);
    font-size: clamp(1rem, 3vw, 1.25rem);
    font-weight: bold;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
    z-index: 5;
}

.spin-button:hover:not(:disabled) {
    transform: translate(-50%, -50%) scale(1.05);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.6);
}

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

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

.spin-button:focus {
    outline: 3px solid #fff;
    outline-offset: 2px;
}

/* Modal styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    overflow: hidden;
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
}

.modal-content {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background: white;
    padding: 1.5rem;
    border-radius: 20px;
    text-align: center;
    width: min(90vw, 400px);
    max-height: 90vh;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease;
    overflow-y: auto;
    z-index: 1001;
    margin: 0; /* Ensure no margins */
    box-sizing: border-box; /* Include padding in width calculation */
}

.modal.show .modal-content {
    transform: translate(-50%, -50%) scale(1);
}

.modal-title {
    font-size: 1.8rem;
    color: #333;
    margin-bottom: 1rem;
}

.result-image-container {
    margin: 1rem 0;
    width: 100%;
    display: flex;
    justify-content: center;
}

.result-image {
    width: 100%;
    height: auto;
    border-radius: 15px;
  /*  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);*/
    transform: scale(0);
    transition: transform 0.4s ease;
    max-width: 300px;
    max-height: 300px;
    object-fit: cover;
}

.result-image.show {
    transform: scale(1);
}

/* Mobile specific image sizing */
@media (max-width: 480px) {
    .result-image {
        max-width: 250px;
        max-height: 250px;
    }
}

.result-text {
    font-size: 1.3rem;
    color: #555;
    margin-bottom: 1.5rem;
    font-weight: 500;
}

.play-again-button {
    background: linear-gradient(45deg, #4CAF50, #45a049);
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 1.1rem;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    min-height: 44px;
    min-width: 44px;
}

.play-again-button:hover {
    background: linear-gradient(45deg, #45a049, #3d8b40);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.4);
}

.play-again-button:focus {
    outline: 3px solid #4CAF50;
    outline-offset: 2px;
}

/* Confetti canvas */
.confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1002; /* Higher than modal (1001) to appear in front */
}

/* Screen reader only text */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .container {
        padding: 1rem;
    }
    
    .title {
        margin-bottom: 1.5rem;
    }
    
    .pointer {
        border-left-width: 15px;
        border-right-width: 15px;
        border-top-width: 25px;
        top: -12px;
    }
    
    .modal-content {
        padding: 1.5rem;
    }
    
    .result-image {
        width: 100%;
        height: auto;
    }
}

/* Ensure minimum tap target sizes */
@media (max-width: 768px) {
    .spin-button {
        min-width: 80px;
        min-height: 80px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .title {
        text-shadow: none;
        color: #fff;
    }
    
    .spin-button {
        border: 2px solid #fff;
    }
}