:root {
  color-scheme: light;
  font-family: system-ui, sans-serif;
  line-height: 1.5;
  color: #172033;
  background: #f3f6fb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 20rem;
}

.app-shell {
  width: min(72rem, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.5rem 0 3rem;
}

button,
select {
  font: inherit;
}

:focus-visible,
:focus {
  outline: 3px solid #145ec7;
  outline-offset: 3px;
}

.beginner-lesson {
  max-width: 56rem;
  padding: 0.5rem 1.25rem;
  border: 1px solid #bbc8d8;
  border-radius: 0.75rem;
  background: #fff;
}

.beginner-lesson h3 {
  margin-bottom: 0.25rem;
}

.beginner-lesson p {
  margin-top: 0;
}

.challenge-values {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.25rem 1rem;
  padding: 1rem;
  border: 1px solid #bbc8d8;
  border-radius: 0.5rem;
  background: #fff;
}

.challenge-values dt {
  font-weight: 700;
}

.challenge-values dd {
  margin: 0;
}

.challenge-values > div {
  min-width: 0;
}

.race-view {
  position: relative;
  min-height: 24rem;
  margin: 1rem 0;
  overflow: hidden;
  border: 3px solid #426f9a;
  border-radius: 1.25rem;
  background: #9bdcf6;
}

.race-canvas {
  display: block;
  width: 100%;
  height: clamp(20rem, 42vw, 32rem);
}

.race-labels {
  position: absolute;
  inset: 0.5rem 1rem auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.35rem;
  color: #173457;
  font-size: clamp(0.75rem, 3.5vw, 1rem);
  font-weight: 900;
  pointer-events: none;
}

.race-labels span {
  padding: 0.2rem 0.45rem;
  border: 2px solid #426f9a;
  border-radius: 1rem;
  background: #fff9d9;
  text-align: center;
}

.race-labels span:first-child {
  border-bottom: 3px solid #2165bc;
}

.race-labels span:last-child {
  border-bottom: 3px solid #e17a2d;
}

.race-marker {
  position: absolute;
  transform: translate(-50%, -100%);
  padding: 0.2rem 0.5rem;
  border: 2px solid #a34a24;
  border-radius: 0.6rem;
  color: #773412;
  background: #fff3b1;
  font-size: 0.75rem;
  font-weight: 900;
  white-space: nowrap;
  pointer-events: none;
}

.race-endpoint {
  border-color: #426f9a;
  color: #173457;
  background: #eaf5ff;
}

.race-sender {
  transform: translate(calc(-100% - 0.75rem), -50%);
}

.race-receiver {
  transform: translate(0.75rem, -50%);
}

.race-endpoint::after {
  position: absolute;
  top: 50%;
  width: 0.75rem;
  border-top: 2px solid #426f9a;
  content: "";
}

.race-sender::after {
  left: 100%;
}

.race-receiver::after {
  right: 100%;
}

.race-description,
.race-stage,
.race-comparison {
  margin: 0;
  padding: 0.6rem 1rem;
  color: #173457;
  background: #f5fbff;
}

.race-stage {
  border-top: 1px solid #c1d9e8;
  font-weight: 700;
}

.race-comparison {
  display: grid;
  gap: 0.25rem;
  border-top: 3px solid #e8ab3a;
  background: #fff7db;
}

.race-comparison[hidden] {
  display: none;
}

.race-comparison p {
  margin: 0;
}

.race-match {
  border-color: #1b8c5c;
  background: #e8fff1;
}

.race-mismatch {
  border-color: #db7a31;
}

.schematic-view {
  display: grid;
  gap: 0.75rem;
  align-content: center;
  padding: 1rem;
  color: #172033;
  background: #eaf0f7;
}

.schematic-path {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.schematic-node,
.schematic-data,
.schematic-ack,
.schematic-bottleneck {
  padding: 0.5rem 0.75rem;
  border: 2px solid #536176;
  border-radius: 0.5rem;
  background: #fff;
  font-weight: 700;
}

.schematic-data {
  border-color: #1b6d43;
}

.schematic-ack {
  border-color: #405ca8;
}

.schematic-bottleneck {
  border-color: #c46b24;
  background: #fff7db;
}

.schematic-state,
.schematic-event,
.schematic-outcome,
.schematic-prediction,
.schematic-notice {
  margin: 0;
}

.response-form fieldset {
  display: grid;
  gap: 0.75rem;
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid #bbc8d8;
  border-radius: 0.5rem;
}

.choice-option {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.25rem;
}

.choice-option input[type="radio"] {
  flex: 0 0 auto;
  margin-top: 0.35rem;
}

.help-controls,
.restart-confirmation {
  margin-block: 1rem;
  padding: 1rem;
  border: 1px solid #bbc8d8;
  border-radius: 0.5rem;
  background: #fff;
}

.help-controls button,
.restart-confirmation button {
  margin: 0.25rem 0.5rem 0.25rem 0;
}

.feedback {
  margin-block: 1rem;
  padding: 1rem;
  border: 2px solid #64748b;
  border-radius: 0.5rem;
  background: #fff;
}

.feedback-correct {
  border-color: #1b6d43;
}

.feedback-incorrect,
.feedback-content-error,
.feedback-invalid-input {
  border-color: #8c4a17;
}

@media (max-width: 36rem) {
  .app-shell {
    width: min(100% - 1rem, 72rem);
  }

  .race-labels {
    inset-inline: 0.25rem;
  }
}
