:root {
    --bg-dark: #050505;
    --bg-panel: rgba(14, 14, 14, 0.7);
    --bg-panel-hover: rgba(26, 26, 26, 0.85);
    --accent-neon: #CCFF00;
    --accent-neon-dim: rgba(204, 255, 0, 0.2);
    --accent-neon-dimmer: rgba(204, 255, 0, 0.06);
    --text-main: #FAF8F5;
    --text-muted: #9B9B9B;
    --border-color: rgba(255, 255, 255, 0.14);
    --danger: #F87171;
    --danger-dim: rgba(248, 113, 113, 0.12);
    --win: #4ADE80;
    --draw: #FACC15;
    --loss: #F87171;
    --sidebar-width: 260px;
    --header-height: 70px;
    --radius: 10px;
    --radius-lg: 18px;
    --shadow-soft: 0 18px 50px rgba(0, 0, 0, 0.35);
    --shadow-glow: 0 0 28px rgba(204, 255, 0, 0.15);
    --font-ui: 'Space Grotesk', system-ui, -apple-system, sans-serif;
    --font-display: 'Oswald', sans-serif;
}

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

body {
    font-family: var(--font-ui);
    background-color: var(--bg-dark);
    background-image:
        radial-gradient(1200px 800px at 10% -10%, rgba(204, 255, 0, 0.08), transparent 60%),
        radial-gradient(900px 600px at 110% 10%, rgba(255, 255, 255, 0.04), transparent 60%),
        radial-gradient(800px 500px at 40% 110%, rgba(204, 255, 0, 0.05), transparent 65%);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

.hidden { display: none !important; }
.auth-locked .app-container { filter: blur(4px); pointer-events: none; }

h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--text-main);
    letter-spacing: 0.02em;
}
.accent-text { color: var(--accent-neon); }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }

.app-container {
    width: 100vw;
    min-height: 100vh;
    display: flex;
    position: relative;
}


@keyframes fadeUp {
    0% { opacity: 0; transform: translateY(16px); }
    100% { opacity: 1; transform: translateY(0); }
}

@keyframes glowPulse {
    0% { box-shadow: 0 0 0 rgba(204, 255, 0, 0); }
    100% { box-shadow: 0 0 24px rgba(204, 255, 0, 0.18); }
}

.view { width: 100%; min-height: 100vh; }

.glass-panel {
    background: linear-gradient(140deg, rgba(20, 20, 20, 0.9), rgba(8, 8, 8, 0.8));
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    animation: fadeUp 0.6s ease both;
}

/* Buttons */
.btn {
    font-family: var(--font-ui);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius);
    border: none;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-large { padding: 14px 24px; font-size: 16px; font-weight: 700; }
.w-full { width: 100%; }
.mt-4 { margin-top: 1rem; }
.mt-8 { margin-top: 2rem; }

.btn-primary { background: var(--accent-neon); color: var(--bg-dark); box-shadow: var(--shadow-glow); }
.btn-primary:hover { box-shadow: 0 0 25px var(--accent-neon-dim); animation: glowPulse 0.4s ease forwards; }
.btn-outline { background: rgba(10, 10, 10, 0.4); border: 1px solid var(--border-color); color: var(--text-main); }
.btn-outline:hover { background: var(--bg-panel-hover); }
.btn-outline-accent { background: var(--accent-neon-dimmer); border: 1px solid var(--accent-neon); color: var(--accent-neon); }
.btn-outline-accent:hover { background: var(--accent-neon-dim); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text-main); }
.btn-danger { background: transparent; border: 1px solid var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger-dim); }
.btn-icon { padding: 8px; background: transparent; border: none; color: var(--text-main); display: inline-flex; cursor: pointer; }
.btn-warning { background: transparent; border: 1px solid var(--draw); color: var(--draw); }
.btn-warning:hover { background: rgba(250, 204, 21, 0.1); }

/* Setup View */
.section-setup { display: flex; justify-content: center; align-items: center; padding: 2rem; }
.setup-container { width: 100%; max-width: 500px; }
.setup-header { text-align: center; margin-bottom: 2rem; }
.setup-header h1 { font-size: 2.7rem; margin-bottom: 0.5rem; letter-spacing: 0.08em; }
.glass-form { padding: 2rem; }
.form-group { margin-bottom: 1.5rem; }
.form-group label { display: block; margin-bottom: 0.5rem; font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }
.form-group.row { display: flex; gap: 1rem; }
.form-col { flex: 1; }

input[type="text"], input[type="number"], input[type="email"], select {
    width: 100%;
    background: rgba(7, 7, 7, 0.9);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 12px 14px;
    border-radius: var(--radius);
    font-family: var(--font-ui);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, select:focus { border-color: var(--accent-neon); box-shadow: 0 0 0 2px rgba(204, 255, 0, 0.15); }

.player-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.player-list { display: flex; flex-direction: column; gap: 0.75rem; max-height: 250px; overflow-y: auto; padding-right: 4px; }
.player-input-row { display: flex; gap: 8px; align-items: center; }
.player-input-row input { flex: 1; }
.remove-player-btn {
    background: var(--bg-panel); border: 1px solid var(--border-color); color: var(--danger);
    width: 42px; height: 42px; border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.remove-player-btn:hover { background: var(--danger-dim); }

/* Dashboard */
.section-dashboard { display: flex; flex-direction: column; }
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, rgba(10, 10, 10, 0.96), rgba(6, 6, 6, 0.9));
    border-right: 1px solid var(--border-color);
    height: 100vh; position: fixed; left: 0; top: 0;
    display: flex; flex-direction: column; padding: 1.5rem; z-index: 50;
}
.sidebar-header { font-size: 1.6rem; font-family: var(--font-display); margin-bottom: 3rem; display: flex; justify-content: space-between; align-items: center; letter-spacing: 0.06em; }
.sidebar-brand { display: flex; align-items: center; gap: 0.55rem; }
.sidebar-logo {
    width: 42px;
    height: 30px;
    background: url('logo.png') center center / 138% auto no-repeat;
    animation: logoPulse 2.4s ease-in-out infinite;
    flex-shrink: 0;
}
@keyframes logoPulse {
    0%, 100% { filter: drop-shadow(0 0 4px rgba(204,255,0,0.5)); transform: scale(1); }
    50%       { filter: drop-shadow(0 0 12px rgba(204,255,0,0.9)); transform: scale(1.08); }
}
.nav-links { list-style: none; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
    position: relative;
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px;
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    font-size: 0.875rem; font-weight: 500; letter-spacing: 0.01em;
    background: transparent; border: none; width: 100%; text-align: left;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.6; transition: opacity 0.15s; }
.nav-item:hover { background: rgba(255,255,255,0.05); color: var(--text-main); }
.nav-item:hover svg { opacity: 1; }
.nav-item.active { background: var(--accent-neon-dimmer); color: var(--accent-neon); }
.nav-item.active svg { opacity: 1; }
.nav-item.active::before {
    content: '';
    position: absolute; left: 0; top: 50%; transform: translateY(-50%);
    width: 3px; height: 55%; background: var(--accent-neon); border-radius: 0 2px 2px 0;
}
.sidebar-footer { padding-top: 1rem; border-top: 1px solid var(--border-color); display: flex; flex-direction: column; gap: 10px; }
.sidebar-footer #host-tools {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.sidebar-divider { border-top: 1px solid var(--border-color); margin: 2px 0; }
.sidebar-signout-btn { color: var(--text-muted); gap: 8px; font-size: 0.8rem; letter-spacing: 0.02em; }
.sidebar-signout-btn:hover { color: var(--danger); background: rgba(239,68,68,0.06); }
.mobile-only { display: none; }
.mobile-share-btn { display: none; }

.dashboard-content {
    margin-left: var(--sidebar-width); flex: 1; padding: 2rem 3rem;
    min-height: 100vh; display: flex; flex-direction: column;
}
.dashboard-header {
    display: flex; justify-content: space-between; align-items: flex-end;
    margin-bottom: 2rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--border-color);
}
.header-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.tourney-title { font-size: 2.7rem; margin-bottom: 0.5rem; letter-spacing: 0.06em; }
.tourney-meta { display: flex; gap: 16px; color: var(--text-muted); font-size: 0.9rem; }

.dashboard-grid { display: grid; grid-template-columns: 1fr; gap: 1.5rem; flex: 1; }
.col-main, .col-side { width: 100%; }
.col-side { display: grid; gap: 1.5rem; }

.bento-card {
    padding: 1.5rem;
    border-radius: var(--radius-lg);
}

.bento-card .section-title { margin-bottom: 1rem; }
.bento-card .standings-container { padding: 0; }

.section-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.section-title h3 { font-size: 1.25rem; font-family: var(--font-display); font-weight: 600; display: flex; align-items: center; gap: 8px; letter-spacing: 0.05em; }
.badge { background: var(--bg-panel); padding: 4px 10px; border-radius: 12px; font-size: 0.7rem; border: 1px solid var(--border-color); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }

/* Match Cards */
.matches-list { display: flex; flex-direction: column; gap: 1rem; }
.match-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    animation: fadeUp 0.6s ease both;
}
.match-card:hover { transform: translateY(-2px); border-color: rgba(255, 255, 255, 0.3); box-shadow: var(--shadow-soft); }
.match-card.active { border-color: var(--accent-neon); box-shadow: 0 6px 24px var(--accent-neon-dimmer); }
.match-card-compact { padding: 1rem; opacity: 0.6; }
.match-header { display: flex; justify-content: space-between; font-size: 0.7rem; color: var(--text-muted); margin-bottom: 1rem; text-transform: uppercase; letter-spacing: 0.08em; }
.match-teams { display: flex; flex-direction: column; gap: 0.5rem; }
.team-row { display: flex; justify-content: space-between; align-items: center; }
.team-name { font-size: 1.15rem; font-weight: 600; letter-spacing: 0.01em; }
.score-controls { display: flex; align-items: center; gap: 0.75rem; }
.score-display { font-size: 1.6rem; font-weight: 700; min-width: 30px; text-align: center; font-family: var(--font-display); letter-spacing: 0.05em; }
.score-btn {
    width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border-color);
    background: rgba(12, 12, 12, 0.9); color: var(--text-main);
    display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.2s;
}
.score-btn:hover { background: var(--bg-panel-hover); border-color: var(--text-muted); }
.score-btn.minus { width: 28px; height: 28px; }
.score-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.match-footer { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border-color); display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* Match Timer */
.match-timer { font-size: 0.8rem; color: var(--accent-neon); font-weight: 600; font-family: var(--font-ui); letter-spacing: 0.05em; }

/* HT Badge */
.ht-badge {
    display: inline-block; font-size: 0.7rem; padding: 2px 8px;
    background: rgba(250, 204, 21, 0.15); color: var(--draw); border-radius: 4px;
    font-weight: 600; margin-left: 8px;
}

/* Penalty Badge */
.pen-badge {
    display: inline-block; font-size: 0.7rem; padding: 2px 8px;
    background: rgba(248, 113, 113, 0.15); color: var(--danger); border-radius: 4px;
    font-weight: 600; margin-left: 8px;
}

/* Standings Table */
.standings-container { padding: 1rem; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 6px; text-align: left; border-bottom: 1px solid var(--border-color); }
th { color: var(--text-muted); font-weight: 600; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; white-space: nowrap; }
td { font-size: 0.9rem; }
tr.leader td { color: var(--accent-neon); }
.col-num { width: 28px; color: var(--text-muted); }
.col-pts { font-weight: 700; }
.col-sm { width: 32px; text-align: center; }
th.col-sm { text-align: center; }

/* Form Guide Dots */
.form-dots { display: flex; gap: 3px; align-items: center; }
.form-dot {
    width: 10px; height: 10px; border-radius: 50%; display: inline-block;
}
.form-dot.w { background: var(--win); }
.form-dot.d { background: var(--draw); }
.form-dot.l { background: var(--loss); }

/* Bracket Visualization */
.bracket-container { display: flex; gap: 0; align-items: flex-start; overflow-x: auto; padding: 1rem 0; min-height: 300px; }
.bracket-round { display: flex; flex-direction: column; justify-content: center; min-width: 180px; gap: 16px; position: relative; }
.bracket-round-title { text-align: center; font-size: 0.7rem; text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; letter-spacing: 0.1em; font-weight: 600; }
.bracket-match {
    background: var(--bg-panel); border: 1px solid var(--border-color); border-radius: var(--radius);
    padding: 8px 12px; font-size: 0.8rem; position: relative;
}
.bracket-match.bm-finished { opacity: 0.7; }
.bracket-match.bm-live { border-color: var(--accent-neon); box-shadow: 0 0 10px var(--accent-neon-dimmer); }
.bracket-team { display: flex; justify-content: space-between; padding: 4px 0; }
.bracket-team.winner { color: var(--accent-neon); font-weight: 600; }
.bracket-team span:last-child { font-weight: 700; }
.bracket-connector { width: 24px; display: flex; flex-direction: column; justify-content: center; min-height: 40px; }
.bracket-connector .line-h { height: 1px; background: var(--border-color); width: 100%; }

/* Group Tables (Hybrid Mode) */
.groups-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.5rem; }
.group-card { border: 1px solid var(--border-color); border-radius: var(--radius-lg); padding: 1rem; background: var(--bg-panel); box-shadow: var(--shadow-soft); }
.group-card h4 { font-family: var(--font-display); font-size: 0.95rem; font-weight: 600; margin-bottom: 0.75rem; color: var(--accent-neon); letter-spacing: 0.06em; }
.group-card table { font-size: 0.85rem; }
.group-card th, .group-card td { padding: 6px 4px; }
.qualify-row td { color: var(--accent-neon); font-weight: 500; }

/* Match Log */
.match-log-list { display: flex; flex-direction: column; gap: 0.75rem; }
.log-entry {
    display: flex; align-items: center; gap: 1rem; padding: 1rem 1.25rem;
    background: var(--bg-panel); border: 1px solid var(--border-color); border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    animation: fadeUp 0.6s ease both;
}
.log-stage { font-size: 0.7rem; text-transform: uppercase; color: var(--text-muted); min-width: 100px; letter-spacing: 0.05em; }
.log-result { flex: 1; font-size: 1rem; text-align: center; }
.log-result .log-winner { color: var(--accent-neon); font-weight: 600; }
.log-meta { font-size: 0.75rem; color: var(--text-muted); text-align: right; min-width: 100px; }

/* Status */
.status-active { color: var(--accent-neon); }
.status-completed { color: var(--text-muted); }

/* Viewer Banner */
.viewer-banner {
    background: var(--accent-neon-dimmer); border: 1px solid var(--accent-neon); color: var(--accent-neon);
    padding: 8px 16px; border-radius: var(--radius); display: flex; align-items: center; gap: 8px;
    margin-bottom: 2rem; font-size: 0.85rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
    /* Reserve room on the right so the fixed auth-bar doesn't cover the text */
    margin-right: 150px;
}
@media (max-width: 768px) {
    .viewer-banner { margin-right: 0; margin-top: 0.5rem; }
}
.status-dot { width: 8px; height: 8px; background-color: var(--accent-neon); border-radius: 50%; display: inline-block; box-shadow: 0 0 8px var(--accent-neon); }

/* History */
.section-history { padding: 2rem 4rem; }
.history-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(350px, 1fr)); gap: 2rem; margin-top: 2rem; }
.history-card {
    padding: 1.5rem; border-radius: var(--radius-lg); border: 1px solid var(--border-color);
    background: #0A0A0A; display: flex; flex-direction: column; gap: 1.25rem;
    cursor: pointer; transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: var(--shadow-soft);
    animation: fadeUp 0.6s ease both;
}
.history-card:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0,0,0,0.5); border-color: var(--text-muted); }
.history-card.is-active { border-color: var(--accent-neon); background: var(--bg-panel); }
.hc-header { display: flex; justify-content: space-between; font-size: 0.8rem; }
.hc-title { font-size: 1.9rem; font-family: var(--font-display); letter-spacing: 0.05em; }
.hc-meta { display: flex; gap: 1rem; font-size: 0.9rem; color: var(--text-muted); }
.hc-winner {
    background: var(--accent-neon-dimmer); color: var(--text-main); padding: 8px 12px;
    border-radius: var(--radius); display: flex; align-items: center; gap: 8px;
    font-size: 0.85rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
}
.hc-winner i { color: var(--accent-neon); }
.hc-actions { border-top: 1px solid var(--border-color); padding-top: 1rem; display: flex; justify-content: space-between; align-items: center; }

/* Modals */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.8); backdrop-filter: blur(4px); }
.modal-content { position: relative; width: 100%; max-width: 420px; padding: 2rem; z-index: 101; text-align: center; box-shadow: var(--shadow-soft); }
.auth-modal { max-width: 460px; }
.auth-hero { margin-bottom: 1rem; }
.auth-kicker {
    display: inline-block;
    font-family: var(--font-display);
    letter-spacing: 0.2em;
    color: var(--accent-neon);
    text-transform: uppercase;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}
.auth-footnote { margin-top: 1rem; font-size: 0.75rem; }
.auth-providers { display: flex; flex-direction: column; gap: 0.65rem; margin-top: 0.5rem; }
.auth-provider-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    width: 100%;
    padding: 0.75rem 1rem;
    font-weight: 600;
    border-radius: 8px;
    transition: filter 0.15s ease, transform 0.05s ease;
}
.auth-provider-btn:hover:not(:disabled) { filter: brightness(1.08); }
.auth-provider-btn:active:not(:disabled) { transform: translateY(1px); }
.auth-provider-btn:disabled { opacity: 0.7; cursor: not-allowed; }
.auth-provider-icon { flex-shrink: 0; }
.auth-google { background: #ffffff; color: #1f1f1f; border: 1px solid #dadce0; }
/* Auth modal guide section */
.auth-guide {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-color);
    text-align: left;
}
.auth-guide-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.auth-guide-list li {
    font-size: 0.83rem;
    color: var(--text-muted);
    line-height: 1.5;
    padding: 0.3rem 0 0.3rem 1rem;
    position: relative;
    border-bottom: 1px solid var(--border-color);
}
.auth-guide-list li:last-child { border-bottom: none; }
.auth-guide-list li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--accent-neon);
}
.auth-guide-list li strong { color: var(--accent-neon); font-weight: 700; }

/* Loading screen */
.loading-logo {
    width: 72px;
    height: 72px;
    object-fit: contain;
    margin-bottom: 0.5rem;
}
.loading-bar {
    width: 120px;
    height: 2px;
    background: rgba(204, 255, 0, 0.15);
    border-radius: 1px;
    overflow: hidden;
    margin-top: 1.5rem;
}
.loading-bar-fill {
    height: 100%;
    width: 40%;
    background: var(--accent-neon);
    border-radius: 1px;
    animation: loadingSweep 1.2s ease-in-out infinite;
}
@keyframes loadingSweep {
    0%   { transform: translateX(-200%); }
    100% { transform: translateX(400%); }
}

.penalty-inputs { margin: 2rem 0; display: flex; flex-direction: column; gap: 1rem; }
.p-team { display: flex; justify-content: space-between; align-items: center; font-size: 1.2rem; }
.p-team input { width: 80px; text-align: center; font-size: 1.5rem; }
.modal-actions { display: flex; gap: 1rem; }
.modal-actions button { flex: 1; }
.forfeit-choices { display: flex; flex-direction: column; gap: 0.6rem; margin: 1.2rem 0 0; }
.checkbox-row { display: flex; align-items: flex-start; gap: 0.75rem; cursor: pointer; }
.checkbox-input { width: 18px; height: 18px; margin-top: 2px; flex-shrink: 0; accent-color: var(--accent-neon); cursor: pointer; }
.checkbox-label { flex: 1; line-height: 1.4; }
.winner-ceremony { display: flex; flex-direction: column; align-items: center; gap: 1rem; }
.trophy-icon { width: 64px; height: 64px; color: var(--accent-neon); }
.winner-ceremony h1 { font-size: 3rem; text-transform: uppercase; letter-spacing: 0.1em; }

/* Draw Animation Overlay */
.draw-overlay {
    position: fixed; inset: 0; z-index: 200;
    background: var(--bg-dark); display: flex; align-items: center; justify-content: center;
    flex-direction: column;
}
.draw-content { text-align: center; }
.draw-title { font-size: 2rem; margin-bottom: 2rem; }
.draw-cards {
    display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; max-width: 500px; margin: 0 auto 2rem;
}
.draw-card {
    background: var(--bg-panel); border: 1px solid var(--accent-neon); border-radius: var(--radius);
    padding: 10px 20px; font-size: 1rem; font-weight: 700; color: var(--text-main);
    text-transform: uppercase; letter-spacing: 0.08em;
    animation: cardShuffle 0.3s ease infinite alternate;
}
.draw-card:nth-child(even) { animation-delay: 0.15s; }
.draw-sub { font-size: 0.9rem; }

@keyframes cardShuffle {
    0% { transform: translateY(0) rotate(0deg); }
    100% { transform: translateY(-8px) rotate(2deg); }
}

/* Toast */
.toast {
    position: fixed; bottom: 2rem; right: 2rem;
    background: rgba(20, 20, 20, 0.96); color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 10px 18px; border-radius: var(--radius); font-weight: 500;
    font-size: 0.875rem;
    z-index: 999; box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    backdrop-filter: blur(10px);
    animation: slideUp 0.3s ease forwards;
}
@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Tab Content */
.tab-content { flex: 1; }

/* Responsive Design */
@media (max-width: 1024px) {
    .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: 64px;
        flex-direction: row;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 0 1rem;
        align-items: center;
        background: rgba(8, 8, 8, 0.96);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }
    .sidebar-header { margin-bottom: 0; width: 100%; font-size: 1.35rem; }
    .mobile-only { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; }
    .nav-links, .sidebar-footer { display: none; }
    .dashboard-content {
        margin-left: 0;
        padding: calc(64px + env(safe-area-inset-top, 0px) + 1rem) 1rem 2rem 1rem;
    }
    .section-history { padding: calc(64px + env(safe-area-inset-top, 0px) + 1rem) 1rem 2rem 1rem; }


    .header-actions { display: flex; flex-direction: row; gap: 8px; flex-wrap: wrap; width: 100%; }
    .header-actions .btn { flex: 1 1 auto; min-width: 0; }
    #end-tourney-wrapper { display: flex; gap: 8px; flex: 1 1 100%; }
    #end-tourney-wrapper .btn { flex: 1; }
    .dashboard-header { flex-direction: column; align-items: stretch; gap: 1rem; }
    .dashboard-header > div:first-child { text-align: left; }
    .tourney-title { font-size: 1.9rem; letter-spacing: 0.06em; margin-bottom: 0.25rem; }
    .tourney-meta { font-size: 0.8rem; }
    .setup-header h1 { font-size: 2.3rem; }
    .section-title h3 { font-size: 1rem; }
    .bracket-round { min-width: 140px; }
    .history-grid { grid-template-columns: 1fr; }

    .sidebar.mobile-open {
        height: 100vh;
        flex-direction: column;
        align-items: flex-start;
        padding: 1rem;
        gap: 1rem;
        overflow-y: auto;
    }
    .sidebar.mobile-open .nav-links,
    .sidebar.mobile-open .sidebar-footer {
        display: flex;
        width: 100%;
    }
    .sidebar.mobile-open .nav-links {
        flex-direction: column;
    }
    .sidebar.mobile-open .sidebar-footer {
        margin-top: auto;
    }
    .sidebar.mobile-open .nav-item { padding: 14px 16px; font-size: 1rem; }

    .form-group.row { flex-direction: column; }
    .setup-container { max-width: 100%; }
    .glass-form { padding: 1.5rem; }
    .player-list { max-height: 200px; }

    /* Match cards: bigger tap targets, no overflow */
    .match-card { padding: 1rem; }
    .dashboard-grid { gap: 1rem; }
    .col-side { gap: 1rem; }
    .bento-card { padding: 1rem; }
    .match-header { flex-direction: row; flex-wrap: wrap; gap: 6px; align-items: center; }
    .match-teams { gap: 0.85rem; }
    .team-row {
        flex-wrap: wrap;
        gap: 8px 12px;
        row-gap: 8px;
    }
    .team-name {
        font-size: 1rem;
        flex: 1 1 100%;
        word-break: break-word;
    }
    .score-controls {
        flex: 1 1 100%;
        justify-content: flex-end;
        gap: 0.85rem;
    }
    .score-display { font-size: 1.5rem; min-width: 28px; }
    .score-btn { width: 40px; height: 40px; }
    .score-btn.minus { width: 34px; height: 34px; }
    .match-footer { gap: 0.4rem; }
    .match-footer .btn { flex: 1 1 auto; padding: 8px 12px; font-size: 12px; }

    /* Standings: drop GF, GA, Form on mobile so the table fits without scroll */
    .standings-container { padding: 0.5rem; overflow-x: auto; }
    table { min-width: 0; width: 100%; }
    th, td { padding: 8px 4px; font-size: 0.85rem; }
    .standings-container th:nth-child(7),
    .standings-container td:nth-child(7),
    .standings-container th:nth-child(8),
    .standings-container td:nth-child(8),
    .standings-container th:nth-child(11),
    .standings-container td:nth-child(11) { display: none; }
    .col-num { width: 22px; }
    .col-sm { width: 26px; }

    .log-entry { flex-direction: column; align-items: stretch; text-align: center; padding: 0.85rem; }
    .log-stage, .log-meta { min-width: auto; }

    .history-card { padding: 1.25rem; }
    .hc-title { font-size: 1.55rem; }

    .modal-content { max-width: 92%; padding: 1.5rem; max-height: 92vh; overflow-y: auto; }
    .auth-modal { max-width: 92%; }
    .toast { left: 1rem; right: 1rem; bottom: 1rem; text-align: center; font-size: 0.85rem; }

    /* Avoid 16px iOS zoom on input focus */
    input[type="text"], input[type="number"], input[type="email"], select { font-size: 16px; }
}

@media (max-width: 480px) {
    .dashboard-content { padding: calc(64px + env(safe-area-inset-top, 0px) + 0.75rem) 0.75rem 1.5rem 0.75rem; }
    .section-history { padding: calc(64px + env(safe-area-inset-top, 0px) + 0.75rem) 0.75rem 1.5rem 0.75rem; }
    .tourney-title { font-size: 1.7rem; }
    .tourney-meta { flex-direction: column; gap: 6px; }
    .match-card-compact { padding: 0.85rem; }
    .btn { padding: 10px 14px; font-size: 13px; }
    .btn-large { padding: 12px 18px; }
    .btn-sm { padding: 5px 10px; font-size: 12px; }
    .player-input-row { flex-direction: column; align-items: stretch; }
    .remove-player-btn { width: 100%; height: 38px; }
    .draw-cards { max-width: 100%; }
    .dashboard-grid { gap: 0.85rem; }
    .col-side { gap: 0.85rem; }
    .bento-card { padding: 0.85rem; }
    /* Even tighter standings on tiny screens */
    th, td { padding: 7px 3px; font-size: 0.8rem; }
}

@media (max-width: 520px) {
    .setup-header h1 { font-size: 2.1rem; }
    .hc-title { font-size: 1.6rem; }
    .btn-large { font-size: 15px; }
}

/* =====================================================
   Mobile Polish Pass (20260523)
   - Auth modal: branded hero, fullscreen on phones
   - Sidebar: backdrop, hamburger → X, smoother open
   - Setup form: cleaner spacing, keep remove-btn inline
   - Dashboard header: tidy action button rows
   ===================================================== */

.auth-brand-logo {
    width: 300px;
    height: 210px;
    /* zoom in 138% to crop the white padding from the PNG */
    background: url('logo.png') center center / 138% auto no-repeat;
    margin: 0 auto -0.25rem;
}
.auth-modal h2 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 0.5rem; letter-spacing: 0.03em; }
.auth-modal .text-muted { font-size: 0.9rem; }
.auth-modal .auth-provider-btn { padding: 0.95rem 1rem; font-size: 0.95rem; }
.auth-modal .auth-providers { margin-top: 1rem; }

/* Sidebar backdrop (mobile-open) */
.sidebar-backdrop {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0; pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 45;
}
.sidebar-backdrop.is-visible { opacity: 1; pointer-events: auto; }

@media (min-width: 769px) {
    .sidebar-backdrop { display: none; }
}

@media (max-width: 768px) {
    /* Auth modal: feel native on phones */
    .auth-modal {
        max-width: 100%;
        width: calc(100vw - 1.5rem);
        margin: 0 0.75rem;
        padding: 1.75rem 1.5rem 1.5rem;
        text-align: center;
    }
    .auth-brand-logo { width: 260px; height: 182px; }
    .auth-modal h2 { font-size: 1.5rem; }
    .auth-modal .auth-kicker { font-size: 0.78rem; letter-spacing: 0.24em; }
    .auth-footnote { font-size: 0.7rem; }

    /* Sidebar mobile-open: smoother panel feel */
    .sidebar.mobile-open {
        height: auto;
        max-height: calc(100vh - env(safe-area-inset-top, 0px));
        padding: 0.85rem 1rem 1.5rem;
        gap: 0.5rem;
        box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
        border-bottom: 1px solid var(--border-color);
    }
    .sidebar.mobile-open .sidebar-header { padding-bottom: 0.5rem; border-bottom: 1px solid var(--border-color); margin-bottom: 0.25rem; }
    .sidebar.mobile-open .nav-links { gap: 0.35rem; padding-top: 0.25rem; }
    .sidebar.mobile-open .nav-item {
        padding: 14px 14px;
        font-size: 0.95rem;
        border-radius: 12px;
        letter-spacing: 0.04em;
    }
    .sidebar.mobile-open .nav-item i { width: 18px; height: 18px; }
    .sidebar.mobile-open .sidebar-footer {
        margin-top: 0.5rem;
        padding-top: 0.85rem;
    }
    .sidebar.mobile-open .sidebar-footer #host-tools { gap: 8px; }
    .sidebar.mobile-open .sidebar-footer .btn {
        padding: 12px 14px;
        font-size: 12px;
        justify-content: flex-start;
        letter-spacing: 0.06em;
    }

    /* Hamburger → X swap when open */
    .sidebar.mobile-open #mobile-menu-toggle { color: var(--accent-neon); }

    /* Tournament create page: keep remove inline, breathe a bit */
    .glass-form { padding: 1.5rem 1.25rem; }
    .setup-header { margin-bottom: 1.5rem; }
    .setup-header h1 { font-size: 2.1rem; letter-spacing: 0.06em; }
    .setup-header p { font-size: 0.85rem; }
    .form-group { margin-bottom: 1.15rem; }
    .form-group label { font-size: 0.72rem; }
    .player-list { max-height: 38vh; }

    /* Dashboard header: clean, predictable button rows */
    .header-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        width: 100%;
    }
    .header-actions .btn { width: 100%; min-width: 0; padding: 11px 10px; font-size: 12px; }
    #end-tourney-wrapper {
        display: contents; /* let its two buttons sit in the grid directly */
    }
    #new-tournament-btn { grid-column: 1 / -1; }
    /* When End Early wrapper is hidden, New Tournament should span both cols */
    #end-tourney-wrapper.hidden + #new-tournament-btn { grid-column: 1 / -1; }
    /* Share buttons stack full-width below New Tournament on mobile */
    .mobile-share-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; grid-column: 1 / -1; }
}

@media (max-width: 480px) {
    /* Keep remove-player button inline with input — stacking it full-width looked bad */
    .player-input-row { flex-direction: row; align-items: center; }
    .player-input-row input { flex: 1; min-width: 0; }
    .remove-player-btn { width: 42px; height: 42px; flex-shrink: 0; }

    /* Tighter setup heading */
    .setup-header h1 { font-size: 1.9rem; }
    .glass-form { padding: 1.25rem 1rem; }

    /* Meta info on tiny screens: keep inline with dot separators rather than column list */
    .tourney-meta { flex-direction: row; flex-wrap: wrap; gap: 6px 10px; font-size: 0.78rem; }
    .tourney-meta > *:not(:last-child)::after { content: '•'; margin-left: 10px; color: var(--text-muted); opacity: 0.6; }

    /* Auth modal: a touch tighter on tiny screens */
    .auth-modal { padding: 1.5rem 1.15rem 1.25rem; }
    .auth-modal h2 { font-size: 1.35rem; }
    .auth-brand-logo { width: 220px; height: 154px; }
}

/* Site footer */
.site-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    padding: 8px 1rem;
    font-size: 0.72rem;
    color: var(--text-muted);
    background: rgba(5, 5, 5, 0.85);
    border-top: 1px solid var(--border-color);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    letter-spacing: 0.03em;
}
.site-footer a { color: var(--text-muted); text-decoration: underline; }
.site-footer a:hover { color: var(--text-main); }

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}
