:root {
  color-scheme: light;
  --bg: #f5f5f4;
  --panel: #ffffff;
  --ink: #333333;
  --muted: #646569;
  --line: #dedfdd;
  --primary: #397761;
  --primary-dark: #316653;
  --accent: #ba4a52;
  --gravel: #c9653d;
  --danger: #ba4a52;
  --warning-bg: #fff5dd;
  --warning-line: #e6bc66;
  --shadow: 0 3px 14px rgba(33, 43, 37, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Open Sans", Arial, sans-serif;
}

button,
input {
  font: inherit;
}

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

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: end;
  padding: 24px 0 26px;
  border-bottom: 3px solid var(--primary);
}

.hero-brand {
  display: flex;
  gap: 18px;
  align-items: center;
  min-width: 0;
}

.club-logo {
  width: 76px;
  height: 76px;
  flex: 0 0 auto;
  object-fit: contain;
}

.hero-copy {
  min-width: 0;
}

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

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

h1 {
  max-width: 780px;
  margin-bottom: 12px;
  font-size: clamp(2.3rem, 5vw, 4.8rem);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 6px;
  font-size: 1.1rem;
}

.intro {
  max-width: 680px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.6;
}

.hero-actions,
.data-actions,
.with-action {
  display: flex;
  gap: 10px;
  align-items: center;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.controls,
.tips,
.output {
  padding: 22px;
}

.tips {
  position: sticky;
  top: 18px;
}

.tips p,
.section-title p,
.hint {
  color: var(--muted);
  line-height: 1.55;
}

.section-title {
  margin-bottom: 16px;
}

.section-title.with-action {
  justify-content: space-between;
  margin-top: 24px;
}

.section-title.with-action > div {
  min-width: 0;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 700;
}

input[type="date"],
input[type="time"],
input[type="number"],
input[type="text"] {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
}

input:focus {
  border-color: var(--primary);
  outline: 3px solid rgba(57, 119, 97, 0.16);
}

.button,
.file-button {
  display: inline-flex;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 6px;
  align-items: center;
  justify-content: center;
  padding: 0 15px;
  cursor: pointer;
  font-weight: 800;
  white-space: nowrap;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

#download-ics[hidden] {
  display: none;
}

#download-ics {
  gap: 8px;
}

.file-button.disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.primary {
  background: var(--primary);
  color: #fff;
}

.primary:hover {
  background: var(--primary-dark);
}

.secondary,
.file-button {
  border-color: rgba(57, 119, 97, 0.25);
  background: #edf4f0;
  color: var(--primary-dark);
}

.ghost {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.danger {
  border-color: rgba(186, 74, 82, 0.3);
  background: #fff0f0;
  color: var(--danger);
}

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

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

.file-button input {
  display: none;
}

.players-list {
  display: grid;
  gap: 12px;
}

.player-card {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  padding: 14px;
}

.player-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.icon-button {
  width: 38px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--danger);
  cursor: pointer;
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1;
}

.hint {
  margin: 7px 0 0;
  font-size: 0.8rem;
}

.data-actions {
  flex-wrap: wrap;
  margin-top: 18px;
}

.share-box p {
  margin-bottom: 14px;
}

.share-actions {
  display: grid;
  gap: 10px;
}

.share-actions .button {
  width: 100%;
}

.participant-links {
  margin-top: 20px;
}

.participant-links[hidden],
.schedule-filter[hidden] {
  display: none;
}

.participant-links h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

#participant-link-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

#participant-link-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

#participant-link-list a {
  overflow-wrap: anywhere;
}

.schedule-filter {
  min-width: 190px;
}

.schedule-filter select {
  width: 100%;
  height: 44px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
}

.planning-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.planning-menu {
  position: relative;
  z-index: 5;
}

.planning-menu > summary {
  display: flex;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--primary-dark);
  cursor: pointer;
  list-style: none;
}

.planning-menu > summary::-webkit-details-marker {
  display: none;
}

.planning-menu > summary:hover {
  background: #edf4f0;
}

.planning-menu > summary:focus-visible {
  outline: 3px solid rgba(57, 119, 97, 0.2);
  outline-offset: 2px;
}

.planning-menu > summary svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.planning-menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  display: none;
  width: min(320px, calc(100vw - 48px));
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 14px;
}

.planning-menu[open] .planning-menu-panel {
  display: grid;
}

.planning-menu-panel .button {
  width: 100%;
}

.divider {
  height: 1px;
  margin: 20px 0;
  background: var(--line);
}

.output {
  margin-top: 18px;
}

.warnings {
  margin: 0 0 16px;
  border: 1px solid var(--warning-line);
  border-radius: 8px;
  background: var(--warning-bg);
  padding: 12px 14px;
  color: #754048;
}

.warnings ul {
  margin: 0;
  padding-left: 20px;
}

.schedule-empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #edf4f0;
  color: var(--primary-dark);
  font-size: 0.78rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

td {
  line-height: 1.45;
}

.date-cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.date-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ics-download {
  display: inline-flex;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  background: #edf4f0;
  color: var(--primary-dark);
  cursor: pointer;
  padding: 0;
}

.ics-download:hover {
  background: #dcebe3;
  color: var(--primary);
}

.ics-download svg,
.ics-calendar-icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ics-download:focus-visible {
  outline: 3px solid rgba(57, 119, 97, 0.25);
  outline-offset: 2px;
}

.status {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.8rem;
  font-weight: 800;
}

.status.ok {
  background: #edf4f0;
  color: var(--primary-dark);
}

.status.short {
  background: #fff0f0;
  color: #8d3841;
}

.stats {
  margin-top: 22px;
}

.stats h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.stats table {
  min-width: 420px;
}

.app-shell.read-only .hero {
  display: block;
  padding: 4px 0 22px;
}

.app-shell.read-only .eyebrow,
.app-shell.read-only .intro,
.app-shell.read-only .hero-actions,
.app-shell.read-only .layout {
  display: none;
}

.app-shell.read-only h1 {
  max-width: 100%;
  margin: 0;
  font-size: clamp(1.7rem, 5vw, 3rem);
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.app-shell.read-only .output {
  margin-top: 0;
}

.app-shell.read-only .output .section-title {
  margin-top: 0;
}

.app-shell.read-only .output .section-title h2 {
  display: none;
}

.app-shell.read-only .output .section-title.with-action > div:first-child {
  display: none;
}

.app-shell.read-only .output .planning-actions {
  width: 100%;
  margin-left: 0;
}

.app-shell.read-only .output .planning-actions .schedule-filter {
  min-width: 0;
  flex: 1 1 auto;
}

.app-shell.read-only .public-schedule {
  min-width: 0;
  table-layout: fixed;
}

.app-shell.read-only .public-schedule th:first-child {
  width: 34%;
}

.app-shell.read-only .public-schedule td:nth-child(2) {
  overflow-wrap: anywhere;
}

.scheduled-players {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.scheduled-players li {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #edf4f0;
  color: var(--primary-dark);
  padding: 4px 9px;
}

.app-shell.read-only .public-schedule .date-cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.absence-details {
  position: relative;
}

.absence-details summary {
  display: inline-flex;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-radius: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-weight: 700;
  list-style: none;
}

.absence-details summary::-webkit-details-marker {
  display: none;
}

.absence-details summary span {
  display: inline-flex;
  width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.absence-popover {
  position: absolute;
  z-index: 2;
  top: calc(100% + 6px);
  right: 0;
  width: max-content;
  min-width: 170px;
  max-width: min(260px, calc(100vw - 48px));
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow);
  padding: 12px;
}

.absence-popover ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.app-shell.read-only .public-schedule tr.played td {
  background: #fff0f0;
  color: var(--accent);
}

.app-shell.read-only .public-schedule .date-cell > span {
  border-radius: 5px;
  background: #edf4f0;
  color: var(--primary-dark);
  padding: 4px 8px;
}

.app-shell.read-only .public-schedule tr.played .date-cell > span,
.app-shell.read-only .public-schedule tr.played .ics-download {
  background: #fff0f0;
  color: var(--accent);
}

@media (max-width: 900px) {
  .hero,
  .layout {
    grid-template-columns: 1fr;
  }

  .hero-actions {
    justify-content: stretch;
  }

  .hero-actions .button {
    flex: 1;
  }

  .tips {
    position: static;
  }
}

@media (max-width: 680px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
  }

  .app-shell.read-only {
    width: min(100% - 16px, 1180px);
    padding-top: 14px;
  }

  .hero-brand {
    gap: 12px;
  }

  .club-logo {
    width: 54px;
    height: 54px;
  }

  h1 {
    font-size: 2.35rem;
  }

  .controls,
  .tips,
  .output {
    padding: 16px;
  }

  .app-shell.read-only .output {
    padding: 12px;
  }

  .app-shell.read-only h1 {
    font-size: clamp(1.5rem, 7vw, 2.25rem);
  }

  .app-shell.read-only .public-schedule th,
  .app-shell.read-only .public-schedule td {
    padding: 10px 6px;
  }

  .app-shell.read-only .public-schedule {
    display: block;
  }

  .app-shell.read-only .public-schedule thead {
    display: none;
  }

  .app-shell.read-only .public-schedule tbody {
    display: grid;
    gap: 12px;
  }

  .app-shell.read-only .public-schedule tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "date" "players";
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    padding: 0 14px 12px;
  }

  .app-shell.read-only .public-schedule td {
    border: 0;
    padding: 0;
    background: transparent;
    color: inherit;
  }

  .app-shell.read-only .public-schedule td:first-child {
    grid-area: date;
    align-self: stretch;
    margin: 0 -14px;
    border-radius: 5px 5px 0 0;
    background: var(--primary);
    color: #fff;
    font-size: 1rem;
    padding: 6px 12px;
  }

  .app-shell.read-only .public-schedule .date-cell > span {
    border-radius: 0;
    background: transparent;
    color: inherit;
    padding: 0;
  }

  .app-shell.read-only .public-schedule .date-cell .ics-download {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
    border-radius: 4px;
    background: #fff;
    color: var(--primary-dark);
  }

  .app-shell.read-only .public-schedule tr.played .date-cell {
    background: var(--gravel);
    color: #fff;
  }

  .app-shell.read-only .public-schedule tr.played .date-cell > span {
    background: transparent;
    color: inherit;
  }

  .app-shell.read-only .public-schedule tr.played .date-cell .ics-download {
    background: #fff;
    color: var(--gravel);
  }

  .app-shell.read-only .public-schedule td:nth-child(2) {
    grid-area: players;
  }

  .app-shell.read-only .public-schedule tr.played {
    border-color: rgba(186, 74, 82, 0.35);
    background: #fff0f0;
  }

  .app-shell.read-only .public-schedule tr.played td {
    background: transparent;
    color: var(--accent);
  }

  .app-shell.read-only .public-schedule tr.played .scheduled-players li {
    border-color: rgba(186, 74, 82, 0.25);
    background: #fff;
    color: var(--accent);
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  .section-title.with-action,
  .data-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .output > .section-title.with-action {
    align-items: center;
    flex-direction: row;
  }

  .planning-actions {
    min-width: 0;
    flex: 1 1 auto;
    justify-content: flex-end;
    gap: 8px;
  }

  .planning-actions .schedule-filter {
    min-width: 0;
    flex: 1 1 auto;
  }

  .button,
  .file-button {
    width: 100%;
  }
}
