:root {
  --bg: #f3ede3;
  --paper: rgba(255, 252, 246, 0.96);
  --paper-strong: #fffdf9;
  --text: #261d16;
  --muted: #6c5b4f;
  --line: rgba(86, 60, 38, 0.12);
  --line-strong: rgba(86, 60, 38, 0.2);

  --green: #0f6a5b;
  --green-dark: #0a5145;
  --green-soft: #dff2ed;

  --copper: #b87333;
  --sand: #ece1d0;

  --danger: #b93a2f;
  --danger-soft: #fff1ef;

  --success-soft: #eefcf2;

  --shadow: 0 22px 60px rgba(38, 29, 22, 0.12);

  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(15, 106, 91, 0.14), transparent 26rem),
    radial-gradient(circle at bottom right, rgba(184, 115, 51, 0.1), transparent 22rem),
    linear-gradient(180deg, #f9f4ec 0%, var(--bg) 100%);
  font-family: "Segoe UI", Arial, sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.08) 1px, transparent 1px);
  background-size: 28px 28px;
  opacity: 0.18;
}

a {
  color: inherit;
}

main {
  width: min(1180px, calc(100% - 28px));
  margin: 28px auto 46px;
  display: grid;
  gap: 18px;
  position: relative;
  z-index: 1;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 16px 14px 0;
}

.topbar-inner {
  width: min(1180px, calc(100% - 4px));
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 252, 246, 0.84);
  backdrop-filter: blur(10px);
  box-shadow: 0 16px 40px rgba(38, 29, 22, 0.08);
}

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

.brand img {
  width: 58px;
  height: 58px;
  object-fit: contain;
  border-radius: 18px;
  background: linear-gradient(180deg, #fffdf9 0%, #f1e8da 100%);
  padding: 6px;
  box-shadow: inset 0 0 0 1px rgba(86, 60, 38, 0.08);
}

.brand .title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.15rem;
  letter-spacing: 0.06em;
  font-weight: 700;
  line-height: 1.1;
}

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

.btn,
.btn-form,
.btn-login {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.btn:hover,
.btn-form:hover,
.btn-login:hover {
  transform: translateY(-1px);
}

.btn-primary,
.btn-form.primary,
.btn-login {
  background: var(--green);
  color: #fff;
}

.btn-primary:hover,
.btn-form.primary:hover,
.btn-login:hover {
  background: var(--green-dark);
}

.btn-ghost,
.btn-form.secondary,
.btn-secondary {
  background: #f8f2e8;
  color: var(--text);
  border: 1px solid var(--line);
}

.btn-ghost:hover,
.btn-form.secondary:hover,
.btn-secondary:hover {
  background: #C2B49D;
}

.btn-form.danger2,
.menu-item.danger,
.pill.reset {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(185, 58, 47, 0.16);
}

.icon-btn {
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-size: 1.25rem;
}

.card,
.login-card,
.modal-card,
.card-pad {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  min-width: 0;
}

.card {
  padding: 22px;
}

.card-pad {
  padding: 18px 20px;
}

.section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  min-width: 0;
}

.section-title h1,
.section-title h2,
.login-card h2,
.card h1,
.card h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1;
  letter-spacing: 0.02em;
}

.subtle {
  color: var(--muted);
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  min-width: 0;
}

input,
select,
textarea,
.input-field {
  width: 100%;
  max-width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.88);
  color: var(--text);
  font-size: 1rem;
  min-width: 0;
}

input:focus,
select:focus,
textarea:focus,
.input-field:focus {
  outline: 2px solid rgba(15, 106, 91, 0.18);
  border-color: rgba(15, 106, 91, 0.35);
}

.linkish,
.forgot-link {
  background: none;
  border: 0;
  color: var(--green-dark);
  font-weight: 700;
  padding: 0;
  text-decoration: none;
  cursor: pointer;
}

.flash {
  border-radius: var(--radius-md);
  padding: 12px 14px;
  border: 1px solid transparent;
}

.flash.error {
  border-color: rgba(185, 58, 47, 0.16);
  background: var(--danger-soft);
  color: var(--danger);
}

.flash.success {
  border-color: rgba(24, 96, 51, 0.14);
  background: var(--success-soft);
  color: #186033;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 20, 15, 0.35);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
  z-index: 29;
}

.overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(92vw, 390px);
  height: 100vh;
  padding: 18px;
  background: rgba(255, 252, 246, 0.98);
  border-left: 1px solid var(--line);
  box-shadow: -16px 0 40px rgba(38, 29, 22, 0.12);
  transform: translateX(100%);
  transition: transform 0.2s ease;
  z-index: 30;
}

.drawer.open {
  transform: translateX(0);
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.drawer-body {
  display: grid;
  gap: 10px;
}

.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  text-decoration: none;
  background: #fff;
  border: 1px solid var(--line);
  font-weight: 700;
}

.menu-item:hover {
  background: #f8f2e8;
}

.login-container {
  display: grid;
  place-items: center;
}

.login-card {
  width: min(100%, 780px);
  padding: 28px;
}

.login-form .row {
  align-items: stretch;
}

.btn-create-account {
  background: none;
  border: 0;
  color: var(--green-dark);
  font-weight: 700;
  cursor: pointer;
}

.register-hidden {
  display: none;
}

.matches-wrap,
.wrap {
  display: grid;
  gap: 14px;
}

.match {
  padding: 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.92) 0%, rgba(249,244,236,0.92) 100%);
  box-shadow: 0 12px 26px rgba(38, 29, 22, 0.06);
}

.match.locked {
  opacity: 0.92;
}

.match-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.team {
  font-weight: 800;
  font-size: 1.02rem;
}

.team.right {
  text-align: right;
}

.scorebox {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
}

.score-side {
  display: flex;
  align-items: center;
  gap: 8px;
}

.scoreA,
.scoreB {
  min-width: 40px;
  text-align: center;
  font-size: 1.35rem;
  font-weight: 900;
}

.score-win {
  color: var(--green-dark);
}

.score-lose {
  color: var(--danger);
}

.dash {
  color: var(--muted);
  font-weight: 700;
}

.match-actions {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.bonus-tag,
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
}

.bonus-tag {
  background: #fff7e8;
  color: #9a5b13;
  border-color: rgba(184, 115, 51, 0.22);
}

.bonus-tag.BO {
  background: #edf8f4;
  color: var(--green-dark);
}

.bonus-tag.BD {
  background: #fff3ea;
  color: #b45b16;
}

.bonus-tag .sub {
  opacity: 0.78;
}

.pill.done {
  background: #edf8f4;
  color: var(--green-dark);
}

.pill.todo {
  background: #fff7e8;
  color: #9a5b13;
}

.pill.edit {
  background: #edf4ff;
  color: #295ea8;
}

/* =========================
   TABLEAUX
   ========================= */
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,0.84);
  min-width: 0;
}

.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.table-wrap thead tr {
  background: #ddd4c6;
}

.table-wrap thead th {
  background: transparent;
  color: #7a562b;
  font-weight: 700;
  text-align: left;
  padding: 14px 12px;
}

.table-wrap th {
  position: sticky;
  top: 0;
  background: #efe5d6;
  color: #5f4c3f;
  text-align: left;
  font-size: 0.9rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.table-wrap th,
.table-wrap td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}

.table-wrap tbody td {
  vertical-align: middle;
}

.table-wrap tbody tr:nth-child(even) {
  background: rgba(255, 252, 246, 0.72);
}

.table-wrap tbody tr:hover {
  background: rgba(15, 106, 91, 0.06);
}

.table-wrap td:last-child {
  text-align: left;
}

/* =========================
   CLASSEMENT
   ========================= */
.table-wrap.table-ranking table {
  width: 100%;
  table-layout: fixed;
}

.table-wrap.table-ranking th,
.table-wrap.table-ranking td {
  padding: 6px 6px;
  font-size: 0.9rem;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-wrap.table-ranking th.name,
.table-wrap.table-ranking td.name {
  text-align: left;
  width: 150px;
  max-width: 150px;
}

.table-wrap.table-ranking td.name a {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-wrap.table-ranking th.rank,
.table-wrap.table-ranking td.rank {
  width: 38px;
}

.table-wrap.table-ranking th.c-j,
.table-wrap.table-ranking td.c-j,
.table-wrap.table-ranking th.c-v,
.table-wrap.table-ranking td.c-v,
.table-wrap.table-ranking th.c-p,
.table-wrap.table-ranking td.c-p {
  width: 44px;
}

.table-wrap.table-ranking th.c-pts,
.table-wrap.table-ranking td.c-pts,
.table-wrap.table-ranking th.c-diff,
.table-wrap.table-ranking td.c-diff {
  width: 56px;
}

.label-mobile {
  display: none;
}

.label-desktop {
  display: inline;
}

.table-ranking tbody tr.rank-1 {
  background: linear-gradient(90deg, rgba(255, 215, 0, 0.18) 0%, rgba(255, 248, 220, 0.9) 100%);
}

.table-ranking tbody tr.rank-2 {
  background: linear-gradient(90deg, rgba(192, 192, 192, 0.18) 0%, rgba(248, 248, 248, 0.9) 100%);
}

.table-ranking tbody tr.rank-3 {
  background: linear-gradient(90deg, rgba(205, 127, 50, 0.18) 0%, rgba(255, 244, 235, 0.9) 100%);
}

.table-ranking tbody tr.rank-1:hover,
.table-ranking tbody tr.rank-2:hover,
.table-ranking tbody tr.rank-3:hover {
  filter: brightness(0.98);
}

.table-ranking tbody tr.rank-1 td.rank {
  font-weight: 900;
  color: #9a6a00;
}

.table-ranking tbody tr.rank-2 td.rank {
  font-weight: 900;
  color: #666;
}

.table-ranking tbody tr.rank-3 td.rank {
  font-weight: 900;
  color: #9a5523;
}

/* =========================
   SCORES
   ========================= */
.matchCell {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.vs {
  color: var(--muted);
  font-weight: 700;
}

.scoreText {
  font-weight: 800;
}

.match-score-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.match-score-inline .u-modal-score-input {
  width: 72px;
  min-width: 72px;
  text-align: center;
  margin: 0;
}

.score-win-box {
  background: #edf8f4;
  border-color: rgba(15, 106, 91, 0.35);
  color: #0a5145;
  font-weight: 800;
}

.score-lose-box {
  background: #fff1ef;
  border-color: rgba(185, 58, 47, 0.28);
  color: #b93a2f;
  font-weight: 800;
}

.u-modal-score-input[readonly] {
  cursor: default;
}

/* =========================
   AUTOCOMPLÉTION
   ========================= */
.field {
  flex: 1;
  min-width: 240px;
}

.ac-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 15;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  box-shadow: 0 16px 30px rgba(38, 29, 22, 0.1);
  overflow: hidden;
}

.ac-item {
  display: block;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-top: 1px solid var(--line);
  background: #fff;
  text-align: left;
  font: inherit;
  color: var(--text);
  cursor: pointer;
}

.ac-item:first-child {
  border-top: 0;
}

.ac-item:hover {
  background: #f8f2e8;
}

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

.search-player-item {
  display: block;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: #fff;
  text-decoration: none;
  font-weight: 700;
}

.search-player-item:hover {
  background: #f8f2e8;
}

/* =========================
   MODALS
   ========================= */
.modal {
  position: fixed;
  inset: 0;
  padding: 18px;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(26, 20, 15, 0.48);
  backdrop-filter: blur(3px);
  z-index: 40;
}

.modal.open {
  display: flex;
}

.modal-card {
  width: min(96vw, 760px);
  overflow: hidden;
}

.modal-header {
  padding: 16px 18px;
  background: linear-gradient(180deg, #f6efe4 0%, #efe2ce 100%);
  border-bottom: 1px solid var(--line);
}

.modal-body {
  padding: 18px;
  background: var(--paper);
}

.modal-close {
  position: absolute;
  right: 16px;
  top: 14px;
  border: 0;
  background: #fff;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  cursor: pointer;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* =========================
   HOME / AUTH
   ========================= */
body.home-page,
body.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

body.home-page,
body.auth-page {
  font-family: Georgia, "Times New Roman", serif;
}

.home {
  width: min(100%, 960px);
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 24px;
  align-items: center;
}

.hero,
.aside,
.panel {
  background: rgba(255, 252, 246, 0.92);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: 0 22px 60px rgba(38, 29, 22, 0.12);
  backdrop-filter: blur(6px);
}

.hero {
  padding: 40px;
}

.aside {
  padding: 28px;
  text-align: center;
}

.logo-wrap {
  aspect-ratio: 1 / 1;
  width: min(100%, 360px);
  margin: 0 auto 20px;
  padding: 20px;
  border-radius: 26px;
  background: linear-gradient(180deg, #fffdf9 0%, #f1e8da 100%);
  display: grid;
  place-items: center;
}

.logo-wrap img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.eyebrow {
  display: inline-block;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green-dark);
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

body.home-page h1,
body.auth-page h1 {
  margin: 18px 0 12px;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 0.98;
}

body.home-page h1 {
  font-size: clamp(2.5rem, 5vw, 4.7rem);
}

body.auth-page h1 {
  font-size: clamp(2.1rem, 4vw, 3.4rem);
}

body.home-page p,
body.auth-page p {
  color: var(--muted);
  line-height: 1.7;
}

.cta,
.actions {
  margin-top: 22px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.club-name {
  margin: 0;
  font-size: 1.5rem;
  line-height: 1.2;
  font-family: Georgia, "Times New Roman", serif;
}

.layout {
  width: min(100%, 1020px);
  display: grid;
  grid-template-columns: 0.95fr 1.05fr;
  gap: 24px;
  align-items: stretch;
}

.form-card,
.brand-panel {
  padding: 34px;
}

.brand-panel {
  text-align: center;
  display: grid;
  align-content: center;
}

.brand-panel h2 {
  margin: 0;
  font-size: 1.6rem;
  font-family: Georgia, "Times New Roman", serif;
}

.brand-panel p {
  margin: 10px 0 0;
}

.intro {
  margin: 0 0 22px;
  max-width: 34rem;
}

/* =========================
   UTILITAIRES
   ========================= */
.u-no-decoration { text-decoration: none; }
.u-disabled-soft { opacity: 0.55; }
.u-border-sep {
  border: none;
  border-top: 1px solid var(--line);
  margin: 12px 0;
}
.u-box {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: #fbfdff;
  min-width: 0;
}
.u-box-danger {
  border: 1px solid rgba(185, 58, 47, 0.16);
  border-radius: 14px;
  padding: 12px;
  background: #fff7f7;
}
.u-box-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.u-title-sm { font-size: 0.98rem; }
.u-title-danger { color: #dc3545; }
.u-input-grow {
  flex: 1;
  min-width: 220px;
}
.u-relative { position: relative; }
.u-full-width { width: 100%; }
.u-mt-6 { margin-top: 6px; }
.u-mt-10 { margin-top: 10px; }
.u-mt-12 { margin-top: 12px; }
.u-center { text-align: center; }
.u-row-end { justify-content: flex-end; gap: 8px; }
.u-card-top { margin-top: 14px; }
.u-padding-14 { padding: 14px; }
.u-padding-16-10 { padding: 16px 10px; }
.u-heading-reset { margin: 0; }
.u-modal-score-input {
  width: 70px;
  text-align: center;
}
.u-hidden { display: none; }

#hamburgerBtn,
#overlay,
#drawer {
  display: none !important;
}

.flash-box {
  margin-top: 10px;
  border-radius: 14px;
  padding: 12px;
}

.flash-box.error {
  border: 1px solid #ffd3d8;
  background: #fff7f7;
}

.flash-box.success {
  border: 1px solid #c7f3d1;
  background: #f1fff5;
}

.flash-box.error strong { color: #dc3545; }
.flash-box.success strong { color: #16a34a; }

/* =========================
   ADMIN ACTIONS
   ========================= */
.edit-player-form input[type="text"] {
  min-width: 180px;
}

.admin-duo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: stretch;
}

.admin-duo-grid .card {
  height: 100%;
}

.admin-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.admin-actions form {
  margin: 0;
}

.td-actions {
  min-width: 220px;
  text-align: left !important;
}

.admin-actions .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
  white-space: nowrap;
}

.admin-actions .btn:hover {
  transform: translateY(-1px);
}

.admin-actions .action-edit,
.admin-actions .action-delete {
  width: 92px;
  height: 36px;
  padding: 0;
  font-size: 0.88rem;
  font-weight: 700;
}

.admin-actions .action-edit {
  background: #e8f1fb;
  color: #0b5ea8;
  border-color: #bfd6f2;
}

.admin-actions .action-edit:hover {
  background: #d9eafb;
}

.admin-actions .action-delete {
  background: #fff1ef;
  color: #b93a2f;
  border-color: rgba(185, 58, 47, 0.22);
}

.admin-actions .action-delete:hover {
  background: #fde5e1;
}

.admin-actions .action-warning,
.action-warning {
  background: #fff7e8;
  color: #9a5b13;
  border: 1px solid rgba(184, 115, 51, 0.25);
}

.admin-actions .action-warning:hover,
.action-warning:hover {
  background: #fcefdc;
}

/* =========================
   MATCHS MOBILE
   ========================= */
.matchs-mobile {
  display: none;
}

@media (max-width: 768px) and (orientation: portrait) {
  .matchs-desktop {
    display: none;
  }

  .matchs-mobile {
    display: grid;
    gap: 12px;
  }

  .match-mobile-card {
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.9);
    padding: 14px;
    box-shadow: 0 10px 24px rgba(38, 29, 22, 0.06);
  }

  .match-mobile-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
  }

  .match-mobile-players {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 8px;
    align-items: center;
    margin-bottom: 14px;
  }

  .match-mobile-player {
    font-weight: 800;
    text-align: center;
    word-break: break-word;
  }

  .match-mobile-vs {
    font-size: 0.85rem;
    color: var(--muted);
    font-weight: 700;
  }

  .match-mobile-score {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: nowrap;
  }

  .match-mobile-score .u-modal-score-input {
    width: 64px;
    min-width: 64px;
    text-align: center;
    padding: 10px 8px;
  }

  .match-mobile-actions {
    display: flex;
    justify-content: center;
  }

  .match-mobile-actions .btn {
    width: 100%;
  }
}

/* =========================
   RESPONSIVE GÉNÉRAL
   ========================= */
@media (max-width: 860px) {
  .topbar {
    padding: 12px 10px 0;
  }

  .topbar-inner {
    border-radius: 24px;
    padding: 12px 14px;
  }

  .brand .title {
    font-size: 1rem;
  }

  main {
    width: min(100%, calc(100% - 18px));
    margin-top: 18px;
  }

  .card,
  .login-card,
  .modal-body {
    padding: 18px;
  }

  .match-top {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .team,
  .team.right {
    text-align: center;
  }

  .scorebox {
    justify-self: center;
  }

  .actions,
  .modal-actions,
  .match-actions {
    justify-content: stretch;
  }

  .btn,
  .btn-form,
  .btn-login {
    width: 100%;
  }

  .home,
  .layout {
    grid-template-columns: 1fr;
  }

  .hero,
  .aside,
  .form-card,
  .brand-panel {
    padding: 24px;
  }

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

/* =========================
   SMARTPHONE
   ========================= */
@media (max-width: 768px) {
  body {
    font-size: 15px;
  }

  main {
    width: calc(100% - 14px);
    margin: 14px auto 24px;
    gap: 14px;
  }

  .topbar {
    padding: 8px 8px 0;
  }

  .topbar-inner {
    width: 100%;
    border-radius: 18px;
    padding: 10px 12px;
    gap: 10px;
    align-items: flex-start;
    flex-direction: column;
  }

  .brand {
    width: 100%;
    gap: 10px;
  }

  .brand img {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    padding: 4px;
  }

  .brand .title {
    font-size: 0.95rem;
    line-height: 1.15;
    letter-spacing: 0.03em;
  }

  .top-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .top-actions .btn,
  .top-actions a.btn {
    width: 100%;
    justify-content: center;
    padding: 10px 12px;
    font-size: 0.92rem;
  }

  .card,
  .login-card,
  .modal-body,
  .card-pad {
    padding: 16px;
    border-radius: 18px;
  }

  .section-title {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: 14px;
  }

  .section-title h1,
  .section-title h2,
  .card h1,
  .card h2 {
    line-height: 1.1;
  }

  .row {
    gap: 10px;
  }

  .u-input-grow {
    min-width: 0;
    width: 100%;
  }

  input,
  select,
  textarea,
  .input-field {
    padding: 12px 14px;
    font-size: 16px;
  }

  .btn,
  .btn-form,
  .btn-login {
    padding: 11px 14px;
    font-size: 0.95rem;
  }

  .u-box,
  .u-box-danger {
    padding: 10px;
    border-radius: 12px;
  }

  .row > .u-box.u-input-grow {
    width: 100%;
    min-width: 100%;
  }

  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 16px;
  }

  .table-wrap table {
    min-width: 720px;
  }

  .table-wrap th,
  .table-wrap td {
    padding: 10px 8px;
    font-size: 0.84rem;
  }

  .admin-actions {
    flex-wrap: wrap;
    gap: 6px;
  }

  .admin-actions .btn {
    font-size: 0.9rem;
  }

  .edit-player-form input[type="text"] {
    min-width: 0;
    width: 100%;
  }

  .ac-list {
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    border-radius: 12px;
  }

  .ac-item {
    padding: 11px 12px;
    font-size: 0.95rem;
  }

  .search-player-list {
    gap: 8px;
  }

  .search-player-item {
    padding: 10px 12px;
  }

  .match-score-inline {
    gap: 8px;
  }

  .match-score-inline .u-modal-score-input {
    width: 58px;
    min-width: 58px;
    padding: 10px 8px;
  }

  .u-modal-score-input {
    width: 58px;
    min-width: 58px;
    padding: 10px 8px;
  }

  .scoreText {
    font-size: 1rem;
  }

  .table-wrap th.action-col,
  .table-wrap td.action-col {
    width: 96px;
  }

  .hero,
  .aside,
  .form-card,
  .brand-panel {
    padding: 20px;
    border-radius: 20px;
  }

  .logo-wrap {
    width: min(100%, 240px);
    padding: 14px;
    border-radius: 20px;
  }

  body.home-page h1 {
    font-size: clamp(2rem, 9vw, 3rem);
  }

  body.auth-page h1 {
    font-size: clamp(1.8rem, 8vw, 2.6rem);
  }

  .cta,
  .actions,
  .modal-actions,
  .match-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .cta .btn,
  .actions .btn,
  .modal-actions .btn,
  .match-actions .btn {
    width: 100%;
  }

  /* Classement smartphone = tableau complet compact */
  .table-wrap.table-ranking {
    overflow: visible;
  }

  .table-wrap.table-ranking table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
  }

  .table-wrap.table-ranking th,
  .table-wrap.table-ranking td {
    padding: 4px 2px;
    font-size: 0.68rem;
    letter-spacing: 0;
  }

  .table-wrap.table-ranking th.name,
  .table-wrap.table-ranking td.name {
    width: 82px;
    max-width: 82px;
  }

  .table-wrap.table-ranking th.rank,
  .table-wrap.table-ranking td.rank {
    width: 24px;
  }

  .table-wrap.table-ranking th.c-j,
  .table-wrap.table-ranking td.c-j,
  .table-wrap.table-ranking th.c-v,
  .table-wrap.table-ranking td.c-v,
  .table-wrap.table-ranking th.c-p,
  .table-wrap.table-ranking td.c-p {
    width: 28px;
  }

  .table-wrap.table-ranking th.c-pts,
  .table-wrap.table-ranking td.c-pts,
  .table-wrap.table-ranking th.c-diff,
  .table-wrap.table-ranking td.c-diff {
    width: 38px;
  }

  .label-desktop {
    display: none;
  }

  .label-mobile {
    display: inline;
  }

  /* Admin : réduire la colonne nom */
  .table-wrap.table-players-admin table {
    table-layout: fixed;
  }

  .table-wrap.table-players-admin th:first-child,
  .table-wrap.table-players-admin td:first-child {
    width: 110px;
    max-width: 110px;
  }

  .table-wrap.table-players-admin td:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* =========================
   TRÈS PETITS ÉCRANS
   ========================= */
@media (max-width: 420px) {
  .top-actions {
    grid-template-columns: 1fr;
  }

  .brand .title {
    font-size: 0.88rem;
  }

  .table-wrap table {
    min-width: 640px;
  }

  .match-score-inline .u-modal-score-input,
  .u-modal-score-input {
    width: 52px;
    min-width: 52px;
  }

  .table-wrap th.action-col,
  .table-wrap td.action-col {
    width: 88px;
  }

  .table-wrap.table-ranking th,
  .table-wrap.table-ranking td {
    padding: 3px 1px;
    font-size: 0.62rem;
  }

  .table-wrap.table-ranking th.name,
  .table-wrap.table-ranking td.name {
    width: 72px;
    max-width: 72px;
  }

  .table-wrap.table-ranking th.rank,
  .table-wrap.table-ranking td.rank {
    width: 22px;
  }

  .table-wrap.table-ranking th.c-j,
  .table-wrap.table-ranking td.c-j,
  .table-wrap.table-ranking th.c-v,
  .table-wrap.table-ranking td.c-v,
  .table-wrap.table-ranking th.c-p,
  .table-wrap.table-ranking td.c-p {
    width: 24px;
  }

  .table-wrap.table-ranking th.c-pts,
  .table-wrap.table-ranking td.c-pts,
  .table-wrap.table-ranking th.c-diff,
  .table-wrap.table-ranking td.c-diff {
    width: 34px;
  }

  .table-wrap.table-players-admin th:first-child,
  .table-wrap.table-players-admin td:first-child {
    width: 85px;
    max-width: 85px;
  }

  .match-mobile-card {
    padding: 12px;
    border-radius: 16px;
  }
}

.recherche-mobile {
  display: none;
}

@media (max-width: 768px) and (orientation: portrait) {
  .recherche-desktop {
    display: none;
  }

  .recherche-mobile {
    display: grid;
    gap: 12px;
  }

  .recherche-card {
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.9);
    padding: 14px;
    box-shadow: 0 10px 24px rgba(38, 29, 22, 0.06);
  }

  .recherche-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
  }

  .recherche-card-players {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 8px;
    align-items: center;
    margin-bottom: 14px;
  }

  .recherche-card-player {
    font-weight: 800;
    text-align: center;
    word-break: break-word;
  }

  .recherche-card-vs {
    font-size: 0.85rem;
    color: var(--muted);
    font-weight: 700;
  }

  .recherche-card-score {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: nowrap;
  }

  .recherche-card-score .u-modal-score-input {
    width: 64px;
    min-width: 64px;
    text-align: center;
    padding: 10px 8px;
  }

  .recherche-card-actions {
    display: flex;
    justify-content: center;
  }

  .recherche-card-actions .btn {
    width: 100%;
  }
}

@media (max-width: 420px) and (orientation: portrait) {
  .recherche-card {
    padding: 12px;
    border-radius: 16px;
  }
}
/* =========================
   TABLEAU CROISE
   ========================= */
.matrix-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,0.84);
}

.matrix-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
}

.matrix-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--muted);
}

.matrix-legend-swatch {
  width: 18px;
  height: 18px;
  min-width: 18px;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.matrix-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.matrix-table th,
.matrix-table td {
  border: 1px solid var(--line);
}

.matrix-corner {
  position: sticky;
  left: 0;
  z-index: 3;
  min-width: 150px;
  padding: 12px 14px;
  background: #e7dac6;
  color: #5f4c3f;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.matrix-player {
  background: #f3e7d5;
  color: #5f4c3f;
  font-size: 0.84rem;
  font-weight: 800;
}

.matrix-player-top {
  position: sticky;
  top: 0;
  z-index: 2;
  min-width: 88px;
  max-width: 88px;
  width: 88px;
  padding: 10px 6px;
  text-align: center;
  white-space: normal;
  word-break: break-word;
}

.matrix-player-side {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 150px;
  max-width: 150px;
  width: 150px;
  padding: 10px 12px;
  text-align: left;
  white-space: nowrap;
}

.matrix-cell {
  min-width: 88px;
  width: 88px;
  height: 54px;
  padding: 0;
  text-align: center;
  vertical-align: middle;
  font-weight: 800;
  font-size: 0.84rem;
}

.matrix-cell span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 4px;
}

.matrix-cell-diag {
  background: #111;
}

.matrix-cell-diag span {
  color: transparent;
}

.matrix-cell-empty {
  background: #fff;
  color: #8c7c6f;
}

.matrix-cell-aller {
  background: #dff2ed;
  color: #0a5145;
}

.matrix-cell-retour {
  background: #fff1ef;
  color: #b93a2f;
}

.matrix-cell-pending {
  opacity: 0.92;
}

.matrix-cell-played {
  box-shadow: inset 0 0 0 2px rgba(38, 29, 22, 0.08);
}

@media (max-width: 860px) {
  .matrix-legend {
    width: 100%;
  }
}

@media (max-width: 420px) {
  .matrix-corner,
  .matrix-player-side {
    min-width: 110px;
    max-width: 110px;
    width: 110px;
    padding: 8px;
    font-size: 0.76rem;
  }

  .matrix-player-top,
  .matrix-cell {
    min-width: 62px;
    max-width: 62px;
    width: 62px;
    font-size: 0.7rem;
  }

  .matrix-cell {
    height: 46px;
  }
}

/* =========================
   TABLEAU CROISE VISIBILITE
   ========================= */
.matrix-cell-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 100%;
  height: 100%;
  padding: 4px;
}

.matrix-phase {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(38, 29, 22, 0.12);
}

.matrix-score {
  font-size: 0.8rem;
  font-weight: 900;
  line-height: 1;
}

.matrix-cell-pending {
  opacity: 0.72;
}

.matrix-cell-pending .matrix-score {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
}

.matrix-cell-played {
  opacity: 1;
  box-shadow: inset 0 0 0 2px rgba(38, 29, 22, 0.08);
}

.matrix-cell-played.matrix-cell-aller {
  background: #8fd3bf;
  color: #083e35;
}

.matrix-cell-played.matrix-cell-retour {
  background: #f7a99d;
  color: #6e1f16;
}

.matrix-cell-played .matrix-phase {
  background: rgba(255, 255, 255, 0.9);
}

@media (max-width: 420px) {
  .matrix-phase {
    min-width: 18px;
    height: 18px;
    font-size: 0.62rem;
    padding: 0 4px;
  }

  .matrix-score {
    font-size: 0.68rem;
  }

  .matrix-cell-pending .matrix-score {
    font-size: 0.56rem;
  }
}

/* =========================
   TABLEAU CROISE COMPACT
   ========================= */
.matrix-page-card {
  overflow: hidden;
}

.matrix-title-row {
  align-items: flex-start;
}

.matrix-fit-wrap {
  overflow: visible;
}

.matrix-table-fit {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

.matrix-corner-fit {
  min-width: 110px;
  width: 110px;
  max-width: 110px;
}

.matrix-player-top-fit {
  min-width: 0;
  width: auto;
  max-width: none;
  height: 132px;
  padding: 6px 2px;
  vertical-align: bottom;
}

.matrix-player-top-fit span {
  display: inline-block;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  white-space: nowrap;
  font-size: 0.72rem;
  line-height: 1;
}

.matrix-player-side-fit {
  min-width: 110px;
  width: 110px;
  max-width: 110px;
  padding: 6px 8px;
  font-size: 0.72rem;
  line-height: 1.15;
  white-space: normal;
  word-break: break-word;
}

.matrix-cell-fit {
  min-width: 0;
  width: auto;
  height: 28px;
}

.matrix-legend.compact .matrix-legend-swatch {
  width: 16px;
  height: 16px;
  min-width: 16px;
}

.matrix-cell-empty {
  background: #ffffff;
}

.matrix-cell-played.matrix-cell-aller {
  background: #79c9b3;
}

.matrix-cell-played.matrix-cell-retour {
  background: #ef8f82;
}

@media (max-width: 1024px) {
  .matrix-corner-fit,
  .matrix-player-side-fit {
    min-width: 92px;
    width: 92px;
    max-width: 92px;
  }

  .matrix-player-top-fit {
    height: 118px;
  }

  .matrix-player-top-fit span {
    font-size: 0.66rem;
  }

  .matrix-player-side-fit {
    font-size: 0.68rem;
  }

  .matrix-cell-fit {
    height: 24px;
  }
}

@media (max-width: 768px) {
  .matrix-fit-wrap {
    overflow: auto;
  }

  .matrix-table-fit {
    min-width: 720px;
  }
}

/* =========================
   IMPRESSION PDF TABLEAU
   ========================= */
.matrix-toolbar {
  align-items: stretch;
}

.matrix-print-btn {
  min-width: 180px;
}

@page {
  size: landscape;
  margin: 10mm;
}

@media print {
  body {
    background: #ffffff !important;
  }

  body::before,
  .topbar,
  .matrix-print-btn {
    display: none !important;
  }

  main {
    width: 100% !important;
    margin: 0 !important;
    max-width: none !important;
    gap: 0 !important;
  }

  .card,
  .matrix-page-card {
    box-shadow: none !important;
    border: 0 !important;
    background: #ffffff !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  .matrix-fit-wrap,
  .table-wrap {
    overflow: visible !important;
  }

  .matrix-table-fit {
    width: 100% !important;
    table-layout: fixed !important;
  }

  .matrix-corner-fit,
  .matrix-player-side-fit {
    width: 90px !important;
    min-width: 90px !important;
    max-width: 90px !important;
    font-size: 0.6rem !important;
    padding: 4px 6px !important;
  }

  .matrix-player-top-fit {
    height: 92px !important;
    padding: 2px !important;
  }

  .matrix-player-top-fit span {
    font-size: 0.56rem !important;
  }

  .matrix-cell-fit {
    height: 18px !important;
    min-width: 0 !important;
  }

  .matrix-legend {
    gap: 8px 12px !important;
  }

  .matrix-legend-item,
  .subtle,
  .u-title-sm {
    color: #000000 !important;
  }

  .u-box {
    border: 1px solid #d7d7d7 !important;
    background: #ffffff !important;
    padding: 8px !important;
  }
}

/* =========================
   TABLEAU CROISE AJUSTEMENTS
   ========================= */
.matrix-stat-box {
  max-width: 170px;
}

.matrix-print-btn {
  min-width: 132px;
  padding: 10px 14px;
  font-size: 0.9rem;
  align-self: center;
}

.matrix-cell-played.matrix-cell-aller {
  background: #69bfa7 !important;
}

.matrix-cell-played.matrix-cell-retour {
  background: #e88376 !important;
}

.matrix-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 0 1px rgba(38, 29, 22, 0.16);
}

@media print {
  .matrix-toolbar {
    gap: 6px !important;
    margin-top: 6px !important;
  }

  .matrix-stat-box {
    max-width: 96px !important;
    min-width: 96px !important;
    padding: 4px 6px !important;
  }

  .matrix-stat-box .u-title-sm {
    font-size: 0.8rem !important;
  }

  .matrix-stat-box .subtle {
    font-size: 0.52rem !important;
    line-height: 1.1 !important;
  }

  .matrix-corner-fit,
  .matrix-player-side-fit {
    width: 76px !important;
    min-width: 76px !important;
    max-width: 76px !important;
    font-size: 0.52rem !important;
    padding: 3px 4px !important;
  }

  .matrix-player-top-fit {
    height: 78px !important;
  }

  .matrix-player-top-fit span {
    font-size: 0.48rem !important;
  }

  .matrix-cell-fit {
    height: 15px !important;
  }

  .matrix-dot {
    width: 7px !important;
    height: 7px !important;
  }
}

/* =========================
   PDF COULEURS TABLEAU
   ========================= */
.matrix-table td,
.matrix-table th,
.matrix-legend-swatch,
.matrix-cell-played,
.matrix-cell-aller,
.matrix-cell-retour,
.matrix-cell-diag {
  -webkit-print-color-adjust: exact !important;
  print-color-adjust: exact !important;
}

@media print {
  html,
  body,
  .matrix-page-card,
  .matrix-table,
  .matrix-table td,
  .matrix-table th {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .matrix-cell-diag {
    background: #111111 !important;
  }

  .matrix-cell-empty {
    background: #ffffff !important;
  }

  .matrix-cell-played.matrix-cell-aller {
    background: #69bfa7 !important;
  }

  .matrix-cell-played.matrix-cell-retour {
    background: #e88376 !important;
  }

  .matrix-stat-box {
    max-width: 82px !important;
    min-width: 82px !important;
    padding: 3px 4px !important;
  }

  .matrix-stat-box .u-title-sm {
    font-size: 0.72rem !important;
  }

  .matrix-stat-box .subtle {
    font-size: 0.48rem !important;
    line-height: 1.05 !important;
  }

  .matrix-print-btn {
    display: none !important;
  }
}

/* =========================
   PDF RENFORCE
   ========================= */
@media print {
  .matrix-table th,
  .matrix-table td {
    border: 1.4px solid #5b5b5b !important;
  }

  .matrix-corner-fit,
  .matrix-player-top-fit,
  .matrix-player-side-fit {
    background: #e3dccf !important;
    color: #111111 !important;
    font-weight: 800 !important;
  }

  .matrix-cell-diag {
    background: #000000 !important;
    border-color: #000000 !important;
  }

  .matrix-cell-played.matrix-cell-aller {
    background: #3f9d84 !important;
    border-color: #2a6f5c !important;
  }

  .matrix-cell-played.matrix-cell-retour {
    background: #d46252 !important;
    border-color: #9f3f32 !important;
  }

  .matrix-legend-swatch.matrix-cell-played.matrix-cell-aller {
    background: #3f9d84 !important;
    border-color: #2a6f5c !important;
  }

  .matrix-legend-swatch.matrix-cell-played.matrix-cell-retour {
    background: #d46252 !important;
    border-color: #9f3f32 !important;
  }

  .matrix-title-row h2 {
    color: #000000 !important;
  }
}

/* =========================
   DATE IMPRESSION PDF
   ========================= */
.matrix-print-meta {
  display: none;
}

@media print {
  .matrix-print-meta {
    display: block !important;
    margin: 4px 0 8px !important;
    font-size: 0.62rem !important;
    font-weight: 700 !important;
    color: #111111 !important;
    text-align: right !important;
  }
}
