/* Mobile first: the phone layout is the default, wider screens get more room. */

:root {
  --text: #1d1d1f;
  --muted: #6e6e73;
  --background: #ffffff;
  --surface: #f2f2f5;
  --accent: #8a2be2;
  --error: #c0392b;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --text: #f5f5f7;
    --muted: #a1a1a6;
    --background: #161618;
    --surface: #232326;
    --accent: #b67cff;
    --error: #ff6b5b;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--background);
}

a {
  color: var(--accent);
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
}

.site-title {
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
}

.site-nav form {
  margin: 0;
}

main {
  padding: 1rem;
  max-width: 40rem;
  margin: 0 auto;
}

h1 {
  font-size: 1.5rem;
}

.stacked-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.stacked-form input[type='text'],
.stacked-form input[type='password'],
.stacked-form input[type='number'],
.stacked-form select,
.stacked-form textarea,
.search-form input[type='search'],
.inline-form input[type='number'] {
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--muted);
  border-radius: 0.5rem;
  background: var(--background);
  color: var(--text);
}

.stacked-form .checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

.stacked-form .errorlist,
.stacked-form .helptext {
  color: var(--muted);
  font-size: 0.875rem;
}

.stacked-form .errorlist {
  color: var(--error);
}

button {
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border: none;
  border-radius: 0.5rem;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
}

a.button {
  display: inline-block;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  background: var(--accent);
  color: #ffffff;
  text-decoration: none;
}

button.link-button {
  padding: 0;
  background: none;
  color: var(--accent);
  text-decoration: underline;
}

h2 {
  font-size: 1.2rem;
  margin-top: 2rem;
}

.muted,
.breadcrumb {
  color: var(--muted);
}

.breadcrumb {
  margin: 0;
  font-size: 0.875rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

/* Marks closed Rooms. */
.badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  vertical-align: middle;
  color: var(--muted);
  border: 1px solid var(--muted);
}

.search-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.search-form input[type='search'] {
  flex: 1;
  min-width: 0;
}

.room-list,
.terpeca-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.room-list li {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--surface);
}

.room-list a {
  font-weight: 600;
}

.room-list .muted {
  font-size: 0.875rem;
}

.details {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 1rem;
}

.details dt {
  color: var(--muted);
}

.details dd {
  margin: 0;
}

.checkbox-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1rem;
  margin: 0;
  padding: 0;
  border: none;
}

.terpeca-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--surface);
}

.terpeca-list form {
  margin: 0;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.5rem;
  margin-top: 1rem;
}

.inline-form label {
  display: flex;
  flex-direction: column;
  font-size: 0.875rem;
  color: var(--muted);
}

.inline-form input[type='number'] {
  width: 7rem;
}

.inline-form .errorlist {
  flex-basis: 100%;
  color: var(--error);
  font-size: 0.875rem;
}

.hidden {
  display: none !important;
}

/* Confirmations after saving: an accent bar instead of a filled box, so they
   don't look like the secondary buttons below them. */
.message {
  padding: 0.25rem 0 0.25rem 0.75rem;
  border-left: 0.25rem solid var(--accent);
}

button.secondary,
a.button.secondary {
  background: var(--surface);
  color: var(--text);
}

button.small-button {
  padding: 0.4rem 0.75rem;
  font-size: 0.875rem;
}

/* The Log */

.day-heading {
  font-size: 1rem;
  margin: 1.5rem 0 0.25rem;
  color: var(--muted);
}

.play-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.play-list li {
  display: flex;
  align-items: start;
  gap: 0.5rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--surface);
  background: var(--background);
}

.play-list .play {
  flex: 1;
  min-width: 0;
}

.play-list .muted,
.play-list .note {
  font-size: 0.875rem;
}

/* The pencil icon that links to an edit form. */
.edit-link {
  display: inline-flex;
  padding: 0.25rem;
  color: var(--muted);
  vertical-align: middle;
}

.edit-link:hover,
.edit-link:focus-visible {
  color: var(--accent);
}

.icon {
  width: 1.25rem;
  height: 1.25rem;
}

.running-number {
  color: var(--muted);
  margin-right: 0.25rem;
}

.room-name {
  font-weight: 600;
}

.rating-value {
  margin-left: 0.25rem;
  white-space: nowrap;
}

.planned .play {
  opacity: 0.75;
}

/* The Log table, shown instead of the cards from tablet width up. */
.log-table {
  display: none;
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.log-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.log-table th,
.log-table td {
  padding: 0.5rem;
  vertical-align: top;
}

.log-table tr {
  background: var(--background);
}

/* A line between the days, a lighter one between a day's Plays. */
.log-table tbody {
  border-top: 2px solid var(--muted);
}

.log-table tbody tr + tr {
  border-top: 1px solid var(--surface);
}

.log-table .number {
  text-align: right;
  white-space: nowrap;
}

.log-table .running-number {
  margin: 0;
}

.log-table .date,
.log-table .rating-value,
.log-table .actions {
  white-space: nowrap;
}

.log-table .room-name {
  font-size: 1rem;
}

.log-table .planned td {
  opacity: 0.75;
}

.log-table .note {
  max-width: 16rem;
}

/* The Play form */

.play-form fieldset {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0 0 1rem;
  padding: 0;
  border: none;
}

.play-form legend {
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.play-form input[type='date'],
.play-form input[type='time'],
.play-form input[type='search'] {
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--muted);
  border-radius: 0.5rem;
  background: var(--background);
  color: var(--text);
}

/* Start time and length side by side, also on the phone. */
.time-fields {
  display: flex;
  gap: 0.5rem;
}

.time-fields label {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.25rem;
}

.chips,
.players {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Team members as big toggle buttons. */
.toggle {
  flex: 1;
}

.toggle input,
.rating-option input {
  position: absolute;
  opacity: 0;
}

.toggle span,
.rating-option span {
  display: block;
  padding: 0.75rem 0.5rem;
  border: 1px solid var(--muted);
  border-radius: 0.5rem;
  text-align: center;
  cursor: pointer;
}

.toggle input:checked + span,
.rating-option input:checked + span {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.toggle input:focus-visible + span,
.rating-option input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.rating {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.25rem;
}

.rating-option span {
  padding: 0.75rem 0;
  white-space: nowrap;
}

.room-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem;
  border-radius: 0.5rem;
  background: var(--surface);
}

.room-card .muted {
  font-size: 0.875rem;
}

.new-room {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem;
  border-radius: 0.5rem;
  background: var(--surface);
}

.room-results {
  list-style: none;
  margin: 0;
  padding: 0;
}

.room-results .result {
  display: block;
  width: 100%;
  padding: 0.6rem 0.25rem;
  border-bottom: 1px solid var(--surface);
  border-radius: 0;
  background: none;
  color: var(--text);
  text-align: left;
}

.room-results .result .muted {
  display: block;
  font-size: 0.875rem;
}

.room-results .result.new {
  color: var(--accent);
}

/* Saving stays in reach while scrolling the form. */
.save-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem 0;
  background: var(--background);
}

.delete-form {
  margin-top: 1rem;
}

/* Noch einordnen and the Comparison screen */

.plain-fieldset {
  margin: 0;
  padding: 0;
  border: none;
}

.unplaced-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.unplaced-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--surface);
}

.unplaced-list .muted {
  font-size: 0.875rem;
}

a.button.small-button {
  padding: 0.4rem 0.75rem;
  font-size: 0.875rem;
  white-space: nowrap;
}

.comparison-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Two cards side by side, also on a phone. */
.comparison-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.comparison-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-height: 10rem;
  padding: 1rem 0.75rem;
  border: 2px solid var(--accent);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  overflow-wrap: anywhere;
}

.comparison-card strong {
  font-size: 1.1rem;
}

.comparison-card .muted {
  font-size: 0.875rem;
}

.next-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* The Ranking */

.player-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-bottom: 1rem;
}

.player-tabs [aria-current='page'] {
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

.ranking-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.5rem 1rem;
  margin-bottom: 1rem;
}

.ranking-filters label {
  display: flex;
  flex-direction: column;
  font-size: 0.875rem;
  color: var(--muted);
}

.ranking-filters label.checkbox {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  padding-bottom: 0.4rem;
}

.ranking-filters select {
  padding: 0.4rem;
  font-size: 1rem;
  border: 1px solid var(--muted);
  border-radius: 0.5rem;
  background: var(--background);
  color: var(--text);
}

.ranking-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.star-heading {
  margin: 1.5rem 0 0.25rem;
  font-weight: 600;
  color: var(--muted);
}

.ranking-row {
  display: flex;
  align-items: start;
  gap: 0.5rem;
  padding: 0.6rem 0.25rem;
  border-bottom: 1px solid var(--surface);
  background: var(--background);
}

/* A Room outside its star group. */
.ranking-row.outside {
  background: var(--surface);
  border-left: 3px solid var(--accent);
}

.ranking-row .place {
  min-width: 2.5rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.ranking-room {
  flex: 1;
  min-width: 0;
}

.ranking-room .muted {
  font-size: 0.875rem;
}

.outside-rating {
  font-weight: 600;
  color: var(--accent);
}

/* Big enough to grab on a phone; dragging only starts here, so the list still scrolls. */
.drag-handle {
  padding: 0 0.5rem;
  cursor: grab;
  color: var(--muted);
  touch-action: none;
  user-select: none;
}

.sortable-ghost {
  opacity: 0.4;
}

@media (min-width: 48rem) {
  main {
    padding: 2rem;
  }

  /* Pages with a table, like the Log. */
  main.wide {
    max-width: 75rem;
  }

  .log-cards {
    display: none;
  }

  .log-table {
    display: table;
  }
}
