* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 24px;
  font-family: Arial, sans-serif;
  background: #f2f2f2;
  color: #222;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Empêche les boutons d'être sélectionnés comme du texte sur mobile */
button {
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Couleur de sélection */
::selection {
  background: #FEF5CC;
  color: #222;
}

::-moz-selection {
  background: #FEF5CC;
  color: #222;
}

button:focus-visible {
  outline: 3px solid #FEF5CC;
  outline-offset: 2px;
}

/* ACCUEIL */

#homeScreen {
  min-height: 100vh;
  max-width: 640px;
  margin: 0 auto;
  padding: 0 24px 40px;
  text-align: center;
  position: relative;
  overflow-x: auto;
  overflow-y: auto;
}

#homeScreen::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 175px;
  width: 100%;
  background-image: url("assets/FOND-noir.png");
  background-repeat: repeat;
  z-index: 0;
}

#homeScreen::after {
  content: "";
  position: absolute;
  top: 175px;
  left: 0;
  height: calc(100% - 175px);
  width: 100%;
  background-image: url("assets/FOND-blanc.png");
  background-repeat: repeat;
  z-index: 0;
}

.home-logo,
.home-actions,
.home-footer {
  position: relative;
  z-index: 1;
}

.txek-logo {
  width: 380px;
  margin: 20px auto 10px;
}

.trophy-icon {
  font-size: 2em;
  vertical-align: middle;
}

.score-logo {
  width: 500px;
  max-width: 110%;
  display: block;
  margin: 0 auto 0px;
}

.home-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  margin-top: -20px;
}

.home-btn {
  display: block;

  width: 360px;
  max-width: 90%;
  aspect-ratio: 856 / 316;

  padding: 0;
  border: 0;
  border-radius: 0;

  background-color: transparent;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;

  color: transparent;
  font-size: 0;

  box-shadow: none;
  cursor: pointer;
}

.install-app-btn {
  display: block;

  width: 240px;
  max-width: 65%;
  aspect-ratio: 856 / 316;

  margin: 18px auto 0;
  padding: 0;

  border: 0;
  border-radius: 0;

  background-color: transparent;
  background-image: url("assets/btn-install.png");
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;

  color: transparent;
  font-size: 0;

  box-shadow: none;
  cursor: pointer;
}

.install-app-btn:active {
  transform: translateY(1px);
}

.new-btn {
  background-image: url("assets/btn-nllepartie.png");
}

.resume-btn {
  background-image: url("assets/btn-partiencours.png");
}

.resume-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.resume-info {
  font-size: 22px;
  line-height: 1.25;
  color: #555;

  margin-top: -12px;
  margin-bottom: 4px;
}

.home-footer {
  margin-top: 10px;
  text-align: center;
}

.about-home-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.from-logo {
  width: 180px;
  max-width: 70%;
  display: block;
  margin: 0 auto;
}

.app-version {
  margin-top: -20px;
  font-size: 16px;
  opacity: 0.7;
}

/* STRUCTURE APP */

.app {
  max-width: 1000px;
  margin: auto;
}

.card {
  background: white;
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.08);
}

h1 {
  margin-top: 0;
  text-align: center;
  letter-spacing: 0;
}

h2 {
  margin-top: 24px;
}

label {
  display: block;
  margin-top: 16px;
  margin-bottom: 6px;
  font-weight: bold;
}

.setup-actions {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 12px;
  margin-top: 18px;
}

.cancel-btn {
  background: #d71915;
  color: white;
  font-weight: 900;
  border-radius: 18px;
}

.start-btn {
  background: #31b84a;
  color: white;
  font-weight: 900;
  border-radius: 18px;
}

input,
select {
  width: 100%;
  padding: 12px;
  border: 1px solid #ccc;
  border-radius: 12px;
  font-size: 16px;
}

select {
  appearance: auto;
  cursor: pointer;
}

button {
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  margin-top: 14px;
  font-size: 16px;
  cursor: pointer;
  background: #e7e7e7;
}

.primary {
  width: 100%;
  background: #111;
  color: white;
  font-weight: bold;
}

/* PARTIE */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;

  margin-top: 30px;
  margin-bottom: 18px;
}

.topbar h1 {
  text-align: left;
  margin-bottom: 4px;
  font-family: 'Permanent Marker', cursive;
  font-size: 70px;
  font-weight: normal;
  color: #0a0a0a;
}

.topbar p {
  margin: 0;
  color: #666;
}

.menu-btn {
  width: 48px;
  height: 48px;
  padding: 0;
  font-size: 26px;
  font-weight: bold;
  margin-top: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 2px;
  overflow: hidden;
}

th,
td {
  border: 3px solid #8f8f8f;
  padding: 6px 4px;
  text-align: center;
}

th {
  font-size: 22px;
  font-weight: 900;
  white-space: nowrap;
  background: #6f6f6f;
  color: white;
}

th:not(:first-child):not(.warning-head) {
  font-size: 30px;
  padding: 4px 2px;
}

.round-cell,
#scoreFoot td:first-child {
  background: #bfbfbf;
  color: #cacaca;
  font-size: 30px;        /* taille */
  font-weight: 750;       /* graisse */
  letter-spacing: -3px;    /* écart entre les caractères */
}

.round-cell,
#scoreTable th:first-child,
#scoreFoot td:first-child {
  width: 38px;
  min-width: 38px;
  max-width: 38px;
  padding: 2px;
}

.score-cell {
  background: #f8f8f8;
  min-width: 0;
}

.rank {
  display: block;
  font-size: 30px;
  color: #8e8e8e;
  margin-top: -20px;
  width: 100%;
  text-align: right;
  padding-right: 6px;
}

.score-value {
  font-family: 'Caveat Brush', cursive;
  font-size: 42px;
  font-weight: 500;
  color: #5e5e5e;
  text-align: center;
}

.score-cell-content {
  position: relative;
  width: 100%;

  display: flex;
  align-items: center;
  justify-content: center;
}

.status-slot {
  position: absolute;
  right: -2px;
  top: 50%;
  transform: translateY(-50%);

  width: 32px;
  height: 32px;

  display: flex;
  align-items: center;
  justify-content: center;
}

.status-slot img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  display: block;
}

.editing-row td {
    background: #fff3b0 !important;
}

.editing-row {
    outline: 4px solid #f4b400;
}

tfoot td {
  background: #bfbfbf;
  font-family: 'Caveat Brush', cursive;
  font-size: 60px;
  font-weight: normal;
  color: #222;
}

#scoreFoot td {
  vertical-align: middle;
  line-height: 1;
  padding-top: 5px;
  padding-bottom: 14px;
}

/* Alternance des colonnes joueurs */
#scoreTable tbody td.score-cell:nth-child(even) {
  background: #e5e5e5;
}

#scoreTable tbody td.score-cell:nth-child(odd) {
  background: #fcfcfc;
}

.warning-head {
  width: 26px;
  padding: 0;
  background: #ffffff00;
}

.warning-cell {
  width: 26px;
  padding: 4px;
  border-left: none;
  cursor: pointer;
  font-size: 16px;
}

.untouched-cell {
  background: #fff6cc !important;
  color: #555;
}

.empty-cell {
  font-size: 22px;
  font-weight: bold;
  opacity: 0.5;
}

.score-cell.cell-warning {
  background: #ffe3e3;
}

/* Manche incohérente */
#scoreTable tbody tr.round-warning td {
  background: #ffd6d6 !important;
}

#scoreTable tbody tr.round-warning .round-cell {
  background: #d98282 !important;
}

#scoreTable tbody tr.round-warning .warning-cell {
  background: #ffd6d6 !important;
}

/* MODALES */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px;
  z-index: 9999;
  pointer-events: auto;
}

.modal-content {
  background: white;
  width: 100%;
  max-width: 420px;
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  pointer-events: auto;
}

.modal-buttons {
  display: flex;
  margin-top: 18px;
}

.modal-buttons button {
  flex: 1;
}

.menu-content button {
  width: 100%;
  display: block;
  position: relative;
  z-index: 10000;
  cursor: pointer;
}

/* FIN DE PARTIE */

.final-ranking {
  padding-left: 0;
  list-style: none;
}

.final-ranking li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid #eee;
}

/* NOUVELLE PARTIE */

.setup-screen {
  max-width: 640px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 190px 28px 40px;
  background-image: url("assets/FOND-blanc.png");
  background-repeat: repeat;
  border-radius: 0;
  box-shadow: none;
  position: relative;
  overflow: hidden;
}

.setup-screen::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 150px;
  width: 100%;
  background-image: url("assets/FOND-noir.png");
  background-repeat: repeat;
  z-index: 0;
}

.setup-screen::after {
  content: "";
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 360px;
  height: 190px;
  background-image: url("assets/TXEK-logo-full-cartes.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  z-index: 1;
}

.setup-screen > * {
  position: relative;
  z-index: 2;
}

.setup-screen h1 {
  font-size: 38px;
  font-weight: 900;
  margin-bottom: 26px;
}

.setup-screen label,
.setup-screen h2 {
  text-align: center;
}

.setup-screen input,
.setup-screen select {
  background: white;
  border: 2px solid #999;
}

.setup-screen .primary {
  background: #d71915;
  color: white;
  border-radius: 16px;
  font-size: 20px;
  font-weight: 900;
}

.setup-title {
  text-align: center;
  font-family: 'Permanent Marker', cursive;
font-weight: normal;
  font-size: 64px;
  font-weight: 900;
  line-height: 0.85;
  letter-spacing: 1px;
  margin-top: 30px;
  margin-bottom: 40px;
  color: #222;
  text-transform: uppercase;

}

/* =========================
   ECRAN SCORE
========================= */

.game-screen {
  max-width: 640px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 190px 20px 40px;

  background-image: url("assets/FOND-blanc.png");
  background-repeat: repeat;

  position: relative;
  overflow: hidden;
}

.game-screen::before {
  content: "";

  position: absolute;
  top: 0;
  left: 0;

  width: 100%;
  height: 150px;

  background-image: url("assets/FOND-noir.png");
  background-repeat: repeat;

  z-index: 0;
}

.game-screen::after {
  content: "";

  position: absolute;
  top: 5px;
  left: 50%;

  transform: translateX(-50%);

  width: 360px;
  height: 190px;

  background-image: url("assets/TXEK-logo-full-cartes.png");
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;

  z-index: 1;
}

.game-screen > * {
  position: relative;
  z-index: 2;
}

.score-table-wrapper {
  width: 100%;
  max-height: 420px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border: 5px solid #8f8f8f;
  background: #bfbfbf;
  position: relative;
}

#scoreTable {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  overflow: visible;
  background: #e6e6e6;
}

.resume-btn.no-save {
  background: #ddd;
  color: #999;
  box-shadow: none;
}

/* JOUEURS - ECRAN NOUVELLE PARTIE */
.player-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.avatar-select {
  flex: 0 0 90px;
  width: 90px;
  min-width: 90px;
  max-width: 90px;
  height: 56px;
  font-size: 32px;
  padding: 0 6px;
}

.player-row input {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  height: 56px;
}

.remove-player {
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  margin-top: 0;
  background: #eda19e;
  color: #000;
}

/* =========================
   TABLEAU RESPONSIVE
========================= */

/* 2 à 4 joueurs : tout tient dans la largeur */
#scoreTable.players-2,
#scoreTable.players-3,
#scoreTable.players-4 {
  width: 100%;
  min-width: 0;
}

/* 5 à 7 joueurs : on garde des colonnes lisibles */
#scoreTable.players-5 {
  min-width: 450px;
}

#scoreTable.players-6 {
  min-width: 530px;
}

#scoreTable.players-7 {
  min-width: 600px;
}

/* Couleurs de la colonne totaux */
#scoreTable tfoot td:nth-child(even) {
  background: #c8c8c8;
}

#scoreTable tfoot td:nth-child(odd):not(:first-child) {
  background: #e1e1e1;
}

/* =========================
   TABLEAU : ÉLÉMENTS FIXES
========================= */

/* Noms des joueurs : fixes en haut */
#scoreTable thead th {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #6f6f6f;
}

/* Totaux : fixes en bas */
#scoreTable tfoot td {
  position: sticky;
  bottom: 0;
  z-index: 20;
}

/* Numéros de manches : fixes à gauche */
#scoreTable tbody td:first-child {
  position: sticky;
  left: 0;
  z-index: 25;
  background: #787878;
}

/* Coin haut-gauche (#) : fixe en haut et à gauche */
#scoreTable thead th:first-child {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 40;
  background: #787878;
}

/* Coin bas-gauche (Σ) : fixe en bas et à gauche */
#scoreTable tfoot td:first-child {
  position: sticky;
  bottom: 0;
  left: 0;
  z-index: 40;
  background: #787878;
}

@media (max-width: 520px) {

  html,
  body {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
  }

.status-slot {
  right: -4px;
  width: 24px;
  height: 24px;
}

.status-slot img {
  width: 22px;
  height: 22px;
}
  .app {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
  }

  #homeScreen,
  .setup-screen,
  .game-screen {
    width: 100%;
    max-width: 100%;
    margin: 0;
  }

  #homeScreen {
    padding-left: 0;
    padding-right: 0;
    overflow-x: hidden;
  }

  .home-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .txek-logo {
    width: 90%;
    max-width: 320px;
    height: auto;
  }

  .score-logo {
    width: 300px;
    max-width: 90%;
    display: block;
    margin: 0 auto 15px;
  }

  .game-screen {
    padding: 150px 0 40px;
    overflow-x: hidden;
  }

  .game-screen::after {
    width: 320px;
    height: 200px;
  }

.topbar,
.score-table-wrapper {
  width: calc(100% - 16px);
  margin-left: auto;
  margin-right: auto;
}

  .topbar {
    margin-top: 45px;
  }

  .topbar h1 {
    font-size: 40px;
    line-height: 0.7;
  }

  .score-value {
    font-size: 26px;
  }

  tfoot td {
    font-size: 35px;
  }

  .rank {
    font-size: 13px;
  }

  .trophy-icon {
    font-size: 1.3em;
  }

  .setup-screen::after {
    width: 300px;
    height: 190px;
  }
}

#editModal {
  align-items: flex-start;
  padding-top: 35px;
  overflow-y: auto;
}

#addRoundBtn {
  display: block;
  width: 320px;
  max-width: 80vw;
  aspect-ratio: 1000 / 441;
  margin: 18px auto 0;

  padding: 0;
  border: 0;

  background: transparent url("assets/NlleMancheUP.png") center / contain no-repeat;

  color: transparent;
  font-size: 0;
  cursor: pointer;
}

#addRoundBtn.pressed {
  background: transparent url("assets/NlleMancheDWN.png") center / contain no-repeat;
}

/* =========================
   POPUP SAISIE SCORE
========================= */

.score-entry-modal {
  position: relative;
  width: 340px;
  max-width: 92vw;
  padding: 0;
  overflow: visible;
  background: #c9c8c8;
  border: 5px solid #8a8a8a;
  border-radius: 22px;
  box-shadow: 0 10px 22px rgba(0,0,0,0.25);
}

/* En-tête joueur */
.score-entry-header {
  position: relative;
  height: 45px;
  min-height: 42px;
  padding: 0 10px;
  overflow: visible;
  background: #747474;
  color: white;
  border-bottom: 5px solid #8a8a8a;
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
}

.score-entry-player {
  position: relative;
  display: flex;
  align-items: center;
  height: 42px;
  padding-left: 50px;
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.15;
}

.player-avatar-pop {
  position: absolute;
  left: -40px;
  top: 50%;
  margin: 0;
  font-size: 66px;
  line-height: 1;
  transform: translateY(-50%);
  z-index: 5;
}

/* Zone score + statut */
.score-entry-body {
  display: grid;
  grid-template-columns: 1fr 79px;
}

.score-input-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 145px;
  padding: 14px 16px;
  background: #dddddd;
  border-right: 5px solid #8a8a8a;
}

.score-entry-label {
  display: block;
  width: 100%;
  margin: 0 0 10px;
  text-align: center;
  font-size: 30px;
  font-weight: 400;
  line-height: 0.6;
}

#modalScoreInput {
  width: 100%;
  margin: 0 auto;
  padding: 0;
  border: none;
  outline: none;
  box-shadow: none;
  background: transparent;
  color: #222;
  font-family: "Caveat Brush", cursive;
  font-size: 4.8rem;
  line-height: 1;
  text-align: center;
}

/* Retire les flèches du champ nombre */
#modalScoreInput::-webkit-outer-spin-button,
#modalScoreInput::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

#modalScoreInput[type="number"] {
  -moz-appearance: textfield;
}

/* Colonne statut */
.status-zone {
  position: relative;
  display: grid;
  grid-template-rows: 1fr 48px;
  width: 79px;
  min-height: 145px;
  background: #ffffff;
}

.status-current-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: #ffffff;
  cursor: default;
  pointer-events: none;
}

.status-current-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  line-height: 1;
}

.status-current-icon img {
  width: 78%;
  height: 78%;
  object-fit: contain;
}

.status-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 40px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: #ffffff;
  color: #2c2a16;
  font-size: 50px;
  cursor: pointer;
  transform: translateY(-12px);
}

/* Menu de choix du statut */
.status-popup-menu {
  position: absolute;
  right: -20px;
  top: calc(100% - 30px);
  width: 220px;
  padding: 6px 8px;
  overflow: hidden;
  background: white;
  border: 5px solid #8a8a8a;
  border-radius: 14px;
  box-shadow: 0 8px 18px rgba(0,0,0,0.25);
  z-index: 30;
}

.status-option {
  display: flex;
  align-items: center;
  width: 100%;
  height: 42px;
  min-height: 0;
  margin: 0;
  padding: 0 8px;
  gap: 6px;
  border: none;
  border-radius: 8px;
  background: white;
  font-size: 16px;
  line-height: normal;
  text-align: left;
  cursor: pointer;
}

.status-option:hover {
  background: #FEF5CC;
  color: #292929;
}

.status-option > span:last-child {
  transform: translateY(-1px);
}

.status-symbol {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 40px;
  min-width: 40px;
  height: 40px;
  overflow: hidden;
}

.status-symbol img {
  display: block;
  width: 40px;
  height: 40px;
  max-width: 40px;
  max-height: 40px;
  object-fit: contain;
}

.hidden-native-select {
  display: none;
}

/* Validation / annulation */
.score-entry-modal .modal-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  height: 64px;
  margin: 0;
  padding: 0;
  gap: 4px;
  background: #8a8a8a;
}

.score-entry-modal .modal-buttons .score-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  max-width: none;
  height: 64px;
  min-height: 64px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: white;
  font-size: 0 !important;
  line-height: 64px;
}

.score-entry-modal .cancel-score-btn {
  background:
    #e01813
    url("assets/btn-cancel.png")
    center / 50px auto
    no-repeat !important;

  border-bottom-left-radius: 16px !important;
}

.score-entry-modal .validate-score-btn {
  background:
    #2dbc50
    url("assets/btn-check.png")
    center / 50px auto
    no-repeat !important;

  border-bottom-right-radius: 16px !important;
}

/* Ajustement mobile du popup : mêmes proportions, nom légèrement plus grand */
@media (max-width: 520px) {
  .score-entry-player {
    font-size: 1.8rem;
  }

}

