:root {
    --bg: #071018;
    --panel: rgba(10, 28, 42, 0.88);
    --line: rgba(232, 197, 71, 0.28);
    --gold: #e8c547;
    --gold-2: #f4e19a;
    --text: #f4f7fb;
    --muted: #9eb0c0;
    --live: #ff3b3b;
    --good: #2ee59d;
}

* { box-sizing: border-box; }
html, body {
    margin: 0;
    height: 100%;
    background:
        radial-gradient(1200px 600px at 50% -10%, rgba(232, 197, 71, 0.16), transparent 55%),
        linear-gradient(180deg, #0b1b28 0%, #071018 55%, #050b11 100%);
    color: var(--text);
    font-family: "Barlow Condensed", "Segoe UI", sans-serif;
    overflow: hidden;
}

.board {
    height: 100%;
    display: grid;
    grid-template-rows: auto 1fr auto auto;
    padding: 1.2vh 1.4vw;
    gap: 1vh;
}

.topbar, .score-row, .players, .footer {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.28);
}

.topbar {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 1.2vh 1.6vw 1.3vh;
    gap: 1vh;
    min-height: 0;
    overflow: hidden;
}
.topbar-main {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1vw;
}
.topbar-spacer { min-width: 0; }

.brand {
    display: flex;
    align-items: center;
    gap: 0.8vw;
    min-width: 0;
}
.brand img, .brand .mark {
    height: 13.5vh;
    width: auto;
    max-width: 16vw;
    object-fit: contain;
}
.brand .mark {
    display: grid;
    place-items: center;
    width: 8.5vh;
    border-radius: 12px;
    background: linear-gradient(180deg, var(--gold), #b0891a);
    color: #1a1203;
    font-family: Anton, sans-serif;
    font-size: 3.2vh;
}
.titles { min-width: 0; }
.titles h1 {
    margin: 0;
    font-size: 2.8vh;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    line-height: 1.05;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.titles p {
    margin: 0.2vh 0 0;
    color: var(--muted);
    font-size: 1.8vh;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.center-meta {
    text-align: center;
}
.live-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5vw;
    background: rgba(255, 59, 59, 0.12);
    border: 1px solid rgba(255, 59, 59, 0.45);
    color: #ffd0d0;
    border-radius: 999px;
    padding: 0.5vh 1vw;
    font-size: 2vh;
    letter-spacing: 0.18em;
    font-weight: 700;
}
.live-pill.idle { background: rgba(158,176,192,0.12); border-color: rgba(158,176,192,0.35); color: var(--muted); }
.dot {
    width: 1.1vh;
    height: 1.1vh;
    border-radius: 50%;
    background: var(--live);
    box-shadow: 0 0 10px var(--live);
    animation: pulse 1s infinite;
}
.live-pill.idle .dot { background: var(--muted); box-shadow: none; animation: none; }
@keyframes pulse { 50% { opacity: 0.35; transform: scale(0.85); } }
.venue {
    margin: 0.6vh 0 0;
    color: var(--gold-2);
    font-size: 1.9vh;
    letter-spacing: 0.08em;
}

.partner-rail {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 0.9vw;
    min-width: 0;
    width: 100%;
    padding: 0.75vh 0.9vw;
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(232, 197, 71, 0.16);
    border-radius: 12px;
    overflow: hidden;
}
.partner-label {
    font-size: 3.35vh;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--gold);
    white-space: normal;
    width: 7.2vw;
    line-height: 1.3;
    text-align: center;
    padding-right: 0.9vw;
    border-right: 1px solid var(--line);
}
.sponsor-card {
    min-width: 0;
    height: 8.8vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.1vh 1.3vw;
    overflow: hidden;
    background: linear-gradient(180deg, #ffffff 0%, #f4f7fb 100%);
    border: 1px solid rgba(232, 197, 71, 0.32);
    border-radius: 8px;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.65);
}
.sponsor-strip {
    display: grid;
    grid-template-columns: repeat(var(--sponsor-count, 5), minmax(0, 1fr));
    align-items: stretch;
    gap: 0.55vw;
    min-width: 0;
    width: 100%;
    overflow: hidden;
}
.sponsor-card img {
    display: block;
    min-width: 0;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    object-position: center;
    background: transparent;
    padding: 0;
    border-radius: 0;
}

.score-row {
    display: grid;
    grid-template-columns: 1fr 12vw 1fr;
    align-items: center;
    padding: 1.5vh 1.5vw;
    min-height: 38vh;
}

.team {
    display: grid;
    grid-template-columns: 9vw 1fr;
    gap: 1.2vw;
    align-items: center;
    min-width: 0;
}
.team.right { grid-template-columns: 1fr 9vw; text-align: right; }
.team img, .team .crest {
    width: 8.5vw;
    height: 16vh;
    object-fit: contain;
}
img[hidden], .crest[hidden], .mark[hidden], [hidden] { display: none !important; }
.crest-wrap img { display: block; }
.team .crest {
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: rgba(255,255,255,0.06);
    font-family: Anton, sans-serif;
    font-size: 5vh;
    color: var(--gold);
}
.team.batting .crest, .team.batting img { filter: drop-shadow(0 0 12px rgba(232,197,71,0.45)); }
.team-name {
    margin: 0;
    font-family: Anton, sans-serif;
    font-size: 7.2vh;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1;
}
.score {
    margin: 0.4vh 0 0;
    font-family: Anton, sans-serif;
    font-size: 22.6vh;
    line-height: 0.9;
    color: var(--gold-2);
    text-shadow: 0 0 24px rgba(232, 197, 71, 0.25);
}
.sub {
    margin-top: 0.5vh;
    color: var(--muted);
    font-size: 2.4vh;
    letter-spacing: 0.08em;
}
.team.winner .team-name {
    color: var(--gold);
    text-shadow: 0 0 18px rgba(232, 197, 71, 0.45);
}
.event-popup.is-win .event-veil {
    background:
        radial-gradient(circle at 50% 78%, rgba(255, 170, 0, 0.42), transparent 42%),
        radial-gradient(circle at 50% 42%, rgba(232, 197, 71, 0.28), transparent 48%),
        rgba(3, 8, 14, 0.88);
}
.event-popup.is-win .event-card {
    border-color: rgba(255, 210, 80, 0.8);
    box-shadow: 0 0 0 1px rgba(255,255,255,0.08) inset, 0 30px 80px rgba(0,0,0,0.45), 0 0 90px rgba(255, 180, 0, 0.35);
}
.event-popup.is-win .event-title {
    color: var(--gold);
    font-size: 7vh;
    letter-spacing: 0.14em;
}
.event-popup.is-win .event-big.is-name {
    font-size: 14vh;
    line-height: 0.95;
    max-width: 80vw;
    word-break: break-word;
}
.event-popup.is-win .event-kicker { color: var(--gold-2); }

.vs {
    text-align: center;
}
.vs strong {
    font-family: Anton, sans-serif;
    font-size: 20vh;
    color: var(--gold);
}
.vs span {
    display: block;
    margin-top: 1vh;
    color: var(--muted);
    letter-spacing: 0.16em;
    font-size: 1.8vh;
}

.players {
    display: grid;
    grid-template-columns: 1.4fr 0.9fr 0.9fr;
    gap: 0;
    min-height: 22vh;
}
.col {
    padding: 1.4vh 1.4vw;
    border-right: 1px solid var(--line);
}
.col:last-child { border-right: 0; }
.col h3 {
    margin: 0 0 1vh;
    font-size: 1.7vh;
    letter-spacing: 0.18em;
    color: var(--gold);
    text-transform: uppercase;
}
.batter, .bowler-line {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1vw;
    padding: 0.7vh 0;
    font-size: 3vh;
}
.batter .name, .bowler-line .name { font-weight: 700; }
.batter .name .star { color: var(--gold); margin-left: 0.3vw; }
.stat { font-family: Anton, sans-serif; font-size: 3.4vh; color: var(--gold-2); }
.meta { color: var(--muted); font-size: 2vh; }

.over-balls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5vw;
    margin-top: 0.8vh;
}
.ball {
    min-width: 3.4vw;
    height: 5.2vh;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: rgba(255,255,255,0.08);
    font-family: Anton, sans-serif;
    font-size: 2.6vh;
}
.ball.b4, .ball.b6 { background: var(--good); color: #042116; }
.ball.w { background: var(--live); }

.footer {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    padding: 0 1.4vw;
    gap: 1vw;
}
.headline {
    font-size: 2.6vh;
    letter-spacing: 0.04em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.clock {
    font-family: Anton, sans-serif;
    font-size: 3.2vh;
    color: var(--gold);
}
.stale {
    color: #ffb703;
    font-size: 1.8vh;
    margin-left: 0.8vw;
}
.error-banner {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: rgba(7,16,24,0.92);
    border: 1px solid var(--line);
    padding: 4vh 4vw;
    border-radius: 16px;
    text-align: center;
    max-width: 60vw;
}
.error-banner a { color: var(--gold); }

.event-popup {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    pointer-events: none;
    overflow: hidden;
}
.event-popup[hidden] { display: none !important; }
.event-veil {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 50% 78%, rgba(255, 90, 0, 0.38), transparent 42%),
        radial-gradient(circle at 50% 48%, rgba(232, 197, 71, 0.22), transparent 46%),
        rgba(3, 8, 14, 0.86);
    animation: veilIn 0.35s ease-out;
}
.event-popup.is-four .event-veil {
    background:
        radial-gradient(circle at 50% 78%, rgba(255, 140, 0, 0.32), transparent 42%),
        radial-gradient(circle at 50% 48%, rgba(56, 189, 248, 0.22), transparent 46%),
        rgba(3, 8, 14, 0.86);
}
.event-popup.is-wicket .event-veil {
    background:
        radial-gradient(circle at 50% 80%, rgba(255, 30, 0, 0.5), transparent 46%),
        radial-gradient(circle at 50% 48%, rgba(255, 59, 59, 0.28), transparent 48%),
        rgba(8, 2, 4, 0.9);
}
.event-cheers {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    overflow: hidden;
}
.cheer-slot {
    position: absolute;
    bottom: 0;
    top: 0;
    width: 44vw;
    overflow: hidden;
}
.cheer-left {
    left: -1.5vw;
    -webkit-mask-image: linear-gradient(to right, #000 54%, transparent 94%);
    mask-image: linear-gradient(to right, #000 54%, transparent 94%);
}
.cheer-right {
    right: -1.5vw;
    transform: scaleX(-1);
    -webkit-mask-image: linear-gradient(to right, #000 54%, transparent 94%);
    mask-image: linear-gradient(to right, #000 54%, transparent 94%);
}
.cheer-gif {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: left bottom;
    pointer-events: none;
    animation: cheerIn 0.55s cubic-bezier(0.16, 1.15, 0.3, 1) both;
    filter: drop-shadow(0 0 32px rgba(255, 186, 40, 0.35));
}
.cheer-gif[hidden] { display: none !important; }
.event-popup.is-four .cheer-gif {
    filter: drop-shadow(0 0 32px rgba(80, 190, 255, 0.4));
}
.event-popup.is-wicket .cheer-gif {
    filter: drop-shadow(0 0 32px rgba(255, 70, 70, 0.42));
}
.event-popup.is-out .cheer-gif { animation: cheerOut 0.32s ease-in forwards; }
.event-rings {
    position: absolute;
    width: 70vmin;
    height: 70vmin;
    pointer-events: none;
}
.event-rings span {
    position: absolute;
    inset: 0;
    border: 3px solid rgba(232, 197, 71, 0.55);
    border-radius: 50%;
    animation: ringOut 1.6s ease-out infinite;
}
.event-popup.is-four .event-rings span { border-color: rgba(125, 211, 252, 0.6); }
.event-popup.is-wicket .event-rings span { border-color: rgba(255, 92, 92, 0.55); }
.event-rings span:nth-child(2) { animation-delay: 0.35s; }
.event-rings span:nth-child(3) { animation-delay: 0.7s; }
.event-sparkles {
    position: absolute;
    inset: 0;
    pointer-events: none;
}
.event-sparkles span {
    position: absolute;
    width: 0.7vw;
    height: 0.7vw;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 12px currentColor;
    animation: spark 1.1s ease-out infinite;
}
.event-card {
    position: relative;
    z-index: 4;
    text-align: center;
    padding: 4vh 6vw 5vh;
    min-width: 52vw;
    border-radius: 28px;
    background:
        linear-gradient(180deg, rgba(18, 32, 48, 0.78), rgba(7, 14, 22, 0.88));
    border: 1px solid rgba(255, 140, 40, 0.55);
    box-shadow:
        0 0 0 1px rgba(255,255,255,0.06) inset,
        0 30px 80px rgba(0,0,0,0.45),
        0 0 80px rgba(255, 90, 0, 0.28);
    animation: cardPop 0.7s cubic-bezier(0.16, 1.2, 0.3, 1) both;
}
.event-popup.is-four .event-card {
    border-color: rgba(125, 211, 252, 0.65);
    box-shadow: 0 0 0 1px rgba(255,255,255,0.06) inset, 0 30px 80px rgba(0,0,0,0.45), 0 0 80px rgba(56, 189, 248, 0.22);
}
.event-popup.is-wicket .event-card {
    border-color: rgba(255, 92, 92, 0.7);
    box-shadow: 0 0 0 1px rgba(255,255,255,0.06) inset, 0 30px 80px rgba(0,0,0,0.45), 0 0 90px rgba(255, 59, 59, 0.28);
    animation: cardHit 0.65s cubic-bezier(0.16, 1.1, 0.3, 1);
}
.event-kicker {
    margin: 0;
    letter-spacing: 0.42em;
    font-size: 2.2vh;
    color: var(--gold-2);
    text-transform: uppercase;
}
.event-popup.is-four .event-kicker { color: #bae6fd; }
.event-popup.is-wicket .event-kicker { color: #fecaca; }
.event-big-wrap {
    position: relative;
    display: grid;
    place-items: center;
}
.event-big {
    position: relative;
    z-index: 1;
    margin: 0.4vh 0 0;
    font-family: Anton, sans-serif;
    font-size: 32vh;
    line-height: 0.82;
    color: #fff8d0;
    text-shadow:
        0 0 10px #fff,
        0 0 24px #ffcc33,
        0 0 48px #ff7a00,
        0 0 80px #ff2a00,
        0 18px 40px rgba(0,0,0,0.45);
    animation: firePulse 0.7s ease-in-out infinite alternate;
}
.event-popup.is-four .event-big {
    color: #fff7e8;
    text-shadow:
        0 0 10px #fff,
        0 0 24px #ffd36a,
        0 0 48px #ff8a1a,
        0 0 72px #38bdf8,
        0 18px 40px rgba(0,0,0,0.45);
}
.event-popup.is-wicket .event-big {
    font-size: 22vh;
    color: #ffe8d8;
    text-shadow:
        0 0 10px #fff,
        0 0 24px #ff6a3a,
        0 0 52px #ff1e00,
        0 0 80px #8a0000,
        0 18px 40px rgba(0,0,0,0.5);
}
.event-title {
    margin: 0;
    font-family: Anton, sans-serif;
    font-size: 9vh;
    letter-spacing: 0.18em;
    color: var(--gold);
}
.event-popup.is-four .event-title { color: #7dd3fc; }
.event-popup.is-wicket .event-title { color: #ff6b6b; letter-spacing: 0.28em; }
.event-sub {
    margin: 0.4vh 0 0;
    font-size: 3.2vh;
    letter-spacing: 0.34em;
    text-transform: uppercase;
    color: #fff;
}
.event-detail {
    margin: 1.6vh 0 0;
    font-size: 2.8vh;
    color: var(--muted);
    max-width: 70vw;
}
.event-popup.is-out .event-card { opacity: 0; animation: cardOut 0.35s ease-in forwards; }
.event-popup.is-out .event-veil { animation: veilOut 0.35s ease-in forwards; }

@keyframes veilIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes veilOut { to { opacity: 0; } }
@keyframes cardPop {
    0% { transform: scale(0.55) rotate(-4deg); opacity: 0; }
    70% { transform: scale(1.06) rotate(1deg); opacity: 1; }
    100% { transform: scale(1) rotate(0); }
}
@keyframes cardHit {
    0% { transform: scale(0.7) translateY(4vh); opacity: 0; }
    40% { transform: scale(1.08) translateX(-1vw); }
    70% { transform: scale(0.98) translateX(0.6vw); }
    100% { transform: scale(1) translateX(0); }
}
@keyframes cardOut { to { transform: scale(0.92); opacity: 0; } }
@keyframes ringOut {
    0% { transform: scale(0.35); opacity: 0.7; }
    100% { transform: scale(1.35); opacity: 0; }
}
@keyframes cheerIn {
    0% { opacity: 0; transform: translateX(-7vw) scale(0.96); }
    100% { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes cheerOut {
    to { opacity: 0; }
}
@keyframes firePulse {
    0% { transform: scale(1); filter: brightness(1); }
    100% { transform: scale(1.05); filter: brightness(1.18); }
}
@keyframes spark {
    0% { transform: translate(0, 0) scale(0.4); opacity: 0; }
    25% { opacity: 1; }
    100% { transform: translate(var(--dx), var(--dy)) scale(0.1); opacity: 0; }
}
