:root {
  color-scheme: light;
  --void: #151515;
  --void-2: #101010;
  --paper: #ffffff;
  --paper-2: #ebe5da;
  --ink: #151515;
  --muted: #77716a;
  --line: rgba(21, 21, 21, 0.14);
  --line-dark: rgba(255, 255, 255, 0.14);
  --signal: #e21c39;
  --danger: #d65b42;
  --success: #2f8e62;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 20% 16%, rgba(226, 28, 57, 0.16), transparent 25rem),
    radial-gradient(circle at 78% 82%, rgba(255, 255, 255, 0.055), transparent 30rem),
    linear-gradient(135deg, var(--void), var(--void-2));
}

body[data-screen="race"] {
  color: #ffffff;
  background: #151515;
}

button,
input {
  font: inherit;
}

.setup-screen {
  display: grid;
  min-height: 100vh;
  padding: clamp(18px, 4vw, 48px);
  place-items: center;
  position: relative;
  overflow: hidden;
}

.setup-screen::before {
  content: "";
  position: fixed;
  right: min(8vw, 90px);
  top: min(12vh, 110px);
  width: clamp(180px, 28vw, 360px);
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  background:
    linear-gradient(90deg, transparent calc(50% - 0.5px), rgba(255, 255, 255, 0.12) 50%, transparent calc(50% + 0.5px)),
    linear-gradient(0deg, transparent calc(50% - 0.5px), rgba(255, 255, 255, 0.12) 50%, transparent calc(50% + 0.5px));
  opacity: 0.8;
}

.setup-screen::after {
  content: "";
  position: fixed;
  left: 12vw;
  bottom: 15vh;
  width: 7px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 38px 12px rgba(226, 28, 57, 0.3);
}

.setup-card {
  position: relative;
  z-index: 1;
  width: min(680px, 100%);
  padding: clamp(22px, 5vw, 42px);
  border: 1px solid var(--line-dark);
  border-radius: 28px;
  background: rgba(21, 21, 21, 0.72);
  box-shadow: 0 34px 80px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(22px);
}

.setup-mark {
  width: 42px;
  aspect-ratio: 1;
  margin-bottom: 28px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  position: relative;
}

.setup-mark::before,
.setup-mark::after {
  content: "";
  position: absolute;
  background: rgba(255, 255, 255, 0.42);
}

.setup-mark::before {
  left: 50%;
  top: -10px;
  width: 1px;
  height: 60px;
}

.setup-mark::after {
  left: -10px;
  top: 50%;
  width: 60px;
  height: 1px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--signal);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 100%;
  margin: 0 0 18px;
  font-size: clamp(3.1rem, 14vw, 6.8rem);
  line-height: 0.88;
  letter-spacing: -0.085em;
  overflow-wrap: anywhere;
}

h2 {
  margin-bottom: 0;
  letter-spacing: -0.04em;
}

.setup-copy p:last-child {
  max-width: 31rem;
  margin-bottom: 32px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 1.02rem;
  line-height: 1.7;
}

.race-form {
  display: grid;
  gap: 13px;
  padding-top: 26px;
  border-top: 1px solid var(--line-dark);
}

label {
  display: grid;
  gap: 8px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

input {
  width: 100%;
  min-height: 52px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  padding: 0 15px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.055);
  outline: none;
}

input::placeholder {
  color: rgba(255, 255, 255, 0.38);
}

input:focus {
  border-color: rgba(226, 28, 57, 0.82);
  box-shadow: 0 0 0 4px rgba(226, 28, 57, 0.14);
}

input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 6px;
}

.single-action {
  grid-template-columns: 1fr;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  padding: 0 16px;
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-decoration: none;
  white-space: nowrap;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, opacity 160ms ease, transform 160ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: wait;
  opacity: 0.48;
}

.button-primary {
  color: #ffffff;
  background: var(--signal);
}

.button-secondary,
.button-quiet {
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #ffffff;
  background: transparent;
}

.button-secondary:hover:not(:disabled),
.button-quiet:hover:not(:disabled) {
  border-color: rgba(226, 28, 57, 0.7);
  background: rgba(226, 28, 57, 0.12);
}

.status {
  min-height: 22px;
  margin: 18px 0 0;
  color: rgba(255, 255, 255, 0.64);
  font-size: 0.9rem;
}

.status.success {
  color: #ffffff;
  font-weight: 800;
}

.status.error {
  color: #e21c39;
  font-weight: 800;
}

.about-note {
  display: grid;
  gap: 6px;
  margin-top: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  padding: 14px 16px;
  color: rgba(255, 255, 255, 0.68);
  background: rgba(255, 255, 255, 0.045);
  font-size: 0.9rem;
  line-height: 1.5;
}

.about-note strong {
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.room-card {
  width: min(760px, 100%);
}

.room-route {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 0 0 16px;
  padding-top: 26px;
  border-top: 1px solid var(--line-dark);
}

.room-pill {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.045);
}

.room-pill span {
  display: block;
  margin-bottom: 8px;
  color: rgba(255, 255, 255, 0.56);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.room-pill strong {
  display: block;
  overflow: hidden;
  color: #ffffff;
  font-size: clamp(1.15rem, 4vw, 1.75rem);
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.target-pill {
  border-color: rgba(226, 28, 57, 0.62);
  background: rgba(226, 28, 57, 0.11);
}

.target-pill strong {
  color: #e21c39;
}

.invite-field {
  margin-top: 14px;
}

.invite-field input {
  font-size: 0.88rem;
  text-overflow: ellipsis;
}

.invite-field input:read-only {
  cursor: text;
}

.room-actions {
  grid-template-columns: 1.2fr 1fr auto;
}

.route-form {
  margin-bottom: 18px;
}

.route-actions {
  grid-template-columns: 1.2fr 1fr;
}

.players-panel {
  display: grid;
  gap: 14px;
  margin: 18px 0 0;
  padding: 18px 0;
  border-top: 1px solid var(--line-dark);
  border-bottom: 1px solid var(--line-dark);
}

.players-panel h2 {
  color: #ffffff;
  font-size: 1.2rem;
}

.players-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.players-list li {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  padding: 7px 10px;
  color: rgba(255, 255, 255, 0.82);
  background: rgba(255, 255, 255, 0.045);
  font-size: 0.82rem;
  font-weight: 760;
}

.race-screen {
  min-height: 100vh;
  width: 100%;
  background: #151515;
}

.race-hud {
  position: sticky;
  top: 0;
  z-index: 20;
  width: 100%;
  color: #ffffff;
  background: rgba(21, 21, 21, 0.97);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(18px);
}

.hud-main {
  display: grid;
  grid-template-columns: auto minmax(220px, 1.1fr) minmax(220px, 1fr) 84px 96px auto;
  gap: 10px;
  align-items: center;
  padding: 14px clamp(14px, 2vw, 24px) 12px;
}

.hud-brand {
  color: #ffffff;
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: -0.06em;
  text-decoration: none;
}

.hud-card {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.045);
}

.target-card {
  border-color: rgba(226, 28, 57, 0.62);
  background: rgba(226, 28, 57, 0.11);
}

.hud-card span {
  display: block;
  margin-bottom: 2px;
  color: rgba(255, 255, 255, 0.58);
  font-size: 0.62rem;
  font-weight: 850;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.hud-card strong {
  display: block;
  overflow: hidden;
  color: #ffffff;
  font-size: 1rem;
  line-height: 1.18;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.target-card strong {
  color: #e21c39;
  font-size: 1.15rem;
}

.compact-stat {
  text-align: center;
}

.compact-stat strong {
  font-variant-numeric: tabular-nums;
}

.race-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.race-actions .button {
  min-height: 34px;
  border-color: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  font-size: 0.78rem;
}

.race-actions .button:hover:not(:disabled) {
  border-color: rgba(226, 28, 57, 0.7);
  background: rgba(226, 28, 57, 0.12);
}

.route-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 0 clamp(14px, 2vw, 24px) 9px;
  overflow-x: auto;
}

.route-bar > span {
  flex: 0 0 auto;
  color: #e21c39;
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.path-list {
  display: flex;
  flex: 1 1 auto;
  gap: 6px;
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-x: auto;
}

.path-list li {
  flex: 0 0 auto;
  max-width: 220px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 999px;
  padding: 5px 9px;
  color: rgba(255, 255, 255, 0.82);
  background: rgba(255, 255, 255, 0.055);
  font-size: 0.78rem;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.race-status {
  margin: 0;
  padding: 0 clamp(14px, 2vw, 24px) 12px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.82rem;
}

.race-status.success {
  color: #ffffff;
}

.race-status.error {
  color: #e21c39;
}

.countdown-banner {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 12px;
  align-items: center;
  margin: 0 clamp(14px, 2vw, 24px) 10px;
  border: 1px solid rgba(226, 28, 57, 0.56);
  border-radius: 16px;
  padding: 10px 12px;
  background: rgba(226, 28, 57, 0.14);
}

.countdown-banner span {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.countdown-banner strong {
  color: #ffffff;
  font-size: 1.3rem;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.countdown-banner p {
  margin: 0;
  color: rgba(255, 255, 255, 0.76);
  font-size: 0.84rem;
  text-align: right;
}

.race-page {
  width: 100%;
  min-height: 100vh;
  background: #151515;
}

.race-context {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: 100%;
  padding: 18px clamp(18px, 3vw, 40px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  background: #151515;
}

.race-context .eyebrow {
  color: #e21c39;
}

.race-context h2 {
  color: #ffffff;
  margin: 0;
}

.race-context h2 {
  font-size: clamp(1.4rem, 2.4vw, 2.2rem);
}

.race-context p:last-child {
  max-width: 430px;
  margin: 0;
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.86rem;
  line-height: 1.45;
  text-align: right;
}

.wiki-viewer {
  display: block;
  width: 100%;
  min-height: calc(100vh - 160px);
  background: #ffffff;
}

.clipboard-helper {
  position: fixed;
  left: -9999px;
  top: 0;
}

.results-card {
  width: min(780px, 100%);
}

.winner-name {
  margin: -8px 0 28px;
  color: #ffffff;
  font-size: clamp(1.6rem, 5vw, 3.2rem);
  font-weight: 900;
  letter-spacing: -0.06em;
  line-height: 1.02;
}

.results-panel {
  display: grid;
  gap: 16px;
  margin: 18px 0 0;
  padding: 20px 0;
  border-top: 1px solid var(--line-dark);
  border-bottom: 1px solid var(--line-dark);
}

.results-panel h2 {
  color: #ffffff;
  font-size: 1.2rem;
}

.results-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.result-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  padding: 13px 14px;
  background: rgba(255, 255, 255, 0.055);
}

.result-row.is-dnf {
  opacity: 0.68;
}

.result-rank {
  color: #e21c39;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.result-player {
  overflow: hidden;
  color: #ffffff;
  font-size: 1rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-detail {
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.86rem;
  font-weight: 760;
  text-align: right;
  white-space: nowrap;
}

@media (max-width: 1120px) {
  .hud-main {
    grid-template-columns: auto minmax(170px, 1fr) minmax(170px, 1fr) 78px 86px;
  }

  .race-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}

@media (max-width: 760px) {
  .setup-screen {
    padding: 12px;
    place-items: start center;
  }

  .setup-card {
    margin-top: 10px;
    border-radius: 22px;
    padding: 22px;
  }

  h1 {
    font-size: clamp(3rem, 18vw, 5.3rem);
    letter-spacing: -0.075em;
  }

  .button-row {
    grid-template-columns: 1fr;
  }

  .room-route,
  .route-actions,
  .room-actions {
    grid-template-columns: 1fr;
  }

  .hud-main {
    grid-template-columns: 1fr 1fr;
    gap: 7px;
  }

  .hud-brand,
  .target-card,
  .current-stat,
  .race-actions {
    grid-column: 1 / -1;
  }

  .race-actions {
    display: grid;
  }

  .race-actions .button {
    width: 100%;
  }

  .race-context {
    display: grid;
    padding: 15px;
  }

  .race-context p:last-child {
    max-width: none;
    text-align: left;
  }

  .countdown-banner {
    grid-template-columns: 1fr auto;
  }

  .countdown-banner p {
    grid-column: 1 / -1;
    text-align: left;
  }

  .result-row {
    grid-template-columns: auto 1fr;
  }

  .result-detail {
    grid-column: 2;
    text-align: left;
  }
}
