html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    min-height: 100vh;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
}

body {
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

img {
    -ms-interpolation-mode: bicubic;
}

#scratch {
    position: relative;
    display: inline-block;
    font-size: 0;
    max-width: 85vw;
    max-height: 85vh;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

#scratch img {
    width: 100%;
    max-width: 85vw;
    max-height: 85vh;
    height: auto;
    object-fit: contain;
    /* Hide the ticket image until overlay is ready */
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

#scratch.ready img {
    opacity: 1;
}

#scratch canvas {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    cursor: pointer;
    will-change: transform;
    transform: translate3d(0,0,0);
    -ms-touch-action: none;
    -webkit-touch-action: none;
    -moz-touch-action: none;
    touch-action: none;
    transition: opacity 500ms ease-out 0ms, height 0ms linear 500ms;
}

#scratch.revealed canvas {
    opacity: 0;
    height: 0;
}

/* Celebration message */
.celebration {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(45deg, #ffd700, #ffed4e);
    color: #333;
    padding: 30px 40px;
    border-radius: 15px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
    animation: celebrationBounce 0.8s ease-in-out;
    z-index: 1000;
    text-align: center;
    max-width: 90vw;
}

.celebration h2 {
    font-size: 2.5rem;
    margin: 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

@keyframes celebrationBounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translate(-50%, -50%) scale(1);
    }
    40% {
        transform: translate(-50%, -50%) scale(1.1);
    }
    60% {
        transform: translate(-50%, -50%) scale(1.05);
    }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.5rem;
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    margin-bottom: 10px;
}

header p {
    color: rgba(255,255,255,0.9);
    font-size: 1.2rem;
}

/* Main content */
main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Ticket container */
.ticket-container {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    max-width: 600px;
    width: 100%;
}

/* Scratch area */
.scratch-area {
    position: relative;
    display: inline-block;
    font-size: 0;
    margin-bottom: 30px;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.scratch-area img {
    width: 100%;
    max-width: 400px;
    height: auto;
    display: block;
    border-radius: 8px;
}

.scratch-area canvas {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    cursor: pointer;
    will-change: transform;
    transform: translate3d(0,0,0);
    -ms-touch-action: none;
    -webkit-touch-action: none;
    -moz-touch-action: none;
    touch-action: none;
    transition: opacity 500ms ease-out 0ms, height 0ms linear 500ms;
}

.scratch-area.revealed canvas {
    opacity: 0;
    height: 0;
}

/* Ticket info */
.ticket-info {
    margin-bottom: 30px;
    text-align: left;
}

.ticket-info h2 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.5rem;
}

.ticket-info p {
    margin-bottom: 8px;
    font-size: 1.1rem;
}

.ticket-info strong {
    color: #555;
}

/* Celebration */
.celebration {
    background: linear-gradient(45deg, #ffd700, #ffed4e);
    color: #333;
    padding: 20px;
    border-radius: 10px;
    margin-top: 20px;
    animation: bounce 0.6s ease-in-out;
}

.celebration h3 {
    font-size: 1.5rem;
    margin: 0;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

/* Controls */
.controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: all 0.3s ease;
    min-width: 120px;
}

.btn-primary {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(108, 117, 125, 0.4);
}

/* Welcome page */
.welcome-container {
    background: white;
    border-radius: 15px;
    padding: 40px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    max-width: 800px;
    width: 100%;
    text-align: left;
}

.welcome-container h2 {
    color: #333;
    margin-bottom: 20px;
    text-align: center;
    font-size: 2rem;
}

.welcome-container > p {
    text-align: center;
    margin-bottom: 30px;
    font-size: 1.1rem;
    color: #666;
}

/* Examples */
.examples {
    margin-bottom: 40px;
}

.examples h3 {
    color: #333;
    margin-bottom: 20px;
    text-align: center;
}

.example-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.example-link {
    display: block;
    padding: 20px;
    background: linear-gradient(45deg, #f8f9fa, #e9ecef);
    border-radius: 10px;
    text-decoration: none;
    color: #333;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.example-link:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    border-color: #667eea;
}

.example-link .amount {
    display: block;
    font-size: 1.5rem;
    font-weight: bold;
    color: #28a745;
    margin-bottom: 5px;
}

.example-link .theme {
    display: block;
    font-size: 0.9rem;
    color: #666;
    text-transform: capitalize;
}

/* Custom ticket form */
.custom-ticket {
    border-top: 2px solid #e9ecef;
    padding-top: 30px;
}

.custom-ticket h3 {
    color: #333;
    margin-bottom: 20px;
    text-align: center;
}

.ticket-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    align-items: end;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 5px;
    font-weight: 600;
    color: #555;
}

.form-group input,
.form-group select {
    padding: 10px;
    border: 2px solid #e9ecef;
    border-radius: 5px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
}

.ticket-form .btn {
    grid-column: 1 / -1;
    justify-self: center;
    margin-top: 10px;
}

/* Error page */
.error-container {
    background: white;
    border-radius: 15px;
    padding: 40px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    max-width: 600px;
    width: 100%;
}

.error-message h2 {
    color: #dc3545;
    margin-bottom: 20px;
    font-size: 2rem;
}

.error-message p {
    font-size: 1.1rem;
    margin-bottom: 20px;
    color: #666;
}

.error-details {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 30px;
    text-align: left;
}

.error-details p {
    margin-bottom: 10px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

/* Footer */
footer {
    margin-top: 30px;
    color: rgba(255,255,255,0.8);
    font-size: 0.9rem;
}

/* Responsive design */
@media (max-width: 768px) {
    .celebration {
        padding: 20px 30px;
        margin: 20px;
    }
    
    .celebration h2 {
        font-size: 1.8rem;
    }
    
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .ticket-container,
    .welcome-container,
    .error-container {
        padding: 20px;
    }
    
    .example-links {
        grid-template-columns: 1fr;
    }
    
    .ticket-form {
        grid-template-columns: 1fr;
    }
    
    .controls {
        flex-direction: column;
        align-items: center;
    }
    
    .btn {
        width: 100%;
        max-width: 200px;
    }
}

@media (max-width: 480px) {
    .celebration h2 {
        font-size: 1.5rem;
    }
    
    .celebration {
        padding: 15px 20px;
        margin: 15px;
    }
}
