/* Polices auto-hébergées (SIL Open Font License) */
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url(fonts/inter-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url(fonts/inter-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Space Grotesk'; font-style: normal; font-weight: 500 700; font-display: swap;
  src: url(fonts/space-grotesk-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Space Grotesk'; font-style: normal; font-weight: 500 700; font-display: swap;
  src: url(fonts/space-grotesk-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --bg: #0d1420;
  --bg-2: #131c2b;
  --card: #172234;
  --line: #24324a;
  --grid: #1f2b40;
  --text: #eef2f8;
  --muted: #8b9ab3;
  --accent: #c8f04a;
  --accent-ink: #0d1420;
  --dot: #7fb4ff;
  --dot-rev: #c8f04a;
  --good: #3ecf7a;
  --close: #f2c14e;
  --miss: #3a4559;
  --danger: #ff6b6b;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 600px at 80% -10%, #1a2a44 0%, transparent 60%), var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, system-ui, sans-serif;
  min-height: 100vh;
  display: flex; flex-direction: column;
}
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3, .brand-name, .score-value, .end-score { font-family: "Space Grotesk", Inter, sans-serif; letter-spacing: -0.02em; }
a { color: var(--accent); }
[hidden] { display: none !important; }

/* Barre du haut */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: rgba(13,20,32,.85); backdrop-filter: blur(8px); z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 0; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.brand-mark svg { width: 20px; height: 20px; }
.brand-name { font-size: 21px; font-weight: 700; }
.top-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg-2); display: grid; place-items: center; font-weight: 700;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { border-color: var(--muted); }
.lang { position: relative; }
.lang-btn { width: auto; min-width: 36px; padding: 0 9px; font-size: 13px; letter-spacing: .04em; }
.lang-menu {
  position: absolute; right: 0; top: calc(100% + 6px); margin: 0; padding: 6px; list-style: none;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; min-width: 150px;
  box-shadow: 0 12px 30px rgba(0,0,0,.4); z-index: 20;
}
.lang-menu button {
  display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; border-radius: 8px; background: none;
}
.lang-menu button:hover { background: var(--bg-2); }
.lang-menu button[aria-pressed="true"] { color: var(--accent); font-weight: 600; }

main { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 32px 24px 24px; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: 12px; font-weight: 600; color: var(--accent); margin: 0 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Accueil */
.hero { max-width: 640px; margin-bottom: 36px; }
.hero h1 { font-size: clamp(34px, 6vw, 56px); line-height: 1.02; margin: 0 0 14px; }
.lede { color: var(--muted); font-size: 17px; margin: 0; }
.section-title { font-size: 14px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-family: Inter, sans-serif; margin: 0 0 12px; }
.league-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.league-card {
  text-align: left; background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 6px; transition: border-color .15s, transform .15s;
}
.league-card:hover { transform: translateY(-2px); border-color: var(--muted); }
.league-card[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(200,240,74,.15); }
.league-flag { line-height: 0; }
.league-flag svg { width: 30px; height: 20px; border-radius: 3px; box-shadow: 0 0 0 1px rgba(255,255,255,.12); }
.league-name { font-weight: 700; font-size: 17px; }
.league-status { font-size: 12.5px; color: var(--muted); }
.league-status.done { color: var(--good); }

.cta-row { margin-top: 28px; display: flex; gap: 12px; flex-wrap: wrap; }

.btn { border-radius: 12px; padding: 13px 22px; font-weight: 700; border: 1.5px solid transparent; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.primary:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.ghost:hover { border-color: var(--muted); }
.btn.wide { width: 100%; }

/* Partie */
.game-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; }
.game-title { margin: 0; font-size: clamp(22px, 3.4vw, 30px); }
.score-box { text-align: right; }
.score-label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.score-value { font-size: 32px; font-weight: 700; color: var(--accent); }
.score-value.bump { animation: bump .35s; }
@keyframes bump { 40% { transform: scale(.9); color: var(--danger); } }

.board { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.chart-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 12px 10px; }
#chart { width: 100%; height: auto; display: block; user-select: none; }
.chart-foot { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; color: var(--muted); padding: 6px 6px 0; flex-wrap: wrap; }
.dot-sample { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--dot); margin-right: 6px; vertical-align: 0; }

#chart .grid line { stroke: var(--grid); }
#chart .axis { stroke: var(--muted); stroke-width: 1.5; }
#chart .tick { fill: var(--muted); font-size: 11px; font-family: Inter, sans-serif; }
#chart .axis-label { fill: var(--muted); font-size: 13px; font-weight: 600; font-family: Inter, sans-serif; }
#chart .axis-label.found { fill: var(--accent); }
#chart .pt { cursor: pointer; }
#chart .pt circle { fill: var(--dot); fill-opacity: .85; stroke: var(--card); stroke-width: 2; transition: r .12s; }
#chart .pt:hover circle { r: 9.5; fill-opacity: 1; }
#chart .pt.rev circle { fill: var(--dot-rev); }
#chart .pt.rev { cursor: default; }
#chart .pt.anchor circle { fill: var(--text); }
#chart .mean { stroke: var(--muted); stroke-width: 1.2; stroke-dasharray: 5 5; opacity: .7; }
#chart .mean-lbl { fill: var(--muted); font-size: 10.5px; font-family: Inter, sans-serif; font-style: italic; }
#chart .pt.ghost-label text { opacity: .55; }
#chart .lbl { fill: var(--text); font-size: 11.5px; font-weight: 600; font-family: Inter, sans-serif; paint-order: stroke; stroke: var(--card); stroke-width: 4px; stroke-linejoin: round; pointer-events: none; }
#chart .lbl-team { fill: var(--muted); font-weight: 500; font-size: 10px; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.attempts { display: flex; flex-direction: column; gap: 6px; }
.attempt { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.chip { border-radius: 9px; padding: 7px 9px; font-size: 12.5px; font-weight: 600; line-height: 1.25; background: var(--miss); }
.chip.empty { background: transparent; border: 1.5px dashed var(--line); color: transparent; min-height: 34px; }
.chip.g { background: var(--good); color: #062312; }
.chip.y { background: var(--close); color: #2a1d00; }
.chip.locked { opacity: .55; }
.chip .ax { font-size: 10px; opacity: .7; display: block; text-transform: uppercase; letter-spacing: .08em; }

.axis-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.axis-field label { font-weight: 600; font-size: 13.5px; display: flex; align-items: center; gap: 8px; }
.axis-tag { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 6px; background: var(--bg-2); border: 1px solid var(--line); font-size: 11.5px; font-weight: 700; color: var(--accent); }
.axis-field.locked input { border-color: var(--good); color: var(--good); }
.combo { position: relative; }
.combo input {
  width: 100%; background: var(--bg-2); border: 1.5px solid var(--line); border-radius: 10px;
  padding: 11px 12px; color: var(--text); font: inherit; outline: none;
}
.combo input:focus { border-color: var(--accent); }
.combo-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; max-height: 340px; overflow: auto; z-index: 10;
  box-shadow: 0 12px 30px rgba(0,0,0,.4);
}
.combo-list li { padding: 8px 10px; border-radius: 7px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.combo-list li small { color: var(--muted); }
.combo-list li[aria-selected="true"], .combo-list li:hover { background: var(--card); }
.combo-list li.tried { text-decoration: line-through; color: var(--muted); }
.combo-list li.empty { cursor: default; color: var(--muted); font-size: 13px; }
.combo-list li.empty:hover { background: none; }
.combo-list mark { background: none; color: var(--accent); font-weight: 700; }
.combo input.picked { border-color: var(--dot); }
.axis-fam { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--close); }
.form-msg { min-height: 20px; margin: 8px 0 0; font-size: 13px; color: var(--muted); }

.hints { border-top: 1px solid var(--line); padding-top: 12px; }
.hints summary { cursor: pointer; font-weight: 600; font-size: 13.5px; color: var(--muted); }
.hint-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.hint-btn { display: flex; justify-content: space-between; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; font-size: 13px; text-align: left; }
.hint-btn b { color: var(--danger); }
.hint-btn:disabled { opacity: .4; cursor: default; }
.hint-btn.used { border-color: var(--close); }

/* Modales */
.modal { background: var(--bg-2); color: var(--text); border: 1px solid var(--line); border-radius: 18px; padding: 26px; width: min(460px, calc(100vw - 32px)); position: relative; }
.modal::backdrop { background: rgba(5,9,16,.7); backdrop-filter: blur(3px); }
.modal h2 { margin: 0 0 10px; font-size: 26px; }
.modal h3 { margin: 18px 0 4px; font-size: 16px; }
.modal-close { position: absolute; top: 12px; right: 14px; background: none; border: 0; font-size: 26px; color: var(--muted); line-height: 1; }
.rules { padding-left: 20px; }
.rules li { margin-bottom: 4px; }
.legend { display: grid; gap: 6px; font-size: 13.5px; }
.legend div { display: flex; align-items: center; gap: 10px; }
.tile { width: 18px; height: 18px; border-radius: 5px; display: inline-block; background: var(--miss); }
.tile.g { background: var(--good); } .tile.y { background: var(--close); }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; margin: 10px 0; }
.stat-grid b { display: block; font-family: "Space Grotesk", sans-serif; font-size: 28px; }
.stat-grid span { font-size: 11.5px; color: var(--muted); }
.answer { display: grid; gap: 8px; margin: 14px 0; }
.answer div { display: flex; gap: 10px; align-items: center; font-weight: 600; }
.end-score { display: flex; align-items: baseline; gap: 8px; margin-bottom: 12px; }
.end-score span:first-child { font-size: 44px; font-weight: 700; color: var(--accent); }
.share-preview { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; font: 14px/1.5 ui-monospace, Consolas, monospace; margin: 0 0 16px; white-space: pre-wrap; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px; font-weight: 600; opacity: 0; pointer-events: none; transition: .2s; z-index: 50; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.footer { text-align: center; font-size: 12px; color: var(--muted); padding: 18px 16px 26px; }

@media (max-width: 860px) {
  .board { grid-template-columns: 1fr; }
  main { padding: 22px 16px; }
  .topbar { padding: 12px 16px; }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .cta-row .btn { flex: 1; }
}

/* Invitation & duels */
.invite { margin: 4px 0 12px; padding-top: 14px; border-top: 1px solid var(--line); }
.invite-title { margin: 0 0 2px; font-weight: 700; }
.invite .small { margin: 0 0 8px; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; color: var(--muted); font: 12.5px ui-monospace, Consolas, monospace; }
.copy-row .btn { padding: 9px 16px; }
.picks { display: flex; flex-wrap: wrap; gap: 6px; }
.pick { background: var(--card); border: 1.5px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; color: var(--muted); }
.pick[aria-pressed="true"] { border-color: var(--accent); color: var(--text); background: rgba(200,240,74,.1); }
.text-input { width: 100%; background: var(--card); border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--text); font: inherit; outline: none; }
.text-input:focus { border-color: var(--accent); }
#setupForm .btn, #joinForm .btn { margin-top: 14px; }
.join-summary { font-weight: 600; margin: 0 0 6px; }
.modal.wide { width: min(620px, calc(100vw - 32px)); }
.duel-table { width: 100%; border-collapse: collapse; margin: 14px 0 8px; font-size: 14px; }
.duel-table th { font-size: 12px; color: var(--muted); font-weight: 600; text-align: right; padding: 4px 8px 8px; vertical-align: bottom; }
.duel-table th.me { color: var(--text); }
.duel-table th small { display: block; font-size: 10.5px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.duel-table td { padding: 10px 8px; border-top: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.duel-table td:first-child, .duel-table th:first-child { text-align: left; }
.duel-table td.top { color: var(--accent); }
.duel-table tfoot td { font-family: "Space Grotesk", sans-serif; font-size: 18px; font-weight: 700; border-top: 1.5px solid var(--muted); }
.graph-cell { display: flex; gap: 10px; align-items: flex-start; font-weight: 500 !important; }
.graph-cell b { font-weight: 600; }
.graph-cell small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.graph-num { flex: none; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--card); border: 1px solid var(--line); font-size: 11.5px; font-weight: 700; color: var(--accent); }
.duel-verdict { font-family: "Space Grotesk", sans-serif; font-size: 20px; font-weight: 700; margin: 4px 0 14px; }

/* Soutien */
.modal .support-link { display: block; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 13.5px; font-weight: 600; text-decoration: none; }
.modal .support-link:hover { text-decoration: underline; }

/* Menu déroulant des stats */
.combo::after { content: ""; position: absolute; right: 14px; top: 50%; width: 8px; height: 8px; margin-top: -6px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); pointer-events: none; }
.combo input { padding-right: 36px; cursor: pointer; }
.combo-list li.grp { cursor: default; padding: 10px 10px 4px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.combo-list li.grp:hover { background: none; }

/* Bilan du défi du jour */
.end-score { margin-bottom: 4px; }
#endRunning { margin: 0 0 12px; }
.day-rows { display: grid; gap: 0; margin: 10px 0 12px; }
.day-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.day-info { flex: 1; min-width: 0; font-size: 13.5px; }
.day-info small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.day-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; font-size: 13px; letter-spacing: 1px; }
.day-score { font-family: "Space Grotesk", sans-serif; font-weight: 700; font-size: 18px; color: var(--accent); font-variant-numeric: tabular-nums; }
.day-score.lost { color: var(--muted); }
.league-status.progress { color: var(--close); }

/* Pied de la fenêtre des règles */
.rules-foot { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 20px -26px -26px; padding: 14px 26px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; position: sticky; bottom: -26px; background: var(--bg-2); border-radius: 0 0 18px 18px; }
@media (max-width: 480px) { .rules-foot { margin: 20px -18px -22px; padding: 12px 18px 16px; bottom: -22px; } }
.check { display: flex; align-items: center; gap: 9px; font-size: 13.5px; font-weight: 600; color: var(--muted); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; margin: 0; }
.rules-foot .btn { padding: 11px 28px; }

/* Finitions */
.link-btn { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; font-size: inherit; }
.link-btn:hover { color: var(--text); }
.footer .support-wrap { display: inline; }
.noscript { text-align: center; padding: 16px; color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn[aria-busy="true"] { cursor: progress; opacity: .7; }
@media (max-width: 560px) {
  .hero { margin-bottom: 24px; }
  .lede { font-size: 15.5px; }
  .league-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .league-card { padding: 11px 12px; gap: 4px; }
  .league-name { font-size: 15px; }
  .league-status { font-size: 11.5px; }
  .cta-row { margin-top: 20px; }
  #home .cta-row .btn { flex: 1 1 100%; }
}
@media (max-width: 480px) {
  .duel-table { font-size: 13px; }
  .graph-cell small { font-size: 11px; }
  .modal { padding: 22px 18px; }
}
