:root {
  color-scheme: light;
  --bg: #f7f5ef;
  --surface: #ffffff;
  --ink: #1f2933;
  --muted: #667085;
  --line: #d9dee7;
  --line-strong: #aeb8c8;
  --green: #167a45;
  --green-soft: #dff4e8;
  --red: #b42318;
  --red-soft: #ffe4e2;
  --blue: #275a8a;
  --focus: #111827;
  --shadow: 0 18px 45px rgba(31, 41, 51, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  line-height: 1.4;
}

button,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.slot-picker {
  min-height: calc(100vh - 80px);
  display: grid;
  align-content: center;
  gap: 28px;
}

.picker-copy {
  max-width: 780px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2.1rem, 5vw, 4.6rem);
  line-height: 1.02;
  letter-spacing: 0;
}

.schedule-header h1 {
  font-size: clamp(1.9rem, 4vw, 3.4rem);
}

.date-range {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.25rem);
}

.picker-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 340px));
  gap: 16px;
}

.time-choice {
  min-height: 132px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--ink);
  text-align: left;
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease;
}

.time-choice:hover,
.time-choice:focus-visible {
  border-color: var(--blue);
  box-shadow: 0 22px 50px rgba(39, 90, 138, 0.2);
  transform: translateY(-2px);
}

.time-choice span {
  display: block;
  font-size: 2rem;
  font-weight: 850;
  letter-spacing: 0;
}

.time-choice small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.96rem;
}

.schedule-view {
  display: grid;
  gap: 16px;
}

.schedule-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.text-button,
.secondary-button {
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 750;
}

.text-button {
  margin-bottom: 16px;
  padding: 0 14px;
}

.secondary-button {
  padding: 0 16px;
}

.text-button:hover,
.secondary-button:hover,
.text-button:focus-visible,
.secondary-button:focus-visible {
  border-color: var(--blue);
}

.status-counts {
  display: flex;
  gap: 10px;
  color: var(--muted);
  white-space: nowrap;
}

.status-counts span {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.instructions-panel {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  background: var(--surface);
}

.instructions-panel h2 {
  margin: 0;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.instructions-panel ol {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 1.25rem;
  color: #344054;
}

.instructions-panel li {
  padding-left: 2px;
}

.instructions-panel strong {
  color: var(--ink);
  font-weight: 850;
}

.notice,
.error-state {
  padding: 12px 14px;
  border: 1px solid #e4b55f;
  border-radius: 8px;
  background: #fff6df;
  color: #654310;
}

.error-state {
  border-color: #f3a29c;
  background: #fff1f0;
  color: var(--red);
}

.save-state {
  min-height: 20px;
  color: var(--muted);
  font-size: 0.92rem;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.legend-item {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 8px;
  font-weight: 800;
}

.legend-open {
  background: var(--green-soft);
  color: var(--green);
}

.legend-claimed {
  background: var(--red-soft);
  color: var(--red);
}

.loading-state {
  min-height: 120px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.schedule-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.schedule-table th,
.schedule-table td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  vertical-align: top;
}

.schedule-table th:last-child,
.schedule-table td:last-child {
  border-right: 0;
}

.schedule-table tr:last-child td {
  border-bottom: 0;
}

.schedule-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 9px;
  background: #e9eef5;
  color: #344054;
  font-size: 0.72rem;
  letter-spacing: 0;
  text-transform: uppercase;
  text-align: left;
}

.schedule-table td {
  padding: 6px;
  background: #fff;
}

.schedule-table tr:nth-child(5n + 1) td {
  border-top: 2px solid var(--line-strong);
}

.week-col {
  width: 68px;
}

.day-col {
  width: 96px;
}

.date-col {
  width: 88px;
}

.week-cell {
  color: var(--blue);
  font-weight: 850;
}

.day-cell,
.date-cell {
  color: #344054;
  font-weight: 720;
}

.slot-editor {
  min-width: 180px;
  display: grid;
  grid-template-columns: 82px minmax(120px, 1fr);
  gap: 6px;
}

.status-select {
  width: 82px;
  height: 32px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 850;
}

.status-select.open {
  background: var(--green);
}

.status-select.claimed {
  background: var(--red);
}

.status-select option.open {
  background: var(--green);
  color: #fff;
}

.status-select option.claimed {
  background: var(--red);
  color: #fff;
}

.teams-text {
  width: 100%;
  height: 42px;
  overflow: hidden;
  resize: none;
  padding: 5px 7px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink);
  font-size: 0.82rem;
  line-height: 1.16;
}

.teams-text:focus,
.status-select:focus {
  outline: 3px solid rgba(39, 90, 138, 0.24);
  outline-offset: 1px;
}

.teams-text[readonly] {
  border-color: var(--line);
  background: #f5f7fa;
  color: var(--muted);
  cursor: default;
}

.slot-editor.needs-teams .teams-text {
  border-color: var(--red);
  background: #fff7f6;
}

.slot-editor.needs-teams .teams-text:focus {
  outline-color: rgba(180, 35, 24, 0.24);
}

.validation-message {
  grid-column: 2;
  color: var(--red);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 20px, 1480px);
    padding: 20px 0 32px;
  }

  .slot-picker {
    min-height: calc(100vh - 40px);
  }

  .picker-actions {
    grid-template-columns: 1fr;
  }

  .schedule-header {
    display: grid;
  }

  .header-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .status-counts {
    white-space: normal;
  }

  .status-counts span,
  .secondary-button {
    flex: 1;
  }

  .instructions-panel {
    padding: 12px 13px;
  }

  .table-wrap {
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
  }

  .schedule-table,
  .schedule-table tbody,
  .schedule-table tr,
  .schedule-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .schedule-table {
    font-size: 0.84rem;
  }

  .schedule-table thead {
    display: none;
  }

  .schedule-table tbody {
    display: grid;
    gap: 10px;
  }

  .schedule-table tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    overflow: hidden;
  }

  .schedule-table tr::before {
    content: attr(data-week) " • " attr(data-day) ", " attr(data-date);
    display: block;
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
    background: #e9eef5;
    color: #344054;
    font-weight: 850;
  }

  .schedule-table th,
  .schedule-table td {
    border: 0;
  }

  .schedule-table tr:nth-child(5n + 1) td {
    border-top: 0;
  }

  .week-cell,
  .day-cell,
  .date-cell {
    display: none !important;
  }

  .court-cell {
    display: grid !important;
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 8px;
    align-items: start;
    padding: 7px 8px !important;
    border-bottom: 1px solid var(--line) !important;
  }

  .schedule-table tr .court-cell:last-child {
    border-bottom: 0 !important;
  }

  .court-cell::before {
    content: attr(data-court-label);
    padding-top: 8px;
    color: var(--blue);
    font-size: 0.76rem;
    font-weight: 850;
    text-transform: uppercase;
  }

  .slot-editor {
    min-width: 0;
    grid-template-columns: 82px minmax(0, 1fr);
  }
}

@media (max-width: 460px) {
  .app-shell {
    width: min(100% - 14px, 1480px);
  }

  .schedule-header h1 {
    font-size: 1.65rem;
  }

  .date-range {
    font-size: 0.94rem;
  }

  .status-counts {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .instructions-panel {
    gap: 7px;
    font-size: 0.92rem;
  }

  .instructions-panel ol {
    padding-left: 1.1rem;
  }

  .court-cell {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .court-cell::before {
    padding-top: 0;
  }
}
