:root {
  --navy: #002244;
  --gold: #ffc72c;
  --ink: #142c43;
  --muted: #526579;
  --line: #d7e0e8;
  --paper: #f1f5f8;
  --green: #147044;
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  color: var(--ink);
  background: var(--paper);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
select {
  font: inherit;
}
button {
  cursor: pointer;
}
button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}
button,
a,
input,
select {
  touch-action: manipulation;
}
button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid #1686ce;
  outline-offset: 3px;
}
button {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px 16px;
  background: white;
  color: var(--navy);
  font-weight: 650;
}
.primary {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--navy);
}
.dark {
  background: var(--navy);
  color: white;
  border-color: var(--navy);
}
.danger {
  color: #a42929;
  border-color: #d7a9a9;
}
.small {
  font-size: 13px;
  padding: 7px 11px;
}
.masthead {
  background: var(--navy);
  color: white;
  border-top: 5px solid var(--gold);
  padding: 28px max(24px, calc((100vw - 1280px) / 2));
}
.eyebrow {
  color: var(--gold);
  font-size: 11px;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  font-weight: 750;
}
.masthead h1 {
  font-size: clamp(28px, 4vw, 43px);
  letter-spacing: -0.04em;
  margin: 8px 0;
}
.masthead p {
  color: #d2dfec;
  margin: 0;
  font-size: 14px;
}
.topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}
.save {
  font-size: 12px;
  color: #d2dfec;
}
main {
  max-width: 1328px;
  margin: auto;
  padding: 24px;
}
.dens,
.views {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 3px 12px;
}
.dens button {
  white-space: nowrap;
}
.dens button.active {
  background: var(--navy);
  color: var(--gold);
  border-color: var(--navy);
}
.den-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 22px 0;
}
.den-head h2 {
  font-size: 28px;
  margin: 0;
  letter-spacing: -0.03em;
}
.meta {
  color: var(--muted);
  font-size: 14px;
  margin: 6px 0;
}
.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 9px;
  border-radius: 6px;
  background: #e5ecf2;
  color: var(--navy);
}
.views {
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}
.views button {
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  white-space: nowrap;
}
.views button.active {
  border-bottom-color: var(--navy);
  color: var(--navy);
}
.panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 20px;
}
.panel h3 {
  margin: 0 0 16px;
  font-size: 18px;
}
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.row.spread {
  justify-content: space-between;
}
.stack {
  display: grid;
  gap: 8px;
}
label {
  font-size: 13px;
  font-weight: 650;
}
input,
select {
  border: 1px solid #aabaca;
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 11px;
  max-width: 100%;
}
input[type="number"] {
  width: 85px;
}
.grow {
  flex: 1;
  min-width: 160px;
}
.two {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 20px;
}
.hint {
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
}
.notice {
  padding: 14px 18px;
  border: 1px solid #d2b45a;
  background: #fff7db;
  color: #514008;
  border-radius: 9px;
  margin-bottom: 16px;
  font-size: 14px;
}
.error {
  background: #fff0ef;
  color: #8b2626;
  border-color: #dfaaaa;
}
.roster {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
}
.roster li {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.seed {
  font:
    12px ui-monospace,
    monospace;
  color: var(--muted);
  min-width: 24px;
}
.racer-name {
  flex: 1;
  overflow-wrap: anywhere;
}
.record {
  font-size: 12px;
  color: var(--muted);
}
.flight-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.heat {
  background: white;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.heat-head {
  background: #e7edf3;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}
.heat-body {
  padding: 18px;
  display: grid;
  gap: 12px;
}
.racer {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  text-align: left;
  width: 100%;
  min-height: 88px;
  padding: 16px;
  border: 2px solid var(--line);
}
.racer.selected {
  border-color: var(--green);
  background: #e9f6ee;
}
.lane {
  display: grid;
  place-items: center;
  width: 35px;
  height: 35px;
  background: var(--navy);
  color: white;
  border-radius: 50%;
  font-size: 15px;
}
.racer strong {
  display: block;
  overflow-wrap: anywhere;
}
.racer .record {
  display: block;
  margin-top: 5px;
  font-weight: 400;
}
.winner-label {
  font-size: 12px;
  color: var(--muted);
}
.selected .winner-label {
  color: var(--green);
  font-weight: 750;
}
.advance {
  position: sticky;
  bottom: 0;
  background: #f1f5f8f5;
  border-top: 1px solid var(--line);
  padding: 18px 0;
  margin-top: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.empty {
  text-align: center;
  padding: 50px 20px;
}
.empty h3 {
  font-size: 23px;
}
.standings {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.medal {
  padding: 22px;
  background: #f4f7fa;
  border-radius: 12px;
  text-align: center;
}
.medal b {
  display: block;
  margin: 10px 0;
  overflow-wrap: anywhere;
  font-size: 20px;
}
.bracket-scroll {
  overflow: auto;
  padding: 6px 3px 20px;
}
.bracket {
  position: relative;
  display: flex;
  gap: 28px;
  align-items: stretch;
  min-width: max-content;
}
.round {
  width: 230px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  justify-content: space-around;
}
.round h4 {
  margin: 0 0 8px;
  font-size: 13px;
  min-height: 20px;
}
.match {
  position: relative;
  background: white;
  border: 1px solid #aabaca;
  border-radius: 8px;
  padding: 12px;
  font-size: 13px;
}
.bracket-lines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}
.match {
  z-index: 1;
}
.match.active {
  border: 2px solid #b07e00;
}
.match-title {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 8px;
}
.match-player {
  padding: 7px 0;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  overflow-wrap: anywhere;
}
.match-player.won {
  font-weight: 750;
  color: var(--green);
}
.source {
  font-size: 11px;
  color: var(--muted);
}
.section-title {
  margin: 28px 0 12px;
}
details {
  margin-top: 20px;
}
summary {
  cursor: pointer;
  font-weight: 650;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th,
td {
  text-align: left;
  padding: 12px 8px;
  border-bottom: 1px solid var(--line);
}
.table-scroll {
  overflow: auto;
}
dialog {
  border: 0;
  border-radius: 20px;
  padding: 0;
  max-width: 650px;
  width: calc(100% - 32px);
  color: white;
  background: var(--navy);
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 30px 100px #0007;
}
dialog::backdrop {
  background: #00152bd9;
}
.podium-content {
  padding: 32px;
  text-align: center;
  position: relative;
  z-index: 1;
}
.podium-content h2 {
  font-size: 30px;
}
.podium-slots {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 12px;
  margin: 32px 0;
  min-height: 220px;
}
.podium-slot {
  flex: 1;
  background: #ffffff0c;
  border: 1px solid #ffffff22;
  border-radius: 12px 12px 0 0;
  padding: 20px 10px;
  min-height: 110px;
  overflow-wrap: anywhere;
}
.podium-slot.revealed {
  background: #ffffff16;
}
.podium-slot[data-place="0"] {
  min-height: 210px;
}
.podium-slot[data-place="1"] {
  min-height: 165px;
}
.podium-slot strong {
  display: block;
  margin: 12px 0;
}
.podium-symbol {
  font-size: 35px;
}
.close-modal {
  background: transparent;
  color: white;
  border-color: #ffffff55;
}
.confetti {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.confetti i {
  position: absolute;
  top: -20px;
  width: 8px;
  height: 13px;
  animation: fall 2.7s ease-in forwards;
}
@keyframes fall {
  to {
    transform: translate(var(--drift), 650px) rotate(700deg);
  }
}
footer {
  font-size: 12px;
  color: var(--muted);
  padding: 28px 0;
  line-height: 1.7;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}
@media (max-width: 760px) {
  main {
    padding: 16px;
  }
  .two,
  .flight-grid {
    grid-template-columns: 1fr;
  }
  .panel {
    padding: 18px;
  }
  .topline {
    align-items: flex-start;
  }
  .save {
    max-width: 105px;
    text-align: right;
  }
  .den-head {
    align-items: flex-start;
  }
  .racer {
    grid-template-columns: auto 1fr;
  }
  .winner-label {
    grid-column: 2;
  }
  .standings {
    gap: 7px;
  }
  .medal {
    padding: 14px 8px;
  }
  .medal b {
    font-size: 16px;
  }
  .podium-content {
    padding: 22px 14px;
  }
  .podium-slots {
    gap: 6px;
  }
  .podium-slot {
    font-size: 13px;
    padding: 15px 6px;
  }
  .advance .primary {
    width: 100%;
  }
}
@media (prefers-reduced-motion: reduce) {
  .confetti i {
    animation: none;
    display: none;
  }
}

/* Phone controls stay visible without horizontal tab scrolling. */
.mobile-den,
.short-label {
  display: none;
}
@media (max-width: 600px) {
  body {
    padding-bottom: env(safe-area-inset-bottom);
  }
  main {
    padding: 16px 12px;
  }
  .masthead {
    padding: 18px 16px;
    border-top-width: 4px;
  }
  .topline {
    display: block;
  }
  .masthead h1 {
    font-size: 29px;
    margin: 6px 0;
    line-height: 1.12;
  }
  .masthead p {
    display: none;
  }
  .eyebrow {
    font-size: 10px;
    letter-spacing: 0.12em;
  }
  .save {
    display: block;
    max-width: none;
    text-align: left;
    font-size: 11px;
    margin-top: 10px;
  }
  .dens {
    display: none;
  }
  .mobile-den {
    display: grid;
    gap: 7px;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .mobile-den select {
    width: 100%;
    font-size: 16px;
    font-weight: 650;
    color: var(--navy);
    min-height: 48px;
    letter-spacing: normal;
    text-transform: none;
  }
  .den-head {
    margin: 20px 0 14px;
    gap: 8px;
  }
  .den-head h2 {
    font-size: 23px;
    overflow-wrap: anywhere;
  }
  .den-head > div {
    min-width: 0;
  }
  .den-head > button {
    flex-shrink: 0;
    max-width: 112px;
    font-size: 12px;
  }
  .meta {
    font-size: 12px;
    line-height: 1.7;
  }
  .badge {
    font-size: 11px;
  }
  .views {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    overflow: visible;
    padding: 4px;
    background: #e2eaf1;
    border: 0;
    border-radius: 11px;
    margin-bottom: 20px;
  }
  .views button {
    padding: 12px 5px;
    border: 0;
    border-radius: 8px;
    font-size: 14px;
    min-width: 0;
    min-height: 46px;
  }
  .views button.active {
    background: var(--navy);
    color: var(--gold);
  }
  .wide-label {
    display: none;
  }
  .short-label {
    display: inline;
  }
  .panel {
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 14px;
  }
  .two {
    gap: 0;
  }
  .panel h3 {
    font-size: 17px;
  }
  input,
  select {
    font-size: 16px;
    min-height: 46px;
  }
  input[type="checkbox"] {
    min-height: 24px;
    width: 24px;
  }
  button,
  .small {
    min-height: 44px;
  }
  .row {
    gap: 10px;
  }
  .grow {
    min-width: 0;
  }
  #add-racer {
    align-items: end;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }
  #add-racer button {
    padding: 12px 10px;
    font-size: 13px;
  }
  #generate {
    align-items: end;
  }
  input[type="file"] {
    width: 100%;
    font-size: 13px;
    padding: 9px 0;
    border: 0;
  }
  .roster li {
    gap: 8px;
  }
  .seed {
    min-width: 18px;
  }
  .roster .record {
    max-width: 78px;
    text-align: right;
  }
  .racer-name .record {
    text-align: left;
    max-width: none;
  }
  .flight-grid {
    gap: 12px;
  }
  .heat {
    border-radius: 12px;
  }
  .heat-head {
    padding: 11px 12px;
    align-items: center;
    font-size: 12px;
  }
  .heat-head strong {
    flex-shrink: 0;
  }
  .heat-head > span {
    text-align: right;
    font-size: 11px;
  }
  .heat-body {
    padding: 10px;
    gap: 8px;
  }
  .racer {
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 4px 10px;
    min-height: 88px;
    padding: 12px;
  }
  .lane {
    width: 30px;
    height: 30px;
    grid-row: 1 / 3;
  }
  .racer strong {
    font-size: 16px;
    line-height: 1.3;
  }
  .racer .record {
    font-size: 11px;
    line-height: 1.5;
    margin-top: 3px;
  }
  .winner-label {
    grid-column: 2;
    font-size: 11px;
  }
  .hint {
    line-height: 1.5;
  }
  .advance {
    z-index: 3;
    gap: 8px;
    padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
    margin-top: 16px;
    background: var(--paper);
    box-shadow: 0 -8px 15px #f1f5f8;
    display: grid;
    grid-template-columns: 1fr auto;
  }
  .advance .hint {
    font-size: 12px;
    margin: 0;
  }
  .advance .small {
    font-size: 11px;
    padding: 8px;
    min-height: 36px;
  }
  .advance .primary {
    grid-column: 1 / -1;
    min-height: 48px;
    font-size: 13px;
    padding: 12px 8px;
  }
  .bracket-scroll {
    overflow: visible;
    padding: 0;
  }
  .bracket {
    display: block;
    min-width: 0;
  }
  .bracket-lines {
    display: none;
  }
  .round {
    width: 100%;
    display: grid;
    gap: 10px;
    margin-bottom: 20px;
  }
  .round h4 {
    position: static;
    margin: 0;
    padding: 10px 12px;
    background: #dfe8f0;
    border-radius: 8px;
    font-size: 13px;
  }
  .match {
    padding: 12px;
  }
  .match-player {
    padding: 5px 0;
  }
  .section-title {
    font-size: 19px;
    margin-top: 24px;
  }
  .standings {
    grid-template-columns: 1fr;
  }
  .medal {
    text-align: left;
    padding: 14px 16px;
  }
  .medal b {
    font-size: 20px;
    margin: 5px 0;
  }
  dialog {
    width: calc(100% - 20px);
    max-height: calc(100dvh - 24px);
    border-radius: 14px;
  }
  .podium-content {
    padding: 22px 12px;
  }
  .podium-content h2 {
    font-size: 24px;
  }
  .podium-slots {
    margin: 22px 0;
    min-height: 190px;
    gap: 5px;
  }
  .podium-slot {
    min-width: 0;
    font-size: 12px;
    padding: 14px 5px;
  }
  .podium-slot strong {
    font-size: 14px;
  }
  .podium-slot[data-place="0"] {
    min-height: 180px;
  }
  .podium-slot[data-place="1"] {
    min-height: 145px;
  }
  .podium-symbol {
    font-size: 28px;
  }
  #reveal-next {
    width: 100%;
  }
  footer {
    padding: 22px 2px;
    font-size: 11px;
  }
  summary {
    min-height: 44px;
    padding: 12px 0;
  }
}

[hidden] {
  display: none !important;
}
.welcome {
  max-width: 880px;
  margin: 24px auto;
}
.welcome > .eyebrow {
  color: #886400;
}
.welcome h2 {
  font-size: clamp(25px, 4vw, 36px);
  margin: 12px 0;
  letter-spacing: -0.03em;
}
.welcome-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 28px;
}
.welcome-options > section {
  background: var(--paper);
  padding: 22px;
  border-radius: 12px;
}
.welcome-options button {
  margin-top: 18px;
  width: 100%;
  min-height: 48px;
}
.resume-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.resume-box .hint {
  margin-bottom: 0;
}
.local-bar {
  background: white;
  border: 1px solid var(--line);
  padding: 16px;
  border-radius: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.local-bar strong {
  display: block;
  font-size: 18px;
  overflow-wrap: anywhere;
}
.local-bar .hint {
  display: block;
  margin-top: 6px;
}
.local-bar .row {
  gap: 8px;
}
.local-bar button {
  font-size: 13px;
  min-height: 44px;
}
.local-dialog {
  background: white;
  color: var(--ink);
  max-width: 480px;
  padding: 26px;
}
.local-dialog h2 {
  margin-top: 0;
}
.local-dialog .stack {
  gap: 10px;
}
.error-text {
  color: #a42929;
  font-size: 14px;
}
.welcome-options input {
  width: 100%;
}
@media (max-width: 600px) {
  .welcome {
    margin: 8px 0;
  }
  .welcome-options {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 20px;
  }
  .welcome-options > section {
    padding: 16px;
  }
  .resume-box {
    align-items: stretch;
    flex-direction: column;
  }
  .local-bar {
    padding: 12px;
    gap: 12px;
  }
  .local-bar .row {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .local-bar .primary {
    grid-column: 1 / -1;
  }
  .local-bar .hint {
    font-size: 12px;
  }
  .local-dialog {
    padding: 22px 16px;
  }
}

#add-racer input {
  width: 100%;
  min-width: 0;
}
.topline > div:first-child {
  min-width: 0;
}
.masthead h1 {
  overflow-wrap: anywhere;
}
#banner-dates {
  display: inline-block;
  font-size: 0.48em;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--gold);
  margin-left: 18px;
  vertical-align: middle;
}
.date-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}
.date-fields input {
  width: 100%;
  min-width: 0;
}
.date-fields label {
  min-width: 0;
}
.local-dialog input {
  width: 100%;
}
@media (max-width: 600px) {
  #banner-dates {
    display: block;
    margin: 10px 0 0;
    font-size: 16px;
    line-height: 1.5;
  }
  .date-fields {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .local-bar .row button:last-child {
    grid-column: 1 / -1;
  }
}
progress {
  width: 100%;
  height: 18px;
  accent-color: var(--navy);
}
.rr-settings {
  padding: 14px;
  background: var(--paper);
  border-radius: 10px;
  margin: 14px 0;
}
.rr-settings input[type="range"] {
  width: 100%;
  padding: 0;
  accent-color: var(--navy);
}
.rr-settings .notice {
  font-size: 12px;
}

#role-picker button,
#watcher-console button {
  min-height: 64px;
}
#watcher-console {
  max-width: 600px;
  margin: 12px auto;
}
#watcher-console input {
  width: 100%;
  min-height: 56px;
  font-size: 20px;
}
#watcher-console label {
  margin: 16px 0;
}
#watcher-console button {
  width: 100%;
  margin: 8px 0;
  white-space: normal;
}
#watcher-code {
  text-transform: uppercase;
  letter-spacing: 0.2em;
}
#watcher-share {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}
#watcher-session-code {
  font-size: 36px;
  letter-spacing: 0.15em;
  color: var(--navy);
}
#watcher-share-text {
  overflow-wrap: anywhere;
}
#watcher-qr {
  width: 160px;
  height: 160px;
  background: white;
}
#watcher-host {
  position: sticky;
  top: 0;
  z-index: 4;
  padding: 12px;
  margin-bottom: 16px;
  max-height: 45dvh;
  overflow: auto;
}
#watcher-toggle {
  width: 22px;
  height: 22px;
}
#watcher-settings summary {
  overflow-wrap: anywhere;
  font-size: 13px;
}
#watcher-connections > div {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin: 8px 0;
}
.watcher-status {
  font-size: 12px;
  display: block;
  flex-basis: 100%;
  overflow-wrap: anywhere;
}
.watcher-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #64748b;
  margin-right: 6px;
}
.watcher-dot.connected {
  background: #07833d;
}
.heat-head {
  flex-wrap: wrap;
}
#watcher-race .selected {
  background: var(--gold);
  color: var(--navy);
  border: 3px solid var(--navy);
}
#watcher-race button {
  font-size: 22px;
  overflow-wrap: anywhere;
}
body.watching #save-status,
body.watching footer {
  display: none;
}
@media (max-width: 600px) {
  #watcher-share {
    align-items: flex-start;
  }
  #watcher-qr {
    width: 112px;
    height: 112px;
  }
  #watcher-session-code {
    font-size: 28px;
  }
  #watcher-host .row {
    gap: 10px;
  }
}

/* Keep the illustrated guide available without leaving the active host tab. */
.guide-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-weight: 700;
  color: #ffc72c;
  text-underline-offset: 3px;
}
.guide-link:focus-visible {
  outline: 2px solid #ffc72c;
  outline-offset: 4px;
}

/* Event configuration, compact connection tools, and optional desktop side panel. */
#event-logo {
  display: inline-block;
  width: 64px;
  height: 64px;
  object-fit: contain;
  vertical-align: middle;
  margin-right: 12px;
}
#event-logo[hidden] {
  display: none;
}
.event-options {
  margin: 18px 0;
}
.event-options summary,
#connection-tools > summary {
  font-weight: 750;
  cursor: pointer;
  padding: 8px 0;
}
.level-settings {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}
.level-setting {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #d5dfe8;
  padding: 6px 0;
}
.level-setting input[type="number"] {
  width: 70px;
}
.level-setting input[type="checkbox"] {
  width: auto;
  min-height: 0;
}
.level-setting label {
  font-size: 14px;
}
#event-settings-dialog {
  width: min(95vw, 800px);
  max-height: 90vh;
  overflow: auto;
}
#setup-error {
  color: #a52121;
}
#new-setup input[type="file"],
#edit-setup input[type="file"] {
  max-width: 100%;
}
#watcher-host {
  position: static;
  padding: 10px 18px;
}
#connection-tools .row {
  margin-top: 10px;
}
.desktop-placement {
  max-width: 230px;
}
.fan-host {
  border-top: 1px solid #ccd7e0;
  margin-top: 16px;
  padding-top: 10px;
}
#fan-code {
  font-size: 28px;
  letter-spacing: 0.15em;
}
#fan-console {
  max-width: 1100px;
  margin: 20px auto;
}
body.watching #watcher-host {
  display: none;
}
@media (min-width: 1200px) {
  body.connections-side main {
    padding-right: 340px;
  }
  body.connections-side #watcher-host {
    position: fixed;
    right: 18px;
    top: 180px;
    width: 300px;
    max-height: 70vh;
    overflow: auto;
    z-index: 10;
  }
  body.connections-side #watcher-share {
    display: block;
  }
}
@media (max-width: 767px) {
  .desktop-placement {
    display: none;
  }
  #event-logo {
    width: 44px;
    height: 44px;
  }
  .level-setting {
    flex-wrap: wrap;
  }
  #fan-console {
    margin: 12px;
  }
  .event-options {
    font-size: 14px;
  }
}

#role-picker .welcome-options button {
  min-height: 100px;
}
#choose-fan {
  order: -1;
}
.tie-estimate {
  font-size: 14px;
}
/* Fan-only colors keep the admin console and racer controls unchanged. */
#fan-console {
  --fan-bg: #f4f7fb;
  --fan-card: #fff;
  --fan-text: #002244;
  --fan-muted: #53677a;
  --fan-line: #cfdae5;
  background: var(--fan-bg);
  color: var(--fan-text);
  border-color: var(--fan-line);
  padding: clamp(16px, 3vw, 32px);
}
#fan-console.fan-dark {
  --fan-bg: #071a2d;
  --fan-card: #10314f;
  --fan-text: #f3f7fb;
  --fan-muted: #bbccdd;
  --fan-line: #42617c;
}
#fan-console h2,
#fan-console h3,
#fan-console h4 {
  color: var(--fan-text);
}
.fan-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
#fan-console #fan-status {
  color: var(--fan-muted);
  font-size: 14px;
}
#fan-console select,
#fan-console input,
#fan-console button {
  background: var(--fan-card);
  color: var(--fan-text);
  border: 1px solid var(--fan-line);
  min-height: 48px;
}
#fan-console button:hover {
  border-color: #d2a000;
}
#fan-console .fan-hero {
  border-left: 4px solid #ffc72c;
  padding: 8px 18px;
  margin: 24px 0;
}
#fan-console .fan-hero h3 {
  margin: 0;
  font-size: clamp(24px, 5vw, 38px);
}
#fan-console .fan-filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
#fan-console .fan-card {
  background: var(--fan-card);
  padding: 18px;
  border: 1px solid var(--fan-line);
  border-radius: 14px;
  margin: 16px 0;
}
#fan-console .fan-card h4 {
  margin: 0 0 12px;
}
#fan-console th,
#fan-console td {
  background: var(--fan-card);
  color: var(--fan-text);
  border-color: var(--fan-line);
}
#fan-console tr.fan-following td {
  border-bottom: 3px solid #ffc72c;
  font-weight: 750;
}
#fan-console .fan-upcoming {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}
#fan-console .fan-race {
  border: 1px solid var(--fan-line);
  border-top: 3px solid #ffc72c;
  border-radius: 10px;
  padding: 14px;
}
#fan-console .fan-race strong {
  display: block;
  margin: 8px 0;
  font-size: 20px;
}
#fan-console .fan-muted {
  color: var(--fan-muted);
}
#fan-console .fan-medals {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-weight: 750;
}
@media (max-width: 500px) {
  #fan-console .fan-filters {
    grid-template-columns: 1fr;
  }
  #fan-console {
    margin: 12px;
  }
}

body.fan-dark-page {
  background: #071a2d;
  color: #f3f7fb;
}

/* Visible in the HTML shell before scripts load, even when a saved tournament exists. */
.role-splash {
  max-width: 1000px;
  margin: clamp(20px, 6vh, 70px) auto;
  padding: clamp(24px, 5vw, 56px);
  text-align: center;
  border-top: 5px solid #ffc72c;
}
.role-splash h2 {
  font-size: clamp(28px, 5vw, 46px);
  margin: 12px 0;
}
#role-picker .welcome-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 28px;
}
#role-picker .welcome-options button {
  min-height: 130px;
  font-size: 22px;
}
#role-picker small {
  display: block;
  font-size: 14px;
  margin-top: 12px;
}
@media (max-width: 650px) {
  #role-picker .welcome-options {
    grid-template-columns: 1fr;
  }
  #role-picker .welcome-options button {
    min-height: 100px;
  }
}
/* Isolated controller sandbox: modal focus prevents accidental race control. */
#button-playground {
  width: min(1100px, 96vw);
  max-width: 96vw;
  max-height: 94dvh;
  overflow: auto;
  box-sizing: border-box;
  padding: 24px;
  border: 3px solid #ffc72c;
  border-radius: 18px;
  background: #002244;
  color: white;
}
#button-playground::backdrop {
  background: #001426e8;
}
#button-playground h2,
#button-playground .hint {
  color: inherit;
}
.playground-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.playground-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
#button-playground .playground-grid button {
  min-height: 130px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  background: #133c60;
  color: white;
  border: 3px solid #7395b6;
}
#button-playground .playground-grid button.received {
  border-color: #ffc72c;
}
#button-playground .playground-grid button.held {
  background: #365e7c;
  box-shadow: inset 0 0 0 3px white;
}
#button-playground.party .playground-grid button {
  background: hsl(var(--tile-hue) 65% 25%);
}
#button-playground.party .playground-grid b {
  font-size: 24px;
}
#playground-count {
  text-align: center;
  font-weight: 800;
  font-size: 24px;
  color: #ffc72c;
}
@media (max-width: 700px) {
  .playground-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  #button-playground {
    padding: 16px;
  }
}
#button-playground.party {
  position: fixed;
  overflow: hidden;
  height: min(800px, 90dvh);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 18px;
  isolation: isolate;
}
#button-playground.party:not([open]) {
  display: none;
}
#button-playground.party.party-expanded {
  width: 100vw;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  inset: 0;
  border: 0;
  border-radius: 0;
}
#button-playground.party .playground-heading,
#button-playground.party .playground-grid {
  position: relative;
  z-index: 3;
}
#button-playground.party .playground-grid button {
  min-height: 0;
  font-size: clamp(18px, 3vw, 36px);
  border-color: #ffffff88;
}
#button-playground.party .playground-heading h2 {
  margin: 0;
  font-size: clamp(22px, 4vw, 42px);
}
.party-effects,
.party-water {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.party-effects {
  z-index: 4;
  overflow: hidden;
}
.party-drop {
  position: absolute;
  top: 0;
  font-size: clamp(40px, 6vw, 85px);
}
.party-water {
  background: linear-gradient(#29c6edbb, #0879cfee);
  transform: translateY(100%);
  z-index: 2;
  border-top: 8px solid #b9f5ff;
}
/* Water washes over the whole party surface while controls remain clickable. */
#button-playground.party .party-water {
  z-index: 4;
}
#button-playground.party .party-effects {
  z-index: 5;
}
/* Keep setup/Arena chrome out of the fullscreen surface, including browser fallbacks. */
body.party-screen-active > :not(#button-playground):not(script):not(style) {
  visibility: hidden;
}
body.party-screen-active #button-playground {
  visibility: visible;
}
#button-playground.party .playground-grid button.party-lit,
#button-playground.party .playground-grid button.held {
  filter: brightness(1.65);
  border-color: white;
  box-shadow:
    inset 0 0 0 5px #fff,
    0 0 24px #ffffff99;
}
#button-playground .mini-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
#button-playground.party.mini-game {
  grid-template-rows: auto auto minmax(0, 1fr);
}
#mini-status {
  position: relative;
  z-index: 3;
  margin: 0;
  text-align: center;
  font-size: clamp(16px, 2vw, 28px);
  color: #fff;
}
#button-playground .mini-target {
  outline: 6px solid #ffc72c;
  outline-offset: -8px;
  filter: brightness(1.7);
}
#button-playground.party .playground-grid button {
  position: relative;
  overflow: hidden;
}
#button-playground .playground-grid small {
  font-size: clamp(12px, 1.4vw, 19px);
}
.mini-track {
  width: 100%;
  height: 55px;
  position: relative;
  border-bottom: 3px dashed white;
}
.mini-boat {
  position: absolute;
  left: 0;
  transition: left 0.12s;
}
.mini-swimmer {
  position: absolute;
  left: 0;
}
.mini-bubbles {
  font-size: 70px;
  animation: mini-bob 2s ease-in-out infinite alternate;
}
@keyframes mini-bob {
  to {
    transform: translateY(-15px);
  }
}
@media (prefers-reduced-motion: reduce) {
  .mini-bubbles {
    animation: none;
  }
  .mini-boat {
    transition: none;
  }
}
@media (max-width: 700px) {
  #button-playground .mini-actions button {
    font-size: 12px;
    padding: 6px;
  }
  #button-playground.mini-menu .playground-grid button {
    font-size: 18px;
  }
}

.mini-progress-panel {
  position: relative;
  z-index: 3;
  text-align: center;
}
#mini-progress {
  display: block;
  width: 90%;
  margin: 8px auto 0;
  height: 20px;
  accent-color: #ffc72c;
}
#encoder-setup {
  margin: 14px 0;
  padding: 14px;
  border: 1px solid #7395b6;
  border-radius: 10px;
}
#encoder-setup summary {
  cursor: pointer;
  font-weight: 750;
  color: #ffc72c;
}
#encoder-device {
  max-width: 100%;
}
#encoder-bindings {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin: 12px 0;
}
#encoder-bindings button {
  min-height: 64px;
}
