/* ===== Christmas Theme Variables ===== */
:root {
    --bg-deep: #0d100d;
    --bg-primary: #1a1f1a;
    --bg-elevated: #242a24;
    --bg-surface: #2d342d;
    
    --cream: #e8e4d9;
    --cream-muted: #d4d0c5;
    --sage: #9a9a84;
    --olive: #6b6b5a;
    --moss: #4a4a3d;
    
    --text-primary: #f5f5f0;
    --text-secondary: #b8b8a8;
    --text-muted: #7a7a6a;
    
    /* Christmas colors */
    --christmas-red: #c41e3a;
    --christmas-green: #228b22;
    --christmas-gold: #ffd700;
    --christmas-blue: #4169e1;
    
    --border-radius: 12px;
    --border-radius-lg: 20px;
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'DM Sans', sans-serif;
    background: linear-gradient(180deg, #0d100d 0%, #1a2a1a 50%, #0d100d 100%);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    position: relative;
}

/* ===== Snow Effect ===== */
.snow-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.snowflake {
    position: absolute;
    top: -20px;
    color: white;
    font-size: 1rem;
    opacity: 0.8;
    animation: snowfall linear infinite;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

@keyframes snowfall {
    0% {
        transform: translateY(-20px) rotate(0deg);
        opacity: 0.8;
    }
    100% {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0.2;
    }
}

/* ===== PIN Screen ===== */
.pin-screen {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #0d100d 0%, #1a2a1a 50%, #0d100d 100%);
}

.pin-screen[hidden] {
    display: none;
}

.pin-container {
    text-align: center;
    padding: 2rem;
}

.pin-logo {
    height: 120px;
    margin-bottom: 1rem;
    filter: drop-shadow(0 2px 20px rgba(255, 255, 255, 0.4));
}

.pin-title {
    font-family: 'Mountains of Christmas', cursive;
    font-size: 1.75rem;
    color: var(--christmas-gold);
    margin-bottom: 1.5rem;
}

.pin-input {
    display: block;
    width: 200px;
    margin: 0 auto 1rem;
    padding: 1rem;
    font-size: 2rem;
    text-align: center;
    letter-spacing: 0.5rem;
    background: var(--bg-elevated);
    border: 2px solid var(--moss);
    border-radius: var(--border-radius);
    color: var(--text-primary);
}

.pin-input:focus {
    outline: none;
    border-color: var(--christmas-gold);
}

.pin-error {
    color: var(--christmas-red);
    margin-top: 1rem;
    font-size: 0.9rem;
}

/* ===== App Layout ===== */
.app {
    position: relative;
    z-index: 2;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem 1rem;
}

/* ===== Header ===== */
.header {
    text-align: center;
    margin-bottom: 1rem;
    animation: fadeInDown 0.6s ease-out;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.logo-img {
    height: clamp(280px, 60vw, 450px);
    margin-bottom: -80px;
    filter: drop-shadow(0 2px 20px rgba(255, 255, 255, 0.4));
    position: relative;
    z-index: 1;
}

.title {
    font-family: 'Mountains of Christmas', cursive;
    font-size: clamp(1.75rem, 5vw, 2.5rem);
    font-weight: 700;
    color: var(--christmas-gold);
    text-shadow: 
        0 0 10px rgba(255, 215, 0, 0.5),
        0 2px 20px rgba(0, 0, 0, 0.5);
    letter-spacing: 0.02em;
    margin: 0;
}

.year {
    font-family: 'Mountains of Christmas', cursive;
    font-size: clamp(1.5rem, 4vw, 2.25rem);
    color: var(--cream);
    opacity: 0.8;
    margin: 0;
}

/* ===== Main ===== */
.main {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    width: 100%;
    max-width: 600px;
}

/* ===== Christmas Lights ===== */
.christmas-lights {
    display: flex;
    justify-content: space-around;
    padding: 0 10px;
    position: relative;
}

.christmas-lights.top {
    margin-bottom: -8px;
}

.christmas-lights.bottom {
    margin-top: -8px;
}

.christmas-lights::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 3px;
    background: #2a2a2a;
    border-radius: 2px;
    z-index: 0;
}

.light {
    width: 16px;
    height: 24px;
    border-radius: 50% 50% 50% 50% / 30% 30% 70% 70%;
    position: relative;
    z-index: 1;
    animation: glow 1.5s ease-in-out infinite;
}

.light::before {
    content: '';
    position: absolute;
    top: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 6px;
    background: #444;
    border-radius: 2px 2px 0 0;
}

.light.red {
    background: radial-gradient(circle at 30% 30%, #ff6b6b, #c41e3a);
    box-shadow: 0 0 15px #c41e3a, 0 0 30px rgba(196, 30, 58, 0.5);
    animation-delay: 0s;
}

.light.green {
    background: radial-gradient(circle at 30% 30%, #5fd35f, #228b22);
    box-shadow: 0 0 15px #228b22, 0 0 30px rgba(34, 139, 34, 0.5);
    animation-delay: 0.3s;
}

.light.gold {
    background: radial-gradient(circle at 30% 30%, #ffe066, #ffd700);
    box-shadow: 0 0 15px #ffd700, 0 0 30px rgba(255, 215, 0, 0.5);
    animation-delay: 0.6s;
}

.light.blue {
    background: radial-gradient(circle at 30% 30%, #6b9fff, #4169e1);
    box-shadow: 0 0 15px #4169e1, 0 0 30px rgba(65, 105, 225, 0.5);
    animation-delay: 0.9s;
}

@keyframes glow {
    0%, 100% { opacity: 1; filter: brightness(1); }
    50% { opacity: 0.6; filter: brightness(0.7); }
}

/* ===== Name Display ===== */
.name-display-wrapper {
    width: 100%;
    animation: fadeInUp 0.6s ease-out 0.2s both;
}

.name-display {
    background: linear-gradient(145deg, var(--bg-elevated), var(--bg-primary));
    border: 3px solid var(--moss);
    border-radius: var(--border-radius-lg);
    padding: 3rem 2rem;
    text-align: center;
    position: relative;
    overflow: hidden;
    box-shadow: 
        0 10px 40px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.name-scroller {
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.current-name {
    font-family: 'Mountains of Christmas', cursive;
    font-size: clamp(2rem, 8vw, 3.5rem);
    font-weight: 700;
    color: var(--cream);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    transition: all 0.1s ease;
}

.current-name.scrolling {
    animation: nameScroll 0.1s ease-in-out;
}

@keyframes nameScroll {
    0% { transform: translateY(100%); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

.current-name.winner {
    color: var(--christmas-gold);
    text-shadow: 
        0 0 20px rgba(255, 215, 0, 0.5),
        0 2px 10px rgba(0, 0, 0, 0.3);
    animation: winnerPulse 0.5s ease-out;
}

@keyframes winnerPulse {
    0% { transform: scale(0.8); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* ===== Controls ===== */
.controls {
    animation: fadeInUp 0.6s ease-out 0.3s both;
}

.btn-draw {
    padding: 1.25rem 3rem;
    font-family: 'Mountains of Christmas', cursive;
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(145deg, var(--christmas-red), #a01830);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all var(--transition-base);
    box-shadow: 
        0 6px 20px rgba(196, 30, 58, 0.4),
        0 2px 5px rgba(0, 0, 0, 0.3);
}

.btn-draw:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 
        0 10px 30px rgba(196, 30, 58, 0.5),
        0 4px 10px rgba(0, 0, 0, 0.3);
}

.btn-draw:active:not(:disabled) {
    transform: translateY(-1px);
}

.btn-draw:disabled {
    opacity: 0.9;
    cursor: wait;
}

.btn-draw.drawing {
    animation: shake 0.1s infinite;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* ===== Stats ===== */
.stats {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
}

.stats strong {
    color: var(--christmas-gold);
}

/* ===== Side Panel ===== */
.side-panel {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.btn-secondary {
    padding: 0.75rem 1.25rem;
    background: var(--bg-surface);
    color: var(--text-secondary);
    border: 1px solid var(--moss);
    border-radius: 8px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-secondary:hover {
    background: var(--moss);
    color: var(--text-primary);
}

.btn-icon {
    padding: 0.75rem;
    background: var(--bg-surface);
    border: 1px solid var(--moss);
    border-radius: 8px;
    font-size: 1.25rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    background: var(--moss);
}

/* ===== Sheet Status ===== */
.sheet-status {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    text-align: center;
    max-width: 400px;
}

.sheet-status.success {
    background: rgba(34, 139, 34, 0.2);
    border: 1px solid rgba(34, 139, 34, 0.4);
    color: #7fcea0;
}

.sheet-status.error {
    background: rgba(196, 30, 58, 0.2);
    border: 1px solid rgba(196, 30, 58, 0.4);
    color: #f5a9a4;
}

.sheet-status.info {
    background: rgba(154, 154, 132, 0.15);
    border: 1px solid rgba(154, 154, 132, 0.3);
    color: var(--text-secondary);
}

/* ===== Modal ===== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.modal[hidden] {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(13, 16, 13, 0.9);
    backdrop-filter: blur(8px);
}

.modal-content {
    position: relative;
    background: var(--bg-primary);
    border: 2px solid var(--christmas-gold);
    border-radius: var(--border-radius-lg);
    padding: 3rem 2.5rem;
    text-align: center;
    max-width: 450px;
    width: 100%;
    box-shadow: 
        0 0 30px rgba(255, 215, 0, 0.2),
        0 25px 80px rgba(0, 0, 0, 0.5);
    animation: scaleIn 0.4s ease-out;
}

.confetti-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    opacity: 0;
    animation: confettiFall 3s ease-out forwards;
}

@keyframes confettiFall {
    0% { opacity: 1; transform: translateY(-100%) rotate(0deg); }
    100% { opacity: 0; transform: translateY(400px) rotate(720deg); }
}

.winner-label {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.winner-name {
    font-family: 'Mountains of Christmas', cursive;
    font-size: clamp(2rem, 8vw, 3rem);
    font-weight: 700;
    color: var(--christmas-gold);
    margin-bottom: 1.5rem;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

.prize-selection {
    margin-bottom: 1.5rem;
    text-align: left;
}

.prize-selection label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.prize-select {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    background: var(--bg-elevated);
    border: 2px solid var(--moss);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
}

.prize-select:focus {
    outline: none;
    border-color: var(--christmas-gold);
}

.cash-amount-field {
    margin-top: 1rem;
}

.cash-amount-field[hidden] {
    display: none;
}

.cash-input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1.25rem;
    background: var(--bg-elevated);
    border: 2px solid var(--moss);
    border-radius: 8px;
    color: var(--christmas-gold);
    text-align: center;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.modal-actions .btn {
    padding: 1rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-primary {
    background: var(--christmas-green);
    color: white;
    border: none;
}

.btn-primary:hover {
    background: #1e7a1e;
}

/* ===== Setup Modal ===== */
.setup-modal {
    text-align: left;
}

.setup-title {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.setup-field {
    margin-bottom: 1.5rem;
}

.setup-field label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.setup-input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-deep);
    border: 1px solid var(--moss);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: monospace;
    font-size: 0.8rem;
}

.setup-input:focus {
    outline: none;
    border-color: var(--christmas-gold);
}

/* ===== Animations ===== */
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

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

/* ===== Responsive ===== */
@media (max-width: 480px) {
    .app {
        padding: 1.5rem 0.75rem;
    }
    
    .name-display {
        padding: 2rem 1rem;
    }
    
    .btn-draw {
        padding: 1rem 2rem;
        font-size: 1.25rem;
    }
    
    .light {
        width: 12px;
        height: 18px;
    }
}
