:root {
  --empty: #1a1a1a;
  --ticker-bg: #0a0a0a;
  --team-box: #6d101c;
  --league-box: #000000;
  --clock-box: #2a2a2a;
  --divider: #ffffff;
  --text: #ffffff;
  --winner: #ffd000;
  --ticker-height: 7rem;
  --ticker-font: "Arial Narrow", "Franklin Gothic Medium", "Helvetica Neue Condensed", Impact, sans-serif;
  --unit-width: clamp(26.5rem, 48vw, 40rem);
}

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

html,
body {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
}

body {
  font-family: var(--ticker-font);
  background: var(--empty);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

.stage {
  flex: 0 0 auto;
  height: clamp(64px, 12vh, 96px);
  min-height: 64px;
  max-height: 96px;
  background: #1f6b32;
  position: relative;
}

#runner {
  display: block;
  width: 100%;
  height: 100%;
}

.filters {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  background: var(--ticker-bg);
}

.filter-group-sports {
  justify-content: flex-end;
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}

.filter-btn {
  border: 0;
  background: #111;
  color: #8a8a8a;
  font: 700 0.75rem var(--ticker-font);
  letter-spacing: 0.12em;
  padding: 0.45rem 0.7rem;
  cursor: pointer;
  text-transform: uppercase;
}

.filter-btn.is-active {
  background: var(--team-box);
  color: var(--text);
}

.filter-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.awake-pill {
  display: none;
  align-self: center;
  margin-left: 0.35rem;
  padding: 0.2rem 0.45rem;
  border: 1px solid #5a4a08;
  color: #ffd000;
  font: 700 0.62rem Arial, Helvetica, sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.awake-pill.is-on {
  display: inline-flex;
}

.awake-bar {
  display: none;
  width: 100%;
  flex-shrink: 0;
  border: 0;
  background: #3a3208;
  color: #ffd000;
  font: 700 0.72rem var(--ticker-font);
  letter-spacing: 0.14em;
  padding: 0.5rem 0.6rem;
  text-transform: uppercase;
  cursor: pointer;
}

.awake-bar.is-needed {
  display: none;
}

@media (max-height: 540px), (hover: none) {
  .awake-bar.is-needed {
    display: block;
  }
}

.ticker-slot {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.ticker {
  flex: 1;
  min-height: 0;
  height: auto;
  display: flex;
  align-items: stretch;
  background: var(--ticker-bg);
}

.ticker-viewport {
  flex: 1;
  overflow: hidden;
  display: flex;
  align-items: stretch;
}

.ticker-track {
  display: flex;
  height: 100%;
  will-change: transform;
}

.ticker-unit {
  flex: 0 0 var(--unit-width);
  width: var(--unit-width);
  height: 100%;
  display: grid;
  grid-template-columns: 4.2rem minmax(10.5rem, 1.15fr) minmax(10.5rem, 1.15fr) minmax(11rem, 12.5rem);
  align-items: stretch;
}

.ticker-unit.is-alert .score-box {
  background: #8a1422;
}

.ticker-unit.is-alert .clock-box {
  background: #3a3208;
}

.ticker-unit.is-shout {
  animation: card-shout-flash 0.4s ease-out;
}

.ticker-unit.is-shout .score-box {
  background: var(--team-box);
  color: var(--text);
}

.ticker-unit.is-shout .score-box.is-scorer {
  color: #ffd000;
  background: #8a1422;
}

.ticker-unit.is-shout .clock-box,
.clock-box.is-shout {
  color: #ffd000;
  background: var(--clock-box);
}

.clock-shout {
  display: block;
  max-width: 100%;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1.1;
  text-transform: uppercase;
  overflow-wrap: break-word;
}

@keyframes card-shout-flash {
  0% {
    filter: brightness(1.45);
  }
  100% {
    filter: none;
  }
}

.league-box,
.unit-league,
.score-box,
.clock-box {
  display: flex;
  align-items: center;
  min-height: 0;
  padding: 0.45rem 0.55rem;
}

.unit-league,
.score-box,
.clock-box {
  border-right: 2px solid var(--divider);
}

.unit-league {
  flex-direction: column;
  justify-content: center;
  gap: 0.15rem;
  background: var(--league-box);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}

.league-icon {
  width: 1.7rem;
  height: 1.7rem;
  display: none;
}

.league-icon.is-visible {
  display: block;
}

.team-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 0.12rem;
}

.team-name-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}

.poss-tag {
  display: none;
  flex: 0 0 auto;
  width: 2.55rem;
  height: 0.9rem;
}

.poss-tag.is-on {
  display: inline-flex;
  align-items: center;
}

.poss-tag img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.team-record {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  opacity: 0.8;
}

.team-record:empty {
  display: none;
}

.score-box {
  justify-content: space-between;
  gap: 0.5rem;
  background: var(--team-box);
  min-width: 0;
  overflow: hidden;
}

.score-box.is-upcoming {
  justify-content: center;
}

.team-score:empty {
  display: none;
}

.score-box.is-winner {
  color: var(--winner);
}

.clock-box {
  flex-direction: column;
  justify-content: center;
  gap: 0.15rem;
  background: var(--clock-box);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: normal;
  line-height: 1.2;
  text-align: center;
  min-width: 0;
  overflow: hidden;
}

.clock-status {
  display: block;
  max-width: 100%;
  overflow-wrap: break-word;
}

.clock-event {
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  opacity: 0.85;
  max-width: 100%;
  overflow: hidden;
  white-space: normal;
}

.clock-event:empty {
  display: none;
}

.team-name {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  min-width: 0;
  overflow: hidden;
  white-space: normal;
  line-height: 1.15;
}

.team-score {
  font-size: 1.95rem;
  font-weight: 800;
  flex: 0 0 auto;
}

@media (max-width: 700px) {
  html,
  body {
    height: 100%;
    height: 100dvh;
    overflow: hidden;
  }

  :root {
    --unit-width: min(100vw, 40rem);
  }

  .stage {
    flex: 1;
    height: auto;
    min-height: 0;
    max-height: none;
    display: block;
  }

  .ticker-slot {
    flex: 2;
  }

  .filters {
    flex-shrink: 0;
    padding-top: env(safe-area-inset-top);
  }

  .filter-btn {
    font-size: 0.7rem;
    padding: 0.55rem 0.55rem;
  }

  .ticker {
    flex: 1;
    height: auto;
    min-height: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .ticker-unit {
    grid-template-columns: 3.6rem minmax(0, 1.2fr) minmax(0, 1.2fr) minmax(9rem, 10.5rem);
  }

  .league-box,
  .score-box,
  .clock-box {
    padding: 0.7rem 0.5rem;
  }

  .league-box,
  .clock-box {
    font-size: 0.78rem;
    letter-spacing: 0.02em;
    white-space: normal;
    line-height: 1.15;
  }

  .league-icon {
    width: 2.2rem;
    height: 2.2rem;
  }

  .clock-event {
    font-size: 0.72rem;
  }

  .team-record {
    font-size: 0.8rem;
  }

  .team-name {
    font-size: 0.95rem;
  }

  .team-score {
    font-size: 1.7rem;
  }
}

@media (orientation: landscape) and (max-height: 540px) {
  html,
  body {
    height: 100%;
    height: 100dvh;
    overflow: hidden;
  }

  :root {
    --unit-width: max(32rem, 62vw);
  }

  .stage {
    flex: 1;
    height: auto;
    min-height: 0;
    max-height: none;
    display: block;
  }

  .ticker-slot {
    flex: 2;
  }

  .filters {
    flex-shrink: 0;
    flex-wrap: nowrap;
    padding-top: env(safe-area-inset-top);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  .filter-group {
    flex-wrap: nowrap;
  }

  .filter-btn {
    font-size: 0.65rem;
    padding: 0.38rem 0.5rem;
    white-space: nowrap;
  }

  .ticker {
    flex: 1;
    height: auto;
    min-height: 0;
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  .ticker-unit {
    grid-template-columns: 3.8rem minmax(0, 1fr) minmax(0, 1fr) minmax(8.5rem, 9.25rem);
  }

  .league-box,
  .score-box,
  .clock-box {
    padding: 0.45rem 0.5rem;
  }

  .league-box,
  .clock-box {
    font-size: 0.92rem;
    white-space: normal;
  }

  .league-icon {
    width: 1.9rem;
    height: 1.9rem;
  }

  .team-name {
    font-size: 1.05rem;
  }

  .team-score {
    font-size: 1.85rem;
  }

  .clock-event {
    font-size: 0.7rem;
  }
}

.rotate-hint {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 9999;
  width: 100%;
  height: 100%;
  height: 100dvh;
  padding: 1.5rem;
  padding-top: max(1.5rem, env(safe-area-inset-top));
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
  background: #0a0a0a;
  color: var(--text);
  text-align: center;
}

.rotate-hint-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 0.55rem;
  background: var(--team-box);
}

.rotate-hint-phone {
  width: 3.4rem;
  height: 2.1rem;
  margin-bottom: 0.35rem;
  border: 3px solid var(--winner);
  border-radius: 0.35rem;
  box-shadow: 0.55rem -0.55rem 0 -0.15rem #3a3a3a;
}

.rotate-hint-line {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--winner);
}

.rotate-hint-sub {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--text);
  max-width: 16rem;
}

html.is-upright .rotate-hint {
  display: flex;
}

@media (orientation: portrait) and (max-width: 1100px),
  (max-aspect-ratio: 1/1) and (max-width: 1100px) {
  .rotate-hint {
    display: flex;
  }
}
