/* ThisOver score overlay — a bottom-third strip on a transparent
   1920x1080 stage. Sizes are in stage pixels; overlay.js scales the stage to
   whatever size the browser source is. */

:root {
  --accent: #C8102E;          /* ThisOver red — the batting side's block */
  --accent-deep: #8E0B20;
  --bar: rgba(14, 14, 18, 0.93);
  --sub: rgba(14, 14, 18, 0.80);
  --text: #FFFFFF;
  --muted: rgba(255, 255, 255, 0.62);
  --line: rgba(255, 255, 255, 0.14);
  --boundary: #22C55E;
  --wicket: #FF4D4D;
  --milestone: #F2B705;
  --sans: "Helvetica Neue", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

/* The dark turf variant: a pitch-green block instead of red. */
body.theme-turf {
  --accent: #0F6B3F;
  --accent-deep: #0A4A2B;
  --bar: rgba(6, 22, 14, 0.93);
  --sub: rgba(6, 22, 14, 0.82);
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  /* Transparent, or the encoder paints a black box over the video. */
  background: transparent;
}

body {
  font-family: var(--sans);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

#stage {
  position: absolute;
  left: 0;
  top: 0;
  width: 1920px;
  height: 1080px;
  transform-origin: 0 0;
}

[hidden] { display: none !important; }

/* Shown only when the page is misconfigured or waiting — so whoever is
   setting up the stream can see why the strip is not there. */
#setup {
  position: absolute;
  left: 64px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 24px;
  background: var(--bar);
  border-left: 6px solid var(--accent);
  border-radius: 10px;
  font-size: 24px;
}
#setup b { font-size: 26px; letter-spacing: .02em; }
#setup span { color: var(--muted); }

/* ---- The strip ---------------------------------------------------------- */

#strip {
  position: absolute;
  left: 64px;
  right: 64px;
  /* Low, so it covers as little of the pitch as possible. Inside the 1080
     frame on every encoder; a TV "title safe" margin would be 54px, which
     streams do not need. */
  bottom: 16px;
}

.bar {
  display: flex;
  align-items: stretch;
  height: 104px;
  background: var(--bar);
  border-radius: 12px 12px 0 0;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .35);
}

.bar > div { display: flex; }

.label {
  display: block;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Batting side and total, on the accent block. */
.team {
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-width: 400px;
  max-width: 470px;
  padding: 0 28px;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
}
.team-name {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.team-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 22px;
}
.team .total { font-size: 52px; font-weight: 900; line-height: 1; letter-spacing: -.02em; }
.team .total .wk { font-size: 34px; font-weight: 800; opacity: .8; }
.team .overs { font-size: 30px; font-weight: 800; white-space: nowrap; }
.team .overs small {
  font-size: 18px;
  font-weight: 700;
  opacity: .75;
  margin-left: 2px;
}

/* The two batters, stacked. */
.batters {
  flex: 1.35;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 0 30px;
  border-right: 1px solid var(--line);
  min-width: 0;
}
.batter {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-size: 27px;
  font-weight: 600;
  color: var(--muted);
  min-width: 0;
}
.batter.striker { color: var(--text); font-weight: 800; }
.batter .name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.batter .fig { font-weight: 800; white-space: nowrap; }
.batter .fig small { font-size: 20px; font-weight: 600; opacity: .7; margin-left: 4px; }
.on-strike {
  width: 0;
  height: 0;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  border-left: 13px solid var(--accent);
  align-self: center;
  visibility: hidden;
  flex: none;
}
.batter.striker .on-strike { visibility: visible; }
body.theme-turf .on-strike { border-left-color: var(--boundary); }

/* Current bowler. */
.bowler {
  flex: 1;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding: 0 30px;
  border-right: 1px solid var(--line);
  min-width: 0;
}
.bowler .name { font-size: 27px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bowler .fig { font-size: 24px; font-weight: 700; color: var(--muted); white-space: nowrap; }

/* This over, as ball chips. */
.over {
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  padding: 0 28px;
}
.balls { display: flex; gap: 8px; }
.ball {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 8px;
  border-radius: 20px;
  background: rgba(255, 255, 255, .12);
  font-size: 20px;
  font-weight: 800;
  box-sizing: border-box;
}
.ball.b4, .ball.b6 { background: var(--boundary); color: #04210F; }
.ball.w { background: var(--wicket); color: #fff; }
.ball.x { background: transparent; border: 2px solid rgba(255, 255, 255, .35); color: var(--muted); }

/* The line under the bar: the chase, the break, or the result. */
.sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 50px;
  padding: 0 28px;
  background: var(--sub);
  border-radius: 0 0 12px 12px;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: .01em;
}
#sub-main b { color: var(--text); font-weight: 900; }
#sub-main { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub-right { display: flex; align-items: center; gap: 22px; color: var(--muted); white-space: nowrap; }
.brand { font-size: 16px; font-weight: 900; letter-spacing: .16em; text-transform: uppercase; opacity: .7; }
#health {
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(242, 183, 5, .18);
  color: var(--milestone);
  font-size: 16px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}

/* ---- The moment: a four, a six, a wicket, a milestone ---------------------- */

#flash {
  position: absolute;
  left: 0;
  bottom: 100%;
  margin-bottom: 12px;
  padding: 14px 30px;
  border-radius: 10px;
  background: var(--accent);
  font-size: 40px;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
  animation: flash-in 320ms cubic-bezier(.2, .9, .3, 1.2) both;
}
#flash.four, #flash.six { background: var(--boundary); color: #04210F; }
#flash.wicket { background: var(--wicket); }
#flash.fifty, #flash.hundred { background: var(--milestone); color: #231A00; }
#flash.overComplete { background: var(--bar); font-size: 28px; }
#flash.leaving { animation: flash-out 260ms ease-in both; }

/* ---- Player card: new batter, new bowler, a batter out --------------------- */

#card {
  position: absolute;
  right: 0;
  bottom: 100%;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 22px;
  min-width: 560px;
  max-width: 820px;
  padding: 18px 30px 18px 18px;
  background: var(--bar);
  border-left: 8px solid var(--accent);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
  animation: flash-in 360ms cubic-bezier(.2, .9, .3, 1.2) both;
}
#card.leaving { animation: flash-out 260ms ease-in both; }
#card.out { border-left-color: var(--wicket); }
body.theme-turf #card.batter, body.theme-turf #card.bowler { border-left-color: var(--boundary); }

.avatar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 104px;
  height: 104px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  font-size: 40px;
  font-weight: 900;
  letter-spacing: .02em;
}
#card.out .avatar { background: linear-gradient(135deg, #FF4D4D, #9B1C1C); }
.avatar { position: relative; overflow: hidden; }
.avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.card-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.card-kicker {
  font-size: 17px;
  font-weight: 900;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--accent);
}
body.theme-turf .card-kicker { color: var(--boundary); }
#card.out .card-kicker { color: var(--wicket); }
.card-name {
  font-size: 38px;
  font-weight: 900;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-line { font-size: 25px; font-weight: 800; white-space: nowrap; }
.card-line.muted { font-size: 21px; font-weight: 700; color: var(--muted); }
#card.out #card-line-0 { font-size: 34px; }

@keyframes flash-in {
  from { opacity: 0; transform: translateY(24px) scale(.96); }
  to   { opacity: 1; transform: none; }
}
@keyframes flash-out {
  to { opacity: 0; transform: translateY(16px); }
}
