.game-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.game-tabs button {
  padding: 13px 20px;
  border: 1px solid #a6b1bc;
  background: transparent;
  color: #4e5761;
  font: 12px var(--mono);
  cursor: pointer;
}
.game-tabs [aria-selected='true'] {
  color: #fff;
  background: #2f3c49;
  border-color: #2f3c49;
  box-shadow: 4px 4px 0 #cbd3db;
}
.game-tabs button:focus-visible,
.derby-shell button:focus-visible {
  outline: 3px solid #b47b35;
  outline-offset: 4px;
}
#orbit-panel[hidden],
#derby-panel[hidden],
.derby-shell [hidden] {
  display: none !important;
}
.derby-shell {
  border: 1px solid #24272a;
  box-shadow: 8px 8px 0 #cfd6dd;
  background: #f1f4f8;
  color: #2f3c49;
}
.derby-shell .player-title {
  background: #24272a;
  color: #fff;
}
.derby-roster {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 20px;
  font: 10px var(--mono);
  color: #656e78;
  border-bottom: 1px solid #cfd6dd;
}
.derby-stage {
  position: relative;
  height: 542px;
  min-height: 360px;
  overflow: hidden;
  background: #f4e5c8;
}
#derby-canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.derby-hud {
  padding: 16px 22px;
  background: #f4e5c8;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  pointer-events: none;
}
.derby-hud span {
  min-width: 80px;
  padding: 10px 14px;
  background: #fffaf3e6;
  border: 1px solid #c8d2db;
}
.derby-hud small {
  display: block;
  margin-bottom: 4px;
  font: 9px var(--mono);
  letter-spacing: 0.6px;
}
.derby-hud b {
  font: 22px var(--mono);
  color: #2f3c49;
}
.derby-overlay {
  position: absolute;
  inset: 99px 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 15px;
  text-align: center;
  background: #f4e5c8ed;
  padding: 30px;
}
.derby-overlay h3 {
  margin: 0;
  font-size: clamp(35px, 5vw, 64px);
  font-weight: 500;
  letter-spacing: -2px;
  line-height: 1.05;
}
.derby-overlay h3 span {
  color: #677d94;
}
.derby-overlay p {
  margin: 0;
  font-size: 14px;
  line-height: 1.7;
}
.derby-overlay .eyebrow,
.derby-overlay small {
  font: 10px var(--mono);
  letter-spacing: 0.6px;
}
.derby-shell button {
  cursor: pointer;
  border: 1px solid #91a0ae;
  background: transparent;
  padding: 10px 15px;
  color: #2f3c49;
  font: 11px var(--mono);
}
.derby-shell .derby-primary {
  background: #2f3c49;
  color: white;
  border-color: #2f3c49;
  padding: 14px 20px;
}
.derby-howto {
  max-width: 420px;
  padding-left: 24px;
  margin: 18px auto 24px;
  text-align: left;
  font-size: 15px;
  line-height: 1.5;
}
.derby-howto li + li {
  margin-top: 10px;
}
.derby-howto li::marker {
  color: #5b6c7c;
  font: bold 13px var(--mono);
}
.derby-controls {
  position: absolute;
  inset: auto 20px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.derby-controls span {
  background: #fffaf3e6;
  padding: 10px 13px;
  font: 11px var(--mono);
}
.derby-controls button {
  background: #fffaf3e6;
}
.derby-roll-console {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 32px;
  padding: 28px;
  background: #f4e5c8;
  border-top: 4px solid #3f5973;
  align-items: center;
}
.derby-roll-instructions h3 {
  margin: 4px 0 8px;
  font-size: 28px;
}
.derby-roll-instructions p {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.5;
}
.derby-roll-instructions label {
  font: 9px var(--mono);
}
.derby-roll-instructions meter {
  display: block;
  width: 100%;
  height: 12px;
}
.derby-shell #derby-roll {
  --marker-position: 50%;
  display: block;
  width: 100%;
  padding: 22px;
  border: 1px solid #a6b1bc;
  background: #fbfcfe;
  box-shadow: 0 3px 0 #a6b1bc;
  touch-action: manipulation;
  user-select: none;
}
#derby-roll:disabled {
  opacity: 1;
  cursor: default;
}
#derby-roll:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #a6b1bc;
}
.derby-roll-meter {
  position: relative;
  display: block;
  height: 44px;
  margin: 0 0 12px;
  overflow: hidden;
  background: #e7ebee;
  border-radius: 4px;
  border: 1px solid #c7cfd7;
}
.derby-roll-zone {
  position: absolute;
  left: 35%;
  width: 30%;
  inset-block: 0;
  background: #d8e5d2;
  border-inline: 1px solid #7a9570;
}
.derby-roll-marker {
  position: absolute;
  top: 5px;
  bottom: 5px;
  left: clamp(5px, var(--marker-position), calc(100% - 5px));
  width: 6px;
  transform: translateX(-50%);
  border-radius: 2px;
  background: #2f3c49;
  box-shadow: 0 0 0 2px #fbfcfe;
}
.derby-roll-guide {
  display: grid;
  grid-template-columns: 35% 30% 35%;
  margin: 0 0 20px;
  color: #616b76;
  font: 9px var(--mono);
  letter-spacing: 1px;
}
.derby-roll-guide span:nth-child(2) {
  color: #41623c;
  font-weight: bold;
}
#derby-roll[data-ready='true']:not(:disabled) .derby-roll-zone {
  background: #c1d8b7;
}
#derby-roll[data-result='good']:not(:disabled) .derby-roll-caption b {
  color: #41623c;
}
.derby-roll-caption {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}
.derby-roll-caption b {
  font-size: 22px;
}
#derby-roll-cue {
  font-size: 10px;
}
#derby-roll[data-ready='true']:not(:disabled) {
  background: #e8f2db;
  border-color: #41623c;
}
.derby-results {
  padding: 32px;
  border-top: 1px solid #cfd6dd;
}
.derby-results h3 {
  font-size: 38px;
  font-weight: 500;
  margin: 0 0 12px;
  letter-spacing: -1px;
}
.derby-results p {
  font-size: 14px;
  line-height: 1.7;
}
.derby-results form {
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid #cfd6dd;
}
.derby-results label {
  display: block;
  font-size: 12px;
  line-height: 1.6;
}
.derby-results input:not([type='checkbox']),
.derby-results textarea {
  display: block;
  width: 100%;
  border: 1px solid #a6b2bd;
  background: #fbfcfe;
  border-radius: 0;
  color: #2f3c49;
  padding: 12px;
  font-family: inherit;
  font-size: 14px;
  margin: 6px 0 12px;
}
.derby-results input:focus-visible,
.derby-results textarea:focus-visible {
  outline: 2px solid #667b90;
  outline-offset: 2px;
}
.derby-results small {
  color: #656e78;
  font-size: 10px;
}
.derby-form-inline {
  display: flex;
  align-items: start;
  gap: 10px;
}
.derby-form-inline input {
  flex: 1;
  min-width: 0;
}
.derby-form-inline button {
  margin-top: 6px;
  flex-shrink: 0;
}
.derby-result-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin: 20px 0 0;
}
.derby-result-actions a {
  color: #656e78;
  font-size: 12px;
}
.derby-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 20px;
}
.derby-results .derby-consent {
  display: flex;
  align-items: start;
  gap: 9px;
  margin-top: 12px;
}
.derby-consent input {
  margin-top: 4px;
}
.derby-honeypot {
  position: absolute;
  left: -10000px;
}
.derby-results h4 {
  margin: 0;
  font-size: 24px;
  font-weight: 500;
}
.derby-leaderboard {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 30px;
  margin-top: 38px;
}
.derby-leaderboard h3 {
  font-size: 26px;
  line-height: 1.3;
  font-weight: 500;
  letter-spacing: -0.7px;
  margin: 0;
}
.derby-leaderboard ol {
  margin: 0;
  padding: 0;
  list-style: none;
}
.derby-leaderboard li {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid #d0d6dd;
  padding: 12px 0;
  font-size: 13px;
}
.derby-leaderboard li:first-child {
  color: #a37438;
}
.derby-leaderboard li b {
  font: 12px var(--mono);
  white-space: nowrap;
}
@media (max-width: 600px) {
  .game-tabs {
    gap: 8px;
  }
  .game-tabs button {
    flex: 1;
    padding: 12px 8px;
    font-size: 10px;
  }
  .derby-stage {
    height: 440px;
  }
  .derby-hud {
    padding: 12px 10px;
    gap: 6px;
  }
  .derby-hud span {
    padding: 8px;
    min-width: 0;
  }
  .derby-hud b {
    font-size: 16px;
  }
  .derby-hud small {
    font-size: 8px;
  }
  .derby-roster {
    padding: 12px;
    font-size: 9px;
  }
  .derby-roster > span:last-child {
    display: none;
  }
  .derby-overlay {
    padding: 22px 14px;
  }
  .derby-overlay h3 {
    font-size: 38px;
  }
  .derby-overlay small {
    font-size: 8px;
  }
  .derby-overlay p {
    font-size: 12px;
  }
  .derby-roll-console {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 16px;
  }
  .derby-roll-instructions h3 {
    font-size: 24px;
  }
  .derby-shell #derby-roll {
    padding: 16px 10px;
  }
  .derby-roll-meter,
  .derby-roll-guide {
    margin-inline: 0;
  }
  .derby-roll-guide {
    font-size: 8px;
    letter-spacing: 0;
  }
  .derby-roll-caption {
    flex-direction: column;
    gap: 8px;
  }
  .derby-controls {
    inset: auto 10px 12px;
    gap: 8px;
  }
  .derby-controls span {
    font-size: 9px;
  }
  .derby-results {
    padding: 22px 15px;
  }
  .derby-form-grid,
  .derby-leaderboard {
    grid-template-columns: 1fr;
  }
  .derby-form-inline {
    flex-direction: column;
  }
  .derby-form-inline input {
    width: 100%;
  }
  .derby-leaderboard {
    gap: 15px;
  }
}
.derby-graphics-fallback {
  position: absolute;
  inset: 120px 30px auto;
  text-align: center;
  font-size: 14px;
}
.derby-controls > span > span {
  padding: 0;
  background: transparent;
}
.derby-controls small {
  display: block;
  margin-top: 5px;
  color: #697a8b;
  font: 9px var(--mono);
}

.derby-shell .player-title button {
  color: #fff;
  border-color: #6b7680;
}

@media (prefers-reduced-motion: reduce) {
  .derby-roll-marker {
    transform: translateX(-50%);
  }
  #derby-roll:active:not(:disabled) {
    transform: none;
  }
}

.derby-announcement {
  min-height: 46px;
  padding: 12px 20px;
  color: #3f5973;
  background: #fff5db;
  border-top: 1px solid #dcc8a9;
  text-align: center;
  font-size: 14px;
  font-weight: bold;
}
.derby-field {
  padding: 12px 20px;
  border-top: 1px solid #dcc8a9;
}
.derby-field summary {
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
  font: 12px var(--mono);
}
.derby-field summary::before {
  content: '+ ';
  margin-right: 10px;
}
.derby-field[open] summary::before {
  content: '− ';
}
.derby-field ol {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.derby-field li {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 4px 8px;
  align-items: center;
  font-size: 14px;
  min-width: 0;
}
.derby-field b {
  display: grid;
  place-items: center;
  background: #3f5973;
  color: #fff5db;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  grid-row: span 2;
}
.derby-field small {
  font: 9px/1.5 var(--mono);
  color: #656e78;
}
.derby-field li span {
  overflow-wrap: anywhere;
}
.derby-board {
  border: 1px solid #c7cfd7;
  background: #fffaf3;
  min-width: 0;
}
.derby-board-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  background: #2f3c49;
  color: #fff;
}
.derby-board-toolbar p {
  font: 10px/1.6 var(--mono);
}
.derby-board-toolbar button {
  min-height: 44px;
  border: 1px solid #c7cfd7;
  background: transparent;
  color: white;
  padding: 9px 12px;
  font: 11px var(--mono);
  cursor: pointer;
}
.derby-board-toolbar button:disabled {
  opacity: 0.6;
  cursor: default;
}
.derby-board-columns,
.derby-leaderboard li {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}
.derby-board-columns {
  padding: 10px 16px;
  font: 9px var(--mono);
  color: #656e78;
  border-bottom: 1px solid #c7cfd7;
}
.derby-leaderboard li {
  padding: 15px 16px;
  font-size: 15px;
  color: #2f3c49;
}
.derby-board-name {
  overflow-wrap: anywhere;
}
.derby-board-rank {
  color: #656e78;
  font: 14px var(--mono);
}
.derby-leaderboard li[data-podium='true'] {
  background: #fff2cd;
}
.derby-leaderboard li[data-podium='true'] .derby-board-rank {
  color: #9b6c23;
  font-weight: bold;
}
.derby-leaderboard li[data-own='true'] {
  background: #e4efd9;
  box-shadow: inset 4px 0 #527c3f;
}
.derby-leaderboard .derby-board-empty {
  color: #2f3c49;
  display: block;
  line-height: 1.6;
}
.derby-placings {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 18px;
  font: 12px/1.6 var(--mono);
}
.derby-placings li {
  padding: 8px 10px;
  border: 1px solid #c7cfd7;
  overflow-wrap: anywhere;
}
.derby-placings [data-own='true'] {
  background: #e4efd9;
  border-color: #527c3f;
  font-weight: bold;
}
.derby-celebrate {
  position: relative;
}
.derby-celebrate::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 8px;
  pointer-events: none;
  background: #59728b;
  animation: derby-ribbon 1.8s ease-out;
}
@keyframes derby-ribbon {
  from {
    opacity: 0;
    transform: scaleX(0.2);
  }
  to {
    opacity: 1;
    transform: scaleX(1);
  }
}
@media (prefers-reduced-motion: reduce) {
  .derby-celebrate::before {
    animation: none;
  }
}
