/* ==========================================================================
   ONLINE FOOTBALL SQUARES - REIMAGINED
   A bold, modern experience that stands out
   ========================================================================== */

:root {
    --team1: <?= h($team1Color) ?>;
    --team2: <?= h($team2Color) ?>;
    --black: #0a0a0a;
    --white: #ffffff;
    --gray-50: #fafafa;
    --gray-100: #f4f4f5;
    --gray-200: #e4e4e7;
    --gray-300: #d4d4d8;
    --gray-400: #a1a1aa;
    --gray-500: #71717a;
    --gray-600: #52525b;
    --gray-700: #3f3f46;
    --gray-800: #27272a;
    --gray-900: #18181b;
    --green: #22c55e;
    --blue: #3b82f6;
    --orange: #f97316;
    --purple: #a855f7;
    --radius: 12px;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    background: var(--gray-100);
    color: var(--gray-900);
    line-height: 1.5;
}

/* ==========================================================================
   LAYOUT
   ========================================================================== */

.game-layout {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Top Navigation */
.top-nav {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 10px;
}

@media (max-width: 480px) {
    .top-nav {
        padding: 10px 12px;
    }
}

.logo {
    font-weight: 800;
    font-size: 1.15rem;
    color: var(--gray-900);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.03em;
    white-space: nowrap;
}

.logo-mark {
    width: 36px;
    height: 36px;
    background: var(--gray-900);
    border-radius: 10px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 2px;
    padding: 5px;
    flex-shrink: 0;
}

.logo-mark span {
    background: #6366f1;
    border-radius: 2px;
}

.logo-mark span:nth-child(1) { opacity: 0.4; }
.logo-mark span:nth-child(2) { opacity: 0.6; }
.logo-mark span:nth-child(3) { opacity: 0.8; }
.logo-mark span:nth-child(4) { opacity: 1; }

/* Mobile nav adjustments */
@media (max-width: 480px) {
    .logo {
        font-size: 0.95rem;
        gap: 8px;
    }
    
    .logo-mark {
        width: 28px;
        height: 28px;
        border-radius: 8px;
        position: relative;
        overflow: hidden;
    }
    

    
    .nav-actions .btn-sm {
        padding: 6px 10px;
        font-size: 0.75rem;
    }
}

@media (max-width: 360px) {
    .logo {
        font-size: 0.85rem;
        gap: 6px;
    }
    
    .logo-mark {
        width: 24px;
        height: 24px;
        border-radius: 6px;
    }
}

.nav-actions {
    display: flex;
    gap: 8px;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* ==========================================================================
   SCOREBOARD HERO
   ========================================================================== */

.scoreboard-hero {
    background: linear-gradient(135deg, var(--gray-900) 0%, var(--gray-800) 100%);
    border-radius: 20px;
    padding: 32px;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
}

.scoreboard-hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse at 20% 20%, rgba(34, 197, 94, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(59, 130, 246, 0.15) 0%, transparent 50%);
    pointer-events: none;
}

.scoreboard-content {
    position: relative;
    z-index: 1;
}

.matchup {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 40px;
    margin-bottom: 24px;
}

.team {
    text-align: center;
    flex: 1;
    max-width: 200px;
}

.team-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--white);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.team-color {
    width: 48px;
    height: 6px;
    border-radius: 3px;
    margin: 0 auto;
}

.team.away .team-color { background: var(--team1); }
.team.home .team-color { background: var(--team2); }

.score-center {
    text-align: center;
}

.score-display {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 8px;
}

.score-num {
    font-size: 4rem;
    font-weight: 900;
    color: var(--white);
    line-height: 1;
    min-width: 80px;
}

.score-sep {
    font-size: 2rem;
    color: var(--gray-500);
}

.game-state {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.game-state.live {
    background: var(--green);
    color: var(--white);
    animation: pulse 2s infinite;
    display: flex;
    align-items: center;
    gap: 6px;
}

.game-state.live::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--white);
    border-radius: 50%;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.game-state.final {
    background: var(--blue);
    color: var(--white);
}

.game-state.scheduled {
    background: var(--gray-700);
    color: var(--gray-300);
}

/* Live status with clock */
.live-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.game-clock {
    color: var(--white);
    font-size: 1rem;
    font-weight: 600;
    background: var(--gray-700);
    padding: 6px 12px;
    border-radius: 6px;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.game-time {
    color: var(--gray-400);
    font-size: 1rem;
}

.game-info {
    display: flex;
    justify-content: center;
    gap: 24px;
    color: var(--gray-400);
    font-size: 0.85rem;
}

/* Quarter Scores in Hero */
.quarter-scores {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--gray-700);
}

.quarter-box {
    background: var(--gray-800);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.quarter-box.winner { border-color: currentColor; }
.quarter-box.winner.q1 { color: var(--green); background: rgba(34, 197, 94, 0.1); }
.quarter-box.winner.q2 { color: var(--blue); background: rgba(59, 130, 246, 0.1); }
.quarter-box.winner.q3 { color: var(--orange); background: rgba(249, 115, 22, 0.1); }
.quarter-box.winner.final { color: var(--purple); background: rgba(168, 85, 247, 0.1); }

.quarter-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--gray-500);
    margin-bottom: 4px;
}

.quarter-box.winner .quarter-label { color: inherit; opacity: 0.7; }

.quarter-result {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--white);
}

.quarter-box.winner .quarter-result { color: inherit; }

.quarter-winner-name {
    font-size: 0.8rem;
    font-weight: 600;
    margin-top: 4px;
    color: inherit;
}

/* ==========================================================================
   THE GRID - THE MAIN EVENT
   ========================================================================== */

.grid-section {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 24px;
    align-items: stretch;
}

.grid-main {
    background: var(--white);
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 4px 12px rgba(0,0,0,0.05);
}

/* Controls */
.grid-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--gray-200);
    flex-wrap: wrap;
}

.admin-badge {
    background: linear-gradient(135deg, var(--blue), var(--purple));
    color: var(--white);
    font-size: 0.65rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.player-label { color: var(--gray-500); font-size: 0.9rem; }
.player-name-display { font-weight: 700; color: var(--gray-900); }
.player-squares {
    background: var(--gray-100);
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-600);
}

.control-spacer { flex: 1; }

/* The Grid Board */
.grid-board {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Top Team Label */
.team-header {
    display: flex;
    align-items: center;
    margin-left: 52px;
}

.team-header-label {
    flex: 1;
    background: var(--team2);
    color: var(--white);
    text-align: center;
    padding: 14px 20px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Grid with Left Label */
.grid-with-label {
    display: flex;
    gap: 8px;
}

/* Left Team Label */
.team-sidebar {
    width: 44px;
    min-width: 44px;
    background: var(--team1);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.team-sidebar-label {
    writing-mode: vertical-lr;
    transform: rotate(180deg);
    color: var(--white);
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    padding: 20px 0;
}

/* The Actual Grid */
.squares-board {
    flex: 1;
    display: grid;
    grid-template-columns: auto repeat(10, 1fr);
    grid-template-rows: auto repeat(10, 1fr);
    gap: 4px;
}

/* Header Cells */
.header-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--blue);
    background: var(--gray-100);
    border-radius: 8px;
    padding: 8px 4px;
    min-height: 32px;
}

.header-cell.row-header {
    color: var(--gray-700);
    padding: 4px 8px;
    min-width: 32px;
}

.header-cell.corner {
    background: transparent;
}

.header-cell.corner .mobile-team1 {
    display: none;
}

.header-cell.pending {
    color: var(--gray-400);
}

/* Square Cells */
.square {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-50);
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-600);
    cursor: pointer;
    transition: all 0.15s;
    overflow: hidden;
    text-align: center;
    line-height: 1.2;
    padding: 4px;
    word-break: break-word;
    hyphens: auto;
}

.square:hover {
    border-color: var(--blue);
    background: rgba(59, 130, 246, 0.05);
    transform: scale(1.02);
}

.square.claimed {
    background: var(--white);
    color: var(--gray-900);
    font-weight: 700;
}

.square.locked {
    cursor: default;
}

.square.locked:hover {
    transform: none;
    border-color: var(--gray-200);
    background: var(--gray-50);
}

.square.claimed.locked:hover {
    background: var(--white);
}

/* WINNER SQUARES - Make them CELEBRATE */
.square.winner {
    color: var(--white);
    font-weight: 700;
    border: none;
    position: relative;
    z-index: 2;
    animation: winner-pop 0.3s ease-out;
}

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

.square.winner.q1 {
    background: linear-gradient(135deg, var(--green), #16a34a);
    box-shadow: 0 0 0 3px var(--green), 0 4px 20px rgba(34, 197, 94, 0.4);
}

.square.winner.q2 {
    background: linear-gradient(135deg, var(--blue), #2563eb);
    box-shadow: 0 0 0 3px var(--blue), 0 4px 20px rgba(59, 130, 246, 0.4);
}

.square.winner.q3 {
    background: linear-gradient(135deg, var(--orange), #ea580c);
    box-shadow: 0 0 0 3px var(--orange), 0 4px 20px rgba(249, 115, 22, 0.4);
}

.square.winner.final {
    background: linear-gradient(135deg, var(--purple), #9333ea);
    box-shadow: 0 0 0 3px var(--purple), 0 4px 20px rgba(168, 85, 247, 0.4);
}

.square.winner.current {
    animation: winner-pulse 1.5s infinite;
}

@keyframes winner-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* ==========================================================================
   SIDEBAR
   ========================================================================== */

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--white);
    border-radius: 20px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 4px 12px rgba(0,0,0,0.05);
}

.sidebar-card {
    background: var(--gray-50);
    border-radius: 12px;
    overflow: hidden;
}

.sidebar-header {
    padding: 16px 20px;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--gray-900);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-body {
    padding: 12px 20px;
}

.sidebar-body.sidebar-collapsible {
    max-height: 250px;
    overflow-y: auto;
}

/* Stats Card */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    padding: 16px 20px;
}

.stat-box {
    text-align: center;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--gray-900);
}

.stat-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Leaderboard */
.lb-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--gray-100);
}

.lb-row:last-child { border-bottom: none; }

.lb-rank {
    width: 28px;
    height: 28px;
    background: var(--gray-100);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--gray-500);
}

.lb-row:nth-child(1) .lb-rank { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: var(--white); }
.lb-row:nth-child(2) .lb-rank { background: linear-gradient(135deg, #94a3b8, #64748b); color: var(--white); }
.lb-row:nth-child(3) .lb-rank { background: linear-gradient(135deg, #cd7f32, #a0522d); color: var(--white); }

.lb-name { flex: 1; font-weight: 600; color: var(--gray-900); }
.lb-count { font-weight: 800; color: var(--blue); font-size: 1.1rem; }

/* Activity */
.activity-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.85rem;
}

.activity-row:last-child { border-bottom: none; }

.activity-time { color: var(--gray-400); font-size: 0.75rem; min-width: 50px; }
.activity-square {
    background: var(--gray-100);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
    font-family: monospace;
    font-size: 0.75rem;
}
.activity-old { color: #ef4444; text-decoration: line-through; }
.activity-new { color: var(--green); font-weight: 600; }

/* Admin Login */
.admin-login-form {
    padding: 20px;
}

.admin-login-form h4 {
    font-size: 0.95rem;
    margin-bottom: 12px;
    color: var(--gray-700);
    font-weight: 600;
}

.admin-login-form form {
    display: flex;
    gap: 8px;
}

.admin-login-form input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--gray-200);
    border-radius: 10px;
    font-size: 0.9rem;
    min-width: 0;
}

.admin-login-form input:focus {
    outline: none;
    border-color: var(--blue);
}

.admin-login-form .btn {
    white-space: nowrap;
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    border: none;
    transition: all 0.15s;
    text-decoration: none;
}

.btn-primary {
    background: var(--blue);
    color: var(--white);
}

.btn-primary:hover {
    background: #2563eb;
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-200);
}

.btn-sm {
    padding: 8px 14px;
    font-size: 0.8rem;
}

/* ==========================================================================
   NOTICES & MESSAGES
   ========================================================================== */

.notice {
    padding: 16px 20px;
    border-radius: 12px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.notice.info {
    background: #dbeafe;
    color: #1e40af;
}

.notice.success {
    background: #dcfce7;
    color: #166534;
}

/* Message Card (Custom Message from Organizer) */
.message-card {
    background: var(--white);
    border-radius: 16px;
    margin-bottom: 16px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border: 1px solid var(--gray-200);
}

.message-header {
    padding: 14px 20px;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--gray-800);
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.message-header:hover {
    background: var(--gray-100);
}

.message-header .collapse-icon {
    font-size: 0.7rem;
    color: var(--gray-400);
    transition: transform 0.2s;
}

.message-card.collapsed .message-header .collapse-icon {
    transform: rotate(-90deg);
}

.message-card.collapsed .message-content {
    display: none;
}

.message-body {
    padding: 16px 20px;
    font-size: 0.95rem;
    color: var(--gray-700);
    line-height: 1.7;
}

.message-body p {
    margin: 0 0 12px 0;
}

.message-body p:last-child {
    margin-bottom: 0;
}

.message-footer {
    padding: 14px 20px;
    background: linear-gradient(to right, var(--gray-50), var(--white));
    border-top: 1px solid var(--gray-100);
}

.message-footer a {
    color: var(--gray-500);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: color 0.15s;
}

.message-footer a:hover {
    color: var(--blue);
}

/* ==========================================================================
   FOOTER
   ========================================================================== */

.game-footer {
    text-align: center;
    padding: 24px 24px 16px;
    color: var(--gray-500);
    font-size: 0.85rem;
}

.game-footer a { color: var(--blue); text-decoration: none; }
.game-footer a:hover { text-decoration: underline; }

.score-delay-notice {
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--gray-400);
}

/* Site Footer */
.site-footer {
    background: var(--gray-900);
    color: var(--gray-400);
    padding: 48px 24px 24px;
    margin-top: 0;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 48px;
    margin-bottom: 32px;
}

.footer-brand .footer-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--white);
    margin-bottom: 8px;
}

.footer-brand .logo-mark {
    width: 28px;
    height: 28px;
    background: var(--gray-900);
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}

.footer-tagline {
    color: var(--gray-500);
    font-size: 0.9rem;
}

.footer-links {
    display: flex;
    gap: 48px;
}

.footer-col h4 {
    color: var(--white);
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.footer-col a {
    display: block;
    color: var(--gray-400);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 4px 0;
    transition: color 0.15s;
}

.footer-col a:hover {
    color: var(--white);
}

.footer-bottom {
    max-width: 1200px;
    margin: 0 auto;
    padding-top: 24px;
    border-top: 1px solid var(--gray-800);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.footer-actions {
    display: flex;
    gap: 8px;
}

@media (max-width: 768px) {
    .footer-content {
        grid-template-columns: 1fr;
        gap: 32px;
    }
    
    .footer-links {
        gap: 32px;
    }
    
    .footer-bottom {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }
}

/* ==========================================================================
   PASSWORD GATE
   ========================================================================== */

.password-gate {
    max-width: 400px;
    margin: 60px auto;
    padding: 48px 32px;
    background: var(--white);
    border-radius: 24px;
    text-align: center;
    box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}

.password-gate h2 {
    font-size: 1.5rem;
    margin-bottom: 8px;
    color: var(--gray-900);
}

.password-gate p {
    color: var(--gray-500);
    margin-bottom: 24px;
}

.password-gate input {
    width: 100%;
    padding: 14px 20px;
    border: 2px solid var(--gray-200);
    border-radius: 12px;
    font-size: 1rem;
    text-align: center;
    margin-bottom: 16px;
}

.password-gate input:focus {
    outline: none;
    border-color: var(--blue);
}

/* ==========================================================================
   RESPONSIVE - MOBILE
   ========================================================================== */

@media (max-width: 1024px) {
    .grid-section {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
    
    .sidebar-card:first-child {
        grid-column: span 2;
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: 6px;
    }
    
    .scoreboard-hero {
        padding: 14px 10px;
        border-radius: 12px;
        margin-bottom: 10px;
    }
    
    .matchup {
        gap: 12px;
    }
    
    .team-name {
        font-size: 0.8rem;
    }
    
    .score-num {
        font-size: 1.75rem;
        min-width: 36px;
    }
    
    .quarter-scores {
        gap: 6px;
        margin-top: 10px;
        padding-top: 10px;
    }
    
    .quarter-box {
        padding: 6px 4px;
        border-radius: 6px;
    }
    
    .quarter-label {
        font-size: 0.5rem;
    }
    
    .quarter-result {
        font-size: 0.85rem;
    }
    
    .quarter-winner-name {
        font-size: 0.6rem;
    }
    
    .game-info {
        font-size: 0.75rem;
        gap: 12px;
    }
    
    /* Grid Section - Stack on mobile */
    .grid-section {
        gap: 10px;
    }
    
    .grid-main {
        padding: 6px;
        border-radius: 10px;
    }
    
    .grid-controls {
        margin-bottom: 6px;
        padding-bottom: 6px;
        gap: 4px;
        flex-wrap: wrap;
    }
    
    .grid-controls .btn-sm {
        padding: 5px 8px;
        font-size: 0.7rem;
    }
    
    .player-info {
        flex-wrap: wrap;
        gap: 4px;
        font-size: 0.8rem;
    }
    
    .player-label {
        font-size: 0.75rem;
    }
    
    .player-squares {
        font-size: 0.7rem;
        padding: 1px 6px;
    }
    
    /* MOBILE GRID - HIDE LEFT SIDEBAR, GO FULL WIDTH */
    .grid-board {
        gap: 3px;
    }
    
    /* Keep the left team sidebar on mobile but make it slim */
    .team-sidebar {
        width: 18px !important;
        min-width: 18px !important;
        border-radius: 6px;
    }
    
    .team-sidebar-label {
        font-size: 0.7rem;
        letter-spacing: 1px;
    }
    
    /* Adjust header to match slim sidebar */
    .team-header {
        margin-left: 20px;
    }
    
    .team-header-label {
        padding: 8px 12px;
        font-size: 0.7rem;
        letter-spacing: 1px;
        border-radius: 6px;
    }
    
    /* Grid with label - just the grid now */
    .grid-with-label {
        gap: 0;
    }
    
    .squares-board {
        gap: 2px;
    }
    
    .header-cell {
        font-size: 0.7rem;
        border-radius: 4px;
        font-weight: 700;
        padding: 4px 2px;
        min-height: 24px;
    }
    
    .header-cell.row-header {
        padding: 2px 4px;
        min-width: 24px;
    }
    
    /* Hide the corner team name on mobile - keep grid clean */
    .header-cell.corner {
        background: transparent !important;
    }
    
    .header-cell.corner .mobile-team1 {
        display: none !important;
    }
    
    .square {
        font-size: 2.4vw;
        border-radius: 4px;
        border-width: 1px;
        padding: 2px;
        aspect-ratio: 1;
        line-height: 1.1;
        word-break: break-word;
        hyphens: auto;
    }
    
    .square.winner {
        box-shadow: 0 0 0 2px currentColor;
    }
    
    /* Sidebar stacks below */
    .sidebar {
        grid-template-columns: 1fr;
    }
    
    .sidebar-card:first-child {
        grid-column: span 1;
    }
    
    .sidebar-header {
        padding: 10px 12px;
        font-size: 0.85rem;
    }
    
    .sidebar-body {
        padding: 6px 12px;
        max-height: 180px;
    }
    
    .stats-grid {
        padding: 10px 12px;
        gap: 8px;
    }
    
    .stat-value {
        font-size: 1.1rem;
    }
    
    .stat-label {
        font-size: 0.6rem;
    }
    
    /* Message card */
    .message-card {
        margin-bottom: 10px;
    }
    
    .message-header {
        padding: 10px 14px;
        font-size: 0.85rem;
    }
    
    .message-body {
        padding: 12px 14px;
        font-size: 0.85rem;
    }
    
    .message-footer {
        padding: 10px 14px;
    }
    
    .message-footer a {
        font-size: 0.8rem;
    }
    
    /* Notice */
    .notice {
        padding: 10px 12px;
        margin-bottom: 10px;
        font-size: 0.8rem;
    }
    
    /* Leaderboard rows */
    .lb-row {
        padding: 8px 0;
    }
    
    .lb-rank {
        width: 24px;
        height: 24px;
        font-size: 0.7rem;
    }
    
    .lb-name {
        font-size: 0.9rem;
    }
    
    .lb-count {
        font-size: 1rem;
    }
    
    /* Activity */
    .activity-row {
        font-size: 0.8rem;
        padding: 6px 0;
    }
    
    /* Footer */
    .game-footer {
        padding: 16px 12px 8px;
        font-size: 0.8rem;
    }
    
    .site-footer {
        padding: 32px 16px 16px;
    }
    
    .footer-content {
        gap: 24px;
    }
    
    .footer-links {
        gap: 24px;
    }
    
    .footer-col h4 {
        font-size: 0.75rem;
    }
    
    .footer-col a {
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 4px;
    }
    
    .matchup {
        flex-direction: column;
        gap: 6px;
    }
    
    .team {
        max-width: none;
    }
    
    .score-display {
        gap: 8px;
    }
    
    .score-num {
        font-size: 1.5rem;
        min-width: 32px;
    }
    
    /* KEEP quarters as 4 columns */
    .quarter-scores {
        grid-template-columns: repeat(4, 1fr);
        gap: 4px;
    }
    
    .quarter-box {
        padding: 5px 2px;
    }
    
    .quarter-label {
        font-size: 0.45rem;
    }
    
    .quarter-result {
        font-size: 0.75rem;
    }
    
    .quarter-winner-name {
        font-size: 0.5rem;
    }
    
    /* Tightest grid */
    .grid-main {
        padding: 4px;
    }
    
    .grid-board {
        gap: 2px;
    }
    
    .team-header-label {
        font-size: 0.6rem;
        padding: 6px 10px;
        letter-spacing: 0.5px;
    }
    
    .team-sidebar-label {
        font-size: 0.6rem;
    }
    
    .squares-board {
        gap: 2px;
    }
    
    .header-cell {
        font-size: 0.6rem;
        padding: 2px;
    }
    
    .square {
        font-size: 2.6vw;
        border-radius: 3px;
        padding: 2px 1px;
    }
    
    /* Smaller controls */
    .grid-controls {
        gap: 3px;
    }
    
    .grid-controls .btn-sm {
        padding: 4px 6px;
        font-size: 0.65rem;
    }
    
    .admin-badge {
        font-size: 0.5rem;
        padding: 2px 5px;
    }
    
    /* Stats grid horizontal on small */
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 4px;
        padding: 8px;
    }
    
    .stat-value {
        font-size: 0.95rem;
    }
    
    .stat-label {
        font-size: 0.5rem;
    }
}

/* ==========================================================================
   UTILITIES
   ========================================================================== */

.hidden { display: none !important; }
.text-muted { color: var(--gray-500); }
.text-center { text-align: center; }
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mt-1 { margin-top: 8px; }
.gap-1 { gap: 8px; }
.flex { display: flex; }

/* Form Elements */
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--gray-200);
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.15s;
    background: var(--white);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--blue);
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--gray-700);
}

.form-hint {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-top: 4px;
}

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.form-checkbox input {
    width: 18px;
    height: 18px;
}

/* Alert */
.alert {
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 0.9rem;
    margin-bottom: 16px;
}

.alert-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.alert-warning {
    background: #fffbeb;
    color: #b45309;
    border: 1px solid #fcd34d;
}

/* Share Box */
.share-box {
    display: flex;
    gap: 8px;
}

.share-box .form-input {
    flex: 1;
}

/* Color Pickers */
.color-pickers {
    display: flex;
    gap: 16px;
}

.color-picker-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-picker-group input[type="color"] {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

/* ==========================================================================
   MODALS - CRITICAL FIX
   ========================================================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    padding: 20px;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--white);
    border-radius: 20px;
    width: 100%;
    max-width: 440px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.95) translateY(20px);
    transition: transform 0.2s ease;
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--gray-100);
    border-radius: 8px;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--gray-500);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--gray-200);
    color: var(--gray-700);
}

.modal-body {
    padding: 24px;
}

/* Body scroll lock when modal is open */
body.modal-open {
    overflow: hidden;
}

/* Button block */
.btn-block {
    width: 100%;
}

.btn-danger {
    background: #ef4444;
    color: var(--white);
}

.btn-danger:hover {
    background: #dc2626;
}

/* Sidebar Game Status Card */
.sidebar-game-status {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    background: linear-gradient(135deg, var(--gray-800), var(--gray-900));
    border-radius: 12px;
    text-align: center;
}

.sidebar-teams {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.sidebar-team {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--white);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-score {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--white);
}

.sidebar-live-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.sidebar-period {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-400);
}

.sidebar-game-time {
    font-size: 0.85rem;
    color: var(--gray-400);
}

/* Sidebar Winners Section */
.sidebar-winners {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
    background: var(--gray-50);
    border-radius: 12px;
}

.sidebar-winners-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--gray-700);
    margin-bottom: 4px;
}

.sidebar-winner-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    background: var(--white);
    border-radius: 8px;
    border: 1px solid var(--gray-200);
}

.sidebar-winner-item.has-winner {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border-color: #f59e0b;
}

.sidebar-winner-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--gray-500);
    text-transform: uppercase;
    min-width: 40px;
}

.sidebar-winner-score {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-700);
    min-width: 45px;
}

.sidebar-winner-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-left: auto;
    padding-left: 8px;
    border-left: 2px solid var(--gray-300);
}

.sidebar-winner-item.has-winner .sidebar-winner-name {
    color: #92400e;
    border-left-color: #f59e0b;
}

/* Collapsible sidebar sections */
.sidebar-collapse-toggle {
    display: none;
}

.sidebar-header-normal {
    padding: 16px 20px;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--gray-900);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-collapse-toggle .sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0;
    cursor: pointer;
    padding: 16px 20px;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--gray-900);
}

.sidebar-collapse-toggle .collapse-icon {
    font-size: 0.7rem;
    transition: transform 0.2s;
    color: var(--gray-400);
}

.sidebar-collapse-toggle.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.sidebar-collapsible {
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

/* Game is live or completed - show collapsible toggles */
body.game-active .sidebar-collapse-toggle {
    display: block;
    width: 100%;
    background: none;
    border: none;
    padding: 0;
    text-align: left;
}

body.game-active .sidebar-header-normal {
    display: none;
}

body.game-active .sidebar-collapse-toggle.collapsed ~ .sidebar-collapsible {
    max-height: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    overflow: hidden;
}

/* Zoom Controls */
.zoom-controls {
    display: none;
    align-items: center;
    gap: 2px;
}

.zoom-btn {
    width: 28px;
    height: 28px;
    padding: 0 !important;
    font-size: 1rem !important;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.zoom-btn.reset {
    font-size: 0.8rem !important;
    width: 32px;
}

/* Show zoom controls on desktop */
@media (min-width: 1025px) {
    .zoom-controls {
        display: flex;
    }
}

/* Adjust for different screen heights */