:root {
  color: #111;
  background: #fff;
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.45;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: #fff;
  color: #111;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 2px solid #111;
  outline-offset: 2px;
}

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

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

h1 {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3em;
  margin-bottom: 2rem;
  font-size: clamp(2rem, 8vw, 3rem);
  font-weight: 700;
  line-height: 1;
  text-align: center;
}

.heading-icon {
  flex: none;
  width: 1.25em;
  height: 1.25em;
}

/* The logo, centred beside the title and tagline, which share a left edge. */
.site-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.site-logo {
  flex: none;
  width: clamp(4rem, 18vw, 5.5rem);
  height: clamp(4rem, 18vw, 5.5rem);
}

.site-title hgroup {
  min-width: 0;
}

.site-title h1 {
  display: block;
  margin-bottom: 0.3rem;
  text-align: left;
}

.tagline {
  margin-bottom: 0;
  font-size: clamp(1.25rem, 5vw, 1.6rem);
  font-style: italic;
  font-weight: 600;
  line-height: 1.2;
  color: #555;
}

/* Keeps the heading centred, with an action beside it on the right. */
.page-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.page-header h1 {
  grid-column: 2;
  margin-bottom: 0;
}

.page-header button {
  justify-self: end;
  white-space: nowrap;
}

h2 {
  margin-bottom: 0.5rem;
  font-size: 1.25rem;
}

.view > p {
  margin-bottom: 1.5rem;
}

input[type="text"],
input[type="number"] {
  width: 100%;
  min-height: 2.5rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid #111;
  border-radius: 0;
  background: #fff;
  color: #111;
}

button {
  min-height: 2.5rem;
  padding: 0.5rem 0.85rem;
  border: 1px solid #111;
  border-radius: 0;
  background: #fff;
  color: #111;
}

button:hover:not(:disabled) {
  background: #111;
  color: #fff;
}

.primary-button {
  width: 100%;
  margin-top: 0.25rem;
  background: #111;
  color: #fff;
}

.primary-button:hover:not(:disabled) {
  background: #fff;
  color: #111;
}

/* Gains .primary-button once the role is revealed. */
.next-round-button {
  width: 100%;
  margin-top: 1.5rem;
}

.previous-round-row {
  margin-top: 0.75rem;
  text-align: center;
}

.finish-row {
  margin-top: 3rem;
  text-align: center;
}

.outline-link {
  min-height: 2rem;
  padding: 0.3rem 0.75rem;
  border: 1px solid #111;
  background: transparent;
  color: #111;
  font-size: 0.9rem;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.outline-link:disabled {
  border-color: #999;
  color: #999;
  text-decoration: none;
}

a {
  color: inherit;
  text-underline-offset: 0.15em;
}

fieldset {
  min-width: 0;
  margin: 0 0 1.5rem;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 0.75rem;
  padding: 0;
  font-weight: 700;
}

.players-list {
  display: grid;
  gap: 0.75rem;
}

.player-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
}

.remove-player {
  min-width: 2.5rem;
  padding-right: 0.6rem;
  padding-left: 0.6rem;
}

.setting-row {
  display: grid;
  grid-template-columns: 1fr minmax(5rem, 7rem);
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.setting-row label {
  font-weight: 700;
}

.setting-row input {
  width: 100%;
}

.round-heading {
  margin-bottom: 0.75rem;
  font-size: 2rem;
  line-height: 1.1;
}

.view > .round-label {
  margin-bottom: 0.25rem;
}

.round-id {
  font-family: "Courier New", Courier, monospace;
  font-size: 1.1em;
  letter-spacing: 0.05em;
}

.error-message,
.sus {
  color: #c00;
}

/* Thicker as well as red, so the error doesn't rely on colour alone. */
input[aria-invalid="true"] {
  border-color: #c00;
  box-shadow: inset 0 0 0 1px #c00;
}

/* The role replaces the Reveal button once shown, so they share the right column. */
.game-player {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  min-height: 2.5rem;
  margin-top: 1.5rem;
}

.game-player .player-name {
  font-size: 1.25rem;
  font-weight: 700;
}

.player-name {
  overflow-wrap: anywhere;
}

.role {
  font-size: 1.25rem;
  white-space: nowrap;
}

.role:focus {
  outline: none;
}

.view > .role-goal {
  margin: 0.75rem 0 0;
  text-align: center;
}

.status,
.error-message {
  min-height: 1.45em;
  margin: 0;
}

.status {
  margin-top: 0.5rem;
}

/* Invite page */

.invite-players {
  margin: 0 0 0.5rem;
  padding: 0;
  list-style: none;
}

.invite-player {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.25rem 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid #111;
}

.invite-player .player-name {
  grid-column: 1 / -1;
  font-weight: 700;
}

.invite-link {
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.invite-actions {
  display: flex;
  gap: 0.5rem;
}

/* Scoring page */

select {
  width: 100%;
  min-height: 2.5rem;
  padding: 0.4rem 0.3rem;
  border: 1px solid #111;
  border-radius: 0;
  background: #fff;
  color: #111;
}

.scoring-section {
  margin-bottom: 2.5rem;
}

.scoring-section h2:focus {
  outline: none;
}

.table-scroll {
  overflow-x: auto;
  margin-bottom: 1rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.5rem 0.4rem;
  border-bottom: 1px solid #111;
  text-align: left;
  vertical-align: middle;
}

th:first-child,
td:first-child {
  padding-left: 0;
}

th:last-child,
td:last-child {
  padding-right: 0;
}

thead th {
  font-size: 0.85rem;
  white-space: nowrap;
}

tbody th {
  font-weight: 400;
  overflow-wrap: anywhere;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.entry-table .vote-cell {
  width: 38%;
}

/* Shrink to the Win/Loss toggle so the spare width goes to the names. */
.entry-table .result-cell {
  width: 1%;
  white-space: nowrap;
}

.result-toggle {
  display: inline-flex;
}

.result-toggle label {
  position: relative;
  cursor: pointer;
}

.result-toggle input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.result-toggle span {
  display: block;
  min-height: 2.5rem;
  padding: 0.5rem 0.55rem;
  border: 1px solid #111;
}

.result-toggle label + label span {
  border-left: 0;
}

.result-toggle input:checked + span {
  background: #111;
  color: #fff;
}

.result-toggle input:focus-visible + span {
  outline: 2px solid #111;
  outline-offset: 2px;
}

.result-toggle[aria-invalid="true"] span {
  border-color: #c00;
  color: #c00;
}

/* High contrast mode drops the black fill, which would hide the choice. */
@media (forced-colors: active) {
  .result-toggle input:checked + span {
    forced-color-adjust: none;
    border-color: Highlight;
    background: Highlight;
    color: HighlightText;
  }
}

.leaderboard .total {
  font-weight: 700;
}

.leaderboard .latest {
  padding-right: 0.4rem;
  background: #f2f2f2;
}

/* Zero width so the asterisk hangs in the cell padding and scores stay aligned. */
.sus-marker {
  display: inline-block;
  width: 0;
  color: #c00;
  font-weight: 700;
  cursor: help;
}

.table-legend {
  margin: -0.5rem 0 1rem;
  text-align: right;
  font-size: 0.85rem;
  color: #555;
}

.player-meta {
  display: block;
  font-size: 0.85rem;
  color: #555;
}

.breakdown {
  font-size: 0.9rem;
}

.round-details {
  margin-bottom: 0.75rem;
}

.round-details summary {
  padding: 0.25rem 0;
  font-weight: 700;
  cursor: pointer;
}

.round-details[open] > summary {
  margin-bottom: 0.5rem;
}

.rules-role {
  margin-bottom: 0.25rem;
}

.rules-list {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
}

.rules-details {
  margin-top: 2.5rem;
}

.error-message {
  margin-bottom: 0.75rem;
}

/* A quiet link to a page off the main path. */
.page-footer {
  margin: 3rem 0 0;
  text-align: center;
  font-size: 0.85rem;
  color: #555;
}

/* Simulator page */

.slider-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));
  column-gap: 1.5rem;
}

.slider-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  column-gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.slider-value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.slider-row input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  height: 2rem;
  margin: 0;
  accent-color: #111;
}

.slider-note {
  margin-bottom: 0.75rem;
}

.slider-subgroup {
  margin-bottom: 0.75rem;
}

.slider-subgroup legend {
  margin-bottom: 0.5rem;
}

.model-details {
  margin-bottom: 1.5rem;
}

.model-details .outline-link {
  margin-bottom: 0.5rem;
}

.progress-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

progress {
  width: 100%;
  height: 0.75rem;
  accent-color: #111;
}

.results h3 {
  margin: 2.5rem 0 0.5rem;
  font-size: 1.1rem;
}

.results h4 {
  margin: 1.5rem 0 0.5rem;
  font-size: 1rem;
}

/* Row names here are words, not player names, so they wrap only between words. */
.results tbody th {
  overflow-wrap: normal;
}

.results .total-row th,
.results .total-row td {
  font-weight: 700;
}

.table-note {
  font-size: 0.85rem;
  color: #555;
}

.chart {
  margin: 0 0 1rem;
  color: #111;
}

/* Shrinks rather than overflows until the chart is redrawn at its new width. */
.chart svg {
  display: block;
  max-width: 100%;
  height: auto;
  overflow: visible;
}

.chart text {
  fill: currentColor;
  font-size: 0.8rem;
}

.chart .bar {
  fill: currentColor;
}

.chart .bar-sus,
.chart .dot-sus {
  fill: #c00;
}

/* Outlined rather than filled, so it doesn't rely on colour. */
.chart .bar-outline {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
}

.chart .axis {
  stroke: currentColor;
}

.chart .grid {
  stroke: #ddd;
}

.chart .reference {
  stroke: currentColor;
  stroke-dasharray: 4 3;
}

.chart .reference-edge {
  stroke: #fff;
  stroke-width: 3;
}

.chart .line-sus {
  fill: none;
  stroke: #c00;
  stroke-width: 2.5;
}

.chart .line-innocent {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-dasharray: 6 4;
}

.chart-legend {
  margin: -0.5rem 0 1rem;
  font-size: 0.85rem;
}

.legend-key {
  display: inline-block;
  width: 1.5rem;
  margin: 0 0.4rem 0.25em 0;
  vertical-align: middle;
}

.chart-legend .legend-innocent {
  margin-left: 1rem;
}

.legend-sus {
  border-top: 3px solid #c00;
}

.legend-innocent {
  border-top: 2px dashed #111;
}

/* High contrast mode keeps the shapes but not the red. */
@media (forced-colors: active) {
  .chart .bar-sus,
  .chart .dot-sus {
    fill: CanvasText;
  }

  .chart .line-sus {
    stroke: CanvasText;
  }

  .chart .grid {
    stroke: GrayText;
  }

  .chart .reference-edge {
    stroke: Canvas;
  }

  .legend-sus {
    border-top-color: CanvasText;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 540px) {
  .app-shell {
    padding-top: 2rem;
  }

  /* Too narrow for a centred heading with a button beside it, so stack them. */
  .page-header {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .page-header h1 {
    grid-column: auto;
  }

  .page-header button {
    justify-self: center;
  }

  .setting-row {
    grid-template-columns: 1fr 5rem;
    gap: 0.75rem;
  }
}
