/* =========================================================
   Aeon's End — Ordre du tour
   Styles propres à l'outil. Le thème et les composants communs
   (boutons, panneaux, feuilles, toast…) sont dans ../shared/.
   ========================================================= */

/* =========================================================
   CONFIGURATION
   ========================================================= */
.name-field.nemesis { margin-top: 8px; }
.sub-input { margin: 0 0 10px; }

/* Choix de règles */
.radio-group { border: 0; margin: 0 0 14px; padding: 0; }
.radio-group:last-child { margin-bottom: 0; }
.radio-group legend { padding: 0; margin-bottom: 4px; font-weight: 650; }
.radio {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 11px 12px; margin-top: 6px;
  border: 1px solid var(--line-2); border-radius: 12px;
  background: var(--bg-2);
  cursor: pointer;
}
.radio input {
  appearance: none; -webkit-appearance: none;
  flex: none; width: 20px; height: 20px; margin: 1px 0 0;
  border-radius: 50%; border: 2px solid var(--faint);
  display: grid; place-items: center;
}
.radio input:checked { border-color: var(--accent); }
.radio input:checked::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.radio:has(input:checked) { border-color: rgba(143, 107, 255, .7); background: rgba(143, 107, 255, .1); }
.radio b { display: block; font-weight: 600; }
.radio small { display: block; color: var(--muted); font-size: 13px; }

/* Composition du paquet */
.comp-editor { display: grid; gap: 6px; margin-top: 12px; }
.comp-row {
  --c: var(--accent);
  display: flex; align-items: center; gap: 10px;
  padding: 6px 6px 6px 12px;
  border-radius: 12px;
  background: var(--bg-2);
  border: 1px solid var(--line);
}
.comp-row .dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.comp-row .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comp-row.zero .lbl { color: var(--faint); }
.comp-row.zero .dot { opacity: .35; }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button {
  width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--panel-2);
  font-size: 20px; line-height: 1;
}
.stepper .n { width: 26px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.btn-row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* ---------- Pastilles (chips) ---------- */
.chips { display: flex; gap: 6px; align-items: center; }
.chips.wrap { flex-wrap: wrap; }
.chips.scroll { overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  --c: var(--accent);
  flex: none;
  display: inline-flex; align-items: center; gap: 6px;
  max-width: 230px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 13px; line-height: 1.2; white-space: nowrap;
  background: rgba(255, 255, 255, .06);
  background: color-mix(in srgb, var(--c) 16%, transparent);
  border: 1px solid var(--line-2);
  border: 1px solid color-mix(in srgb, var(--c) 42%, transparent);
}
.chip .lbl { overflow: hidden; text-overflow: ellipsis; }
.chip .dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--c); box-shadow: 0 0 6px var(--c); }
.chip b { font-weight: 700; color: var(--c); }
.chip.now { background: color-mix(in srgb, var(--c) 32%, transparent); border-color: var(--c); }
.chip.browsed { box-shadow: inset 0 0 0 2px #fff; }
.chip.empty { --c: var(--faint); color: var(--muted); }

/* =========================================================
   JEU
   ========================================================= */
.play {
  height: 100vh;
  height: 100dvh;
  display: flex; flex-direction: column;
  padding-top: var(--safe-t);
  overflow: hidden;
  user-select: none; -webkit-user-select: none;
}
.play-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; }
.status { display: flex; gap: 8px; align-items: center; font-weight: 700; font-size: 15px; color: var(--muted); font-variant-numeric: tabular-nums; }
.status #st-turn { color: var(--text); }
.sep { opacity: .5; }

/* Jetons (Joker, 1/2, 3/4) */
.tokens { flex: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; padding-bottom: 4px; }
.token {
  --c: var(--accent);
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px 4px 4px;
  border-radius: 999px;
  font-size: 13px;
  background: rgba(255, 255, 255, .05);
  background: color-mix(in srgb, var(--c) 12%, transparent);
  border: 1px dashed var(--line-2);
  border: 1px dashed color-mix(in srgb, var(--c) 60%, transparent);
}
.token .tk {
  min-width: 26px; height: 26px; padding: 0 5px; border-radius: 999px;
  display: grid; place-items: center;
  background: var(--c); color: var(--ink);
  font-weight: 800; font-size: 11px;
}
.token b { color: var(--c); font-weight: 700; }

/* Zone de la carte */
.stage {
  position: relative;
  flex: 1 1 auto; min-height: 0;
  display: grid; place-items: center;
  padding: 6px 0;
  container-type: size;
  cursor: pointer;
  touch-action: pan-y; /* les glissements horizontaux sont gérés par l'app */
}

/* Flèches de navigation dans la défausse */
.nav-btn {
  position: absolute; top: 50%; z-index: 2;
  width: 30px; height: 64px; margin-top: -32px; padding: 0;
  display: grid; place-items: center;
  border: 1px solid var(--line-2); border-radius: 12px;
  background: rgba(21, 16, 42, .78);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: var(--muted);
}
.nav-btn.prev { left: -6px; }
.nav-btn.next { right: -6px; }
.nav-btn svg { width: 18px; height: 18px; }

/* ---------- Carte ---------- */
.card {
  --c: var(--accent);
  --c2: var(--c);
  position: relative;
  width: min(80vw, 46vh);                 /* repli sans container queries */
  width: min(86cqw, 100cqh * 5 / 7);
  aspect-ratio: 5 / 7;
  border-radius: 18px;
  overflow: hidden;
  isolation: isolate;
  container-type: inline-size;
  color: #fff;
  background: #15102a;
  background:
    radial-gradient(85% 55% at 50% 34%, color-mix(in srgb, var(--c) 50%, transparent), transparent 72%),
    linear-gradient(165deg, color-mix(in srgb, var(--c) 32%, #15102a) 0%, #100b22 55%, color-mix(in srgb, var(--c2) 24%, #0b0816) 100%);
  border: 2px solid var(--c);
  border: 2px solid color-mix(in srgb, var(--c) 75%, #fff);
  box-shadow:
    0 20px 60px -18px color-mix(in srgb, var(--c) 70%, transparent),
    0 0 0 1px rgba(0, 0, 0, .5),
    inset 0 0 0 1px rgba(255, 255, 255, .06);
}
.card.dual {
  background:
    radial-gradient(60% 45% at 28% 34%, color-mix(in srgb, var(--c) 45%, transparent), transparent 72%),
    radial-gradient(60% 45% at 72% 34%, color-mix(in srgb, var(--c2) 45%, transparent), transparent 72%),
    linear-gradient(165deg, color-mix(in srgb, var(--c) 28%, #15102a) 0%, #100b22 55%, color-mix(in srgb, var(--c2) 28%, #0b0816) 100%);
}
.card::before {                           /* filet intérieur décoratif */
  content: "";
  position: absolute; inset: 9px; z-index: -1;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
  pointer-events: none;
}
.card::after {                            /* reflet */
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, .07) 45%, transparent 60%);
  pointer-events: none;
}
.card-inner {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center;
  gap: 3cqw;
  padding: 7cqw 7cqw 8cqw;
  text-align: center;
}
.card-top { flex: none; align-self: stretch; display: flex; justify-content: space-between; align-items: center; gap: 2cqw; margin-bottom: auto; }
.card-inner > :last-child { margin-bottom: auto; } /* centre le contenu sous l'en-tête */
.badge {
  min-width: 11cqw; height: 11cqw; padding: 0 2.5cqw;
  border-radius: 999px;
  display: grid; place-items: center;
  background: var(--c); color: var(--ink);
  font-weight: 800; font-size: 5.5cqw;
  box-shadow: 0 0 4cqw -1cqw var(--c);
}
.card.dual .badge { background: linear-gradient(90deg, var(--c), var(--c2)); }
.tag {
  font-size: 4.2cqw; font-weight: 700;
  text-transform: uppercase; letter-spacing: .14em;
  color: color-mix(in srgb, var(--c) 55%, #fff);
}
.emblem {
  flex: 1 1 50cqw; min-height: 14cqw; max-height: 56cqw; width: 100%;
  display: flex; align-items: center; justify-content: center;
  color: var(--c);
  filter: drop-shadow(0 0 5cqw color-mix(in srgb, var(--c) 70%, transparent));
}
.emblem svg { height: 100%; width: auto; max-width: 70cqw; }
.name {
  flex: none; max-width: 100%;
  font-size: 11cqw; font-weight: 800; line-height: 1.05; letter-spacing: -.01em;
  overflow-wrap: anywhere;
  text-shadow: 0 2px 12px rgba(0, 0, 0, .5);
}
.name.long { font-size: 8.5cqw; }
.name.xlong { font-size: 7cqw; }
.hint { flex: none; margin: 0; max-width: 100%; font-size: 4.6cqw; line-height: 1.35; color: #ddd6f7; }
.choose { flex: none; display: flex; gap: 3cqw; width: 100%; }
.choose button {
  flex: 1; min-width: 0; min-height: max(40px, 13cqw);
  padding: 2cqw 3cqw;
  border: 0; border-radius: 3.5cqw;
  background: var(--c); color: var(--ink);
  font-weight: 800; font-size: 5cqw;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  box-shadow: 0 0 5cqw -1cqw var(--c);
}

/* Dos de carte */
.card.back {
  --c: #7a5cff;
  --c2: #4fd1ff;
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, .025) 0 2px, transparent 2px 12px),
    radial-gradient(circle at 50% 45%, #3a2a85 0%, #1a1240 45%, #0d0920 100%);
}
.card.back .card-inner { justify-content: center; gap: 7cqw; }
.rune { width: 62cqw; color: #b9a6ff; filter: drop-shadow(0 0 4cqw rgba(143, 107, 255, .7)); }
.rune svg { width: 100%; height: auto; }
.rune .spin { transform-box: fill-box; transform-origin: center; animation: spin 60s linear infinite; }
.back-text { margin: 0; font-size: 5cqw; font-weight: 600; color: #cfc4ff; }

/* Carte de la défausse consultée */
.card.past { filter: saturate(.55) brightness(.8); }
.card.past::before { border-style: dashed; }
.past-note { flex: none; margin: 0; font-size: 3.9cqw; font-weight: 600; color: #cfc6ee; opacity: .85; }

/* Animations : révélation, glissement dans la défausse */
.card.flip { animation: flip .55s cubic-bezier(.2, .75, .25, 1) both; }
.card.from-left { animation: from-left .3s cubic-bezier(.2, .8, .2, 1) both; }
.card.from-right { animation: from-right .3s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes from-left { from { transform: translateX(-55%) rotate(-5deg); opacity: 0; } }
@keyframes from-right { from { transform: translateX(55%) rotate(5deg); opacity: 0; } }
@keyframes flip {
  0%   { transform: perspective(1000px) rotateY(-100deg) scale(.9); filter: brightness(2.2) saturate(.6); }
  55%  { filter: brightness(1.3); }
  100% { transform: perspective(1000px) rotateY(0) scale(1); filter: none; }
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Pioche + bouton principal */
.draw-row { flex: none; display: flex; align-items: center; gap: 14px; padding: 8px 0; }
.deck { position: relative; flex: none; width: 46px; height: 62px; border: 0; padding: 0; margin-top: 4px; background: transparent; }
.deck-card, .deck::before, .deck::after {
  position: absolute; inset: 0;
  border-radius: 7px;
  background: radial-gradient(circle at 50% 45%, #3a2a85, #140e33);
  border: 1.5px solid #7a5cff;
}
.deck::before { content: ""; transform: translate(5px, -5px); opacity: .45; }
.deck::after { content: ""; transform: translate(2.5px, -2.5px); opacity: .7; }
.deck-card { z-index: 1; }
.deck-count {
  position: absolute; inset: 0; z-index: 2;
  display: grid; place-items: center;
  font-weight: 800; font-size: 20px;
  text-shadow: 0 1px 4px #000;
}
.deck.empty::before, .deck.empty::after { display: none; }
.deck.empty .deck-card { background: transparent; border-style: dashed; border-color: var(--faint); }
.btn-draw { flex: 1; padding: 16px; font-size: 17px; border-radius: 16px; }

/* Défausse / paquet restant */
.piles { flex: none; display: grid; gap: 6px; padding: 2px 0 8px; }
.pile { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pile-label {
  flex: none; width: 70px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--faint);
}
.pile .chips { position: relative; flex: 1; min-width: 0; min-height: 28px; }
#discard { cursor: pointer; }

/* Barre d'effets */
.actions {
  flex: none;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
  padding: 6px;
  margin-bottom: calc(8px + var(--safe-b));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
}
.actions button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  min-height: 58px; padding: 6px 2px;
  border: 0; border-radius: 13px;
  background: transparent;
  color: var(--muted);
  font-size: 11px; font-weight: 600; line-height: 1.15; text-align: center;
}
.actions button svg { width: 22px; height: 22px; color: var(--text); }
.actions button:active { background: var(--panel-2); }

@media (hover: hover) {
  .actions button:hover { background: var(--panel-2); }
}

/* Paysage sur téléphone : carte à gauche, commandes à droite */
@media (orientation: landscape) and (max-height: 540px) {
  .play {
    max-width: none;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
    grid-template-rows: auto auto 1fr auto auto;
    column-gap: 16px;
  }
  .play-head { grid-column: 1 / -1; }
  .stage { grid-column: 1; grid-row: 2 / 6; }
  .tokens { grid-column: 2; grid-row: 2; }
  .draw-row { grid-column: 2; grid-row: 3; align-self: end; }
  .piles { grid-column: 2; grid-row: 4; }
  .actions { grid-column: 2; grid-row: 5; }
}

/* =========================================================
   FEUILLES : listes de cartes
   ========================================================= */
.sheet-sub svg { display: inline-block; width: 15px; height: 15px; vertical-align: -3px; }
.row { padding: 8px 8px 8px 10px; }
.row .pos { flex: none; width: 20px; text-align: center; color: var(--faint); font-weight: 700; font-variant-numeric: tabular-nums; }
.row .ico { flex: none; width: 26px; height: 26px; color: var(--c); }
.row .ico svg { width: 100%; height: 100%; }
.row-btns { display: flex; gap: 4px; flex: none; }
.mini-btn {
  height: 38px; min-width: 38px; padding: 0 9px;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--panel-2);
  font-size: 13px; font-weight: 600;
}
.mini-btn svg { width: 17px; height: 17px; }

@media (prefers-reduced-motion: reduce) {
  .card.flip, .card.from-left, .card.from-right { animation: fade .2s ease; }
  .rune .spin { animation: none; }
}
