/* Thème sombre, responsive, sans framework. HEFT : tons chauds (fonte, laiton, pierre) accordés au canvas. */
:root {
  --bg: #0e0c0b;
  --bg-2: #18140f;
  --bg-3: #221c16;
  --line: #3a3026;
  --text: #f1ebe1;
  --muted: #a99d8b;
  --accent: #e6b45e; /* HEFT : laiton du fléau (le bleu reste celui du joueur B) */
  --accent-2: #ffb454;
  --a: #ff7b73; /* joueur A : robot et plateau rouges (moitié gauche) */
  --b: #6aa8ff; /* joueur B : bleus (moitié droite) */
  --ok: #4cd97b;
  --danger: #ff5c5c;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Arabic", "Noto Naskh Arabic", "Noto Sans SC", "Noto Sans CJK SC", "Noto Sans JP", Ubuntu, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 600px at 50% -10%, #2b2119 0%, var(--bg) 60%);
  color: var(--text);
  font: 16px/1.5 var(--font);
  min-height: 100vh;
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5rem; }
h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); }
h2 { font-size: 1.25rem; color: var(--text); }
.container { max-width: 1080px; margin: 0 auto; padding: 24px 16px 64px; }
header.site { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
header.site .brand { font-weight: 700; letter-spacing: 0.02em; text-decoration: none; color: var(--text); }
header.site .brand span { color: var(--accent); }
.brand-block { display: flex; flex-direction: column; gap: 2px; }
.byline { margin: 0 0 8px; color: var(--accent); font-size: 0.95rem; font-weight: 650; }
.header-tools { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; margin-inline-start: auto; max-width: 100%; }
.header-tag { text-align: end; }
.lang-switch { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.lang-switch button {
  appearance: none; border: 1px solid var(--line); background: var(--bg-3); color: var(--text);
  border-radius: 999px; padding: 3px 8px; font: inherit; font-size: 0.75rem; font-weight: 700; cursor: pointer; line-height: 1.3;
}
.lang-switch button[aria-pressed="true"] { background: var(--accent); color: #1a1208; border-color: transparent; }
.promo { color: var(--text); font-weight: 600; margin: 0 0 8px; }
html.i18n-boot body { visibility: hidden; }
html[dir="rtl"] .header-tools { align-items: flex-start; }
html[dir="rtl"] .header-tag { text-align: start; }
html[dir="rtl"] .hud,
html[dir="rtl"] .stage,
html[dir="rtl"] .controls,
html[dir="rtl"] .ticker { direction: ltr; }
.url-row label.for-a { box-shadow: inset 3px 0 0 var(--a); padding-inline-start: 8px; }
.url-row label.for-b { box-shadow: inset 3px 0 0 var(--b); padding-inline-start: 8px; }
.pitch { color: var(--muted); max-width: 70ch; margin: 0 0 20px; }
.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.btn {
  appearance: none; border: 1px solid transparent; border-radius: 10px; padding: 10px 18px;
  font: inherit; font-weight: 600; cursor: pointer; color: #0b0f17; background: var(--accent);
  transition: transform 0.05s ease, filter 0.15s ease;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: wait; }
.btn.secondary { background: var(--bg-3); color: var(--text); border-color: var(--line); }
.btn.small { padding: 6px 10px; font-size: 0.85rem; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 0.9rem; }
.urls { display: grid; gap: 12px; }
.url-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.url-row label { grid-column: 1 / -1; font-weight: 600; }
.url-row label .side-a { color: var(--a); }
.url-row label .side-b { color: var(--b); }
.url-row input {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font-family: var(--mono); font-size: 0.85rem;
}
pre.block {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow: auto;
  font-family: var(--mono); font-size: 0.82rem; white-space: pre-wrap; word-break: break-word; margin: 8px 0;
}
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--bg-3); border: 1px solid var(--line);
  padding: 8px 14px; border-radius: 8px; opacity: 0; transition: opacity 0.2s; pointer-events: none; }
.toast.show { opacity: 1; }
table.matches { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
table.matches th, table.matches td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.matches th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; background: var(--bg-3); color: var(--muted); }
.badge.playing, .badge.countdown { background: #1f3b2a; color: var(--ok); }
.badge.finished { background: #2f2820; color: var(--text); }
.name-a { color: var(--a); font-weight: 600; }
.name-b { color: var(--b); font-weight: 600; }
.error { color: var(--danger); }
footer.site { margin-top: 32px; color: var(--muted); font-size: 0.85rem; }
@media (max-width: 640px) {
  .url-row { grid-template-columns: 1fr; }
  table.matches th:nth-child(3), table.matches td:nth-child(3) { display: none; }
}

/* ------------------------------------------------------------ spectateur */
.match-page .container { max-width: 1200px; }
.hud { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; margin-bottom: 12px; }
.hud .player { display: flex; flex-direction: column; gap: 2px; }
.hud .player.b { text-align: right; }
.hud .player .name { font-weight: 700; font-size: 1.1rem; }
.hud .player.a .name { color: var(--a); }
.hud .player.b .name { color: var(--b); }
.hud .player .sub { color: var(--muted); font-size: 0.85rem; min-height: 1.2em; }
.hud .center { text-align: center; }
.hud .clock { font-family: var(--mono); font-size: 1.8rem; font-weight: 700; letter-spacing: 0.02em; }
.hud .phase { color: var(--muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.08em; }
.stage { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #0b0908; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.stage canvas { display: block; width: 100%; height: 100%; }
.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; background: rgba(12, 9, 7, 0.72); padding: 16px; }
.overlay .box { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 28px; max-width: 90%; }
.overlay .big { font-size: clamp(1.4rem, 4vw, 2.2rem); font-weight: 800; margin-bottom: 4px; }
.ticker { margin-top: 10px; min-height: 1.6em; color: var(--muted); font-size: 0.9rem; font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.controls input[type="range"] { flex: 1 1 200px; accent-color: var(--accent); }
.controls .time { font-family: var(--mono); color: var(--muted); min-width: 8ch; }
.controls select { background: var(--bg-3); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font: inherit; }
.status-line { margin-top: 8px; color: var(--muted); font-size: 0.85rem; }
@media (max-width: 640px) {
  .hud { grid-template-columns: 1fr 1fr; }
  .hud .center { grid-column: 1 / -1; order: -1; }
  .hud .clock { font-size: 1.4rem; }
}

/* ------------------------------------------------------------ accueil et écran de résultat */
.hero { display: grid; grid-template-columns: 160px 1fr; gap: 24px; align-items: center; margin-bottom: 24px; }
.hero img { width: 160px; height: 160px; border-radius: 50%; border: 2px solid var(--line); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5); display: block; }
.hero h1 { margin-bottom: 6px; }
.hero .tagline { color: var(--accent-2); font-weight: 600; margin: 0 0 8px; }
.hero .pitch { margin-bottom: 0; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 0 0 20px; padding: 0; list-style: none; }
.steps li { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; font-size: 0.92rem; color: var(--muted); }
.steps li strong { display: block; color: var(--text); margin-bottom: 2px; }
.overlay .trophy { width: 96px; height: auto; display: block; margin: 0 auto 8px; filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.6)); }
.overlay table.result { margin: 14px auto 0; border-collapse: collapse; font-size: 0.9rem; }
.overlay table.result th, .overlay table.result td { padding: 4px 12px; border-bottom: 1px solid var(--line); text-align: right; }
.overlay table.result th { font-weight: 700; }
.overlay table.result td:first-child, .overlay table.result th:first-child { text-align: left; color: var(--muted); }
.overlay table.result tr:last-child td { border-bottom: none; }
.legend { margin-top: 14px; font-size: 0.85rem; max-width: 90ch; }
@media (max-width: 640px) {
  .hero { grid-template-columns: 1fr; text-align: center; }
  .hero img { margin: 0 auto; }
  .steps { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------ « I am not Human » : le bouton fuit la main */
.not-human {
  position: fixed; top: 84px; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; align-items: flex-start; justify-content: center; padding: 12px;
  background: rgba(8, 6, 4, 0.62);
}
.not-human-card {
  width: min(440px, 100%); background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px 20px 16px; position: relative;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}
.not-human-x {
  position: absolute; top: 8px; inset-inline-end: 8px; width: 32px; height: 32px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg-3); color: var(--text);
  font: inherit; font-size: 1.1rem; cursor: pointer;
}
.not-human-yard {
  position: relative; height: 148px; margin-top: 12px; border: 1px dashed var(--line);
  border-radius: 10px; background: rgba(0, 0, 0, 0.25); overflow: hidden; touch-action: none;
}
.not-human-btn {
  position: absolute; left: 16px; top: 48px; max-width: calc(100% - 16px);
  appearance: none; border: 1px solid rgba(76, 217, 123, 0.45); border-radius: 10px;
  background: #14261a; color: var(--ok); font: inherit; font-weight: 700; padding: 10px 14px;
  cursor: pointer; white-space: nowrap;
}
.not-human-miss { min-height: 1.4em; margin: 10px 0 0; color: var(--accent-2); font-size: 0.92rem; }
.robot-veil {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(28, 120, 64, 0.55);
}
.robot-veil-card {
  text-align: center; background: rgba(10, 28, 18, 0.92); border: 1px solid rgba(76, 217, 123, 0.55);
  border-radius: var(--radius); padding: 28px 24px; max-width: 420px; box-shadow: 0 0 0 8px rgba(76, 217, 123, 0.12);
}
.robot-veil-mark { margin: 0 0 8px; font-size: 2.4rem; color: var(--ok); }
.robot-veil-card h2 { color: var(--ok); }
.robot-veil-card p { color: var(--text); }
html[dir="rtl"] .not-human-btn { direction: rtl; }

/* ------------------------------------------------------------ HEFT : le chrono est dessiné dans le canvas (HUD du renderer) */
.match-page .hud .clock { display: none; }
.match-page .hud .phase { font-size: 0.8rem; }
