/* ==========================================================================
   Lelouche Arena — design « club d'échecs »
   Noyer & érable pour l'échiquier, ivoire pour le texte, laiton pour l'action.
   ========================================================================== */

:root {
  /* Surfaces — brun espresso chaud, jamais noir pur */
  --bg: #15110e;
  --bg-2: #1b1612;
  --surface: #221c17;
  --surface-2: #2a231d;
  --surface-3: #352c24;
  --line: rgba(240, 226, 203, 0.08);
  --line-2: rgba(240, 226, 203, 0.15);

  /* Texte — ivoire */
  --text: #f4ebdd;
  --text-2: #cbbda9;
  --text-3: #978a7b;

  /* Accents */
  --gold: #e0b25c;
  --gold-2: #f0c97a;
  --gold-3: #b9893a;
  --gold-ink: #2a1c06;
  --gold-soft: rgba(224, 178, 92, 0.13);
  --green: #86c27f;
  --green-soft: rgba(134, 194, 127, 0.13);
  --red: #e86a5f;
  --red-soft: rgba(232, 106, 95, 0.13);

  /* Échiquier (thème « noyer » par défaut) */
  --sq-light: #ecd5ad;
  --sq-dark: #a97a50;
  --coord-on-light: #a97a50;
  --coord-on-dark: #ecd5ad;
  --hl-last: rgba(236, 196, 80, 0.48);
  --hl-sel: rgba(236, 196, 80, 0.62);
  --hint: rgba(40, 24, 10, 0.3);
  --frame-1: #4a311f;
  --frame-2: #2c1c11;

  /* Typo */
  --font-display: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* Rythme */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --shadow-1: 0 1px 0 rgba(255, 240, 215, 0.04) inset, 0 6px 18px rgba(0, 0, 0, 0.28);
  --shadow-2: 0 1px 0 rgba(255, 240, 215, 0.05) inset, 0 18px 50px rgba(0, 0, 0, 0.45);
  --ease: cubic-bezier(0.22, 0.8, 0.26, 1);
  --ease-spring: cubic-bezier(0.34, 1.4, 0.5, 1);
  --appbar-h: 60px;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

[data-board="tournoi"] {
  --sq-light: #e8e4cd;
  --sq-dark: #6a9160;
  --coord-on-light: #6a9160;
  --coord-on-dark: #e8e4cd;
  --hl-last: rgba(222, 214, 70, 0.55);
  --hl-sel: rgba(222, 214, 70, 0.7);
  --hint: rgba(20, 40, 15, 0.28);
  --frame-1: #2f3a28;
  --frame-2: #1b2316;
}

[data-board="ardoise"] {
  --sq-light: #dfe4e7;
  --sq-dark: #7a8d9c;
  --coord-on-light: #7a8d9c;
  --coord-on-dark: #dfe4e7;
  --hl-last: rgba(120, 185, 225, 0.5);
  --hl-sel: rgba(120, 185, 225, 0.68);
  --hint: rgba(15, 30, 45, 0.28);
  --frame-1: #343c44;
  --frame-2: #1e2328;
}

[data-board="marbre"] {
  --sq-light: #efe9df;
  --sq-dark: #8b7f74;
  --coord-on-light: #8b7f74;
  --coord-on-dark: #efe9df;
  --hl-last: rgba(214, 160, 90, 0.5);
  --hl-sel: rgba(214, 160, 90, 0.68);
  --hint: rgba(40, 30, 20, 0.28);
  --frame-1: #3d3631;
  --frame-2: #24201c;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(900px 480px at 50% -160px, rgba(224, 178, 92, 0.10), transparent 70%),
    radial-gradient(700px 500px at 110% 30%, rgba(169, 122, 80, 0.07), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  font-feature-settings: "cv11", "ss01";
}
body.sheet-open { overflow: hidden; }
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; }
h1, h2, h3, p, dl, dd, ol, ul { margin: 0; padding: 0; }
ol, ul { list-style: none; }
:focus-visible { outline: 2px solid var(--gold-2); outline-offset: 2px; border-radius: 6px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ico .fill, symbol .fill { fill: currentColor; stroke: none; opacity: 0.28; }
.muted { color: var(--text-3); font-size: 13px; }
.num, .clock, .stakes dd, .stat strong, .balance-amount strong { font-variant-numeric: tabular-nums; }

.pc { display: block; background-size: 100% 100%; background-repeat: no-repeat; }

.display {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(26px, 6.6vw, 40px);
  line-height: 1.08;
  letter-spacing: -0.015em;
  font-optical-sizing: auto;
}
.title { font-family: var(--font-display); font-weight: 700; font-size: 24px; line-height: 1.15; letter-spacing: -0.01em; }
.eyebrow { color: var(--text-3); font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.eyebrow strong { color: var(--text-2); font-weight: 600; }
.kicker { display: inline-block; color: var(--gold); font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.section-title { font-family: var(--font-display); font-weight: 600; font-size: 20px; margin-bottom: 14px; }

/* ---------- Boutons ---------- */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; padding: 0 20px;
  border-radius: var(--r-md);
  font-weight: 600; font-size: 15px; letter-spacing: 0.005em;
  transition: transform 160ms var(--ease), background-color 200ms, box-shadow 200ms, opacity 200ms;
  user-select: none; -webkit-user-select: none;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; }
.btn-block { width: 100%; }
.btn-lg { min-height: 54px; font-size: 16px; }
.btn-xl { min-height: 60px; font-size: 17px; border-radius: 16px; }
.btn-gold {
  color: var(--gold-ink);
  background: linear-gradient(180deg, var(--gold-2), var(--gold) 55%, var(--gold-3));
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.45) inset, 0 -2px 0 rgba(0, 0, 0, 0.12) inset, 0 10px 26px rgba(224, 178, 92, 0.25);
}
.btn-gold .ico { fill: currentColor; stroke-width: 1.4; }
.btn-gold:hover:not(:disabled) { box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5) inset, 0 -2px 0 rgba(0, 0, 0, 0.12) inset, 0 14px 34px rgba(224, 178, 92, 0.34); }
.btn-ghost { background: var(--surface-2); color: var(--text); box-shadow: 0 0 0 1px var(--line-2) inset; }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); }
.btn-danger { background: var(--red); color: #2a0c08; box-shadow: 0 10px 24px rgba(232, 106, 95, 0.22); }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid rgba(42, 28, 6, 0.3); border-top-color: var(--gold-ink);
  animation: spin 700ms linear infinite;
}
.btn-ghost.is-loading::after { border-color: rgba(244, 235, 221, 0.25); border-top-color: var(--text); }
.link-btn { display: inline-flex; align-items: center; gap: 2px; color: var(--gold); font-size: 13px; font-weight: 600; padding: 6px 0; }
.link-btn .ico { width: 16px; height: 16px; }
.icon-btn {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px;
  color: var(--text-2); background: var(--surface); box-shadow: 0 0 0 1px var(--line) inset;
  transition: background-color 180ms, color 180ms, transform 160ms var(--ease);
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn:active { transform: scale(0.94); }

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Splash ---------- */
.splash {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-content: center; justify-items: center; gap: 18px;
  background: var(--bg); color: var(--text-3); font-size: 14px;
  transition: opacity 360ms var(--ease), visibility 360ms;
}
body:not(.is-loading) .splash { opacity: 0; visibility: hidden; pointer-events: none; }
.splash-mark {
  width: 76px; height: 76px; padding: 12px; border-radius: 22px;
  background: linear-gradient(145deg, var(--surface-3), var(--surface));
  box-shadow: var(--shadow-2), 0 0 0 1px var(--line-2) inset;
  animation: splash-bob 1.6s var(--ease) infinite;
}
.splash-mark .pc { width: 100%; height: 100%; }
@keyframes splash-bob { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-6px) rotate(-4deg); } }

/* ---------- Barre d'application ---------- */
.app { min-height: 100dvh; }
.appbar {
  position: sticky; top: 0; z-index: 30;
  padding-top: var(--safe-t);
  background: rgba(21, 17, 14, 0.78);
  backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3);
  border-bottom: 1px solid var(--line);
}
.appbar-inner { display: flex; align-items: center; gap: 12px; height: var(--appbar-h); max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 38px; height: 38px; padding: 5px; border-radius: 11px;
  background: linear-gradient(145deg, var(--gold-2), var(--gold-3));
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.4) inset, 0 6px 16px rgba(224, 178, 92, 0.25);
}
.brand-mark .pc { width: 100%; height: 100%; filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.25)); }
.brand-text { display: flex; flex-direction: column; line-height: 1; text-align: left; }
.brand-text strong { font-family: var(--font-display); font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.brand-text small { margin-top: 3px; color: var(--gold); font-size: 10.5px; font-weight: 600; letter-spacing: 0.22em; text-transform: uppercase; }
.topnav { display: none; }
.appbar-end { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.env-badge {
  padding: 4px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
  color: var(--gold); background: var(--gold-soft); box-shadow: 0 0 0 1px rgba(224, 178, 92, 0.25) inset;
}
.balance-chip {
  display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 12px 0 10px; border-radius: 999px;
  background: var(--surface); box-shadow: 0 0 0 1px var(--line-2) inset; transition: background-color 180ms;
}
.balance-chip:hover { background: var(--surface-2); }
.balance-chip .ico { width: 18px; height: 18px; color: var(--gold); }
.balance-chip strong { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.balance-chip small { color: var(--text-3); font-size: 12px; font-weight: 600; margin-left: -3px; }
.avatar {
  display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 13px;
  font-weight: 700; font-size: 14px; letter-spacing: 0.02em;
  color: var(--gold-ink); background: linear-gradient(145deg, #f3dcb0, #c99a5d);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.4) inset;
}
.avatar-sm { width: 38px; height: 38px; border-radius: 11px; font-size: 13px; }
.avatar-engine { color: var(--text-2); background: linear-gradient(145deg, #3c332b, #26201b); box-shadow: 0 0 0 1px var(--line-2) inset; }
.avatar-engine .ico { width: 24px; height: 24px; }

/* ---------- Vues ---------- */
.main { padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 24px); }
.view { animation: view-in 380ms var(--ease) both; }
@keyframes view-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.container { max-width: 1120px; margin: 0 auto; padding: 22px 16px 8px; }
.container.narrow { max-width: 640px; }
.view-head { margin-bottom: 22px; }
.greeting { margin-bottom: 18px; }

/* ---------- Bandeau de reprise ---------- */
.resume-banner {
  display: flex; align-items: center; gap: 12px; width: 100%; margin-bottom: 16px; padding: 12px 14px;
  text-align: left; border-radius: var(--r-md);
  background: linear-gradient(90deg, rgba(134, 194, 127, 0.16), rgba(134, 194, 127, 0.05));
  box-shadow: 0 0 0 1px rgba(134, 194, 127, 0.3) inset;
  transition: transform 160ms var(--ease);
}
.resume-banner:active { transform: scale(0.985); }
.resume-pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 rgba(134, 194, 127, 0.6); animation: pulse 1.6s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 10px rgba(134, 194, 127, 0); } 100% { box-shadow: 0 0 0 0 rgba(134, 194, 127, 0); } }
.resume-copy { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.resume-copy strong { font-size: 14px; }
.resume-copy small { color: var(--text-3); font-size: 12px; }
.resume-clock { margin-left: auto; font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.resume-cta { display: inline-flex; align-items: center; color: var(--green); font-weight: 600; font-size: 13px; }
.resume-cta .ico { width: 16px; height: 16px; }

/* ---------- Carte défi ---------- */
.home-grid { display: grid; gap: 16px; }
.challenge-card {
  position: relative; overflow: hidden; border-radius: var(--r-xl); isolation: isolate;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  box-shadow: var(--shadow-2), 0 0 0 1px var(--line) inset;
}
.challenge-visual { position: relative; height: 176px; overflow: hidden; border-radius: var(--r-xl) var(--r-xl) 0 0; perspective: 640px; perspective-origin: 50% 0%; clip-path: inset(0 round var(--r-xl) var(--r-xl) 0 0); }
.mini-board {
  position: absolute; left: 50%; bottom: -6%; width: 112%; aspect-ratio: 1;
  transform: translateX(-50%) rotateX(54deg);
  transform-origin: 50% 100%;
  display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr);
  transform-style: preserve-3d;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
}
.mini-board > span { position: relative; background: var(--sq-dark); transform-style: preserve-3d; }
.mini-board > span.l { background: var(--sq-light); }
.mini-board .pc { position: absolute; inset: 0 6% 12%; transform-origin: 50% 100%; transform: rotateX(-54deg); filter: drop-shadow(0 4px 2px rgba(0, 0, 0, 0.35)); }
.challenge-visual-fade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(42, 35, 29, 0.9) 0%, rgba(42, 35, 29, 0) 26%, rgba(42, 35, 29, 0) 42%, rgba(42, 35, 29, 0.8) 76%, var(--surface-2)); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.countdown-pill {
  position: absolute; top: 14px; left: 14px; display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 999px; font-size: 12px; color: var(--text-2);
  background: rgba(21, 17, 14, 0.72); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 0 0 1px var(--line-2) inset;
}
.countdown-pill .ico { width: 14px; height: 14px; color: var(--gold); }
.countdown-pill strong { color: var(--text); font-variant-numeric: tabular-nums; }
.challenge-body { position: relative; padding: 0 18px 18px; margin-top: -26px; }
.challenge-head { margin-bottom: 16px; }
.challenge-head .title { margin: 6px 0 6px; }
.engine-line { color: var(--text-3); font-size: 13px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.engine-line strong { color: var(--text-2); font-weight: 600; }
.dot-online { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px rgba(134, 194, 127, 0.7); }
.dot-online.off { background: var(--gold); box-shadow: 0 0 10px rgba(224, 178, 92, 0.6); }

.stakes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.stakes > div { padding: 12px 10px; border-radius: var(--r-md); background: rgba(21, 17, 14, 0.45); box-shadow: 0 0 0 1px var(--line) inset; text-align: center; }
.stakes dt { color: var(--text-3); font-size: 11.5px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; }
.stakes dd { margin-top: 2px; font-weight: 700; font-size: 17px; }
.stakes .stake-win { background: linear-gradient(180deg, rgba(224, 178, 92, 0.16), rgba(224, 178, 92, 0.06)); box-shadow: 0 0 0 1px rgba(224, 178, 92, 0.3) inset; }
.stakes .stake-win dd { color: var(--gold-2); }
.assurances { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; margin-top: 14px; color: var(--text-3); font-size: 12.5px; }
.assurances li { display: inline-flex; align-items: center; gap: 5px; }
.assurances .ico { width: 15px; height: 15px; color: var(--green); }

/* ---------- Panneaux ---------- */
.home-side { display: grid; gap: 16px; align-content: start; }
.panel { padding: 16px; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-1), 0 0 0 1px var(--line) inset; }
.panel + .panel { margin-top: 0; }
.container.narrow .panel { margin-bottom: 14px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.panel-title { font-size: 15px; font-weight: 600; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat { padding: 10px 4px; border-radius: var(--r-sm); background: var(--bg-2); text-align: center; }
.stat span { display: block; color: var(--text-3); font-size: 11.5px; }
.stat strong { display: block; font-size: 18px; font-weight: 700; margin-top: 1px; }

/* ---------- Classement ---------- */
.rank-list { display: grid; gap: 6px; }
.rank-row {
  display: grid; grid-template-columns: 30px 38px 1fr auto; align-items: center; gap: 10px;
  padding: 8px 12px 8px 8px; border-radius: var(--r-md); background: var(--surface);
  box-shadow: 0 0 0 1px var(--line) inset;
}
.rank-list.compact .rank-row { background: transparent; box-shadow: none; padding: 6px 2px; border-radius: 10px; }
.rank-row.is-me { background: var(--gold-soft) !important; box-shadow: 0 0 0 1px rgba(224, 178, 92, 0.3) inset !important; padding-left: 8px !important; padding-right: 10px !important; }
.rank-pos { text-align: center; font-weight: 700; color: var(--text-3); font-variant-numeric: tabular-nums; }
.rank-pos.p1 { color: #f2c86b; } .rank-pos.p2 { color: #cfd3d6; } .rank-pos.p3 { color: #d69a6a; }
.rank-avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; font-size: 12.5px; font-weight: 700; color: var(--text-2); background: var(--surface-3); }
.rank-row.is-me .rank-avatar { color: var(--gold-ink); background: linear-gradient(145deg, #f3dcb0, #c99a5d); }
.rank-name { min-width: 0; line-height: 1.25; }
.rank-name strong { display: block; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-name small { color: var(--text-3); font-size: 12px; }
.rank-score { font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }
.rank-score small { color: var(--text-3); font-size: 11px; font-weight: 500; margin-left: 2px; }

.podium { display: grid; grid-template-columns: 1fr 1.12fr 1fr; align-items: end; gap: 10px; margin: 6px 0 18px; }
.podium-step { display: flex; flex-direction: column; align-items: center; text-align: center; min-width: 0; }
.podium-step .avatar { width: 56px; height: 56px; border-radius: 18px; font-size: 16px; margin-bottom: 8px; }
.podium-step.first .avatar { width: 68px; height: 68px; border-radius: 22px; font-size: 19px; }
.podium-crown { color: #f2c86b; margin-bottom: 4px; }
.podium-crown .ico { width: 26px; height: 26px; fill: rgba(242, 200, 107, 0.25); }
.podium-name { font-size: 13px; font-weight: 600; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.podium-pts { color: var(--text-3); font-size: 12px; margin-bottom: 8px; }
.podium-block {
  width: 100%; display: grid; place-items: center; border-radius: 14px 14px 6px 6px;
  font-family: var(--font-display); font-size: 26px; font-weight: 700;
  background: linear-gradient(180deg, var(--surface-3), var(--surface));
  box-shadow: 0 0 0 1px var(--line-2) inset;
}
.podium-step.first .podium-block { height: 96px; color: #f2c86b; background: linear-gradient(180deg, rgba(242, 200, 107, 0.28), var(--surface)); }
.podium-step.second .podium-block { height: 72px; color: #cfd3d6; }
.podium-step.third .podium-block { height: 56px; color: #d69a6a; }
.footnote { margin-top: 16px; color: var(--text-3); font-size: 12.5px; text-align: center; }

/* ---------- Comment ça marche ---------- */
.how { margin-top: 28px; }
.how-steps { display: grid; gap: 10px; }
.how-steps li { display: flex; gap: 14px; padding: 14px; border-radius: var(--r-lg); background: var(--surface); box-shadow: 0 0 0 1px var(--line) inset; }
.how-num {
  display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 50%;
  font-family: var(--font-display); font-weight: 700; color: var(--gold);
  background: var(--gold-soft); box-shadow: 0 0 0 1px rgba(224, 178, 92, 0.3) inset;
}
.how-steps strong { display: block; font-size: 15px; margin-bottom: 2px; }
.how-steps p { color: var(--text-3); font-size: 13.5px; }

/* ---------- Portefeuille ---------- */
.balance-card {
  position: relative; overflow: hidden; margin-bottom: 14px; padding: 22px 20px;
  border-radius: var(--r-xl);
  background:
    radial-gradient(400px 200px at 100% 0%, rgba(255, 220, 150, 0.22), transparent 60%),
    repeating-linear-gradient(100deg, rgba(0, 0, 0, 0) 0 9px, rgba(0, 0, 0, 0.035) 9px 11px),
    linear-gradient(135deg, #6b4a2d, #3d2817 60%, #2c1c10);
  box-shadow: var(--shadow-2), 0 0 0 1px rgba(255, 220, 160, 0.12) inset;
}
.balance-label { color: rgba(244, 235, 221, 0.7); font-size: 13px; font-weight: 500; }
.balance-amount { display: flex; align-items: baseline; gap: 8px; margin: 4px 0 6px; }
.balance-amount strong { font-family: var(--font-display); font-size: 44px; font-weight: 700; line-height: 1; letter-spacing: -0.02em; }
.balance-amount small { color: var(--gold-2); font-weight: 600; }
.balance-hint { color: rgba(244, 235, 221, 0.65); font-size: 13px; }
.balance-piece { position: absolute; right: -14px; bottom: -18px; width: 132px; height: 132px; opacity: 0.16; transform: rotate(-12deg); }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px; margin-bottom: 14px; border-radius: var(--r-md); background: var(--gold-soft); color: var(--text-2); font-size: 13px; box-shadow: 0 0 0 1px rgba(224, 178, 92, 0.22) inset; }
.notice .ico { color: var(--gold); margin-top: 1px; }
.notice strong { color: var(--text); }
.notice.is-secure { background: var(--green-soft); box-shadow: 0 0 0 1px rgba(134, 194, 127, 0.25) inset; }
.notice.is-secure .ico { color: var(--green); }
.notice-safe { background: var(--green-soft); box-shadow: 0 0 0 1px rgba(134, 194, 127, 0.25) inset; }
.notice-safe .ico { color: var(--green); }
.amount-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.amount {
  min-height: 56px; border-radius: var(--r-md); font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums;
  background: var(--bg-2); box-shadow: 0 0 0 1px var(--line-2) inset;
  transition: background-color 180ms, box-shadow 180ms, transform 160ms var(--ease);
}
.amount small { display: block; color: var(--text-3); font-size: 11px; font-weight: 500; }
.amount:active { transform: scale(0.97); }
.amount[aria-checked="true"] { background: var(--gold-soft); box-shadow: 0 0 0 2px var(--gold) inset; color: var(--gold-2); }
.tx-list { display: grid; }
.tx { display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.tx:first-child { border-top: 0; padding-top: 0; }
.tx-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; color: var(--text-3); background: var(--surface-3); }
.tx-icon .ico { width: 17px; height: 17px; }
.tx.is-credit .tx-icon { color: var(--green); background: var(--green-soft); }
.tx-copy { min-width: 0; line-height: 1.3; }
.tx-copy strong { display: block; font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-copy small { color: var(--text-3); font-size: 12px; }
.tx-amount { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-2); }
.tx.is-credit .tx-amount { color: var(--green); }
.empty { color: var(--text-3); font-size: 13.5px; text-align: center; padding: 14px 0; }

/* ---------- Règles ---------- */
.payout-table { display: grid; gap: 8px; }
.payout { display: grid; grid-template-columns: 38px 1fr auto auto; align-items: center; gap: 12px; padding: 10px 12px 10px 10px; border-radius: var(--r-md); background: var(--bg-2); }
.payout strong { font-size: 14px; font-weight: 600; }
.payout span:not(.payout-icon) { font-weight: 700; font-variant-numeric: tabular-nums; }
.payout em { font-style: normal; color: var(--text-3); font-size: 12.5px; min-width: 42px; text-align: right; }
.payout-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; }
.payout.win .payout-icon { color: var(--gold-2); background: var(--gold-soft); }
.payout.win span:not(.payout-icon) { color: var(--gold-2); }
.payout.draw .payout-icon { color: var(--text-2); background: var(--surface-3); }
.payout.lose .payout-icon { color: var(--red); background: var(--red-soft); }
.faq details { border-top: 1px solid var(--line); }
.faq details:first-child { border-top: 0; }
.faq summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; font-weight: 600; font-size: 14.5px; cursor: pointer; list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary .ico { width: 18px; height: 18px; color: var(--text-3); transition: transform 220ms var(--ease); }
.faq details[open] summary .ico { transform: rotate(90deg); }
.faq details p { padding: 0 0 14px; color: var(--text-2); font-size: 14px; }

/* ---------- Barre d'onglets ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-b)); padding: 0 6px var(--safe-b);
  background: rgba(24, 19, 15, 0.86);
  backdrop-filter: blur(16px) saturate(1.3); -webkit-backdrop-filter: blur(16px) saturate(1.3);
  border-top: 1px solid var(--line);
}
.tabbar button { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--text-3); font-size: 11px; font-weight: 600; transition: color 200ms; }
.tabbar button .ico { width: 23px; height: 23px; transition: transform 240ms var(--ease-spring); }
.tabbar button.is-active { color: var(--gold-2); }
.tabbar button.is-active .ico { transform: translateY(-1px) scale(1.06); }
.tabbar button::before { content: ""; position: absolute; top: 0; width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--gold); transform: scaleX(0); transition: transform 240ms var(--ease); }
.tabbar button.is-active::before { transform: scaleX(1); }

/* ==========================================================================
   ÉCRAN DE PARTIE
   ========================================================================== */
body.in-game .appbar, body.in-game .tabbar { display: none; }
body.in-game .main { padding-bottom: 0; }
body.in-game { background: var(--bg); }
.game {
  --board: min(100vw - 12px, 100dvh - 290px - var(--safe-t) - var(--safe-b), 680px);
  display: flex; flex-direction: column; min-height: 100dvh;
  padding-top: var(--safe-t);
}
.game-bar { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 8px; padding: 8px 10px; }
.game-title { text-align: center; line-height: 1.2; min-width: 0; }
.game-title strong { display: block; font-family: var(--font-display); font-size: 16px; font-weight: 600; }
.game-title small { color: var(--text-3); font-size: 12px; }

.move-strip {
  order: 0; display: flex; gap: 4px; align-items: center; height: 36px; padding: 0 2px; margin-bottom: 2px;
  overflow-x: auto; scrollbar-width: none; scroll-behavior: smooth; white-space: nowrap;
  mask-image: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 14px), transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 14px), transparent);
}
.move-strip::-webkit-scrollbar { display: none; }
.move-strip .mv-num { color: var(--text-3); font-size: 12.5px; padding-left: 6px; font-variant-numeric: tabular-nums; }
.move-strip .mv { display: inline-flex; align-items: center; gap: 1px; padding: 4px 7px; border-radius: 8px; font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.move-strip .mv.is-last { color: var(--gold-ink); background: var(--gold); }
.move-strip .mv-empty { color: var(--text-3); font-size: 13px; margin: 0 auto; }
.move-strip .mv:first-of-type, .move-strip .mv-num:first-child { margin-left: 0; }
.fig { display: inline-block; width: 1.25em; height: 1.25em; margin: -0.2em 0 -0.2em -0.1em; background-size: 100% 100%; vertical-align: middle; }

.game-layout { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.board-col { width: var(--board); display: flex; flex-direction: column; gap: 6px; }

.player-bar {
  display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 6px 2px;
  transition: opacity 240ms;
}
.player-bar .avatar { width: 40px; height: 40px; border-radius: 12px; font-size: 13px; }
.player-meta { flex: 1; min-width: 0; line-height: 1.2; }
.player-name { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.player-name strong { font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rating { color: var(--text-3); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.captures { display: flex; align-items: center; min-height: 20px; margin-top: 2px; }
.captures:empty { display: none; }
.captures .cap { width: 17px; height: 17px; margin-right: -6px; }
.captures .cap-gap { width: 9px; }
.captures .cap[class*="pc-b"] { filter: drop-shadow(0 0 0.7px rgba(244, 235, 221, 0.9)); }
#opponent-bar { order: 1; } .board-wrap { order: 2; } #player-bar { order: 3; }
.board-col.is-flipped #opponent-bar { order: 3; }
.board-col.is-flipped #player-bar { order: 1; }
.captures .adv { margin-left: 10px; color: var(--text-3); font-size: 12px; font-weight: 600; }

.engine-status { display: inline-flex; align-items: center; gap: 8px; padding: 7px 11px; border-radius: 999px; color: var(--text-3); font-size: 12.5px; font-weight: 500; background: var(--surface); box-shadow: 0 0 0 1px var(--line) inset; transition: color 200ms, background-color 200ms; }
.engine-status .thinking { display: none; gap: 3px; }
.engine-status .thinking i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; animation: think 1s infinite ease-in-out; }
.engine-status .thinking i:nth-child(2) { animation-delay: 0.15s; }
.engine-status .thinking i:nth-child(3) { animation-delay: 0.3s; }
.engine-status.is-thinking { color: var(--gold-2); background: var(--gold-soft); box-shadow: 0 0 0 1px rgba(224, 178, 92, 0.3) inset; }
.engine-status.is-thinking .thinking { display: inline-flex; }
@keyframes think { 0%, 80%, 100% { transform: translateY(0); opacity: 0.4; } 40% { transform: translateY(-3px); opacity: 1; } }

.clock {
  min-width: 104px; padding: 8px 14px; border-radius: 12px; text-align: center;
  font-size: 26px; font-weight: 700; line-height: 1.1; letter-spacing: 0.01em;
  color: var(--text-3); background: var(--surface); box-shadow: 0 0 0 1px var(--line) inset;
  transition: color 220ms, background-color 220ms, box-shadow 220ms;
}
.clock.is-running { color: var(--gold-ink); background: linear-gradient(180deg, #f6ead2, #e6d3b0); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3), 0 1px 0 #fff inset; }
.clock.is-low { color: #fff; background: linear-gradient(180deg, #ee7b70, #cf4b40); animation: clock-pulse 1s infinite; }
@keyframes clock-pulse { 50% { box-shadow: 0 0 0 6px rgba(232, 106, 95, 0.18); } }

/* ---------- Échiquier ---------- */
.board-wrap {
  position: relative; padding: 5px; border-radius: 10px;
  background:
    repeating-linear-gradient(92deg, rgba(255, 255, 255, 0.025) 0 3px, rgba(0, 0, 0, 0.04) 3px 7px),
    linear-gradient(160deg, var(--frame-1), var(--frame-2));
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.5), 0 1px 0 rgba(255, 255, 255, 0.07) inset;
}
.board {
  position: relative; width: 100%; aspect-ratio: 1; border-radius: 4px; overflow: hidden;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}
.board-squares { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); }
.sq { position: relative; display: block; width: 100%; height: 100%; background: var(--sq-dark); cursor: default; }
.sq.l { background: var(--sq-light); }
.sq:focus-visible { outline: 3px solid var(--gold-2); outline-offset: -3px; border-radius: 0; z-index: 1; }
.sq.is-last::before, .sq.is-sel::before { content: ""; position: absolute; inset: 0; background: var(--hl-last); }
.sq.is-sel::before { background: var(--hl-sel); }
.sq.is-check::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle, rgba(255, 60, 40, 0.95) 0%, rgba(230, 40, 30, 0.55) 35%, rgba(200, 20, 20, 0) 72%); }
.sq.is-hover { box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.55); }
.sq .hint { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.sq .hint.dot::after { content: ""; position: absolute; left: 50%; top: 50%; width: 30%; height: 30%; border-radius: 50%; transform: translate(-50%, -50%); background: var(--hint); }
.sq .hint.ring::after { content: ""; position: absolute; inset: 0; border-radius: 50%; box-shadow: inset 0 0 0 calc(var(--board) * 0.0085) var(--hint); background: radial-gradient(transparent 62%, var(--hint) 63%); }
.board.is-mine .sq.can-move, .board.is-mine .sq.is-target { cursor: pointer; }
.coord { position: absolute; font-size: max(9px, calc(var(--board) * 0.021)); font-weight: 700; line-height: 1; pointer-events: none; z-index: 2; color: var(--coord-on-dark); }
.sq.l .coord { color: var(--coord-on-light); }
.coord.rank { top: 4%; left: 5%; }
.coord.file { bottom: 4%; right: 6%; }
.no-coords .coord { display: none; }

.board-pieces { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.piece {
  position: absolute; left: 0; top: 0; width: 12.5%; height: 12.5%;
  transform: translate(calc(var(--x) * 100%), calc(var(--y) * 100%));
  will-change: transform;
}
.piece > i { position: absolute; inset: 2%; background-size: 100% 100%; filter: drop-shadow(0 2px 1.5px rgba(0, 0, 0, 0.28)); }
.piece.anim { transition: transform 220ms var(--ease); }
.piece.is-captured { animation: captured 220ms var(--ease) forwards; }
@keyframes captured { to { opacity: 0; transform: translate(calc(var(--x) * 100%), calc(var(--y) * 100%)) scale(0.6); } }
.piece.is-dragging { z-index: 10; transition: none; }
.piece.is-dragging > i { transform: scale(1.22); filter: drop-shadow(0 10px 8px rgba(0, 0, 0, 0.4)); }
.piece.is-ghost { opacity: 0.3; }
@media (pointer: coarse) { .piece.is-dragging > i { transform: translateY(-38%) scale(1.5); } }
.piece.is-pop > i { animation: pop 260ms var(--ease-spring); }
@keyframes pop { from { transform: scale(0.6); } to { transform: scale(1); } }

.board.is-locked .sq { cursor: default !important; }
.board.is-over .board-pieces { filter: saturate(0.85); }

/* Promotion */
.promotion { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(15, 11, 8, 0.62); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); animation: fade 160ms ease both; }
.promotion-card { padding: 14px 14px 8px; border-radius: var(--r-lg); background: var(--surface-2); box-shadow: var(--shadow-2), 0 0 0 1px var(--line-2) inset; text-align: center; animation: rise 260ms var(--ease-spring) both; }
.promotion-card p { color: var(--text-2); font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.promotion-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.promotion-options button { width: calc(var(--board) * 0.17); height: calc(var(--board) * 0.17); max-width: 86px; max-height: 86px; border-radius: 14px; background: var(--sq-light); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2) inset; transition: transform 160ms var(--ease), background-color 160ms; }
.promotion-options button:nth-child(even) { background: var(--sq-dark); }
.promotion-options button:hover, .promotion-options button:focus-visible { transform: translateY(-3px); }
.promotion-options .pc { width: 86%; height: 86%; margin: 7%; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(0.96); } }

.status-banner {
  position: absolute; left: 50%; top: 50%; z-index: 15; transform: translate(-50%, -50%);
  padding: 10px 18px; border-radius: 999px; font-weight: 700; font-size: 15px; white-space: nowrap;
  color: #fff; background: rgba(205, 60, 50, 0.92); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  animation: banner 1.2s var(--ease) both; pointer-events: none;
}
.status-banner[data-tone="win"] { color: var(--gold-ink); background: rgba(232, 186, 96, 0.96); }
.status-banner[data-tone="draw"] { background: rgba(70, 60, 52, 0.95); }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, -40%) scale(0.9); } 15%, 75% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -55%) scale(0.98); } }

/* Actions de partie */
.game-side { display: none; }
.game-actions { margin-top: auto; padding: 8px 10px calc(8px + var(--safe-b)); }
.actions-live { display: grid; grid-template-columns: repeat(3, 64px) 1fr; gap: 6px; align-items: center; max-width: var(--board); margin: 0 auto; }
.action { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: 56px; border-radius: 14px; color: var(--text-2); font-size: 11px; font-weight: 600; transition: background-color 180ms, color 180ms, transform 160ms var(--ease); }
.action:hover { background: var(--surface); color: var(--text); }
.action:active { transform: scale(0.94); }
.action .ico { width: 22px; height: 22px; }
#resign-btn:hover { color: var(--red); }
.action.is-off { color: var(--text-3); }
.action-stake { justify-self: end; text-align: right; padding: 8px 12px; border-radius: 14px; background: var(--gold-soft); box-shadow: 0 0 0 1px rgba(224, 178, 92, 0.25) inset; line-height: 1.2; }
.action-stake small { display: block; color: var(--text-3); font-size: 11px; white-space: nowrap; }
.action-stake strong { color: var(--gold-2); font-size: 16px; font-variant-numeric: tabular-nums; }
.actions-over { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; max-width: var(--board); margin: 0 auto; }

/* Liste des coups (desktop) */
.move-table { display: grid; grid-template-columns: 40px 1fr 1fr; align-content: start; max-height: 320px; overflow-y: auto; font-size: 14px; margin: 0 -8px; padding: 0 8px; scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
.move-table > span { padding: 5px 6px; border-radius: 6px; }
.move-table .mt-num { color: var(--text-3); font-variant-numeric: tabular-nums; }
.move-table .mt-mv { font-weight: 600; color: var(--text-2); }
.move-table .mt-mv.is-last { color: var(--gold-ink); background: var(--gold); }
.move-table .empty { grid-column: 1 / -1; }
.verified { display: inline-flex; align-items: center; gap: 4px; color: var(--green); font-size: 12px; font-weight: 600; }
.verified .ico { width: 15px; height: 15px; }
.stakes-small dd { font-size: 15px; }

/* ==========================================================================
   FEUILLES (bottom sheets) & TOAST
   ========================================================================== */
.sheet { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.sheet-scrim { position: absolute; inset: 0; background: rgba(8, 6, 4, 0.62); opacity: 0; transition: opacity 280ms var(--ease); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.sheet-panel {
  position: relative; width: 100%; max-width: 520px; max-height: 92dvh; overflow-y: auto;
  padding: 10px 20px calc(20px + var(--safe-b));
  border-radius: 26px 26px 0 0; background: var(--surface-2);
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--line-2) inset;
  transform: translateY(100%); transition: transform 360ms var(--ease);
  text-align: center;
}
.sheet.is-open .sheet-scrim { opacity: 1; }
.sheet.is-open .sheet-panel { transform: none; }
.sheet-grip { display: block; width: 40px; height: 5px; margin: 0 auto 14px; border-radius: 3px; background: var(--line-2); }
.sheet-title { font-family: var(--font-display); font-size: 24px; font-weight: 700; line-height: 1.15; margin-bottom: 6px; }
.sheet-title.left { text-align: left; }
.sheet-title.big { font-size: 34px; }
.sheet-text { color: var(--text-2); font-size: 14.5px; margin-bottom: 18px; }
.sheet-hero { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 4px 0 12px; }
.sheet-hero .pc { width: 56px; height: 56px; filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.4)); }
.sheet-hero .vs { font-family: var(--font-display); color: var(--gold); font-weight: 700; font-style: italic; }
.sheet-icon { display: inline-grid; place-items: center; width: 56px; height: 56px; margin: 4px 0 12px; border-radius: 18px; }
.sheet-icon .ico { width: 28px; height: 28px; }
.sheet-icon.danger { color: var(--red); background: var(--red-soft); }
.sheet-actions { display: grid; grid-template-columns: 1fr 1.3fr; gap: 10px; margin-top: 18px; }
.sheet-actions.single { grid-template-columns: 1fr; }
.receipt { text-align: left; padding: 4px 14px; border-radius: var(--r-md); background: var(--bg-2); box-shadow: 0 0 0 1px var(--line) inset; }
.receipt > div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px dashed var(--line-2); font-size: 14px; }
.receipt > div:first-child { border-top: 0; }
.receipt dt { color: var(--text-3); }
.receipt dd { font-weight: 600; font-variant-numeric: tabular-nums; }
.receipt dd.neg { color: var(--red); }
.receipt-total dt { color: var(--text) !important; font-weight: 600; }
.receipt-total dd { color: var(--gold-2); font-size: 16px; }
.checklist { display: grid; gap: 8px; margin-top: 14px; text-align: left; }
.checklist li { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-size: 14px; }
.checklist .ico { width: 18px; height: 18px; color: var(--gold); }

/* Réglages */
.setting-label { text-align: left; color: var(--text-3); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; margin: 10px 0 10px; }
.theme-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.theme-opt { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 4px; border-radius: var(--r-md); font-size: 12px; font-weight: 600; color: var(--text-2); background: var(--bg-2); box-shadow: 0 0 0 1px var(--line) inset; transition: box-shadow 180ms; }
.theme-opt[aria-checked="true"] { color: var(--gold-2); box-shadow: 0 0 0 2px var(--gold) inset; }
.theme-swatch { display: grid; grid-template-columns: 1fr 1fr; width: 44px; height: 44px; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3); }
.theme-swatch i:nth-child(1), .theme-swatch i:nth-child(4) { background: var(--l); }
.theme-swatch i:nth-child(2), .theme-swatch i:nth-child(3) { background: var(--d); }
.toggles { margin-top: 16px; border-radius: var(--r-md); background: var(--bg-2); box-shadow: 0 0 0 1px var(--line) inset; text-align: left; }
.toggle { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px; border-top: 1px solid var(--line); cursor: pointer; font-size: 14.5px; }
.toggle:first-child { border-top: 0; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle i { position: relative; flex: none; width: 46px; height: 28px; border-radius: 999px; background: var(--surface-3); transition: background-color 200ms; }
.toggle i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--text-2); box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3); transition: transform 240ms var(--ease-spring), background-color 200ms; }
.toggle input:checked + i { background: var(--gold); }
.toggle input:checked + i::after { transform: translateX(18px); background: #fff; }
.toggle input:focus-visible + i { outline: 2px solid var(--gold-2); outline-offset: 2px; }

/* Résultat */
.result-sheet .sheet-panel { padding-top: 26px; overflow: hidden; }
.result-sheet .kicker { display: block; }
.result-emblem { position: relative; display: grid; margin-left: auto; margin-right: auto; place-items: center; width: 84px; height: 84px; margin-bottom: 12px; border-radius: 28px; }
.result-emblem .ico { width: 42px; height: 42px; stroke-width: 1.6; }
.result-sheet.win .result-emblem { color: var(--gold-ink); background: linear-gradient(145deg, var(--gold-2), var(--gold-3)); box-shadow: 0 0 0 8px rgba(224, 178, 92, 0.12), 0 16px 40px rgba(224, 178, 92, 0.35); animation: emblem 700ms var(--ease-spring) both; }
.result-sheet.win .result-emblem .ico { fill: rgba(42, 28, 6, 0.15); }
.result-sheet.draw .result-emblem { color: var(--text); background: var(--surface-3); box-shadow: 0 0 0 8px rgba(240, 226, 203, 0.05); }
.result-sheet.lose .result-emblem { color: var(--red); background: var(--red-soft); box-shadow: 0 0 0 8px rgba(232, 106, 95, 0.06); }
.result-sheet.win .kicker { color: var(--gold-2); }
.result-sheet.lose .kicker { color: var(--red); }
@keyframes emblem { from { transform: scale(0.4) rotate(-20deg); opacity: 0; } }
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.result-stats > div { padding: 12px 6px; border-radius: var(--r-md); background: var(--bg-2); box-shadow: 0 0 0 1px var(--line) inset; }
.result-stats dt { color: var(--text-3); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; }
.result-stats dd { font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums; }
.result-sheet.win #result-reward { color: var(--gold-2); }
.result-sheet .sheet-actions { grid-template-columns: 1fr 1fr; margin-top: 10px; }
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i { position: absolute; top: -16px; width: 8px; height: 14px; border-radius: 2px; opacity: 0.95; animation: confetti 2.4s var(--ease) forwards; }
@keyframes confetti { to { transform: translate(var(--dx), 520px) rotate(var(--rot)); opacity: 0; } }

.toast {
  position: fixed; left: 50%; top: calc(12px + var(--safe-t)); z-index: 90; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; width: max-content; max-width: calc(100vw - 24px);
  padding: 12px 16px; border-radius: 16px; font-size: 14px; font-weight: 500;
  background: #f4ebdd; color: #241a10; box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  animation: toast-in 320ms var(--ease-spring) both;
}
.toast .ico { color: var(--gold-3); }
.toast.is-error { background: #fbe3df; }
.toast.is-error .ico { color: #c4463b; }
.toast.is-success .ico { color: #3f8a3a; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -16px) scale(0.96); } }

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 359px) {
  .stakes dd { font-size: 15px; }
  .stat strong { font-size: 16px; }
  .actions-live { grid-template-columns: repeat(3, 54px) 1fr; }
  .clock { min-width: 92px; font-size: 22px; }
}

@media (min-width: 700px) {
  .container { padding-top: 32px; }
  .home-grid { grid-template-columns: 1.25fr 1fr; align-items: start; }
  .challenge-visual { height: 220px; }
  .how-steps { grid-template-columns: repeat(3, 1fr); }
  .sheet { align-items: center; padding: 24px; }
  .sheet-panel { border-radius: 26px; transform: translateY(24px) scale(0.97); opacity: 0; transition: transform 320ms var(--ease), opacity 240ms; padding-bottom: 24px; }
  .sheet.is-open .sheet-panel { opacity: 1; }
  .sheet-grip { display: none; }
}

@media (min-width: 900px) {
  .tabbar { display: none; }
  .main { padding-bottom: 48px; }
  .topnav { display: flex; gap: 4px; margin-left: 28px; }
  .topnav button { padding: 8px 14px; border-radius: 10px; color: var(--text-3); font-weight: 600; font-size: 14px; transition: color 180ms, background-color 180ms; }
  .topnav button:hover { color: var(--text); background: var(--surface); }
  .topnav button.is-active { color: var(--gold-2); background: var(--gold-soft); }
  .brand-mark { width: 40px; height: 40px; }

  .game {
    --board: min(100dvh - 220px, 100vw - 440px, 760px);
    display: grid; grid-template-columns: var(--board) 340px; grid-template-rows: auto 1fr;
    column-gap: 32px; justify-content: center; align-content: start; padding-bottom: 24px;
  }
  .game-bar { grid-column: 1 / -1; width: 100%; padding: 14px 0; }
  .move-strip { display: none; }
  .game-layout { display: contents; }
  .board-col { grid-column: 1; grid-row: 2; }
  .game-side { display: grid; gap: 14px; grid-column: 2; grid-row: 2; align-self: start; align-content: start; margin-top: 62px; }
  .game-actions { grid-column: 2; grid-row: 2; align-self: end; margin: 0 0 62px; padding: 0; }
  .actions-live, .actions-over { max-width: none; }
  .actions-live { grid-template-columns: repeat(3, 1fr) 1.3fr; padding: 8px; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-1), 0 0 0 1px var(--line) inset; }
  .move-table { max-height: calc(100dvh - 560px); min-height: 120px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
}
