:root {
  --blue: #0d4574;
  --blue-2: #114f83;
  --border: #d4dbe3;
  --text: #1b2a3a;
  --muted: #627286;
  --bg: #f3f6f9;
  --green: #dff2e3;
  --green-border: #9dd1a8;
  --amber: #fff4db;
  --amber-border: #e0c27d;
  --shadow: 0 8px 24px rgba(13, 34, 64, 0.08);

  --topbar-h: 108px;
  --footer-h: 84px;

  /* hauteur d’un créneau de 30 min */
  --slot-h: clamp(24px, calc((100vh - var(--topbar-h) - var(--footer-h) - 90px) / 28), 52px);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  font-family: Inter, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

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

button {
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--blue);
  color: white;
  cursor: pointer;
  box-shadow: var(--shadow);
}

button.secondary {
  background: white;
  color: var(--blue);
  border: 1px solid var(--border);
  box-shadow: none;
}

button.small {
  padding: 6px 10px;
  font-size: 12px;
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

input,
select,
textarea {
  width: 100%;
  margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: white;
}

label {
  display: block;
  margin-bottom: 12px;
  font-size: 14px;
  color: var(--muted);
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

.helper,
.hint,
#playerCount {
  color: var(--muted);
  font-size: 12px;
}

/* HEADER */

.topbar {
  position: relative;
  height: var(--topbar-h);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 12px 18px;
  background: white;
  border-bottom: 1px solid var(--border);
}

.winner-cup {
  margin-right: 6px;
  font-size: 0.95em;
}

.match-winner .match-player-name {
  font-weight: 900;
}

.match-winner .match-player-name {
  font-weight: 900;
}

.club-logo-host {
  display: flex;
  align-items: center;
  justify-content: center;
}

.club-logo-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.club-logo-card img {
  max-height: 54px;
  max-width: 140px;
  object-fit: contain;
  display: block;
}

.match-event-name {
  font-size: 11px;
  font-weight: 700;
  color: #557089;
  text-transform: uppercase;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-main {
  /*width: 100%;*/
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.topbar h1 {
  margin: 0 0 4px;
  font-size: 26px;
}

.topbar p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

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

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--blue);
  text-decoration: none;
}

.topbar-actions {
  position: absolute;
  right: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.principal-sponsor-host {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

/* remet les clics sur le logo */
.principal-sponsor-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.principal-sponsor-card img {
  max-height: 80px;
  max-width: 327px;
  object-fit: contain;
  display: block;
}

/* LAYOUT */

.app-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 320px;
  gap: 14px;
  padding: 14px;
  height: calc(100vh - var(--topbar-h) - var(--footer-h));
  min-height: 0;
  overflow: hidden;
}

.panel,
.board-panel,
.app-footer {
  background: white;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 14px;
  overflow: auto;
}

.compact-panel {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: auto;
}

.panel h2,
.panel h3 {
  margin: 0 0 12px;
  font-size: 18px;
}

.left-tools-panel {
  overflow: auto;
}

.date-nav,
.panel-title-row,
.board-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.grow {
  flex: 1;
}

.admin-menu-buttons {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}

/* BOARD */

.board-panel {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.board-toolbar {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.planning-board {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background: linear-gradient(180deg, #fbfdff 0%, #f6f9fc 100%);
}

.planning-grid {
  display: grid;
  width: 100%;
  height: 100%;
  min-width: 0;
  position: relative;
}

.grid-header {
  position: sticky;
  top: 0;
  z-index: 4;
  background: white;
  border-bottom: 1px solid var(--border);
}

.time-header {
  background: #f8fbfe;
  border-right: 1px solid var(--border);
}

.court-header {
  padding: 10px 10px 8px;
  text-align: center;
  font-weight: 700;
  color: var(--blue);
  border-left: 1px solid var(--border);
  background: linear-gradient(180deg, #ffffff 0%, #f3f8fc 100%);
}

.court-header small {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}

.time-cell {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 6px;
  font-weight: 700;
  color: #4b5f74;
  border-right: 1px solid var(--border);
  border-bottom: 1px dashed #d8e0e8;
  background: #fafcfe;
  font-size: 12px;
}

.slot-cell {
  border-left: 1px solid var(--border);
  border-bottom: 1px dashed #d8e0e8;
  position: relative;
  background: transparent;
}

.slot-cell.blocked {
  background: rgba(234, 242, 249, 0.35);
}

.slot-cell.drag-over {
  outline: 2px dashed var(--blue);
  outline-offset: -4px;
  background: rgba(17, 79, 131, 0.06);
}

.slot-cell.occupied-start {
  z-index: 3;
  padding: 4px;
}

/* JOUEURS */

.player-panel-tv .player-pool {
  flex: 1 1 auto;
  min-height: 0;
}

.player-pool {
  display: grid;
  gap: 10px;
  overflow: auto;
  padding-right: 6px;
  min-height: 0;
}

.player-card {
  border: 1px solid #c7d6e7;
  border-left: 5px solid var(--blue-2);
  border-radius: 12px;
  padding: 8px 10px;
  background: linear-gradient(180deg, #ffffff 0%, #f9fbfd 100%);
  cursor: grab;
}

.player-card.male {
  border-left-color: #2f6fb3;
  background: linear-gradient(180deg, #f4f9ff 0%, #eaf3ff 100%);
}

.player-card.female {
  border-left-color: #c05a8d;
  background: linear-gradient(180deg, #fff5fa 0%, #fdebf4 100%);
}

.player-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}

.player-name {
  font-weight: 700;
  font-size: 15px;
}

.player-ranking {
  font-weight: 700;
  color: var(--blue);
  white-space: nowrap;
}

.player-club {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty-state {
  padding: 18px;
  color: var(--muted);
}

/* CARTE MATCH */

.match-card {
	overflow: hidden;
  position: relative;
  height: 100%;
  overflow: hidden;
  border: 1px solid #c7d6e7;
  border-radius: 18px;
  padding: 12px 14px;
  box-shadow: 0 8px 18px rgba(13, 34, 64, 0.06), inset 0 1px 0 rgba(255,255,255,.7);
}

.match-card.complete {
  background: linear-gradient(180deg, #eef8f0 0%, #e8f4ea 100%);
  border-color: #8fc89c;
}

.match-card.partial {
  background: linear-gradient(180deg, #fff9ec 0%, #f8efd8 100%);
  border-color: #d8bd78;
}

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

.match-title {
  font-size: 13px;
  font-weight: 800;
  color: #1b4261;
}

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

.match-actions .secondary.small {
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
}

.match-court-label {
  font-size: 13px;
  font-weight: 700;
  color: #1b4261;
}

.match-main-layout.premium {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 16px;
  align-items: center;
}

.match-players-col {
  display: grid;
  grid-template-rows: auto auto auto;
  align-content: center;
  min-width: 0;
}

.match-player-block {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  column-gap: 10px;
  row-gap: 3px;
  align-items: end;
}

.match-player-name {
  grid-column: 1;
  grid-row: 1;
  font-size: 17px;
  font-weight: 800;
  color: #0f3150;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.1;
}

.match-card .player-ranking {
  grid-column: 2;
  grid-row: 1;
  align-self: end;
  justify-self: end;
  font-size: 14px;
  font-weight: 500;
  color: #57616b;
}

.match-player-club {
  grid-column: 1 / span 2;
  grid-row: 2;
  font-size: 12px;
  color: #557089;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.match-vs {
  margin: 10px 0;
  text-align: center;
  font-size: 18px;
  font-weight: 900;
  color: #3e5d78;
  letter-spacing: .06em;
}

.match-placeholder {
  margin-top: 8px;
  border: 1px dashed rgba(131, 107, 24, 0.35);
  border-radius: 10px;
  padding: 12px 8px;
  text-align: center;
  color: #8a6f22;
  font-size: 13px;
}

.match-score-col {
  width: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.match-score-inline {
  width: 100%;
  display: grid;
  grid-template-rows: auto auto;
  gap: 18px;
  padding: 4px 0;
}

.score-inline-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  align-items: center;
}

.score-inline-cell {
  display: block;
  text-align: center;
  font-size: 32px;
  line-height: 1;
  font-weight: 800;
  color: #1f2a33;
  text-shadow: 0 1px 0 rgba(255,255,255,.45);
}

.match-card.drop-over {
  outline: 2px dashed #406c97;
  outline-offset: -3px;
}

/* DRAWERS */

.admin-drawers {
  position: fixed;
  left: 14px;
  bottom: 110px;
  width: min(420px, calc(100vw - 28px));
  z-index: 70;
  display: grid;
  gap: 12px;
  pointer-events: none;
}

.drawer-panel {
  pointer-events: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 14px;
  max-height: 60vh;
  overflow: auto;
}

.drawer-panel.hidden {
  display: none;
}

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

/* SPONSORS */

.sponsor-list,
.score-admin-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.sponsor-row,
.score-admin-item {
  display: grid;
  grid-template-columns: 52px 1fr auto auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 10px;
}

.score-admin-item {
  grid-template-columns: 1fr auto auto;
}

.sponsor-row img {
  width: 52px;
  height: 40px;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
}

.sponsor-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 4px 8px;
}

.sponsor-badge.principal {
  background: #dcecff;
  color: #0b4878;
}

.sponsor-badge.majeur {
  background: #e5f6e8;
  color: #267041;
}

.sponsor-badge.mineur {
  background: #f4f1e7;
  color: #836b18;
}

/* FOOTER */

.app-footer {
  height: var(--footer-h);
  min-height: var(--footer-h);
  margin: 0 14px 14px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 16px;
  overflow: hidden;
}

.footer-title {
  font-weight: 700;
  color: var(--blue);
  white-space: nowrap;
}

.footer-sponsors {
  display: flex;
  align-items: center;
  gap: 14px;
  overflow: auto;
}

.sponsor-chip {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px 10px;
  background: #fff;
}

.sponsor-chip.mineur img {
  width: 80px;
  height: 34px;
  object-fit: contain;
}

.sponsor-chip.majeur img {
  width: 120px;
  height: 46px;
  object-fit: contain;
}

/* DISPLAY */

.display-layout {
  padding: 14px;
  height: calc(100vh - var(--topbar-h) - var(--footer-h));
  overflow: hidden;
}

/* SCOREBOARD */

.scoreboard-wrap {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px;
  max-width: 1100px;
  margin: 0 auto;
}

.scoreboard-head {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.scoreboard-topbar {
  display: grid;
  grid-template-columns: 140px 1fr 140px;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
}

.scoreboard-topbar-center {
  display: flex;
  flex-direction: column;   /* important */
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  text-align: center;
}

.scoreboard-topbar-center h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
}

.scoreboard-topbar-center p {
  margin: 0;
}

.scoreboard-topbar .secondary {
  justify-self: center;
  min-width: 120px;
}

.scoreboard-topbar .secondary:disabled {
  opacity: .45;
  cursor: default;
}

.scoreboard-players {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.score-name {
  font-size: 28px;
  font-weight: 800;
  text-align: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.score-set {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 18px;
  text-align: center;
}

.score-set h3 {
  margin: 0 0 12px;
}

.score-row {
  display: grid;
  grid-template-columns: 80px 1fr 80px;
  gap: 10px;
  align-items: center;
  margin: 12px 0;
}

.score-value {
  font-size: 42px;
  font-weight: 800;
}

/* RESPONSIVE SOUPLE */

@media (max-width: 1400px) {
  .app-layout {
    grid-template-columns: 260px 1fr 290px;
  }

  .admin-drawers {
    width: min(380px, calc(100vw - 28px));
  }

  .match-main-layout.premium {
    grid-template-columns: minmax(0, 1fr) 150px;
  }

  .match-score-col {
    width: 150px;
  }

  .score-inline-cell {
    font-size: 26px;
  }
}

