:root {
  --bg: #020617;
  --card: #0f172a;
  --border: #1e293b;
  --input: #334155;
  --fg: #e2e8f0;
  --muted: #94a3b8;
  --dim: #64748b;
  --faint: #475569;
  --primary: #2563eb;
  --link: #60a5fa;
  --link-hover: #93c5fd;
  --ok: #22c55e;
  --ok-text: #4ade80;
  --danger: #f87171;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family:
    system-ui,
    -apple-system,
    'Segoe UI',
    sans-serif;
  background: var(--bg);
  color: var(--fg);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

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

h1,
h2 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.02em;
}
h1 {
  font-size: 22px;
}
h2 {
  font-size: 18px;
}
p {
  margin: 0;
}

.muted {
  color: var(--muted);
}
.small {
  font-size: 12px;
}
.mono {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.center-text {
  text-align: center;
}

/* ---- Barre haute ------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 56px;
  padding: 0 16px;
  padding-top: env(safe-area-inset-top);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 600;
  color: var(--fg);
  white-space: nowrap;
  flex-shrink: 0;
}
.brand svg {
  color: var(--primary);
  flex-shrink: 0;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.topbar-right::-webkit-scrollbar {
  display: none;
}
.topbar-right form {
  display: contents;
}
@media (max-width: 559px) {
  #ua-badge {
    display: none;
  }
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---- Mise en page ------------------------------------------------------ */
.container {
  width: 100%;
  max-width: 1360px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.page-head-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.seg {
  display: flex;
  gap: 6px;
}
.seg button {
  min-height: 36px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.seg button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.players {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
.players.single {
  grid-template-columns: 1fr;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-width: 0;
}
.card-head,
.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
}
.card-foot {
  min-height: 44px;
}
.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.name {
  font-size: 14px;
  font-weight: 600;
}
.tag {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--border);
  color: var(--muted);
}
.link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  min-height: 44px;
}
.link.muted {
  color: var(--muted);
}

/* Le conteneur ne contraint rien : c'est l'iframe collée qui décide de sa taille. */
.embed {
  width: 100%;
  background: #000;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  line-height: 0;
}
.embed iframe {
  display: block;
  max-width: 100%;
}
.embed-solo {
  border: 0;
}

.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 160px;
  padding: 24px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--faint);
  font-size: 13px;
  text-align: center;
}

.sitefoot {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--faint);
}
.sitefoot a {
  color: var(--faint);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

/* ---- Player seul ------------------------------------------------------- */
body.solo {
  background: #000;
}
.solo-bar {
  border-bottom: 0;
}
.solo-main {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.solo-foot {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}

/* ---- Formulaires / admin ---------------------------------------------- */
.center {
  flex-grow: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.login {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 380px;
  padding: 28px;
}
.login-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.error {
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.4);
  color: var(--danger);
  font-size: 13px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
}
.field-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.field input[type='text'],
.field input[type='password'],
.field textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--input);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: 14px;
}
.field textarea {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  resize: vertical;
}
.field input:focus,
.field textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: 0;
  border-color: var(--primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--input);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn.primary:disabled {
  opacity: 0.6;
  cursor: default;
}
.btn.ghost {
  border-color: var(--border);
}
.btn.icon {
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  border-color: var(--border);
}
.btn.icon:disabled {
  opacity: 0.3;
  cursor: default;
}
.btn.danger {
  color: var(--danger);
  border-color: var(--border);
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
  align-items: start;
}
.col {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
.form {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px;
}
.actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.status {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--ok-text);
}
.status.bad {
  color: var(--danger);
}
.status .note {
  color: var(--muted);
}

.toggle {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 400;
  color: var(--muted);
  min-height: 44px;
}
.toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.switch {
  position: relative;
  flex-shrink: 0;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: var(--input);
  transition: background 0.15s;
}
.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--fg);
  transition: transform 0.15s;
}
.toggle input:checked + .switch {
  background: var(--primary);
}
.toggle input:checked + .switch::after {
  transform: translateX(18px);
}
.toggle input:focus-visible + .switch {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

.preview {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.preview .placeholder {
  line-height: 1.4;
  padding: 16px;
  text-align: center;
}
.preview:has(iframe) {
  display: block;
}

/* Tableau des players (grille) */
.table {
  overflow: hidden;
}
.row {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 96px;
  gap: 8px 12px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.row:last-child {
  border-bottom: 0;
}
.row.head {
  display: none;
}
.row .order {
  display: flex;
  gap: 4px;
}
.row .cell-name {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.row .cell-name .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row .cell-source {
  display: none;
}
.row .cell-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.row .cell-status.on {
  color: var(--ok-text);
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--faint);
}
.on .dot {
  background: var(--ok);
}
.row .cell-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}
.row.draft .name {
  color: var(--muted);
}
.row.empty-row {
  color: var(--faint);
  font-size: 13px;
  justify-content: center;
  display: flex;
}

@media (min-width: 760px) {
  .topbar {
    height: 64px;
    padding-inline: 32px;
  }
  .container {
    padding: 28px 32px 48px;
  }
  .row {
    grid-template-columns: 76px minmax(0, 1fr) 160px 100px 150px;
  }
  .row.head {
    display: grid;
    padding: 10px 14px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--dim);
  }
  .row .cell-source {
    display: block;
  }
  .row .cell-name .mono {
    display: none;
  }
}

@media (min-width: 900px) {
  .players {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
  }
  .players.single {
    grid-template-columns: 1fr;
    max-width: 960px;
    margin: 0 auto;
    width: 100%;
  }
}

@media (min-width: 1100px) {
  .admin-grid {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    gap: 32px;
  }
}

[hidden] {
  display: none !important;
}
