html { font-size: clamp(12px, 1.1vw, 19px); }

body {
  font-family: 'Inter', -apple-system, sans-serif;
}

a { text-decoration: none; }

/* ---- TOP BAR ---- */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 100;
}

.top-bar-center p { margin-top: 0.1rem; }
.top-bar-right { gap: 0.75rem; }
.help-btn { border: 1px solid var(--border-light); }
.back-button { display: inline-block; }

/* ---- ZONE DE JEU ---- */
.game-area {
  max-width: 82.5rem;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 5rem;
}

.screen-title {
  text-align: center;
  margin-bottom: 2rem;
  position: relative;
}
.screen-title h2 { font-size: 1.5rem; font-weight: 800; color: var(--text-primary); }

.back-screen-btn {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.55rem 1.1rem;
  background: var(--accent);
  border: none;
  color: var(--bg-main);
  border-radius: 0.6rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(182, 216, 242, 0.25);
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}
.back-screen-btn:hover { background: var(--accent-hover); transform: translateY(calc(-50% - 1px)); box-shadow: 0 6px 16px rgba(182, 216, 242, 0.35); }

/* ---- BOUTONS ---- */
.tl-btn {
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.5rem 0.95rem;
  background: rgba(10, 22, 40, 0.6);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  border-radius: 0.55rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
.tl-btn:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--accent); }
.tl-btn:disabled { opacity: 0.45; cursor: default; }
.tl-btn-main { background: var(--accent); color: var(--bg-main); border-color: var(--accent); font-weight: 700; }
.tl-btn-main:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.tl-btn-danger { color: #fca5a5; border-color: #7f1d1d; }
.tl-btn-danger:hover:not(:disabled) { background: #7f1d1d; border-color: #ef4444; }

.tl-search {
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.5rem 0.8rem;
  background: var(--bg-main);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 0.55rem;
  outline: none;
}
.tl-search:focus { border-color: var(--accent); }
.tl-search::placeholder { color: var(--text-muted); }

/* =============================================
   ÉCRAN 1 — QUE CLASSER ?
   ============================================= */
.mode-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
  max-width: 64rem;
  margin: 0 auto;
}

.mode-card, .zone-card, .resume-card {
  font-family: inherit;
  color: inherit;
  background: rgba(10, 22, 40, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(170, 190, 215, 0.18);
  cursor: pointer;
  text-align: center;
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}
.mode-card:hover, .zone-card:hover, .resume-card:hover {
  transform: translateY(-3px);
  background: rgba(15, 31, 52, 0.65);
  border-color: rgba(236, 172, 74, 0.65);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45), 0 0 28px rgba(236, 172, 74, 0.12);
}

.mode-card {
  border-radius: 1.25rem;
  padding: 1.75rem 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.mode-card-count { font-size: 2.3rem; font-weight: 800; color: var(--accent); line-height: 1.1; }
.mode-card-icon  { font-size: 2rem; line-height: 1.3; }
.mode-card-title { font-size: 1rem; font-weight: 800; color: var(--text-primary); }
.mode-card-label { font-size: 0.8rem; color: var(--text-secondary); }

.resume-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  max-width: 30rem;
  width: 100%;
  margin: 0 auto 1.75rem;
  padding: 1.1rem 1.5rem;
  border-radius: 1rem;
  border-color: rgba(182, 216, 242, 0.45);
  background: linear-gradient(135deg, rgba(182, 216, 242, 0.12), rgba(10, 22, 40, 0.6));
}
.resume-label { font-size: 0.75rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 0.06em; }
.resume-title { font-size: 1.05rem; font-weight: 800; }
.resume-sub   { font-size: 0.8rem; color: var(--text-secondary); }

/* =============================================
   ÉCRAN 2 — CHOIX DE L'ARC
   ============================================= */
.zone-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: 0.75rem;
}
.zone-card { border-radius: 0.875rem; padding: 1.25rem 1rem; }
.zone-card-name  { font-size: 0.88rem; font-weight: 700; color: var(--text-primary); margin-bottom: 0.375rem; }
.zone-card-count { font-size: 0.75rem; color: var(--text-muted); }

/* =============================================
   ÉCRAN 3 — CHOIX UN PAR UN
   ============================================= */
.pick-search {
  display: block;
  width: 100%;
  max-width: 26rem;
  margin: 0 auto 1.25rem;
  font-size: 0.95rem;
  padding: 0.65rem 1rem;
}

.pick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr));
  gap: 0.6rem;
}

.pick-item {
  font-family: inherit;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 0.65rem;
  overflow: hidden;
  cursor: pointer;
  color: var(--text-secondary);
  transition: border-color 0.15s, transform 0.15s;
}
.pick-item:hover { border-color: var(--border-light); transform: translateY(-2px); }
.pick-item img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; opacity: 0.55; transition: opacity 0.15s; }
.pick-item span {
  padding: 0.3rem 0.3rem;
  font-size: 0.68rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pick-item.selected { border-color: #22c55e; color: #fff; background: #14532d; }
.pick-item.selected img { opacity: 1; }

.pick-bar {
  position: sticky;
  bottom: 0.75rem;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.6rem 0.9rem;
  margin-top: 1.5rem;
  padding: 0.75rem 1rem;
  background: rgba(10, 22, 40, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(170, 190, 215, 0.25);
  border-radius: 0.9rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
.pick-count { font-size: 0.88rem; font-weight: 700; }
.pick-bar .tl-btn-main { padding: 0.55rem 1.6rem; font-size: 0.88rem; }

/* =============================================
   ÉCRAN 4 — LA TIER LIST
   ============================================= */
#boardScreen {
  --tl-size: 5.2rem;   /* côté d'une photo */
  --tl-label: 7rem;    /* largeur du nom de rangée */
}

.shared-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
  margin-bottom: 1.5rem;
  padding: 0.9rem 1.2rem;
  background: linear-gradient(135deg, rgba(182, 216, 242, 0.14), rgba(10, 22, 40, 0.7));
  border: 1px solid rgba(182, 216, 242, 0.4);
  border-radius: 0.9rem;
}
.shared-banner p { font-size: 0.88rem; color: var(--text-secondary); }
.shared-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.board-head { display: flex; justify-content: center; margin-bottom: 1rem; }
.tl-title {
  width: 100%;
  max-width: 36rem;
  font-family: inherit;
  font-size: 1.35rem;
  font-weight: 800;
  text-align: center;
  color: var(--text-primary);
  background: transparent;
  border: 1px dashed transparent;
  border-radius: 0.5rem;
  padding: 0.3rem 0.6rem;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}
.tl-title:hover { border-color: var(--border-light); }
.tl-title:focus { border-color: var(--accent); background: rgba(10, 22, 40, 0.6); }
.tl-title-view { font-size: 1.35rem; font-weight: 800; text-align: center; }

.tl-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
.tl-toolbar-sep { width: 0.75rem; }

/* ---- Rangées ---- */
.tl-board {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: #0b1222;
  border: 3px solid #0b1222;
  border-radius: 0.5rem;
  overflow: hidden;
}

.tl-row {
  display: flex;
  min-height: var(--tl-size);
  background: rgba(30, 41, 59, 0.92);
  transition: background 0.15s;
}
.tl-row.tl-over { background: rgba(51, 65, 85, 0.95); }

.tl-label {
  flex: 0 0 var(--tl-label);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem;
  border: none;
  font-family: inherit;
  font-size: 1.35rem;
  font-weight: 800;
  color: #111827;
  cursor: pointer;
  overflow-wrap: anywhere;
  line-height: 1.15;
}
.tl-label span { max-width: 100%; }
.tl-label:hover { filter: brightness(1.08); }

.tl-items {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  min-width: 0;
}

.tl-row-tools {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.2rem;
  padding: 0 0.35rem;
  background: #0f172a;
}
.tl-row-tools button {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 0.2rem 0.3rem;
  cursor: pointer;
  border-radius: 0.3rem;
}
.tl-row-tools button:hover:not(:disabled) { color: var(--text-primary); background: var(--bg-hover); }
.tl-row-tools button:disabled { opacity: 0.25; cursor: default; }

.tl-add-row {
  display: block;
  margin: 0.6rem auto 0;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.4rem 1rem;
  background: transparent;
  color: var(--text-secondary);
  border: 1px dashed var(--border-light);
  border-radius: 0.5rem;
  cursor: pointer;
}
.tl-add-row:hover:not(:disabled) { color: var(--text-primary); border-color: var(--accent); }
.tl-add-row:disabled { opacity: 0.4; cursor: default; }

/* ---- Persos ---- */
.tl-item {
  position: relative;
  width: var(--tl-size);
  height: var(--tl-size);
  flex: 0 0 auto;
  cursor: grab;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  outline: 1px solid #0b1222;
  outline-offset: -1px;
}
.tl-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
}
.tl-name {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0.12rem 0.2rem;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}
.tl-show-names .tl-name { display: block; }

.tl-item:hover { filter: brightness(1.12); }
.tl-item.tl-selected { outline: 3px solid #f59e0b; outline-offset: -3px; z-index: 1; }
.tl-item.tl-placeholder { opacity: 0.3; }

.tl-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 3000;
  pointer-events: none;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.55);
  outline: 2px solid var(--accent);
  border-radius: 0.2rem;
  overflow: hidden;
}
.tl-ghost .tl-name { display: block; }

body.tl-dragging, body.tl-dragging * { cursor: grabbing !important; }

/* Un perso est sélectionné : les rangées invitent à le recevoir */
.tl-has-selection .tl-row, .tl-has-selection .tl-pool { cursor: pointer; }
.tl-has-selection .tl-row:hover { background: rgba(51, 65, 85, 0.95); }

/* ---- Réserve ---- */
.tl-pool {
  margin-top: 1.5rem;
  padding: 1rem;
  background: rgba(10, 22, 40, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(170, 190, 215, 0.18);
  border-radius: 0.9rem;
  transition: border-color 0.15s;
}
.tl-pool.tl-over { border-color: var(--accent); }
.tl-pool-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.4rem;
}
.tl-pool-head h3 { font-size: 1rem; font-weight: 800; color: var(--accent); }
.tl-pool-head .tl-search { width: 14rem; max-width: 100%; }
.tl-hint { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 0.75rem; }

#poolItems {
  min-height: var(--tl-size);
  max-height: 24rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: 0.4rem;
  background: rgba(15, 23, 42, 0.5);
}

/* ---- Tier list reçue par un lien : rien de modifiable ---- */
.tl-readonly .tl-toolbar > :not(#btnNames):not(#btnImage),
.tl-readonly .tl-add-row,
.tl-readonly #boardBack,
.tl-readonly .tl-pool,
.tl-readonly .tl-row-tools { display: none; }
.tl-readonly .tl-label, .tl-readonly .tl-item { cursor: default; pointer-events: none; }
.tl-readonly .tl-item:hover { filter: none; }

/* =============================================
   POPUPS
   ============================================= */
.modal-overlay { z-index: 2000; }

@keyframes popIn { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: scale(1); } }
.modal-box {
  border-radius: 1.25rem;
  padding: 2rem;
  max-width: 520px;
}
.modal-box h3 { font-weight: 800; margin-bottom: 0.75rem; }
.modal-box p { font-size: 0.87rem; line-height: 1.7; margin-bottom: 0.4rem; }
.modal-box strong { color: var(--text-primary); }
.modal-close { font-size: 1.1rem; color: var(--text-muted); padding: 0.25rem; line-height: 1; }

.row-box { max-width: 26rem; }
.row-field { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1rem; }
.row-field > span { font-size: 0.75rem; font-weight: 700; color: #60a5fa; text-transform: uppercase; letter-spacing: 0.07em; }
.row-field input {
  font-family: inherit;
  font-size: 1rem;
  padding: 0.55rem 0.8rem;
  background: var(--bg-main);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 0.55rem;
  outline: none;
}
.row-field input:focus { border-color: var(--accent); }
.row-colors { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.row-color {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s;
}
.row-color:hover { transform: scale(1.1); }
.row-color.active { border-color: #fff; box-shadow: 0 0 0 2px var(--bg-main), 0 0 0 4px #fff; }
.row-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-bottom: 1rem; }
.row-actions .tl-btn { white-space: normal; }
.row-ok { display: block; width: 100%; padding: 0.65rem; }

/* ---- Confirmation ---- */
.confirm-box { max-width: 25rem; text-align: center; }
.modal-box.confirm-box h3 { margin-bottom: 0.5rem; padding-right: 0; } /* (pas de ✕ à éviter) */
.confirm-box p { margin-bottom: 1.4rem; }
.confirm-actions { display: flex; gap: 0.6rem; }
.confirm-actions .tl-btn { flex: 1; padding: 0.65rem 0.8rem; font-size: 0.88rem; white-space: normal; }
.tl-btn-confirm { background: #dc2626; border-color: #ef4444; color: #fff; font-weight: 700; }
.tl-btn-confirm:hover:not(:disabled) { background: #ef4444; border-color: #fca5a5; }

/* ---- Message bref ---- */
.tl-toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  z-index: 2500;
  max-width: calc(100% - 2rem);
  padding: 0.7rem 1.2rem;
  background: #14532d;
  border: 1px solid #22c55e;
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 0.7rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  text-align: center;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 900px) {
  .mode-cards { grid-template-columns: repeat(2, 1fr); }
}

/* Téléphone : photos plus petites, nom de rangée plus étroit */
@media (max-width: 700px) {
  .game-area { padding: 1.25rem 0.75rem 4rem; }
  .screen-title { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; margin-bottom: 1.25rem; }
  .back-screen-btn { position: static; transform: none; align-self: flex-start; }
  .back-screen-btn:hover { transform: translateY(-1px); }
  .mode-cards { gap: 0.6rem; }
  .mode-card { padding: 1.1rem 0.75rem; }
  .zone-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; }
  .zone-card { padding: 0.75rem 0.5rem; }
  .pick-grid { grid-template-columns: repeat(auto-fill, minmax(5rem, 1fr)); gap: 0.4rem; }

  #boardScreen { --tl-size: 3.7rem; --tl-label: 3.6rem; }
  .tl-label { font-size: 1rem; padding: 0.2rem; }
  .tl-row-tools { padding: 0 0.1rem; }
  .tl-name { font-size: 0.5rem; }
  .tl-toolbar .tl-btn { font-size: 0.75rem; padding: 0.45rem 0.7rem; }
  .tl-toolbar-sep { flex-basis: 100%; width: auto; height: 0; }
  .tl-pool { padding: 0.75rem 0.6rem; }
  .tl-pool-head .tl-search { width: 100%; }
  #poolItems { max-height: 45vh; }
  .row-actions { grid-template-columns: 1fr; }
}
