:root {
    --primary: #0f172a;
    --accent: #3b82f6;
    --gold: #fbbf24;
    --bg: #f8fafc;
    --card-bg: rgba(255, 255, 255, 0.9);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    height: 100vh;
    overflow: auto;
    display: flex;
    flex-direction: column;
    font-family: 'Inter', -apple-system, sans-serif;
    background: radial-gradient(circle at top right, #e2e8f0, var(--bg));
    color: var(--primary);
}

/* Full Page Winner Overlay */
.winner-overlay {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, var(--primary) 0%, #1e293b 100%);
    z-index: 999;
    display: none; /* Hidden by default */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    text-align: center;
}

.winner-overlay.show-winner {
    display: flex; /* Show when competition ends */
}

.winner-content h1 {
    font-size: clamp(2rem, 8vw, 5rem);
    color: var(--gold);
    text-shadow: 0 0 20px rgba(251, 191, 36, 0.5);
    margin-bottom: 20px;
}

.winner-display {
    background: white;
    padding: 20px 60px;
    border-radius: 100px;
    margin: 20px;
    box-shadow: 0 0 50px rgba(59, 130, 246, 0.5);
}

#winner-name {
    font-size: clamp(3rem, 10vw, 6rem);
    font-weight: 900;
    color: var(--accent);
    text-transform: uppercase;
}

.view-anyway {
    margin-top: 40px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.3);
}

/* Confetti */
.confetti {
    position: fixed;
    width: 12px;
    height: 12px;
    top: -20px;
    z-index: 1000;
    animation: fall 4s linear forwards;
}

@keyframes fall {
    to { transform: translateY(110vh) rotate(720deg); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}
.bounce { animation: bounce 2s infinite; }

header {
    background: var(--primary);
    color: white;
    padding: 1rem;
    text-align: center;
    box-shadow: var(--shadow);
    z-index: 10;
}

h1 { font-size: 1.5rem; letter-spacing: -0.025em; }
#timer-box { 
    margin-top: 5px;
    font-size: 1rem; 
    color: var(--gold); 
    font-family: monospace;
    background: rgba(255,255,255,0.1);
    display: inline-block;
    padding: 2px 12px;
    border-radius: 20px;
}

#houses {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 12px;
    padding: 20px;
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
}

.house {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(255,255,255,0.7);
    box-shadow: var(--shadow);
    transition: transform 0.2s ease;
}

.house:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

.logo-container { height: 50px; display: flex; justify-content: center; margin-bottom: 8px; }
.logo { height: 100%; width: auto; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1)); }

.house-name {
    font-size: 0.8rem;
    font-weight: 800;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary);
    margin-bottom: 8px;
}

.book-pile {
    flex: 1;
    background: rgba(241, 245, 249, 0.5);
    margin: 4px 0;
    border-radius: 8px;
    border: 1px inset rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column-reverse;
    padding: 6px;
    overflow: hidden;
}

.book {
    height: 8px;
    margin-bottom: 2px;
    border-radius: 2px;
    background: linear-gradient(90deg, #2563eb 0%, #60a5fa 100%);
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.count-number { font-size: 1.5rem; font-weight: 900; text-align: center; color: var(--accent); line-height: 1; margin-top: 5px; }
.count-label { font-size: 0.6rem; text-align: center; color: #64748b; font-weight: 600; }

/* --- Increased & Centered Footer --- */
footer {
    background: white;
    padding: 20px; /* Increased padding */
    display: flex;
    flex-direction: column; /* Stacked for better centering */
    align-items: center;
    justify-content: center;
    gap: 8px; /* Space between the two lines */
    font-size: 0.9rem; /* Slightly larger text */
    border-top: 1px solid #e2e8f0;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

/* Modern Admin FAB */
#admin-fab { 
    position: fixed; 
    bottom: 60px; 
    right: 20px; 
    width: 45px;
    height: 45px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    cursor: pointer; 
    font-size: 1.2rem;
    transition: all 0.3s ease;
    border: 1px solid #e2e8f0;
    z-index: 50;
}

#admin-fab:hover {
    transform: rotate(45deg) scale(1.1);
    background: var(--accent);
    color: white;
}

/* Modern Modal */
.modal-overlay { 
    position: fixed; 
    inset: 0; 
    background: rgba(15, 23, 42, 0.8); 
    backdrop-filter: blur(4px);
    display: none; 
    align-items: center; 
    justify-content: center; 
    z-index: 100; 
}

.modal-content { 
    background: white; 
    padding: 30px; 
    border-radius: 20px; 
    width: 95%;
    max-width: 700px; 
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
}

.close-btn { 
    position: absolute; 
    top: 15px; 
    right: 15px; 
    border: none; 
    background: #f1f5f9; 
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 1.2rem; 
    cursor: pointer; 
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.close-btn:hover { background: #e2e8f0; }

/* --- Two-Column Admin Dashboard --- */
.admin-scroll-area { 
    max-height: 450px; /* Increased height to use available vertical space */
    overflow-y: auto; 
    margin: 20px 0;
    display: grid;
    grid-template-columns: 1fr 1fr; /* Two columns */
    gap: 10px; /* Space between columns */
    padding-right: 5px;
}

.house-update-row { 
    display: grid; 
    grid-template-columns: 1fr 60px 50px; /* Slimmer widths for 2-column fit */
    align-items: center; 
    gap: 8px;
    padding: 8px;
    background: #f8fafc;
    border-radius: 8px;
    font-size: 0.75rem; /* Slightly smaller text for better fit */
    border: 1px solid #e2e8f0;
}

/* Modal sizing adjustment for two columns */
.modal-content { 
    width: 95%;
    max-width: 700px; /* Widened to accommodate two columns side-by-side */
}

.house-update-row input {
    width: 100%;
    padding: 4px;
    font-size: 0.8rem;
}

.house-update-row button {
    padding: 4px 8px;
    font-size: 0.7rem;
}

input:focus { border-color: var(--accent); }

button { 
    padding: 8px 16px; 
    background: var(--accent); 
    color: white; 
    border: none; 
    border-radius: 8px; 
    font-weight: 600;
    cursor: pointer; 
    transition: opacity 0.2s;
}

button:hover { opacity: 0.9; }