.match-runtime {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-content: start;
  gap: 1rem;
  width: min(100%, 76rem);
  justify-self: center;
  overflow: visible;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.match-runtime > .section-heading {
  grid-column: 1;
  order: 1;
  min-width: 0;
  align-items: center;
  border: 1px solid var(--color-border);
  border-radius: 1.15rem;
  padding: 1rem 1.15rem;
  background:
    linear-gradient(110deg, color-mix(in srgb, var(--color-accent) 9%, transparent), transparent 52%),
    var(--color-surface);
  box-shadow: 0 1rem 2.75rem rgb(0 0 0 / 16%);
}

.match-runtime > .section-heading h2 {
  margin: 0;
  font-size: clamp(1.35rem, 3vw, 1.8rem);
  letter-spacing: -0.035em;
}

.match-runtime > .section-heading p {
  max-width: 48rem;
  margin-top: 0.2rem;
  font-size: 0.8rem;
}

.match-runtime[data-phase="ready"] > .section-heading {
  border-color: color-mix(in srgb, var(--color-accent-secondary) 34%, var(--color-border));
}

.match-runtime[data-phase="failed"] > .section-heading,
.match-runtime[data-phase="unauthorized"] > .section-heading {
  border-color: color-mix(in srgb, var(--color-danger) 48%, var(--color-border));
}

.match-lifecycle {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: minmax(0, 1fr) auto;
  order: 2;
  align-items: center;
  gap: 0.85rem 1.25rem;
  border: 1px solid color-mix(in srgb, var(--color-accent) 36%, var(--color-border));
  border-radius: 1.1rem;
  padding: 1rem 1.15rem;
  background:
    linear-gradient(120deg, color-mix(in srgb, var(--color-accent) 12%, transparent), transparent 58%),
    var(--color-surface);
  box-shadow: 0 1rem 2.5rem rgb(0 0 0 / 14%);
}

.match-lifecycle h3,
.match-lifecycle p {
  margin-bottom: 0;
}

.match-lifecycle h3 {
  font-size: 1rem;
}

.match-lifecycle .eyebrow {
  margin-bottom: 0.15rem;
  font-size: 0.65rem;
}

.match-lifecycle [data-match-deadline-owner] {
  margin-top: 0.15rem;
  font-size: 0.78rem;
}

.match-countdown {
  min-inline-size: 5.5rem;
  color: var(--color-text);
  font-size: clamp(1.65rem, 4vw, 2.35rem);
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  line-height: 1;
  text-align: end;
}

.match-lifecycle-actions {
  display: flex;
  grid-column: 1 / -1;
  justify-content: flex-end;
}

.match-lifecycle-actions > button,
.match-resignation-confirmation button {
  min-height: 2.75rem;
}

.match-resignation-confirmation {
  display: grid;
  width: min(100%, 38rem);
  gap: 0.75rem;
  border: 1px solid color-mix(in srgb, var(--color-danger) 38%, var(--color-border));
  border-radius: 0.9rem;
  padding: 0.85rem;
  background: color-mix(in srgb, var(--color-danger) 8%, var(--color-surface-soft));
}

.match-resignation-confirmation > p {
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

.match-resignation-confirmation > div {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
}

.match-runtime button.danger {
  border: 1px solid color-mix(in srgb, var(--color-danger) 68%, transparent);
  background: color-mix(in srgb, var(--color-danger) 82%, var(--color-canvas));
  color: var(--color-on-accent);
}

.match-runtime button.danger:hover:not(:disabled),
.match-runtime button.danger:focus-visible {
  background: color-mix(in srgb, var(--color-danger) 90%, var(--color-canvas));
}

.terminal-ceremony,
.game-client-host {
  grid-column: 1 / -1;
  order: 3;
}

.game-client-host {
  display: grid;
  min-width: 0;
  gap: 0.75rem;
  border-radius: 1.25rem;
}

.game-client-plugin-root {
  min-width: 0;
}

.game-client-participants {
  display: grid;
  gap: 0.65rem;
  margin: 0;
  border: 1px solid var(--color-border);
  border-radius: 1rem;
  padding: 0.75rem;
  background: color-mix(in srgb, var(--color-surface) 94%, var(--color-accent) 6%);
  color: var(--color-text);
  box-shadow: 0 0.75rem 2rem rgb(0 0 0 / 12%);
}

.game-client-participants-title {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.game-client-participant-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.game-client-participant {
  min-width: 0;
}

.game-client-participant-button {
  width: 100%;
  min-height: 2.75rem;
  border: 1px solid var(--color-border);
  border-radius: 0.8rem;
  padding: 0.6rem 0.7rem;
  background: rgb(255 255 255 / 3%);
  color: var(--color-text);
  font: inherit;
  font-size: 0.76rem;
  font-weight: 750;
  text-align: start;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.game-client-participant-button:hover,
.game-client-participant-button:focus-visible {
  border-color: color-mix(in srgb, var(--color-accent) 42%, var(--color-border));
  background: color-mix(in srgb, var(--color-accent) 12%, var(--color-surface));
}

.game-client-participant[data-self="true"] .game-client-participant-button {
  border-color: color-mix(in srgb, var(--color-accent) 48%, var(--color-border));
  background: color-mix(in srgb, var(--color-accent) 13%, var(--color-surface));
}

.match-runtime:is([data-status="finished"], [data-status="aborted"]) .game-client-host {
  display: none !important;
}

.terminal-ceremony {
  display: grid;
  gap: 1rem;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--color-accent) 42%, var(--color-border));
  border-radius: 1.25rem;
  padding: clamp(1.15rem, 3vw, 1.75rem);
  background:
    radial-gradient(circle at 100% 0, color-mix(in srgb, var(--color-accent) 22%, transparent), transparent 24rem),
    linear-gradient(145deg, rgb(255 255 255 / 2%), transparent 58%),
    var(--color-surface);
  box-shadow: 0 1.5rem 4rem rgb(0 0 0 / 20%);
}

.terminal-ceremony[data-outcome="win"] {
  border-color: color-mix(in srgb, var(--color-success) 48%, var(--color-border));
  background:
    radial-gradient(circle at 100% 0, color-mix(in srgb, var(--color-success) 15%, transparent), transparent 24rem),
    var(--color-surface);
}

.terminal-ceremony[data-outcome="loss"] {
  border-color: color-mix(in srgb, var(--color-danger) 40%, var(--color-border));
}

.terminal-ceremony h3 {
  max-width: 14ch;
  margin: 0;
  font-size: clamp(2.35rem, 8vw, 4.75rem);
  line-height: 0.94;
  letter-spacing: -0.055em;
}

.terminal-ceremony > p:not(.eyebrow) {
  max-width: 44rem;
  margin-bottom: 0;
}

.terminal-ceremony-placement {
  color: var(--color-text);
  font-size: 1rem;
  font-weight: 850;
}

.terminal-result-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
  gap: 0.65rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.terminal-result {
  display: grid;
  align-content: start;
  gap: 0.65rem;
  min-width: 0;
  border: 1px solid var(--color-border);
  border-radius: 0.95rem;
  padding: 0.85rem;
  background: rgb(255 255 255 / 2.5%);
}

.terminal-result[data-current="true"] {
  border-color: color-mix(in srgb, var(--color-accent) 50%, var(--color-border));
  background: color-mix(in srgb, var(--color-accent) 10%, var(--color-surface));
}

.terminal-result-identity {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}

.terminal-result-identity strong {
  overflow: hidden;
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.terminal-result-identity code {
  font-size: 0.65rem;
}

.terminal-result .badge {
  min-height: 1.7rem;
  padding: 0.2rem 0.5rem;
  font-size: 0.68rem;
}

.post-match-effects {
  display: grid;
  gap: 0.85rem;
  border-top: 1px solid var(--color-border);
  padding-top: 1rem;
}

.post-match-effects-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
}

.post-match-effects-heading h4,
.post-match-effect h5 {
  margin: 0;
}

.post-match-effects-heading h4 {
  font-size: 1.1rem;
}

.post-match-effects-status {
  max-width: 26rem;
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.75rem;
  font-weight: 750;
  text-align: right;
}

.post-match-effects-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
}

.post-match-effect {
  display: grid;
  align-content: start;
  gap: 0.55rem;
  min-width: 0;
  border: 1px solid var(--color-border);
  border-radius: 0.9rem;
  padding: 0.85rem;
  background: rgb(255 255 255 / 2.5%);
}

.post-match-effect[data-status="settled"] {
  border-color: color-mix(in srgb, var(--color-accent) 38%, var(--color-border));
}

.post-match-effect-state {
  justify-self: start;
  min-height: 1.65rem;
  margin: 0;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  background: rgb(255 255 255 / 6%);
  color: var(--color-text-muted);
  font-size: 0.68rem;
  font-weight: 800;
}

.post-match-effect[data-status="settled"] .post-match-effect-state {
  background: color-mix(in srgb, var(--color-accent) 16%, transparent);
  color: var(--color-accent-soft);
}

.post-match-effect-value {
  margin: 0;
  color: var(--color-text);
  font-size: clamp(1.15rem, 3vw, 1.55rem);
  font-weight: 850;
  overflow-wrap: anywhere;
}

.post-match-effect-details {
  display: grid;
  gap: 0.4rem;
  margin: 0;
}

.post-match-effect-details div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  border-top: 1px solid var(--color-border);
  padding-top: 0.4rem;
}

.post-match-effect-details dt {
  color: var(--color-text-muted);
  font-size: 0.7rem;
}

.post-match-effect-details dd {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 750;
  text-align: right;
  overflow-wrap: anywhere;
}

.post-match-effects > button {
  min-height: 2.75rem;
  justify-self: start;
}

.match-error {
  grid-column: 1 / -1;
  order: 4;
  margin: 0;
  border: 1px solid color-mix(in srgb, var(--color-danger) 38%, var(--color-border));
  border-radius: 0.9rem;
  padding: 0.75rem 0.85rem;
  background: color-mix(in srgb, var(--color-danger) 8%, var(--color-surface));
  color: var(--color-danger);
  font-size: 0.78rem;
  font-weight: 700;
}

.match-actions {
  display: contents;
}

.match-actions button {
  min-height: 2.75rem;
}

.match-actions [data-action="return-to-lobby"] {
  grid-column: 2;
  grid-row: 1;
  order: 1;
  align-self: center;
  justify-self: end;
  white-space: nowrap;
}

.match-actions [data-action="retry-command"],
.match-actions [data-action="retry-game-client"],
.match-actions [data-action="retry-match"] {
  grid-column: 1 / -1;
  order: 4;
  justify-self: start;
}

.match-actions [data-action="open-match-history"] {
  grid-column: 1 / -1;
  order: 3;
  justify-self: start;
}

.match-diagnostics {
  display: grid;
  grid-column: 1 / -1;
  order: 5;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: 1rem;
  background: color-mix(in srgb, var(--color-surface-soft) 84%, transparent);
}

.match-diagnostics > summary {
  display: flex;
  min-height: 2.75rem;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  color: var(--color-text-muted);
  font-size: 0.7rem;
  font-weight: 800;
  cursor: pointer;
  list-style: none;
}

.match-diagnostics > summary::-webkit-details-marker {
  display: none;
}

.match-diagnostics > summary strong {
  margin-left: auto;
  color: var(--color-text);
  font-size: 0.75rem;
  text-align: right;
}

.match-diagnostics > summary::after {
  display: grid;
  width: 1.6rem;
  height: 1.6rem;
  flex: 0 0 1.6rem;
  place-items: center;
  border: 1px solid var(--color-border-strong);
  border-radius: 50%;
  color: var(--color-accent-soft);
  content: "+";
  font-size: 1rem;
  line-height: 1;
}

.match-diagnostics[open] > summary::after {
  content: "−";
}

.match-diagnostics[open] > summary {
  border-bottom: 1px solid var(--color-border);
}

.match-metadata {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr));
  gap: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.match-metadata div {
  display: grid;
  min-width: 0;
  align-content: start;
  gap: 0.15rem;
  border: 0;
  border-right: 1px solid var(--color-border);
  padding: 0.65rem 0.75rem;
}

.match-metadata div:last-child {
  border-right: 0;
}

.match-metadata dt {
  color: var(--color-text-muted);
  font-size: 0.62rem;
  font-weight: 750;
}

.match-metadata dd {
  margin: 0;
  overflow: hidden;
  font-size: 0.72rem;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.match-metadata code {
  display: block;
  overflow: hidden;
  font-size: 0.62rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 58rem) {
  .post-match-effects-grid {
    grid-template-columns: 1fr;
  }

  .post-match-effect {
    grid-template-columns: minmax(9rem, 0.7fr) minmax(0, 1.3fr);
  }

  .post-match-effect h5,
  .post-match-effect-state,
  .post-match-effect-value {
    grid-column: 1;
  }

  .post-match-effect-details {
    grid-column: 2;
    grid-row: 1 / span 3;
  }
}

@media (max-width: 48rem) {
  .match-runtime {
    grid-template-columns: 1fr;
  }

  .match-runtime > .section-heading,
  .match-actions [data-action="return-to-lobby"] {
    grid-column: 1;
  }

  .match-runtime > .section-heading {
    order: 1;
  }

  .match-actions [data-action="return-to-lobby"] {
    grid-row: auto;
    order: 2;
    width: 100%;
    justify-self: stretch;
  }

  .match-lifecycle {
    order: 3;
  }

  .terminal-ceremony,
  .game-client-host,
  .match-actions [data-action="open-match-history"] {
    order: 4;
  }

  .match-error,
  .match-actions [data-action="retry-command"],
  .match-actions [data-action="retry-game-client"],
  .match-actions [data-action="retry-match"] {
    order: 5;
  }

  .match-diagnostics {
    order: 6;
  }
}

@media (max-width: 38rem) {
  .match-runtime {
    gap: 0.75rem;
  }

  .match-runtime > .section-heading,
  .match-lifecycle,
  .terminal-ceremony {
    border-radius: 1rem;
    padding: 0.85rem;
  }

  .match-runtime > .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .match-lifecycle {
    grid-template-columns: 1fr;
  }

  .match-countdown {
    text-align: start;
  }

  .match-lifecycle-actions,
  .match-resignation-confirmation > div {
    justify-content: stretch;
  }

  .match-lifecycle-actions button,
  .match-resignation-confirmation button,
  .match-actions [data-action="open-match-history"],
  .match-actions [data-action="retry-command"],
  .match-actions [data-action="retry-game-client"],
  .match-actions [data-action="retry-match"] {
    width: 100%;
    justify-self: stretch;
  }

  .terminal-ceremony h3 {
    font-size: clamp(2.2rem, 14vw, 3.6rem);
  }

  .terminal-result-list,
  .game-client-participant-list {
    grid-template-columns: 1fr;
  }

  .post-match-effects-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .post-match-effects-status {
    max-width: none;
    text-align: left;
  }

  .post-match-effect {
    grid-template-columns: 1fr;
  }

  .post-match-effect h5,
  .post-match-effect-state,
  .post-match-effect-value,
  .post-match-effect-details {
    grid-column: 1;
    grid-row: auto;
  }

  .post-match-effect-details div {
    align-items: start;
    flex-direction: column;
    gap: 0.1rem;
  }

  .post-match-effect-details dd {
    text-align: left;
  }

  .match-metadata {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .match-metadata div {
    border-right: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
  }

  .match-metadata div:nth-child(even) {
    border-right: 0;
  }

  .match-metadata div:nth-last-child(-n + 2) {
    border-bottom: 0;
  }
}

@media (max-width: 22rem) {
  .match-runtime > .section-heading,
  .match-lifecycle,
  .terminal-ceremony,
  .game-client-participants {
    padding: 0.75rem;
  }

  .match-diagnostics > summary {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.15rem 0.5rem;
  }

  .match-diagnostics > summary strong {
    width: calc(100% - 2.1rem);
    margin-left: 0;
    text-align: left;
  }

  .match-diagnostics > summary::after {
    margin-left: auto;
  }

  .match-metadata {
    grid-template-columns: 1fr;
  }

  .match-metadata div,
  .match-metadata div:nth-child(even),
  .match-metadata div:nth-last-child(-n + 2) {
    border-right: 0;
    border-bottom: 1px solid var(--color-border);
  }

  .match-metadata div:last-child {
    border-bottom: 0;
  }
}
