:root {
  --primary-red: #D32F2F;
  --primary-red-dark: #B71C1C;
  --primary-red-light: #EF5350;
  --gold: #FFD700;
  --bg: #F5F5F5;
  --surface: rgba(255,255,255,0.7);
  --surface-border: rgba(255,255,255,0.4);
  --text-dark: #1A1A1A;
  --text-muted: #6B6B6B;
  --radius-lg: 20px;
  --radius-md: 14px;
  --shadow-soft: 0 8px 32px rgba(0,0,0,0.08);
  --space-xs: .5rem;
  --space-sm: .75rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2.5rem;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  min-width: 320px; min-height: 100vh; margin: 0; color: var(--text-dark);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(circle at 7% 4%, rgba(211,47,47,.14), transparent 26rem),
              radial-gradient(circle at 95% 100%, rgba(255,215,0,.18), transparent 29rem), var(--bg);
}
button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid rgba(211,47,47,.42); outline-offset: 3px; }
.app { width: min(1720px, calc(100% - 2rem)); margin: 0 auto; padding: 3.2rem 0 2rem; }
.eyebrow { margin: 0 0 .35rem; color: var(--primary-red); font-size: .76rem; font-weight: 800; letter-spacing: .16em; text-align: center; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(2rem, 5vw, 3.25rem); letter-spacing: -.055em; text-align: center; }
.subtitle { margin: .65rem auto 1.7rem; max-width: 37rem; color: var(--text-muted); text-align: center; }

/* Role badge shown top-right so you can tell Admin vs Viewer at a glance */
.role-badge { position: fixed; top: 1rem; right: 1rem; z-index: 5; padding: .4rem .85rem; border-radius: 999px; font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; box-shadow: var(--shadow-soft); }
.role-badge.admin { color: #fff; background: linear-gradient(135deg, var(--primary-red), var(--primary-red-dark)); }
.role-badge.viewer { color: var(--primary-red-dark); background: rgba(255,215,0,.28); border: 1px solid rgba(255,215,0,.5); }
.role-badge .live-dot { display: inline-block; width: 8px; height: 8px; margin-right: .35rem; border-radius: 50%; background: #2e7d32; vertical-align: middle; animation: livePulse 1.4s ease-in-out infinite; }

.matchup { display: grid; grid-template-columns: 1fr auto 1fr; gap: var(--space-md); align-items: center; margin-bottom: var(--space-md); }
.team-badge, .scoreboard, .team-card, .dialog-card { background: var(--surface); border: 1px solid var(--surface-border); box-shadow: var(--shadow-soft); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.team-badge { display: flex; align-items: center; justify-content: center; gap: .6rem; min-height: 66px; padding: .75rem; border-radius: var(--radius-md); font-size: clamp(1rem, 2.7vw, 1.3rem); font-weight: 800; }
.team-badge:last-child { color: var(--primary-red-dark); }
.cricket { font-size: 1.55em; }
.versus { display: grid; width: 52px; height: 52px; place-items: center; color: #fff; border-radius: 50%; background: linear-gradient(135deg, var(--primary-red-light), var(--primary-red-dark)); box-shadow: 0 7px 19px rgba(183,28,28,.28); font-size: .85rem; font-weight: 900; animation: pulse 1.8s ease-in-out infinite; }

.scoreboard { display: grid; grid-template-columns: 1fr 1fr auto; align-items: center; gap: var(--space-sm); padding: .75rem 1rem; margin-bottom: var(--space-lg); border-radius: var(--radius-lg); }
.score-value { display: flex; align-items: baseline; justify-content: center; gap: .5rem; min-width: 0; font-weight: 800; }
.score-value span { overflow: hidden; color: var(--text-muted); font-size: .76rem; font-weight: 700; letter-spacing: .05em; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.score-value strong { color: var(--primary-red-dark); font-size: 1.45rem; font-variant-numeric: tabular-nums; }
.leader-pill { justify-self: end; padding: .48rem .75rem; color: #6f5700; border: 1px solid rgba(255,215,0,.42); border-radius: 999px; background: rgba(255,215,0,.22); font-size: .82rem; font-weight: 800; white-space: nowrap; }

.competition-layout { display: grid; grid-template-columns: minmax(210px, 1fr) minmax(800px, 940px) minmax(210px, 1fr); gap: var(--space-lg); align-items: start; }
.dashboard { min-width: 0; }
.member-panel { position: sticky; top: 1rem; padding: 1.1rem; border: 1px solid var(--surface-border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-soft); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.member-panel h2 { margin: 0; color: var(--primary-red-dark); font-size: 1.15rem; letter-spacing: -.02em; }
.member-panel p { margin: .35rem 0 1rem; color: var(--text-muted); font-size: .83rem; line-height: 1.4; }
.member-form { display: grid; gap: .55rem; }
.member-form label { color: var(--text-dark); font-size: .8rem; font-weight: 800; }
.member-form input { width: 100%; min-height: 40px; padding: .45rem .65rem; color: var(--text-dark); border: 1px solid rgba(26,26,26,.15); border-radius: 9px; background: rgba(255,255,255,.78); }
.member-form .button { min-height: 40px; padding: .5rem .7rem; }
.member-divider { height: 1px; margin: 1.1rem 0 .7rem; background: rgba(26,26,26,.1); }
.member-count { display: block; margin-bottom: .55rem; color: var(--text-muted); font-size: .76rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.member-list { display: grid; gap: .45rem; max-height: calc(100vh - 315px); padding: 0; margin: 0; overflow: auto; list-style: none; }
.member-item, .member-empty { min-height: 39px; padding: .5rem .55rem .5rem .7rem; border-radius: 9px; background: rgba(255,255,255,.52); }
.member-item { display: flex; align-items: center; justify-content: space-between; gap: .4rem; font-size: .88rem; font-weight: 700; }
.member-item::before { content: "•"; color: var(--primary-red); font-size: 1.25rem; }
.member-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.remove-member { display: grid; width: 27px; height: 27px; place-items: center; flex: 0 0 auto; color: var(--primary-red-dark); border: 0; border-radius: 7px; background: rgba(211,47,47,.1); font-size: 1.05rem; }
.remove-member:hover { background: rgba(211,47,47,.2); }
.member-empty { color: var(--text-muted); font-size: .83rem; font-style: italic; }
.teams-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-lg); }
.team-card { overflow: hidden; border-radius: var(--radius-lg); }
.card-head { display: flex; align-items: flex-start; justify-content: center; min-height: 224px; padding: 1.05rem 1.25rem; color: #fff; background: linear-gradient(135deg, var(--primary-red), var(--primary-red-dark)); }
.team-card[data-team="ganguli"] .card-head { background: linear-gradient(135deg, #7d1515, var(--primary-red)); }
.card-head h2 { margin: 0; font-size: 1.32rem; letter-spacing: -.02em; }
.card-head span { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 50%; background: rgba(255,255,255,.17); font-size: 1.2rem; }
.card-identity { display: grid; width: 100%; justify-items: center; gap: .7rem; text-align: center; }
.card-portrait { display: grid; width: 154px; height: 154px; place-items: center; overflow: hidden; border: 4px solid rgba(255,255,255,.85); border-radius: 50%; background: rgba(255,255,255,.2); box-shadow: 0 8px 20px rgba(0,0,0,.25); }
.card-portrait img { width: 100%; height: 100%; object-fit: cover; object-position: center top; }
.card-portrait .portrait-fallback { display: none; width: 100%; height: 100%; border-radius: 0; background: transparent; font-size: 1.8rem; }
.checklist { padding: .7rem 1.15rem; }
.check-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .55rem 1rem; align-items: center; padding: .8rem .05rem; border-bottom: 1px solid rgba(26,26,26,.08); }
.check-row:last-child { border: 0; }
.item-label { overflow: hidden; font-size: .94rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.input-area { display: flex; align-items: center; justify-content: flex-end; gap: .6rem; }
input[type="number"] { width: 76px; min-height: 37px; padding: .35rem .5rem; color: var(--text-dark); border: 1px solid rgba(26,26,26,.15); border-radius: 9px; background: rgba(255,255,255,.78); font-weight: 700; text-align: center; }
.present { display: flex; align-items: center; gap: .38rem; color: var(--text-muted); font-size: .82rem; font-weight: 700; }
input[type="checkbox"] { width: 1.1rem; height: 1.1rem; accent-color: var(--primary-red); }
.points { grid-column: 1 / -1; color: var(--text-muted); font-size: .76rem; font-weight: 700; }
.card-total { display: flex; align-items: center; justify-content: space-between; margin: .15rem 1.15rem 1.2rem; padding: 1rem; color: var(--primary-red-dark); border-radius: var(--radius-md); background: linear-gradient(135deg, rgba(211,47,47,.11), rgba(255,215,0,.18)); }
.card-total span { font-weight: 800; }
.card-total strong { font-size: 1.65rem; font-variant-numeric: tabular-nums; }

/* Viewer read-only display: replaces the score input with a static value */
.score-readonly { min-width: 76px; padding: .35rem .5rem; color: var(--primary-red-dark); border-radius: 9px; background: rgba(211,47,47,.08); font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; }

.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .8rem; margin-top: var(--space-xl); }
.button { min-height: 49px; padding: .75rem 1.15rem; border: 1px solid transparent; border-radius: 12px; font-weight: 800; transition: all .25s ease; }
.button:hover { transform: translateY(-2px); }
.button-primary { color: #fff; background: linear-gradient(135deg, var(--primary-red), var(--primary-red-dark)); box-shadow: 0 10px 22px rgba(183,28,28,.26); }
.button-primary:hover { box-shadow: 0 14px 28px rgba(183,28,28,.38); }
.button-secondary { color: var(--primary-red-dark); border-color: rgba(211,47,47,.4); background: rgba(255,255,255,.48); }
.button-secondary:hover { background: rgba(211,47,47,.08); }

.modal { position: fixed; z-index: 10; inset: 0; display: none; place-items: center; padding: 1rem; background: rgba(26,26,26,.46); backdrop-filter: blur(6px); }
.modal.open { display: grid; }
.dialog-card { position: relative; width: min(440px, 100%); padding: 2.5rem 1.75rem 1.7rem; border-radius: var(--radius-lg); text-align: center; }
.close { position: absolute; top: .75rem; right: .75rem; display: grid; width: 37px; height: 37px; place-items: center; color: var(--text-dark); border: 0; border-radius: 50%; background: rgba(26,26,26,.07); font-size: 1.25rem; }
.close:hover { background: rgba(211,47,47,.14); }
.winner-avatar { display: grid; width: 144px; height: 144px; place-items: center; margin: 0 auto 1.15rem; overflow: hidden; border-radius: 50%; background: #fff; box-shadow: 0 0 40px var(--gold); animation: popIn .45s cubic-bezier(.2,1.5,.5,1) both; font-size: 4rem; }
.winner-avatar img { width: 100%; height: 100%; object-fit: cover; }
.tie-icon { display: block; margin-bottom: 1rem; font-size: 5rem; animation: handshake .85s ease-in-out infinite alternate; }
.dialog-card h2 { margin: 0; color: var(--primary-red-dark); font-size: clamp(1.55rem, 6vw, 2rem); }
.dialog-score { margin: .65rem 0 1.4rem; color: var(--text-muted); font-size: 1.12rem; font-weight: 700; }
.dialog-card .button { width: 100%; }
.confirm-card { width: min(380px, 100%); padding-top: 2rem; }
.confirm-card h2 { margin-bottom: .6rem; }
.confirm-card p { margin: 0 0 1.25rem; color: var(--text-muted); }
.confirm-actions { display: flex; gap: .7rem; }
.confirm-actions .button { flex: 1; }
.confetti { position: absolute; top: -18px; width: 9px; height: 15px; pointer-events: none; animation: fall var(--fall-duration, 1.5s) ease-in forwards; }

/* ---------- BNI "Ignition" loading overlay ---------- */
.loader-overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; gap: 1.8rem; background: #ffffff; transition: opacity .55s ease, visibility .55s ease; }
.loader-overlay.hidden { opacity: 0; visibility: hidden; transform: scale(1.04); }
.bni-loader { display: grid; place-items: center; gap: 1.5rem; }
/* logo zooms + fades in, then a shine sweeps across it */
.bni-logo-wrap { position: relative; display: inline-block; animation: ignIn 1s cubic-bezier(.2,1.3,.4,1) both; }
.bni-logo { display: block; height: 88px; width: auto; }
.bni-shine { position: absolute; top: 0; left: -40%; width: 40%; height: 100%; background: linear-gradient(100deg, transparent, rgba(255,255,255,.85), transparent); transform: skewX(-18deg); pointer-events: none; animation: ignShine 1.7s ease-in-out .55s infinite; }
/* red energy bar charging underneath */
.bni-bar { width: 200px; height: 5px; border-radius: 99px; background: rgba(211,47,47,.14); overflow: hidden; }
.bni-bar::after { content: ""; display: block; height: 100%; width: 40%; border-radius: 99px; background: var(--primary-red); animation: ignCharge 1.5s ease-in-out infinite; }
.loader-text { display: flex; align-items: center; gap: .45rem; color: var(--primary-red-dark); font-size: .78rem; font-weight: 800; letter-spacing: .22em; text-transform: uppercase; }
.loader-text .dots span { display: inline-block; animation: bounce 1.2s ease-in-out infinite; }
.loader-text .dots span:nth-child(2) { animation-delay: .18s; }
.loader-text .dots span:nth-child(3) { animation-delay: .36s; }

@keyframes ignIn { 0% { opacity: 0; transform: scale(.72); } 100% { opacity: 1; transform: scale(1); } }
@keyframes ignShine { 0% { left: -40%; } 55%, 100% { left: 130%; } }
@keyframes ignCharge { 0% { width: 8%; transform: translateX(0); } 50% { width: 60%; } 100% { width: 8%; transform: translateX(480%); } }
@keyframes bounce { 0%, 100% { transform: translateY(0); opacity: .4; } 50% { transform: translateY(-4px); opacity: 1; } }
@keyframes livePulse { 0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(46,125,50,.5); } 50% { opacity: .55; box-shadow: 0 0 0 5px rgba(46,125,50,0); } }
@keyframes pulse { 50% { transform: scale(1.08); box-shadow: 0 0 0 11px rgba(211,47,47,.11); } }
@keyframes popIn { from { opacity: 0; transform: scale(.3); } to { opacity: 1; transform: scale(1); } }
@keyframes handshake { from { transform: rotate(-8deg) scale(.96); } to { transform: rotate(8deg) scale(1.04); } }
@keyframes fall { to { transform: translate(var(--drift), 110vh) rotate(720deg); opacity: 0; } }

/* Soft flash when a viewer score updates live */
@keyframes liveFlash { 0% { background: rgba(255,215,0,.55); } 100% { background: rgba(211,47,47,.08); } }
.score-readonly.flash { animation: liveFlash .7s ease; }

@media (max-width: 1300px) { .app { width: min(1120px, calc(100% - 2rem)); } .competition-layout { grid-template-columns: repeat(2, minmax(0, 1fr)); } .dashboard { grid-column: 1 / -1; grid-row: 1; } .member-panel { position: static; grid-row: 2; } .member-list { max-height: 270px; } }
@media (max-width: 767px) { .app { width: min(100% - 1.25rem, 560px); padding-top: 2rem; } .competition-layout { grid-template-columns: 1fr; } .dashboard, .member-panel { grid-column: auto; grid-row: auto; } .teams-grid { grid-template-columns: 1fr; } .member-list { max-height: none; } }
@media (max-width: 475px) { .matchup { gap: .4rem; } .team-badge { min-height: 56px; padding: .45rem; font-size: .92rem; } .versus { width: 42px; height: 42px; font-size: .73rem; } .scoreboard { grid-template-columns: 1fr 1fr; } .leader-pill { grid-column: 1 / -1; justify-self: center; } .actions { display: grid; } .button { width: 100%; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }
