/* ===== 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;
}

.header[hidden],
.page-bar[hidden] {
    display: none !important;
}

.logo-img {
    height: clamp(120px, 32vw, 200px);
    margin-bottom: 0.25rem;
    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: 1.25rem;
    width: 100%;
    max-width: 640px;
}

.mode-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    padding: 0.3rem;
    background: rgba(13, 16, 13, 0.65);
    border: 1px solid var(--moss);
    border-radius: 999px;
}

.mode-btn {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: 'Mountains of Christmas', cursive;
    font-size: 1.35rem;
    padding: 0.55rem 1rem;
    border-radius: 999px;
    cursor: pointer;
}

.mode-btn.active {
    background: linear-gradient(145deg, var(--christmas-red), #8e1528);
    color: white;
    box-shadow: 0 4px 16px rgba(196, 30, 58, 0.35);
}

.page {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
    width: 100%;
}

.page[hidden] {
    display: none !important;
}

.page-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
}

.back-btn {
    border: 1px solid var(--moss);
    background: rgba(13, 16, 13, 0.65);
    color: var(--cream);
    border-radius: 999px;
    padding: 0.45rem 0.95rem;
    cursor: pointer;
    font-family: 'DM Sans', sans-serif;
}

.page-title {
    font-family: 'Mountains of Christmas', cursive;
    font-size: 2rem;
    color: var(--christmas-gold);
    font-weight: 700;
}

.menu-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    width: 100%;
}

.menu-card {
    text-align: left;
    padding: 1.05rem 1.15rem;
    background: rgba(26, 31, 26, 0.92);
    border: 1px solid var(--moss);
    border-radius: 16px;
    color: var(--text-primary);
    cursor: pointer;
}

.menu-card-draw {
    border-color: rgba(196, 30, 58, 0.85);
    background: linear-gradient(145deg, rgba(196, 30, 58, 0.38), rgba(26, 31, 26, 0.94));
}

.menu-kicker {
    display: block;
    color: var(--christmas-gold);
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.menu-title {
    display: block;
    font-family: 'Mountains of Christmas', cursive;
    font-size: 2.1rem;
    line-height: 1.1;
    margin: 0.15rem 0 0.25rem;
}

.menu-meta {
    display: block;
    color: var(--text-secondary);
}

.share-status {
    width: 100%;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.45;
    word-break: break-word;
}

.summary-row {
    width: 100%;
    color: var(--christmas-gold);
    text-align: center;
}

.prize-badge {
    flex: 0 0 auto;
    font-size: 0.95rem;
    font-weight: 600;
    white-space: nowrap;
}

.prize-badge.cash {
    color: var(--christmas-gold);
}

.prize-badge.other {
    color: var(--text-secondary);
}

.page-link {
    align-self: center;
}

@media (min-width: 700px) {
    .menu-grid {
        grid-template-columns: 1fr 1fr;
    }

    #homeSettingsBtn {
        grid-column: 1 / -1;
    }
}

.check-in-view,
.draw-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

.check-in-view[hidden],
.draw-view[hidden] {
    display: none !important;
}

.checkin-toolbar,
.employee-list,
.draw-hint {
    width: 100%;
}

.search-input {
    width: 100%;
    padding: 0.9rem 1rem;
    font-size: 1rem;
    background: var(--bg-elevated);
    border: 2px solid var(--moss);
    border-radius: 12px;
    color: var(--text-primary);
}

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

.filter-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.site-row {
    margin-top: 0.45rem;
}

.filter-btn {
    border: 1px solid var(--moss);
    background: var(--bg-surface);
    color: var(--text-secondary);
    border-radius: 999px;
    padding: 0.4rem 0.9rem;
    cursor: pointer;
}

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

.checkin-count {
    margin-left: auto;
    color: var(--christmas-gold);
    font-size: 0.9rem;
}

.employee-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    max-height: min(52vh, 560px);
    overflow: auto;
    padding-right: 0.15rem;
}

.employee-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 0.85rem;
    background: rgba(26, 31, 26, 0.9);
    border: 1px solid var(--moss);
    border-radius: 12px;
}

.employee-row.is-here {
    border-color: rgba(255, 215, 0, 0.55);
    background: rgba(34, 70, 34, 0.45);
}

.employee-main {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
    min-width: 0;
}

.employee-name {
    font-size: 1.05rem;
    word-break: break-word;
}

.employee-title {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.drawn-badge {
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--christmas-gold);
}

.checkin-btn {
    flex: 0 0 auto;
    min-width: 6.5rem;
    min-height: 44px;
    border-radius: 999px;
    border: 1px solid var(--christmas-gold);
    background: transparent;
    color: var(--christmas-gold);
    font-weight: 600;
    cursor: pointer;
}

.checkin-btn.is-here {
    background: var(--christmas-green);
    border-color: var(--christmas-green);
    color: white;
}

.checkin-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.employee-empty {
    padding: 1.25rem;
    text-align: center;
    color: var(--text-secondary);
    border: 1px dashed var(--moss);
    border-radius: 12px;
}

.draw-hint {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.92rem;
}

.text-btn {
    background: none;
    border: none;
    color: var(--sage);
    cursor: pointer;
    text-decoration: underline;
    margin-left: 10px;
}

.setup-help {
    margin-top: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.45;
}

.setup-help code {
    color: var(--cream);
}

/* ===== 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 {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    animation: fadeInUp 0.6s ease-out 0.3s both;
}

.prize-label {
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
}

.prize-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
}

.prize-choice {
    min-height: 52px;
    border-radius: 12px;
    border: 1px solid var(--moss);
    background: var(--bg-deep);
    color: var(--cream);
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
}

.prize-choice[data-prize="Not Cash"] {
    grid-column: 1 / -1;
}

.prize-choice.active {
    background: var(--christmas-green);
    border-color: var(--christmas-gold);
    color: white;
}

body.is-present .main {
    max-width: 1100px;
}

body.is-present .current-name,
body.is-present .winner-name {
    font-size: clamp(3.5rem, 9vw, 8rem);
    line-height: 0.95;
}

body.is-present .name-display {
    min-height: 38vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6vh 2rem;
}

body.is-present .modal-content {
    max-width: 760px;
}

.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;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
    width: 100%;
}

.email-export .email-input {
    flex: 1 1 220px;
    max-width: 360px;
}

.btn-secondary {
    flex: 0 0 auto;
    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;
    white-space: nowrap;
    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;
    }
}
