/* ====================================================================
   Prompt Fighter : feuille de styles
   ==================================================================== */

:root {
  --ink: #17131c;
  --ink-2: #241e2b;
  --ink-line: rgba(255, 255, 255, 0.08);
  --paper: #f5efe6;
  --paper-2: #fffaf3;
  --card: #ffffff;
  --text: #221d26;
  --muted: #6b6270;
  --line: #e4d9ca;
  --orange: #f28a1a;
  --red: #d8361f;
  --yellow: #ffc93c;
  --good: #2f9e5b;
  --mid: #d99a12;
  --bad: #d8361f;
  --seg-off: #e9e0d3;
  --quote-bg: #241e2b;
  --quote-text: #fff4e4;
  --code-bg: #f1e8da;
  --shadow: 0 1px 2px rgba(23, 19, 28, 0.06), 0 6px 20px rgba(23, 19, 28, 0.06);
  --radius: 14px;
  --font-display: "Anton", "Impact", "Arial Narrow", sans-serif;
  --font-body: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1b171f;
    --paper-2: #221d27;
    --card: #26202b;
    --text: #efe8de;
    --muted: #a99fae;
    --line: #3a3240;
    --seg-off: #3a3240;
    --quote-bg: #120f15;
    --code-bg: #322a38;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #1b171f;
  --paper-2: #221d27;
  --card: #26202b;
  --text: #efe8de;
  --muted: #a99fae;
  --line: #3a3240;
  --seg-off: #3a3240;
  --quote-bg: #120f15;
  --code-bg: #322a38;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--paper);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Mise en page générale */
.layout {
  display: grid;
  grid-template-columns: 272px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--ink);
  color: #f4ece0;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px 18px;
  border-right: 4px solid var(--orange);
}

.brand { display: block; text-align: center; margin-bottom: 18px; }
.brand img { width: 180px; height: auto; filter: drop-shadow(0 6px 14px rgba(242, 138, 26, 0.25)); }

.rounds { display: flex; flex-direction: column; gap: 6px; }

.round-link {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 10px;
  color: inherit;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}
.round-link:hover { background: var(--ink-2); }
.round-link.active { background: var(--ink-2); border-color: rgba(242, 138, 26, 0.55); }
.round-link .num {
  grid-row: span 2;
  font-family: var(--font-display);
  font-size: 26px;
  line-height: 1;
  color: var(--orange);
  width: 30px;
  text-align: center;
}
.round-link.active .num { color: var(--yellow); }
.round-link .lbl { font-weight: 700; font-size: 15px; line-height: 1.2; }
.round-link .sub { font-size: 13px; color: #b8aebd; }
.round-link.soon { opacity: 0.45; cursor: default; }
.round-link.soon:hover { background: transparent; }

.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12.5px;
  color: #9d93a3;
  border-top: 1px solid var(--ink-line);
  padding-top: 14px;
}

/* Sélecteur de modèle */
.model-pick { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.model-pick span { font-family: var(--font-display); text-transform: uppercase; letter-spacing: 0.1em; font-size: 12.5px; color: var(--orange); }
.model-pick select {
  font: inherit;
  font-size: 15px;
  color: #f4ece0;
  background: var(--ink-2);
  border: 1.5px solid #4a4050;
  border-radius: 9px;
  padding: 8px 10px;
  cursor: pointer;
}
.model-pick select:focus { outline: none; border-color: var(--orange); }

/* Zone d'exercice */
.stage {
  padding: 40px clamp(16px, 4vw, 56px) 80px;
  max-width: 1280px;
  width: 100%;
  outline: none;
}

.ex-head { margin-bottom: 26px; }
.kicker {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--red);
  font-size: 15px;
}
.ex-head h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(34px, 4.6vw, 54px);
  line-height: 1.02;
  margin: 4px 0 6px;
  letter-spacing: 0.01em;
}
.ex-head .tagline { color: var(--muted); font-size: clamp(20px, 2.2vw, 26px); line-height: 1.3; margin: 4px 0 0; }

.section-title {
  font-family: var(--font-display);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 20px;
  margin: 34px 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title::before {
  content: "";
  width: 18px;
  height: 4px;
  background: linear-gradient(90deg, var(--yellow), var(--red));
  border-radius: 2px;
}

.prose p { margin: 0 0 0.8em; }
.prose ul, .prose ol { margin: 0 0 0.9em; padding-left: 1.3em; }
.prose li { margin: 0.2em 0; }
.prose h3, .prose h4 { margin: 1.1em 0 0.4em; line-height: 1.25; }
.prose h3 { font-size: 1.15em; }
.prose h4 { font-size: 1.02em; }
.prose code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 5px;
  word-break: break-word;
}
.prose pre { background: var(--code-bg); padding: 12px 14px; border-radius: 10px; overflow-x: auto; }
.prose pre code { background: none; padding: 0; }
.prose img { display: block; max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 10px; margin: 0.4em 0 1em; background: #fff; }
.prose blockquote { margin: 0.6em 0; padding: 4px 14px; border-left: 3px solid var(--orange); color: var(--muted); }
.prose table { border-collapse: collapse; width: 100%; margin: 0.6em 0 1em; font-size: 0.94em; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; vertical-align: top; }
.prose th { background: var(--paper-2); font-weight: 700; }
.prose > :last-child { margin-bottom: 0; }

/* Carte « prompt de départ » */
.opponent {
  background: var(--quote-bg);
  color: var(--quote-text);
  border-radius: var(--radius);
  padding: 22px 26px 24px;
  margin: 14px 0 6px;
  position: relative;
  overflow: hidden;
}
.opponent::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 6px;
  background: linear-gradient(180deg, var(--yellow), var(--orange), var(--red));
}
.opponent .tag {
  font-family: var(--font-display);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 13px;
  color: var(--orange);
}
.opponent q {
  display: block;
  font-size: clamp(19px, 2.2vw, 24px);
  font-weight: 600;
  line-height: 1.35;
  margin-top: 6px;
  quotes: "«\00a0" "\00a0»";
}
.opponent.narratif q { font-size: 17.5px; font-weight: 400; line-height: 1.6; quotes: none; }

/* Blocs repliables */
details.fold {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: 14px 0;
  box-shadow: var(--shadow);
}
details.fold > summary {
  cursor: pointer;
  list-style: none;
  padding: 14px 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before {
  content: "";
  width: 9px;
  height: 9px;
  border-right: 2.5px solid var(--orange);
  border-bottom: 2.5px solid var(--orange);
  transform: rotate(-45deg);
  transition: transform 0.15s;
  flex: none;
}
details.fold[open] > summary::before { transform: rotate(45deg); }
details.fold > summary .hint { font-weight: 400; color: var(--muted); font-size: 14px; margin-left: auto; }
details.fold .fold-body { padding: 0 22px 20px 37px; }
details.fold.tips { border-style: dashed; }

.mission {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 22px;
  box-shadow: var(--shadow);
}

/* Zone de saisie */
.arena {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.arena label { display: block; font-weight: 700; margin-bottom: 8px; }
.arena textarea {
  width: 100%;
  min-height: 240px;
  resize: vertical;
  font: inherit;
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--paper-2);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.arena textarea:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 4px rgba(242, 138, 26, 0.18); }
.arena-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.arena-bar .count { margin-left: auto; color: var(--muted); font-size: 13.5px; font-variant-numeric: tabular-nums; }

.btn {
  font: inherit;
  border: 0;
  border-radius: 10px;
  padding: 11px 18px;
  cursor: pointer;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform 0.08s, filter 0.15s, background 0.15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn-fight {
  font-family: var(--font-display);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 18px;
  color: #fff;
  background: linear-gradient(135deg, var(--orange), var(--red));
  box-shadow: 0 4px 0 #8f2312;
  padding: 11px 24px;
}
.btn-fight:hover { filter: brightness(1.06); }
.btn-ghost { background: transparent; color: var(--text); border: 1.5px solid var(--line); }
.btn-ghost:hover { border-color: var(--orange); }
.btn-small { padding: 6px 12px; font-size: 14px; }

.alert {
  margin-top: 12px;
  padding: 11px 14px;
  border-radius: 10px;
  background: rgba(216, 54, 31, 0.1);
  border: 1px solid rgba(216, 54, 31, 0.35);
  color: var(--text);
}

/* Pièces jointes */
.pj-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.pj-list:empty { display: none; }
.pj-list li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px 5px 12px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--paper-2);
  font-size: 14px;
  max-width: 100%;
}
.pj-nom { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.pj-taille { color: var(--muted); font-variant-numeric: tabular-nums; }
.pj-suppr {
  border: 0;
  background: var(--seg-off);
  color: var(--text);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}
.pj-suppr:hover { background: var(--red); color: #fff; }
label.btn { user-select: none; }
.arena-bar .btn { line-height: 1.4; }

/* Chargement */
.loading {
  margin-top: 26px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-weight: 600;
  color: var(--muted);
}
.loading .bar {
  width: 160px;
  height: 10px;
  border-radius: 5px;
  background: var(--seg-off);
  overflow: hidden;
  position: relative;
}
.loading .bar::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 40%;
  background: linear-gradient(90deg, var(--yellow), var(--red));
  border-radius: 5px;
  animation: charge 1.1s ease-in-out infinite alternate;
}
@keyframes charge { from { transform: translateX(-10%); } to { transform: translateX(160%); } }

/* Résultats */
.results {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 22px;
  margin-top: 30px;
  align-items: start;
}
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--paper-2);
}
.panel-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 17px;
}
.panel-body { padding: 18px 20px; }
.panel-head .chars { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.panel-head .fmt { border-radius: 999px; padding: 2px 10px; font-size: 12.5px; font-weight: 700; color: #fff; }
.panel-head .fmt.ok { background: var(--good); }
.panel-head .fmt.ko { background: var(--red); }
.panel-head .cut { color: #fff; background: var(--red); border-radius: 999px; padding: 2px 10px; font-size: 12.5px; font-weight: 700; }

/* Score global façon barre de vie */
.score-main { padding: 20px 20px 16px; border-bottom: 1px solid var(--line); }
.score-main .top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.score-main .label { font-family: var(--font-display); text-transform: uppercase; letter-spacing: 0.1em; font-size: 14px; color: var(--muted); }
.score-main .value { font-family: var(--font-display); font-size: 54px; line-height: 1; }
.score-main .value small { font-size: 24px; color: var(--muted); }

.lifebar { display: grid; gap: 3px; margin-top: 12px; }
.lifebar.l20 { grid-template-columns: repeat(20, 1fr); }
.lifebar.l5 { grid-template-columns: repeat(5, 1fr); margin-top: 6px; }
.lifebar span { height: 14px; border-radius: 3px; background: var(--seg-off); }
.lifebar.l5 span { height: 9px; }
.lifebar span.on { background: var(--seg-color); }

.crit-list { list-style: none; margin: 0; padding: 6px 20px 18px; }
.crit { padding: 14px 0; border-bottom: 1px solid var(--line); }
.crit:last-child { border-bottom: 0; }
.crit .row { display: flex; justify-content: space-between; gap: 10px; font-weight: 700; }
.crit .pts { font-variant-numeric: tabular-nums; color: var(--seg-color); }
.crit p { margin: 8px 0 0; color: var(--muted); font-size: 15.5px; }
.crit p.piste { color: var(--text); display: flex; gap: 10px; align-items: baseline; }
.crit p.piste span, .next-step span {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12.5px;
  color: var(--orange);
  flex: none;
}
.next-step {
  margin: 0 20px 20px;
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--paper-2);
  border-left: 4px solid var(--orange);
}
.next-step p { margin: 4px 0 0; }


/* Rounds à venir */
.soon-page { text-align: center; padding: 80px 20px; color: var(--muted); }
.soon-page h1 { font-family: var(--font-display); font-weight: 400; color: var(--text); font-size: 44px; margin: 6px 0; }

/* Écrans étroits */
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    height: auto;
    z-index: 5;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-right: 0;
    border-bottom: 3px solid var(--orange);
  }
  .brand { margin: 0; flex: none; }
  .brand img { width: 64px; }
  .rounds { flex-direction: row; overflow-x: auto; gap: 4px; scrollbar-width: none; }
  .round-link { grid-template-columns: auto; padding: 6px 10px; text-align: center; white-space: nowrap; }
  .round-link .num { grid-row: auto; font-size: 20px; width: auto; }
  .round-link .lbl, .round-link .sub { display: none; }
  .round-link.soon { display: none; }
  .sidebar-foot { display: flex; margin: 0 0 0 auto; padding: 0; border: 0; flex: none; }
  .sidebar-foot .brand-foot, .model-pick span { display: none; }
  .model-pick { margin: 0; }
  .model-pick select { padding: 6px 8px; font-size: 14px; }
  .stage { padding: 26px 16px 60px; }
  details.fold .fold-body { padding: 0 16px 16px 18px; }
}
