:root {
  --bg: #f5f7f4;
  --panel: #ffffff;
  --ink: #152119;
  --muted: #647067;
  --line: #dde5dc;
  --primary: #176b3a;
  --primary-dark: #0f4b2a;
  --accent: #f0b429;
  --danger: #b42318;
  --danger-bg: #fff0ee;
  --shadow: 0 18px 60px rgba(19, 36, 24, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

a {
  color: var(--primary);
  text-decoration: none;
}

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

button,
.button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  font-weight: 700;
  white-space: nowrap;
}

canvas,
img {
  max-width: 100%;
}

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

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

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  filter: grayscale(0.2);
}

.ghost {
  background: #eef3ee;
  color: var(--ink);
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 42px);
  background: rgba(245, 247, 244, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand,
.brand-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 900;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background:
    linear-gradient(90deg, transparent 48%, rgba(255,255,255,0.9) 48% 52%, transparent 52%),
    radial-gradient(circle at center, transparent 0 34%, rgba(255,255,255,0.9) 35% 38%, transparent 39%),
    linear-gradient(135deg, #176b3a, #0f4b2a);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.75), 0 8px 20px rgba(15, 75, 42, 0.22);
}

.ball-icon {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #152119 0 24%, transparent 25%),
    linear-gradient(36deg, transparent 38%, #152119 39% 46%, transparent 47%),
    linear-gradient(-36deg, transparent 38%, #152119 39% 46%, transparent 47%),
    #ffffff;
  border: 2px solid #152119;
  display: block;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.nav-links form {
  margin: 0;
}

.nav-links a {
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--ink);
}

.nav-links a.active {
  background: #e8efe7;
}

.user-chip,
.participant-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #dce8dc;
  color: var(--primary-dark);
  border: 2px solid #fff;
  font-weight: 900;
  object-fit: cover;
}

.avatar-sm {
  width: 30px;
  height: 30px;
  font-size: 0.75rem;
}

.avatar-md {
  width: 44px;
  height: 44px;
}

.avatar-lg {
  width: 72px;
  height: 72px;
  font-size: 1.25rem;
}

.avatar-xl {
  width: 118px;
  height: 118px;
  font-size: 2rem;
}

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

.auth-layout {
  min-height: calc(100vh - 64px);
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  align-items: center;
  gap: clamp(28px, 6vw, 84px);
}

.auth-copy {
  display: grid;
  gap: 22px;
}

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

h1 {
  max-width: 780px;
  margin-bottom: 0;
  font-size: clamp(2rem, 5vw, 4.75rem);
  line-height: 0.96;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

h2 {
  margin-bottom: 18px;
  font-size: 1.35rem;
}

h3 {
  margin-bottom: 0;
  font-size: 1.2rem;
}

.auth-copy p {
  max-width: 620px;
  color: var(--muted);
  font-size: 1.12rem;
  line-height: 1.6;
}

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

.mini-grid span,
.pill,
.badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: #fff;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.install-box {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
}

.install-app-button {
  min-width: 150px;
}

.install-app-message {
  margin: 0;
  max-width: 360px;
}

.panel,
.match-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-card {
  padding: clamp(22px, 4vw, 34px);
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
  color: var(--ink);
  padding: 12px 13px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(23, 107, 58, 0.12);
}

.auth-card,
.stack {
  display: grid;
  gap: 14px;
}

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

.hint {
  margin-bottom: 0;
  font-size: 0.9rem;
}

.alert {
  margin: 0;
  border-radius: 8px;
  background: var(--danger-bg);
  color: var(--danger);
  padding: 12px;
  font-weight: 700;
}

.success {
  margin: 0;
  border-radius: 8px;
  background: #e9f7ef;
  color: var(--primary-dark);
  padding: 12px;
  font-weight: 700;
}

.page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.page-head h1 {
  font-size: clamp(2rem, 4vw, 3.4rem);
}

.eyebrow {
  display: block;
  margin-bottom: 8px;
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 900;
  text-transform: uppercase;
}

.notice-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.notice-strip div {
  display: grid;
  gap: 5px;
  border-left: 4px solid var(--accent);
  background: #fff9e8;
  border-radius: 8px;
  padding: 14px;
}

.notice-strip span {
  color: var(--muted);
}

.sound-toggle {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  border: 0;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  padding: 12px 16px;
  box-shadow: 0 14px 30px rgba(16, 33, 22, 0.22);
  font-weight: 900;
  cursor: pointer;
}

.sound-toast {
  position: fixed;
  right: 16px;
  bottom: 74px;
  z-index: 49;
  display: grid;
  gap: 4px;
  max-width: min(360px, calc(100vw - 32px));
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: #fff9e8;
  color: var(--ink);
  padding: 14px 16px;
  box-shadow: 0 14px 30px rgba(16, 33, 22, 0.18);
}

.sound-toast span {
  color: var(--muted);
  font-size: 0.92rem;
}

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

.match-card {
  padding: 20px;
  display: grid;
  gap: 16px;
}

.match-card.cancelled {
  opacity: 0.72;
}

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

.badge.confirmed {
  background: #e9f7ef;
  color: var(--primary);
}

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

.badge.waiting {
  background: #fff9e8;
  color: #8a5a00;
}

.stats,
.actions,
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.stats span {
  background: #f3f7f2;
  border-radius: 8px;
  padding: 10px 12px;
}

.people {
  display: grid;
  gap: 5px;
  color: var(--muted);
  line-height: 1.5;
}

.people strong {
  color: var(--ink);
}

.absence-reason {
  flex: 1 1 240px;
  min-width: min(100%, 240px);
}

.presence-report {
  margin-bottom: 16px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.section-head h2 {
  margin-bottom: 0;
}

.compact-head {
  margin-bottom: 12px;
}

.date-filter {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.date-filter label {
  min-width: 150px;
}

.presence-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.65fr);
  gap: 14px;
  align-items: start;
}

.presence-list,
.absence-summary {
  display: grid;
  gap: 10px;
}

.presence-card {
  display: grid;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbf7;
  padding: 12px;
  line-height: 1.45;
}

.reserve-box {
  display: grid;
  gap: 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfdfb;
  padding: 14px;
}

.reserve-box p {
  margin: 4px 0 0;
}

.reserve-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(140px, 0.55fr) auto;
  gap: 10px;
  align-items: end;
}

.reserve-tag {
  display: inline-flex;
  border-radius: 999px;
  background: #eef3ee;
  color: var(--muted);
  padding: 2px 7px;
  font-size: 0.78rem;
  font-weight: 800;
}

.table-wrap.compact table {
  min-width: 360px;
}

.draft-box,
.draft-admin-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbf7;
  padding: 14px;
}

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

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

.draft-team {
  display: grid;
  gap: 8px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  padding: 12px;
}

.draft-roster {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.draft-roster span {
  border-radius: 999px;
  background: #edf4ec;
  color: var(--ink);
  padding: 6px 9px;
  font-size: 0.85rem;
  font-weight: 700;
}

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

.draft-actions form,
.draft-admin-card form {
  margin: 0;
}

.draft-admin-panel {
  margin-bottom: 16px;
  padding: 20px;
}

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

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

.draft-admin-form button {
  grid-column: 1 / -1;
}

.draft-history {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.rating-form {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 190px;
}

.rating-form select {
  min-width: 110px;
}

.rating-form button {
  padding-inline: 12px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}

.formation-panel,
.team-field-panel {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
  padding: 20px;
  overflow: hidden;
}

.team-field-panel {
  margin: 10px 0 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbf7;
}

.formation-copy {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.formation-copy h2 {
  margin-bottom: 0;
}

#formationCanvas,
.teamFormationCanvas {
  width: 100%;
  height: clamp(300px, 42vw, 540px);
  display: block;
  border-radius: 8px;
  background: #12351f;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1);
}

.teamFormationCanvas {
  height: clamp(240px, 34vw, 420px);
}

.dashboard-grid .panel,
section.panel {
  padding: 20px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

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

th {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
}

td form {
  display: inline-flex;
  margin: 0;
}

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

.account-form {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 18px;
  padding: 22px;
  align-items: start;
}

.profile-photo-box {
  display: grid;
  gap: 14px;
  justify-items: center;
  text-align: center;
}

.photo-cropper {
  width: 100%;
  display: grid;
  gap: 10px;
  justify-items: stretch;
}

.photo-cropper[hidden] {
  display: none;
}

.photo-crop-canvas {
  width: min(100%, 260px);
  aspect-ratio: 1;
  height: auto;
  justify-self: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f3f7f0;
}

.photo-cropper label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-weight: 700;
  text-align: left;
}

.photo-cropper input[type="range"] {
  width: 100%;
  accent-color: var(--green);
}

.crop-status {
  margin: 0;
}

.account-fields {
  padding: 0;
}

.check-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
}

.check-row input {
  width: auto;
}

.wide {
  grid-column: 1 / -1;
}

.empty {
  grid-column: 1 / -1;
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

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

  .auth-layout {
    align-items: start;
  }

  .auth-copy {
    max-width: 760px;
  }

  .notice-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .topbar,
  .page-head,
  .match-head {
    align-items: stretch;
    flex-direction: column;
  }

  .nav-links {
    flex-wrap: wrap;
  }

  .topbar {
    position: static;
  }

  .brand,
  .nav-links,
  .user-chip {
    width: 100%;
  }

  .nav-links a,
  .nav-links form,
  .nav-links button {
    flex: 1 1 auto;
  }

  .auth-layout,
  .match-grid,
  .dashboard-grid,
  .notice-strip,
  .draft-admin-grid,
  .draft-admin-form,
  .draft-teams,
  .presence-grid,
  .reserve-form,
  .account-form,
  .form-grid,
  .mini-grid {
    grid-template-columns: 1fr;
  }

  .shell {
    width: min(100% - 24px, 1180px);
    padding-top: 22px;
  }

  .auth-layout {
    align-items: start;
  }

  h1 {
    line-height: 1.02;
  }

  .actions button,
  .actions .button,
  .page-head .button {
    width: 100%;
  }

  .date-filter,
  .date-filter label,
  .date-filter button,
  .date-filter .button,
  .reserve-form button,
  .rating-form,
  .rating-form select,
  .rating-form button {
    width: 100%;
  }

  .row-actions {
    align-items: stretch;
  }

  .row-actions,
  .row-actions form,
  .row-actions a,
  .row-actions button {
    width: 100%;
  }
}

@media (max-width: 560px) {
  button,
  .button {
    min-height: 44px;
    padding-inline: 12px;
    white-space: normal;
    text-align: center;
  }

  .shell {
    width: min(100% - 16px, 1180px);
    padding: 18px 0 36px;
  }

  .panel,
  .match-card,
  .dashboard-grid .panel,
  section.panel,
  .form-grid,
  .account-form {
    padding: 14px;
  }

  .auth-card {
    padding: 18px;
  }

  .page-head h1,
  h1 {
    font-size: clamp(1.85rem, 12vw, 2.55rem);
    line-height: 1.04;
  }

  h2 {
    font-size: 1.18rem;
  }

  .participant-title {
    align-items: flex-start;
  }

  .avatar-lg {
    width: 58px;
    height: 58px;
  }

  .stats span,
  .pill,
  .badge {
    width: 100%;
  }

  .match-head .badge {
    width: fit-content;
    max-width: 100%;
  }

  .draft-head,
  .formation-copy,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .teamFormationCanvas,
  #formationCanvas {
    height: 260px;
  }

  table {
    min-width: 720px;
  }
}

@media (max-width: 380px) {
  .brand span:last-child {
    display: none;
  }

  .brand,
  .brand-row {
    width: auto;
  }

  .nav-links {
    gap: 8px;
  }

  .mini-grid span,
  .pill,
  .badge,
  .draft-roster span {
    font-size: 0.82rem;
  }

  table {
    min-width: 660px;
  }
}
