:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --panel: #ffffff;
  --panel-strong: #fafafc;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: #d2d2d7;
  --brand: #16883a;
  --brand-strong: #106d30;
  --brand-dark: #050807;
  --viper: #9bff3f;
  --blue: #0071e3;
  --blue-soft: #edf4ff;
  --danger: #d92d20;
  --danger-bg: #fff1f0;
  --ok-bg: #e8f6ef;
  --wait-bg: #fff5d6;
  --radius-card: 8px;
  --radius-pill: 9999px;
  font-family: "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:active:not(:disabled) {
  transform: scale(0.98);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(0, 113, 227, 0.32);
  outline-offset: 3px;
}

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

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

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 58px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  margin: 0 calc(50% - 50vw) 30px;
  padding: 8px max(16px, calc((100vw - 1120px) / 2));
  background: rgba(250, 250, 252, 0.78);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}

.topbar-actions {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

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

.brand-mark {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 8px;
  background: var(--brand);
  overflow: hidden;
}

button.brand-mark:hover {
  background: var(--brand-strong);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
}

.brand h1 {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.12;
  font-weight: 650;
}

.brand p,
.muted {
  margin: 0;
  color: var(--muted);
}

.brand p {
  font-size: 0.86rem;
  line-height: 1.2;
}

.login {
  min-height: 100vh;
  display: grid;
  align-items: center;
  padding: 28px 0;
}

.login-panel,
.admin-panel,
.profile-panel,
.session,
.empty-state,
.notice {
  background: var(--panel);
  border-radius: var(--radius-card);
}

.login-panel {
  width: min(440px, 100%);
  margin: 0 auto;
  padding: 30px;
}

.login-panel h1,
.section-title,
.admin-panel h2,
.profile-panel h2 {
  margin: 0 0 8px;
  color: var(--text);
  font-weight: 650;
  line-height: 1.16;
}

.section-title {
  font-size: 1.7rem;
}

.login-panel h1,
.admin-panel h2,
.profile-panel h2 {
  font-size: 1.28rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.settings-layout {
  width: min(760px, 100%);
  display: grid;
  gap: 14px;
}

.admin-panel .form-grid {
  grid-template-columns: 1fr;
}

.field {
  display: grid;
  gap: 7px;
}

.field.full,
.button-row.full {
  grid-column: 1 / -1;
}

label {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
}

input,
textarea,
select {
  width: 100%;
  min-height: 44px;
  padding: 11px 13px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: var(--radius-card);
  background: var(--panel);
  color: var(--text);
}

textarea {
  min-height: 92px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--blue);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.btn {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--blue);
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  background: rgba(0, 113, 227, 0.08);
}

.btn.primary {
  background: var(--brand);
  color: #ffffff;
}

.btn.primary:hover {
  background: var(--brand-strong);
}

.btn.danger {
  background: rgba(217, 45, 32, 0.08);
  color: var(--danger);
}

.btn.danger:hover {
  background: rgba(217, 45, 32, 0.14);
}

.btn.ghost {
  color: var(--blue);
}

.btn.small {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.84rem;
}

.tabs {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.06);
}

.view-tabs {
  flex: 0 1 auto;
}

.tab {
  min-height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
}

.tab.active {
  background: var(--panel);
  color: var(--text);
}

.icon-tab {
  width: 42px;
  min-width: 42px;
  padding: 0;
  display: grid;
  place-items: center;
}

.tab-icon {
  width: 20px;
  height: 20px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.layout > section {
  min-width: 0;
}

.side-stack {
  display: grid;
  gap: 16px;
  position: sticky;
  top: 82px;
}

.admin-panel,
.profile-panel {
  padding: 22px;
}

.calendar-sync {
  margin: 30px 0 0;
}

.calendar-sync details {
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  padding-top: 15px;
}

.calendar-sync summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
}

.calendar-sync-body {
  display: grid;
  gap: 11px;
  padding-top: 13px;
}

.calendar-link-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}

.calendar-link-row input {
  color: var(--muted);
  font-size: 0.88rem;
}

.calendar-steps {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 0.9rem;
}

.calendar-steps li + li {
  margin-top: 4px;
}

.session-list {
  display: grid;
  gap: 16px;
}

.player-list {
  display: grid;
  gap: 10px;
}

.player-row {
  width: 100%;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-card);
  background: var(--panel);
  color: var(--text);
  text-align: left;
}

.player-row.active {
  outline: 2px solid rgba(22, 136, 58, 0.24);
  background: #f4fbf6;
}

.player-row span {
  min-width: 0;
}

.player-row strong,
.player-row small {
  display: block;
}

.player-row small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
}

.player-row > span:last-child {
  flex: 0 0 auto;
  text-align: right;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.stat-grid div {
  min-height: 70px;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 10px;
  border-radius: var(--radius-card);
  background: var(--bg);
}

.stat-grid strong {
  font-size: 1.45rem;
  line-height: 1;
}

.stat-grid span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.8rem;
}

.result-history {
  margin-top: 20px;
}

.result-history h3 {
  margin: 0 0 10px;
  font-size: 0.96rem;
}

.result-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.result-row span {
  min-width: 0;
}

.result-row strong,
.result-row small {
  display: block;
}

.result-row small {
  color: var(--muted);
  font-size: 0.78rem;
}

.result-lineup {
  margin-top: 4px;
  line-height: 1.3;
}

.result-row > span:last-child {
  flex: 0 0 auto;
  text-align: right;
}

.list-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin: 10px 0 18px;
}

.session {
  padding: 24px;
}

.session-summary {
  min-width: 0;
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 20px;
  gap: 20px;
  align-items: start;
  list-style: none;
  cursor: pointer;
}

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

.session-summary-body {
  min-width: 0;
}

.expand-indicator {
  width: 10px;
  height: 10px;
  margin-top: 10px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.16s ease;
}

.session[open] .expand-indicator {
  transform: rotate(225deg);
}

.session.cancelled {
  background: #fff7f7;
}

.session-grid {
  min-width: 0;
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  margin-top: 18px;
}

.session-body {
  min-width: 0;
}

.date-tile {
  width: 76px;
  height: 92px;
  display: grid;
  place-items: center;
  align-content: center;
  border-radius: var(--radius-card);
  background: var(--brand-dark);
  color: #f5f5f7;
  box-shadow: 0 8px 22px rgba(5, 8, 7, 0.16);
}

.date-tile strong {
  font-size: 2.2rem;
  line-height: 0.98;
  font-weight: 760;
}

.date-tile span {
  color: rgba(245, 245, 247, 0.76);
  font-size: 0.72rem;
  font-weight: 650;
  text-transform: uppercase;
}

.session-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.session h3 {
  margin: 0 0 6px;
  color: var(--text);
  font-size: 1.35rem;
  line-height: 1.18;
  font-weight: 650;
}

.session-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  color: var(--muted);
  font-size: 0.94rem;
}

.badge {
  min-height: 28px;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  padding: 0 11px;
  border-radius: var(--radius-pill);
  background: var(--blue-soft);
  color: #0057b7;
  font-size: 0.82rem;
  font-weight: 650;
  white-space: nowrap;
}

.badge.attending {
  background: var(--ok-bg);
  color: #0d6931;
}

.badge.waitlisted {
  background: var(--wait-bg);
  color: #8a5a00;
}

.badge.cancelled {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge.declined {
  background: #eef0f3;
  color: #515b68;
}

.progress {
  height: 7px;
  margin: 18px 0 10px;
  border-radius: var(--radius-pill);
  background: #e8e8ed;
  overflow: hidden;
}

.progress > span {
  width: var(--value, 0%);
  max-width: 100%;
  height: 100%;
  display: block;
  border-radius: inherit;
  background: var(--brand);
}

.people {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

@media (max-width: 1100px) {
  .people {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.people-group {
  min-width: 0;
  padding: 12px;
  border-radius: var(--radius-card);
  background: var(--bg);
}

.people-group h4 {
  margin: 0 0 8px;
  font-size: 0.9rem;
  font-weight: 650;
}

.people-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.people-list small {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.match-list,
.match-editor {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.match-list h4,
.match-editor h4 {
  margin: 0 0 8px;
  font-size: 0.9rem;
  font-weight: 650;
}

.match-card,
.match-draft {
  padding: 12px;
  border-radius: var(--radius-card);
  background: var(--bg);
}

.match-card + .match-card,
.match-draft + .match-draft {
  margin-top: 8px;
}

.match-draft-list {
  display: grid;
  gap: 8px;
}

.match-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.match-score {
  font-weight: 700;
  white-space: nowrap;
}

.match-teams {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.match-teams em {
  color: var(--text);
  font-style: normal;
  font-weight: 650;
}

.match-reporter {
  margin: 8px 0 0;
  font-size: 0.82rem;
}

.result-form {
  display: grid;
  grid-template-columns: minmax(0, 96px) minmax(0, 96px) auto;
  gap: 8px;
  align-items: end;
  margin-top: 10px;
}

.result-form label {
  display: grid;
  gap: 4px;
}

.result-form input {
  min-height: 38px;
  padding: 8px 10px;
}

.ranking-list {
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--radius-card);
  background: var(--bg);
}

.ranking-list h4 {
  margin: 0 0 8px;
  font-size: 0.9rem;
  font-weight: 650;
}

.ranking-list ol {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ranking-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.ranking-list small {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.match-editor-head,
.match-draft-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.match-draft-head {
  align-items: center;
  margin-bottom: 10px;
}

.match-draft-head > div {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.match-slot-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.session-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.substitute-session-controls {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.substitute-session-controls h4 {
  margin: 0 0 8px;
  font-size: 0.9rem;
  font-weight: 650;
}

.substitute-session-list {
  display: grid;
  gap: 8px;
}

.substitute-session-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-card);
  background: var(--bg);
  color: var(--text);
}

.substitute-session-row strong,
.substitute-session-row small {
  display: block;
}

.substitute-session-row small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
}

.notice,
.empty-state {
  padding: 14px 16px;
}

.notice {
  margin: 0 0 16px;
  border: 1px solid #bfe7cf;
  background: #eef8f3;
}

.notice.error {
  border-color: #ffc6c2;
  background: var(--danger-bg);
  color: var(--danger);
}

.member-admin {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.choice-block {
  margin-top: 16px;
}

.choice-block h3 {
  margin: 0 0 8px;
  font-size: 0.96rem;
  font-weight: 650;
}

.settings-hint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.check-list {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
  padding-right: 2px;
}

.check-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  padding: 10px;
  border-radius: var(--radius-card);
  background: var(--bg);
  color: var(--text);
  font-size: 0.92rem;
}

.check-row input {
  width: 18px;
  min-height: 18px;
  margin: 2px 0 0;
  padding: 0;
}

.check-row span,
.admin-list span {
  min-width: 0;
}

.check-row strong,
.admin-list strong {
  display: block;
}

.check-row small,
.admin-list small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
}

.admin-list {
  display: grid;
  gap: 8px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.admin-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border-radius: var(--radius-card);
  background: var(--bg);
}

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

  .side-stack {
    position: static;
  }
}

@media (max-width: 700px) {
  .app-shell {
    width: 100%;
    padding: 0 12px 48px;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    margin: 0 0 22px;
    padding: 8px 0;
  }

  .topbar-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
  }

  .view-tabs {
    width: auto;
    max-width: 100%;
  }

  .tabs {
    max-width: 100%;
  }

  .tab {
    padding: 0 10px;
    font-size: 0.86rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .icon-tab {
    width: 38px;
    min-width: 38px;
    padding: 0;
  }

  .topbar-actions .btn {
    width: auto;
    min-height: 36px;
    padding: 0 10px;
  }

  .topbar .brand {
    min-width: 0;
  }

  .topbar .brand h1,
  .topbar .brand p {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .login-panel {
    padding: 24px;
  }

  .form-grid,
  .people,
  .match-slot-grid,
  .match-teams,
  .result-form {
    grid-template-columns: 1fr;
  }

  .list-header,
  .session-head,
  .match-editor-head {
    align-items: stretch;
    flex-direction: column;
  }

  .section-title {
    font-size: 1.45rem;
  }

  .session {
    padding: 16px;
    max-width: 100%;
    overflow: hidden;
  }

  .session-summary {
    grid-template-columns: 58px minmax(0, 1fr) 18px;
    gap: 12px;
  }

  .session-summary .date-tile {
    width: 58px;
    height: 66px;
    min-height: 66px;
    display: grid;
    padding: 0;
    grid-template-columns: 1fr;
    justify-content: center;
    gap: 0;
  }

  .session-summary .date-tile strong {
    font-size: 1.62rem;
  }

  .session-summary .date-tile span {
    font-size: 0.62rem;
  }

  .session-grid {
    grid-template-columns: 1fr;
    gap: 14px;
    min-width: 0;
  }

  .date-tile {
    width: 100%;
    max-width: 100%;
    height: auto;
    min-height: 62px;
    grid-template-columns: auto auto auto;
    justify-content: start;
    gap: 8px;
    padding: 10px 14px;
  }

  .date-tile strong {
    font-size: 1.7rem;
  }

  .session-actions .btn,
  .button-row .btn,
  .calendar-link-row .btn {
    width: 100%;
  }

  .admin-list li,
  .player-row,
  .result-row,
  .substitute-session-row,
  .calendar-link-row {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .player-row > span:last-child,
  .result-row > span:last-child {
    text-align: left;
  }
}

@media (max-width: 420px) {
  body {
    font-size: 15px;
  }

  .topbar .brand p {
    display: none;
  }

  .session h3 {
    font-size: 1.18rem;
  }

  .admin-panel,
  .profile-panel {
    padding: 18px;
  }
}

@media (max-width: 360px) {
  .topbar {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 8px;
  }

  .topbar-actions {
    justify-content: flex-start;
  }
}
