.spectator {
  --sp-paper: #f7f5eb;
  --sp-ink: #18362c;
  --sp-mute: #536b5e;
  --sp-line: #d9ded0;
  color: var(--sp-ink);
  background: var(--sp-paper);
  border: 1px solid var(--sp-line);
  border-radius: 18px;
  overflow: hidden;
}

.spectator button {
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.spectator button[hidden],
.spectator .sp-post[hidden],
.spectator .sp-loading[hidden] {
  display: none;
}

.sp-controls,
.sp-score,
.sp-position,
.sp-commentary,
.sp-legend {
  display: flex;
  align-items: center;
  padding-inline: 13px;
}

.sp-controls {
  min-height: 50px;
  justify-content: space-between;
  gap: 6px;
  background: #fffdf5;
}

.sp-live,
.sp-playback,
.sp-speeds {
  display: flex;
  align-items: center;
}

.sp-live {
  gap: 6px;
  font-size: 12px;
  white-space: nowrap;
}

.sp-live > span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #da6b4c;
  box-shadow: 0 0 0 3px #f6e3d8;
}

.sp-complete .sp-live > span {
  background: #32644d;
  box-shadow: 0 0 0 3px #dfe9da;
}

.sp-playback { gap: 5px; }

.sp-playback button {
  min-height: 44px;
  padding: 0 7px;
  color: var(--sp-mute);
  border: 0;
  background: transparent;
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

.sp-playback button:disabled { opacity: 0.5; }

.sp-speeds {
  padding: 0 2px;
  border-radius: 9px;
  background: #eaece0;
}

.sp-speeds button {
  position: relative;
  isolation: isolate;
  min-width: 44px;
  font-variant-numeric: tabular-nums;
}

.sp-speeds button[aria-pressed="true"] {
  color: #fffdf5;
}

.sp-speeds button[aria-pressed="true"]::before {
  position: absolute;
  z-index: -1;
  inset: 8px 2px;
  border-radius: 6px;
  background: #234839;
  content: "";
}

.sp-score {
  min-height: 57px;
  gap: 10px;
  background: #173a2f;
  color: #fffaf0;
}

.sp-distance {
  font-size: 11px;
  white-space: nowrap;
}

.sp-distance strong {
  margin-left: 3px;
  color: #f8df9c;
  font-size: 29px;
  font-weight: 780;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.sp-phase {
  padding: 3px 7px;
  border: 1px solid #769084;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.sp-condition {
  margin-left: auto;
  color: #d6e3d7;
  font-size: 11px;
  white-space: nowrap;
}

.sp-course {
  --sp-sky-top: #b8d8d1;
  --sp-sky-bottom: #e9e6c2;
  --sp-trees: #577c61;
  --sp-lane-1: #9eb477;
  --sp-lane-2: #a5b984;
  --sp-lane-height: 29px;
  --sp-gutter: 30px;
  --sp-scroll: 0px;
  --sp-flow: 0;
  position: relative;
  height: calc(41px + var(--sp-rows) * var(--sp-lane-height));
  isolation: isolate;
  overflow: hidden;
  background: var(--sp-lane-1);
}

.sp-course[data-camera="launch"] { --sp-flow: .42; }
.sp-course[data-camera="follow"], .sp-course[data-camera="finish"] { --sp-flow: 1; }

.sp-loading {
  position: absolute;
  z-index: 4;
  inset: 0 0 0 var(--sp-gutter);
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 6px;
  text-align: center;
  color: #f8f4e6;
  background: #173a2fea;
  font-size: .78rem;
}
.sp-loading strong { font-size: 1rem; }
.sp-loading button { min-height: 44px; margin-top: 3px; padding: 0 18px; border: 1px solid #b99a62; border-radius: 6px; background: #f4dda6; color: #342e20; font-weight: 750; }

.sp-course[data-surface="dirt"] {
  --sp-lane-1: #c0a581;
  --sp-lane-2: #c7ad8d;
}

.sp-course[data-weather="cloudy"] {
  --sp-sky-top: #bbc9c6;
  --sp-sky-bottom: #e0e2cf;
  --sp-trees: #587567;
}

.sp-course[data-weather="rain"] {
  --sp-sky-top: #8fabae;
  --sp-sky-bottom: #c8d4ce;
  --sp-trees: #4c7167;
}

.sp-sky {
  position: absolute;
  inset: 0 0 auto;
  height: 41px;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 71% 28%, rgb(255 253 221 / 70%) 0 6%, transparent 7%),
    radial-gradient(ellipse at 65% 35%, rgb(255 253 221 / 48%) 0 8%, transparent 9%),
    linear-gradient(var(--sp-sky-top), var(--sp-sky-bottom));
}

.sp-course[data-weather="rain"] .sp-sky::after {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(109deg, transparent 0 14px, rgb(255 255 255 / 35%) 14px 15px, transparent 15px 20px);
  content: "";
}

.sp-landscape {
  position: absolute;
  inset: 8px -48px 0;
  background:
    radial-gradient(ellipse at 50% 111%, var(--sp-trees) 65%, transparent 67%) var(--sp-scroll) bottom / 48px 16px repeat-x,
    radial-gradient(ellipse at 50% 111%, #77987a 65%, transparent 67%) calc(var(--sp-scroll) / 2) bottom / 96px 23px repeat-x,
    linear-gradient(transparent 83%, #5d8066 84%);
}

.sp-landscape::after {
  position: absolute;
  right: 6%;
  bottom: 5px;
  width: 30%;
  height: 18px;
  background:
    linear-gradient(#e9e9d5, #e9e9d5) 0 1px / 100% 3px no-repeat,
    repeating-linear-gradient(90deg, #e1e4cf 0 2px, #7f9b8b 2px 10px) 0 5px / 100% 8px no-repeat,
    #b1c0a7;
  border-radius: 12px 3px 0 0;
  opacity: .9;
  content: "";
}

.sp-basin {
  position: absolute;
  inset: 0 0 0 var(--sp-gutter);
}

.sp-basin::before,
.sp-numbers {
  position: absolute;
  top: 41px;
  bottom: 0;
}

.sp-basin::before {
  right: 0;
  left: 0;
  background: repeating-linear-gradient(to bottom,
    var(--sp-lane-1) 0 calc(var(--sp-lane-height) - 1px),
    rgb(55 72 47 / 20%) calc(var(--sp-lane-height) - 1px) var(--sp-lane-height),
    var(--sp-lane-2) var(--sp-lane-height) calc(2 * var(--sp-lane-height) - 1px),
    rgb(55 72 47 / 20%) calc(2 * var(--sp-lane-height) - 1px) calc(2 * var(--sp-lane-height)));
  content: "";
}

.sp-basin::after {
  position: absolute;
  inset: 41px 0 0;
  background:
    repeating-linear-gradient(92deg, transparent 0 22px, #fff8db22 23px, transparent 25px 48px) var(--sp-scroll) 0 / 48px 100%,
    linear-gradient(180deg, #152d3130, transparent 18%, #40372710 60%, #192c1e40),
    linear-gradient(180deg, var(--sp-lane-2), var(--sp-lane-1));
  opacity: var(--sp-flow);
  transition: opacity 400ms linear;
  content: "";
}

.sp-numbers {
  z-index: 3;
  left: 0;
  width: var(--sp-gutter);
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-rows: repeat(var(--sp-rows), 1fr);
  background: #305643;
  box-shadow: 2px 0 0 rgb(244 247 215 / 45%);
  list-style: none;
}

.sp-lane {
  display: grid;
  place-items: center;
  border-bottom: 1px solid rgb(255 255 255 / 14%);
}

.sp-lane-badge,
.sp-position li {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 21px;
  height: 19px;
  border-radius: 4px;
  background: #fffcee;
  color: #294536;
  font-size: 11px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.sp-lane-badge[data-bet],
.sp-position li[data-bet] { background: #f7d878; }

.sp-lane-badge[data-side],
.sp-position li[data-side] { box-shadow: inset 0 0 0 2px #db7456; }

.sp-rail {
  position: absolute;
  z-index: 1;
  top: 32px;
  left: 0;
  right: 0;
  height: 11px;
  background:
    linear-gradient(#fffded, #e8ebce) 0 0 / 100% 3px no-repeat,
    linear-gradient(#f3f4db, #e4e8cd) 0 6px / 100% 2px no-repeat,
    repeating-linear-gradient(90deg, #f6f6de 0 2px, transparent 2px 31px) var(--sp-scroll) 0;
  filter: drop-shadow(0 1px 0 rgb(50 80 46 / 37%));
}

.sp-post {
  position: absolute;
  top: 30px;
  bottom: 0;
  z-index: 1;
  width: 4px;
  margin-left: -2px;
  background: repeating-linear-gradient(0deg, #274b3c 0 5px, #fffce9 5px 10px);
  box-shadow: 0 0 0 1px rgb(255 255 240 / 45%);
}

.sp-basin canvas {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
}

.sp-position {
  min-height: 40px;
  flex-wrap: wrap;
  gap: 6px 9px;
  padding-block: 7px;
  background: #e9eddf;
  color: #3a594a;
  font-size: 10px;
  font-weight: 750;
}

.sp-position > span { white-space: nowrap; }

.sp-position ol {
  display: flex;
  align-items: center;
  gap: 3px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sp-commentary {
  align-items: baseline;
  gap: 8px;
  min-height: 45px;
  padding-block: 6px;
  border-bottom: 1px solid var(--sp-line);
}

.sp-commentary-label {
  flex-shrink: 0;
  padding: 2px 6px;
  border-radius: 4px;
  background: #e8e9d9;
  color: #345948;
  font-size: 10px;
  font-weight: 800;
}

.sp-commentary p {
  margin: 0;
  color: var(--sp-ink);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.55;
}

.sp-legend {
  gap: 13px;
  min-height: 33px;
  color: var(--sp-mute);
  font-size: 10px;
  font-weight: 750;
}

.sp-legend span {
  display: flex;
  align-items: center;
  gap: 5px;
}

.sp-legend i {
  width: 9px;
  height: 9px;
  border-radius: 3px;
}

.sp-legend-bet { background: #f7d878; }
.sp-legend-side { border: 2px solid #db7456; }

.spectator .sp-results {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 45px;
  width: calc(100% - 26px);
  margin: 0 13px 12px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: #1d4b3a;
  color: #fff8e5;
  font-size: 14px;
  font-weight: 750;
}

@media (max-width: 350px) {
  .sp-controls, .sp-score, .sp-position, .sp-commentary, .sp-legend { padding-inline: 9px; }
  .sp-position { gap: 5px; }
  .sp-position ol { gap: 2px; }
  .sp-position li { min-width: 19px; }
}

@media (max-width: 500px) and (max-height: 740px) {
  .sp-course { --sp-lane-height: 27px; }
}
