/* Challenge Carddass */
:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --surface-2: #ebe8e1;
  --ink: #1a1d29;
  --muted: #676b7a;
  --line: #dcd8cf;
  --accent: #d6336c;
  --accent-ink: #ffffff;
  --gold: #c88a00;
  --ok: #1f8a5b;
  --danger: #c0392b;
  --prism: linear-gradient(120deg, #ffcf4a, #ff5d8f 40%, #8f6bff 70%, #4ab8ff);
  --shadow: 0 6px 24px rgba(20, 22, 40, .10);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1220;
    --surface: #181c2e;
    --surface-2: #22273d;
    --ink: #eceef6;
    --muted: #9aa0b8;
    --line: #2d334c;
    --accent: #ff5d8f;
    --accent-ink: #160b12;
    --gold: #ffcf4a;
    --ok: #4fd39a;
    --danger: #ff7262;
    --shadow: 0 8px 30px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh; display: flex; flex-direction: column;
}
main.wrap { flex: 1; padding-top: 28px; padding-bottom: 48px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
h1 { font-size: clamp(1.6rem, 3.5vw, 2.3rem); line-height: 1.15; margin: 0 0 .4em; letter-spacing: -.01em; }
h2 { font-size: 1.3rem; margin: 1.8em 0 .7em; }
h3 { font-size: 1.05rem; margin: 1.4em 0 .5em; }
code { background: var(--surface-2); padding: .1em .35em; border-radius: 5px; font-size: .9em; }
kbd { border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 .35em; font-size: .85em; background: var(--surface); }
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.lead { font-size: 1.1rem; color: var(--muted); max-width: 46em; }
.kicker { text-transform: uppercase; letter-spacing: .08em; font-size: .78rem; color: var(--muted); margin: 0 0 .3em; font-weight: 600; }

/* En-tête */
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.top-in { display: flex; align-items: center; gap: 16px; min-height: 60px; }
.brand { font-weight: 800; color: var(--ink); display: flex; align-items: center; gap: 10px; font-size: 1.08rem; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.logo { width: 26px; height: 34px; border-radius: 5px; background: var(--prism); transform: rotate(8deg); box-shadow: -7px 2px 0 -1px var(--surface-2); }
nav#nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; align-items: center; }
nav#nav a { color: var(--ink); padding: 7px 11px; border-radius: 9px; font-size: .95rem; }
nav#nav a:hover { background: var(--surface-2); text-decoration: none; }
nav#nav a.on { background: var(--surface-2); font-weight: 600; }
nav#nav a.nav-cta { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
nav#nav a.nav-user { font-weight: 600; }
.menu-btn { display: none; margin-left: auto; background: none; border: 1px solid var(--line); color: var(--ink); border-radius: 8px; font-size: 1.2rem; padding: 4px 10px; cursor: pointer; }
@media (max-width: 860px) {
  .menu-btn { display: block; }
  nav#nav { display: none; position: absolute; left: 0; right: 0; top: 60px; background: var(--surface); border-bottom: 1px solid var(--line); flex-direction: column; align-items: stretch; padding: 8px 16px 14px; }
  .nav-open nav#nav { display: flex; }
}
.foot { border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; padding: 18px 0; }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent); color: var(--accent-ink); border: 1px solid transparent;
  padding: 10px 18px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn-big { padding: 14px 26px; font-size: 1.08rem; }
.btn-small { padding: 6px 12px; font-size: .88rem; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--line); }
.linkish { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; text-decoration: underline; padding: 0; }
form.inline { display: inline; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.is-sending { opacity: .7; pointer-events: none; }

/* Messages */
.flash { padding: 12px 16px; border-radius: 10px; margin: 0 0 18px; border: 1px solid var(--line); background: var(--surface); }
.flash-ok { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.flash-error { border-color: var(--danger); color: var(--danger); }
.flash-info { border-color: var(--line); }
.empty { text-align: center; padding: 40px 16px; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); }
.empty h1, .empty h2 { color: var(--ink); margin-top: 0; }

/* Accueil */
.hero { display: grid; grid-template-columns: 1.4fr 1fr; gap: 32px; align-items: center; padding: 18px 0 8px; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.1rem); }
.hero h1 em { font-style: normal; background: var(--prism); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stats-line { color: var(--muted); }
.how { background: var(--surface); border-radius: var(--radius); padding: 22px 22px 22px 46px; box-shadow: var(--shadow); margin: 0; }
.how li { margin: 8px 0; }
@media (max-width: 760px) { .hero { grid-template-columns: 1fr; } }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.sec-head h2 { margin-bottom: .7em; }
.game-list { display: grid; gap: 8px; }
.game-row { display: grid; grid-template-columns: 1fr auto auto; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; color: var(--ink); }
.game-row:hover { border-color: var(--accent); text-decoration: none; }
.g-status { color: var(--muted); font-size: .88rem; }
.g-go { color: var(--accent); font-weight: 600; }
@media (max-width: 600px) { .game-row { grid-template-columns: 1fr; gap: 2px; } }

/* Vignettes */
.grid-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 18px; }
.thumb { display: flex; flex-direction: column; gap: 6px; color: var(--ink); }
.thumb:hover { text-decoration: none; }
.thumb:hover .thumb-img { transform: translateY(-3px); box-shadow: var(--shadow); }
.thumb-img { position: relative; aspect-ratio: 63 / 88; background: var(--surface-2); border-radius: 9px; overflow: visible; transition: transform .15s, box-shadow .15s; display: flex; align-items: center; justify-content: center; }
.thumb-img img { width: 100%; height: 100%; object-fit: contain; border-radius: 9px; }
.thumb-cap { font-size: .85rem; line-height: 1.3; }
.thumb-cap small { display: block; color: var(--muted); }
.thumb-xs { width: 74px; }
.thumb-xs .thumb-cap small, .thumb-xs .badge { display: none; }
.thumb-xs .thumb-cap { font-size: .75rem; }
.thumb-s { width: 100%; }
.thumb-l { width: min(320px, 100%); }
.thumb-l .thumb-cap { font-size: 1rem; }
.missing { font-size: .75rem; color: var(--muted); text-align: center; padding: 6px; }
.rank-badge { position: absolute; top: -8px; left: -8px; min-width: 30px; height: 30px; padding: 0 6px; border-radius: 15px; background: var(--ink); color: var(--bg); font-weight: 800; display: flex; align-items: center; justify-content: center; font-size: .9rem; box-shadow: 0 2px 6px rgba(0,0,0,.25); }
.rank-badge.r1 { background: var(--prism); color: #1a1020; min-width: 38px; height: 38px; border-radius: 19px; font-size: 1.1rem; }
.rank-badge.r2, .rank-badge.r3 { background: var(--gold); color: #1a1406; }
.ranked .pts, .ranked .who { font-size: .85rem; margin-top: 4px; }
.ranked .pts { font-weight: 700; color: var(--accent); }
.ranked .who small { display: block; color: var(--muted); }
.badge { display: inline-block; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 1px 7px; border-radius: 20px; vertical-align: middle; border: 1px solid var(--line); color: var(--muted); }
.badge.prisme { background: var(--prism); color: #1a1020; border-color: transparent; }
.meta-line { display: block; color: var(--muted); font-size: .85rem; }
.strip { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; padding-top: 8px; }
.strip .thumb-s { width: 120px; }

/* Formulaires */
.form-card { max-width: 460px; margin: 10px auto; background: var(--surface); padding: 28px; border-radius: var(--radius); box-shadow: var(--shadow); }
.form { display: grid; gap: 14px; margin: 16px 0; }
.form label { display: grid; gap: 5px; font-weight: 600; font-size: .92rem; }
input[type=text], input:not([type]), input[type=password], select {
  font: inherit; padding: 10px 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); width: 100%;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.logout { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }

/* Sélecteur */
.picker { display: grid; gap: 16px; }
.picker-tools { display: flex; gap: 8px; }
.lic { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 6px 18px 16px; margin: 0; }
.lic legend { padding: 0 8px; }
.chk { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.chk input { width: 18px; height: 18px; accent-color: var(--accent); }
.chk small { color: var(--muted); }
.chk-lic { font-weight: 800; font-size: 1.15rem; }
.series { display: grid; gap: 12px; }
.serie { padding: 10px 0 0; border-top: 1px solid var(--line); }
.serie:first-child { border-top: 0; }
.chk-serie { font-weight: 700; }
.parts { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 0 26px; }
.chk-part { background: var(--surface-2); padding: 5px 12px; border-radius: 20px; font-size: .92rem; }
.picker-bar { position: sticky; bottom: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; box-shadow: var(--shadow); flex-wrap: wrap; }

/* Duel */
.duel-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; }
.duel-head h1 { margin: 0; }
.progress { min-width: 220px; flex: 0 1 300px; }
.progress-txt { font-size: .9rem; color: var(--muted); margin-bottom: 4px; text-align: right; }
progress.bar { width: 100%; height: 8px; border: 0; border-radius: 6px; background: var(--surface-2); overflow: hidden; -webkit-appearance: none; appearance: none; }
progress.bar::-webkit-progress-bar { background: var(--surface-2); border-radius: 6px; }
progress.bar::-webkit-progress-value { background: var(--prism); border-radius: 6px; }
progress.bar::-moz-progress-bar { background: var(--prism); border-radius: 6px; }
.duel-hint { text-align: center; margin: 22px 0 12px; font-weight: 600; }
.kbd-hint { display: block; font-weight: 400; color: var(--muted); font-size: .88rem; }
@media (hover: none) { .kbd-hint { display: none; } }
.duel { display: grid; grid-template-columns: 1fr auto 1fr; gap: 18px; align-items: center; max-width: 900px; margin: 0 auto; }
.vs { font-weight: 900; font-size: 1.4rem; color: var(--muted); letter-spacing: .05em; }
.duel-card {
  appearance: none; border: 2px solid transparent; background: var(--surface); color: var(--ink); font: inherit; text-align: center;
  border-radius: 18px; padding: 14px; cursor: pointer; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; align-items: center;
  transition: transform .12s, border-color .12s; width: 100%;
}
.duel-card:hover { transform: translateY(-4px); border-color: var(--accent); }
.duel-card.picked { border-color: var(--accent); transform: scale(.98); }
.duel-card { max-width: calc(54vh * 0.716 + 32px); justify-self: center; }
.duel-img { position: relative; width: 100%; aspect-ratio: 63 / 88; display: flex; align-items: center; justify-content: center; }
.duel-img img { width: 100%; height: 100%; object-fit: contain; border-radius: 10px; }
.duel-cap { font-size: .95rem; }
.holder { position: absolute; top: 8px; right: 8px; background: var(--ink); color: var(--bg); font-size: .7rem; font-weight: 700; padding: 2px 8px; border-radius: 12px; text-transform: uppercase; letter-spacing: .05em; opacity: .85; }
@media (max-width: 600px) {
  .duel { gap: 8px; }
  .vs { font-size: .9rem; }
  .duel-card { padding: 8px; border-radius: 12px; }
  .duel-cap { font-size: .8rem; }
  .duel-cap .meta-line { font-size: .72rem; }
  .duel-card { max-width: none; }
  .holder { font-size: .6rem; }
}
.duel-tools { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin: 26px 0 8px; }
.duel-tools + .muted { text-align: center; }
.found { margin-top: 28px; }
.found h2 { font-size: 1rem; margin-bottom: .4em; }

/* Révélation du top 1 */
.reveal { text-align: center; max-width: 640px; margin: 0 auto; }
.reveal-card { position: relative; width: min(340px, 80vw); margin: 18px auto 14px; border-radius: 16px; padding: 6px; background: var(--prism); box-shadow: var(--shadow); }
.reveal-card img { border-radius: 12px; width: 100%; }
.reveal-card .rank-badge { top: -14px; left: -14px; }
.reveal-title { font-size: 1.1rem; }
.choice-box { background: var(--surface); border-radius: var(--radius); padding: 18px 20px; margin: 22px 0 12px; border: 1px solid var(--line); }
.choice-box .actions { justify-content: center; }
.undo-line { margin-top: 12px; }

/* Résultat */
.podium { display: grid; grid-template-columns: minmax(200px, max-content) 1fr; gap: 32px; align-items: start; margin-top: 20px; }
.rest { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 18px; }
@media (max-width: 700px) { .podium { grid-template-columns: 1fr; } .podium-first { display: flex; justify-content: center; } }
.result-actions { margin-top: 28px; }

/* Profils, listes */
.game-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px 16px; margin: 0 0 14px; }
.game-card header { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.g-title { font-weight: 700; color: var(--ink); }
.st-finished { color: var(--ok); }
.players { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.player { display: flex; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; color: var(--ink); }
.player:hover { border-color: var(--accent); text-decoration: none; }
.player-fav { width: 48px; aspect-ratio: 63/88; background: var(--surface-2); border-radius: 6px; flex: none; overflow: hidden; }
.player-fav img { width: 100%; height: 100%; object-fit: cover; }
.player-info small { display: block; color: var(--muted); }
a.user { font-weight: 600; }

/* Classements */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin: 10px 0 16px; flex-wrap: wrap; }
.tabs a { padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 600; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.scope-form { margin: 0 0 14px; }
.scope-form label { display: inline-flex; gap: 8px; align-items: center; font-weight: 600; }
.scope-form select { width: auto; max-width: 70vw; }
.rank-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.rank-table th, .rank-table td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.rank-table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); }
.rank-table .num { text-align: right; white-space: nowrap; }
.rank-table .pos { font-weight: 800; width: 40px; }
.rank-table.compact td { padding: 6px 12px; font-size: .92rem; }
.row-card { display: flex; gap: 12px; align-items: center; color: var(--ink); }
.row-card img { width: 44px; aspect-ratio: 63/88; object-fit: contain; border-radius: 5px; background: var(--surface-2); }
.row-card:hover { text-decoration: none; }
@media (max-width: 600px) { .rank-table th:nth-child(5), .rank-table td:nth-child(5) { display: none; } }

/* Fiche carte */
.card-page { display: grid; grid-template-columns: minmax(220px, 380px) 1fr; gap: 36px; align-items: start; }
.card-big img { border-radius: 14px; box-shadow: var(--shadow); width: 100%; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; margin: 16px 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }
.big-stat strong { font-size: 1.6rem; color: var(--accent); }
.plain { list-style: none; padding: 0; }
.plain li { padding: 4px 0; }
@media (max-width: 700px) { .card-page { grid-template-columns: 1fr; } .card-big { max-width: 300px; margin: 0 auto; } }

/* Admin */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 20px 20px; margin-bottom: 20px; }
.panel .rank-table { margin-top: 14px; }
.warn-list { max-height: 300px; overflow: auto; font-size: .85rem; font-family: ui-monospace, Menlo, Consolas, monospace; }

/* Orientation des cartes (portrait par défaut) */
.thumb-img img, .duel-img img { object-fit: contain; }
.is-landscape .thumb-img, .is-landscape .duel-img { aspect-ratio: 88 / 63; }
.is-square .thumb-img, .is-square .duel-img { aspect-ratio: 1 / 1; }
/* En grille, une carte paysage occupe deux colonnes : même hauteur qu'une portrait */
.grid-thumbs > .ranked:has(> .is-landscape), .rest > li:has(> .is-landscape) { grid-column: span 2; }
.thumb-xs.is-landscape { width: 148px; }
.strip .thumb-s.is-landscape { width: 240px; }
.thumb-l.is-landscape { width: min(480px, 100%); }
/* Duel : chaque carte tient dans la même zone, quel que soit son format */
.duel-card.is-landscape { max-width: calc(54vh * 1.397 + 32px); }
.duel-card.is-square { max-width: calc(54vh + 32px); }
.reveal-card.is-landscape { width: min(520px, 92vw); }
.reveal-card.is-square { width: min(400px, 86vw); }
.row-card img { height: 62px; width: auto; max-width: 90px; aspect-ratio: auto; }
.card-page:has(.card-big.is-landscape) { grid-template-columns: minmax(260px, 560px) 1fr; }
@media (max-width: 700px) { .card-big.is-landscape { max-width: 100%; } }
@media (max-width: 600px) {
  /* Sur mobile, si une carte est en paysage, on empile les deux cartes */
  .duel:has(.is-landscape) { grid-template-columns: 1fr; gap: 6px; }
  .duel:has(.is-landscape) .duel-card { max-width: none; }
  .duel:has(.is-landscape) .duel-img { max-height: 22vh; }
  .duel:has(.is-landscape) .duel-card { padding: 6px; gap: 4px; }
  .duel:has(.is-landscape) .vs { font-size: .75rem; justify-self: center; }
}
