/* ============================================================
   LE CERCLE — système de design "le Club"
   Noir profond, lumière de bougie, laiton, matières. Anti-flat.
   Mobile-first, un pouce, safe-area. Thème par jeu via [data-theme].
   ============================================================ */

:root {
  --ink: #0B0A08;
  --ink-2: #14110d;
  --ink-3: #1d1813;
  --paper: #f4efe3;
  --gold: #c9a24b;
  --gold-bright: #e8d29a;
  --gold-deep: #8a6d2c;
  --brass: #b08d3f;
  --text: #ece5d6;
  --text-dim: #aa9f8c;
  --text-faint: #6f6453;
  --line: rgba(201,162,75,0.18);
  --line-strong: rgba(201,162,75,0.42);
  --danger: #c0492f;
  --win: #6fae7a;
  --radius: 14px;
  --radius-lg: 20px;
  --ease: cubic-bezier(.22,.61,.36,1);
  --ease-out: cubic-bezier(.16,1,.3,1);
  --shadow: 0 18px 50px rgba(0,0,0,.55), 0 2px 0 rgba(255,255,255,.03) inset;
  --tap: 52px;
  /* accents pilotés par le thème de chaque jeu */
  --accent: var(--gold);
  --accent-bright: var(--gold-bright);
  --surface: #161009;
  --surface-2: #1f1812;
  font-size: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background:
    radial-gradient(120% 80% at 50% -10%, #1a140c 0%, var(--ink) 60%) fixed,
    var(--ink);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  overscroll-behavior: none;
  user-select: none;
  touch-action: manipulation;
}

#vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background:
    radial-gradient(140% 100% at 50% 0%, transparent 55%, rgba(0,0,0,.55) 100%),
    radial-gradient(80% 60% at 50% 22%, rgba(201,162,75,.06), transparent 60%);
  mix-blend-mode: normal;
}

#app {
  position: relative; z-index: 2;
  min-height: 100%;
  min-height: 100dvh;
  display: flex; flex-direction: column;
  padding: max(env(safe-area-inset-top), 14px) 16px max(env(safe-area-inset-bottom), 16px);
  max-width: 560px; margin: 0 auto;
}

/* ---------- typographie ---------- */
.display { font-family: 'Playfair Display', Georgia, serif; font-weight: 600; letter-spacing: .01em; }
.serif { font-family: 'Cormorant Garamond', Georgia, serif; }
h1,h2,h3 { font-family: 'Playfair Display', Georgia, serif; font-weight: 600; margin: 0; line-height: 1.05; }
.eyebrow { font-size: 11px; letter-spacing: .32em; text-transform: uppercase; color: var(--text-faint); font-weight: 500; }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }

/* ---------- boot ---------- */
.boot { margin: auto; text-align: center; }
.boot-ring {
  width: 78px; height: 78px; margin: 0 auto 22px; border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  border-top-color: var(--gold-bright);
  animation: spin 1.1s linear infinite;
  box-shadow: 0 0 40px rgba(201,162,75,.25);
}
@keyframes spin { to { transform: rotate(360deg); } }
.boot-word { font-family: 'Playfair Display', serif; letter-spacing: .42em; color: var(--gold-bright); font-size: 15px; padding-left: .42em; opacity: .9; }

/* ---------- éléments génériques ---------- */
.gold { color: var(--gold-bright); }
.center { text-align: center; }
.stack > * + * { margin-top: 14px; }
.row { display: flex; align-items: center; gap: 12px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grow { flex: 1; }
.hidden { display: none !important; }
.fade-in { animation: fadeIn .5s var(--ease-out) both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- boutons ---------- */
.btn {
  -webkit-appearance: none; appearance: none; border: 0; cursor: pointer;
  font-family: 'Inter', sans-serif; font-size: 16px; font-weight: 500;
  min-height: var(--tap); padding: 0 22px; border-radius: var(--radius);
  color: var(--ink); position: relative; overflow: hidden;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold) 55%, var(--gold-deep));
  box-shadow: 0 10px 24px rgba(138,109,44,.35), 0 1px 0 rgba(255,255,255,.4) inset, 0 -2px 6px rgba(0,0,0,.25) inset;
  letter-spacing: .01em; transition: transform .12s var(--ease), filter .2s;
  width: 100%;
}
.btn:active { transform: scale(.975); filter: brightness(1.05); }
.btn .sheen { position:absolute; inset:0; background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.55) 48%, transparent 60%); transform: translateX(-120%); }
.btn.shine .sheen { animation: sheen 1.6s var(--ease); }
@keyframes sheen { to { transform: translateX(120%);} }
.btn.ghost {
  background: transparent; color: var(--text);
  box-shadow: 0 0 0 1px var(--line-strong) inset;
}
.btn.ghost:active { background: rgba(201,162,75,.08); }
.btn.small { min-height: 44px; font-size: 14px; padding: 0 16px; width: auto; }
.btn:disabled { opacity: .4; filter: grayscale(.4); pointer-events: none; }

/* ---------- cartes / surfaces ---------- */
.panel {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 18px;
}
.tile {
  display: flex; align-items: center; gap: 14px; width: 100%;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; text-align: left; cursor: pointer; color: var(--text);
  transition: transform .14s var(--ease), border-color .2s, box-shadow .2s;
  box-shadow: 0 8px 22px rgba(0,0,0,.4);
}
.tile:active { transform: scale(.985); border-color: var(--line-strong); }
.tile .ico { width: 44px; height: 44px; flex: none; border-radius: 11px; display: grid; place-items: center; color: var(--accent-bright); background: radial-gradient(circle at 30% 25%, rgba(201,162,75,.22), rgba(201,162,75,.05)); border: 1px solid var(--line); font-size: 20px; }
.tile .ico svg { width: 24px; height: 24px; }
.tile .meta { flex: 1; min-width: 0; }
.tile .meta .nm { font-family: 'Playfair Display', serif; font-size: 19px; }
.tile .meta .tg { font-size: 12.5px; color: var(--text-dim); margin-top: 3px; line-height: 1.4; }
.tile .meta .th { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); margin-top: 7px; }
.tile .chev { color: var(--text-faint); flex: none; }

/* badge / pill */
.pill { display:inline-flex; align-items:center; gap:6px; font-size:11px; letter-spacing:.08em; text-transform:uppercase; color: var(--accent-bright); border:1px solid var(--line-strong); border-radius:999px; padding:5px 11px; background: rgba(201,162,75,.06); }

/* ---------- en-tête de jeu ---------- */
.topbar { display:flex; align-items:center; justify-content:space-between; gap:10px; padding: 2px 2px 14px; }
.topbar .back { width:42px; height:42px; border-radius:50%; display:grid; place-items:center; background: rgba(255,255,255,.03); border:1px solid var(--line); color: var(--text-dim); cursor:pointer; flex:none; }
.topbar .ttl { font-family:'Playfair Display',serif; font-size:18px; text-align:center; flex:1; }
.topbar .right { min-width:42px; display:flex; justify-content:flex-end; }

/* score bar */
.scorebar { display:flex; align-items:stretch; gap:10px; }
.scorebar .who { flex:1; background: linear-gradient(180deg, var(--surface-2), var(--surface)); border:1px solid var(--line); border-radius:var(--radius); padding:10px 12px; }
.scorebar .who.me { border-color: var(--line-strong); }
.scorebar .who .lbl { font-size:11px; letter-spacing:.1em; text-transform:uppercase; color:var(--text-faint); display:flex; align-items:center; gap:6px; }
.scorebar .who .val { font-family:'Playfair Display',serif; font-size:30px; line-height:1.1; margin-top:2px; }
.dot { width:7px; height:7px; border-radius:50%; background: var(--win); box-shadow:0 0 8px var(--win); }
.dot.off { background: var(--text-faint); box-shadow:none; }

/* timer */
.timer { height:4px; border-radius:999px; background: rgba(255,255,255,.06); overflow:hidden; }
.timer > i { display:block; height:100%; background: linear-gradient(90deg, var(--accent), var(--accent-bright)); transition: width .25s linear; }

/* toast */
.toast {
  position: fixed; left:50%; bottom: calc(env(safe-area-inset-bottom) + 22px); transform: translate(-50%, 30px);
  background: rgba(10,8,6,.92); border:1px solid var(--line-strong); color: var(--text);
  padding: 12px 18px; border-radius: 999px; font-size: 14px; z-index: 50; opacity: 0;
  transition: transform .35s var(--ease-out), opacity .35s; pointer-events: none; max-width: 86vw; text-align:center;
  box-shadow: 0 12px 30px rgba(0,0,0,.5);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* result overlay */
.result-wrap { position: fixed; inset:0; z-index: 40; display:grid; place-items:center; padding: 24px; background: radial-gradient(80% 60% at 50% 40%, rgba(20,15,9,.7), rgba(5,4,3,.94)); backdrop-filter: blur(3px); animation: fadeIn .4s both; }
.result-card { width:100%; max-width: 420px; text-align:center; }
.result-card .verdict { font-family:'Playfair Display',serif; font-size: 44px; line-height:1; margin: 8px 0 4px; }
.result-card .verdict.win { color: var(--gold-bright); }
.result-card .verdict.lose { color: var(--text-dim); }
.result-card .verdict.draw { color: var(--text); }
.score-final { display:flex; justify-content:center; gap: 28px; margin: 18px 0 24px; }
.score-final .sf { font-family:'Playfair Display',serif; font-size: 40px; }
.score-final .sf small { display:block; font-family:'Inter'; font-size:11px; letter-spacing:.12em; text-transform:uppercase; color:var(--text-faint); }

/* lobby share */
.codebox { text-align:center; padding: 8px 0 4px; }
.codebox .code { font-family:'Playfair Display',serif; font-size: 46px; letter-spacing:.12em; color: var(--gold-bright); }
.seats { display:flex; gap:12px; margin: 18px 0; }
.seat { flex:1; border:1px dashed var(--line-strong); border-radius: var(--radius); padding:18px 12px; text-align:center; min-height: 96px; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:8px; }
.seat.filled { border-style: solid; background: linear-gradient(180deg, var(--surface-2), var(--surface)); }
.seat .av { width:38px; height:38px; border-radius:50%; background: radial-gradient(circle at 30% 25%, var(--gold-bright), var(--gold-deep)); display:grid; place-items:center; color: var(--ink); font-weight:600; }
.seat .av.empty { background: transparent; border:1px dashed var(--line-strong); color: var(--text-faint); }
.seat .nm { font-size:13px; }

/* generic playing-card look (used by Encre & others) */
.hand { display:flex; justify-content:center; gap: 8px; flex-wrap: wrap; }
.card {
  position: relative; width: 58px; height: 84px; border-radius: 10px; flex: none;
  display:grid; place-items:center; cursor: pointer;
  font-family:'Playfair Display', serif; font-size: 30px;
  transition: transform .16s var(--ease), box-shadow .2s, opacity .2s;
}
.card:active { transform: translateY(-2px) scale(1.02); }
.card.sel { transform: translateY(-14px) scale(1.04); }
.card.spent { opacity: .28; pointer-events:none; }
.card.back { color: transparent; }

/* === thèmes par jeu === */
[data-theme="encre"] {
  --accent: #c4402a; --accent-bright: #e0644a;
  --surface: #1a1611; --surface-2: #221c15;
}
[data-theme="contrebande"] {
  --accent: #d98a2b; --accent-bright: #f0b25a;
  --surface: #121822; --surface-2: #18202c;
}
[data-theme="remparts"] {
  --accent: #b5482f; --accent-bright: #d46a4a;
  --surface: #1a160f; --surface-2: #221d14;
}
[data-theme="part-du-diable"] {
  --accent: #e08a1e; --accent-bright: #f6b53a;
  --surface: #160f0a; --surface-2: #20140c;
}
[data-theme="filature"] {
  --accent: #6f86b0; --accent-bright: #a8c0e0;
  --surface: #10141c; --surface-2: #161c26;
}
[data-theme="minuit"] {
  --accent: #c9a24b; --accent-bright: #e8d29a;
  --surface: #0f1422; --surface-2: #161d2f;
}
[data-theme="le-casse"] {
  --accent: #d8b25c; --accent-bright: #f0d79a;
  --surface: #141210; --surface-2: #0e0d0b;
}
[data-theme="vertige"] {
  --accent: #b5683a; --accent-bright: #e0a36a;
  --surface: #1b1320; --surface-2: #241827;
}
[data-theme="encre-noire"] {
  --accent: #9aa0a6; --accent-bright: #e8eaed;
  --surface: #100f0e; --surface-2: #181614;
}
[data-theme="butin"] {
  --accent: #d8a93a; --accent-bright: #f4d27a;
  --surface: #16120a; --surface-2: #1f1810;
}
[data-theme="triade"] {
  --accent: #3fae8f; --accent-bright: #7fd8bd;
  --surface: #0f1614; --surface-2: #16201d;
}
[data-theme="forteresse"] {
  --accent: #c06a2f; --accent-bright: #e89a5a;
  --surface: #14110d; --surface-2: #1d1813;
}
[data-theme="reliques"] {
  --accent: #c49a4e; --accent-bright: #e6c982;
  --surface: #121010; --surface-2: #1a1614;
}
[data-theme="enigmes"] {
  --accent: #c8923a; --accent-bright: #ecc878;
  --surface: #16110a; --surface-2: #1f1810;
}

/* topbar help (?) button */
.topbar .help { width:42px; height:42px; border-radius:50%; display:grid; place-items:center; background: rgba(201,162,75,.08); border:1px solid var(--line-strong); color: var(--accent-bright); cursor:pointer; font-family:'Playfair Display',serif; font-size:20px; line-height:1; }
.topbar .help:active { transform: scale(.94); }

/* rules sheet */
.rules-wrap { position: fixed; inset:0; z-index:60; display:flex; align-items:flex-end; justify-content:center; background: rgba(5,4,3,.72); backdrop-filter: blur(4px); animation: fadeIn .3s both; }
.rules-card {
  width:100%; max-width: 560px; max-height: 90vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border:1px solid var(--line-strong); border-bottom:0; border-radius: 22px 22px 0 0;
  padding: 20px 20px calc(env(safe-area-inset-bottom) + 22px);
  box-shadow: 0 -24px 70px rgba(0,0,0,.65); animation: sheetUp .4s var(--ease-out) both;
}
@keyframes sheetUp { from { transform: translateY(60px); opacity:.4; } to { transform:none; opacity:1; } }
.rules-card:before { content:""; display:block; width:38px; height:4px; border-radius:99px; background: var(--line-strong); margin: 0 auto 14px; }
.rules-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:2px; }
.rules-x { width:36px; height:36px; border-radius:50%; display:grid; place-items:center; border:1px solid var(--line); color: var(--text-dim); cursor:pointer; }
.rules-obj { background: rgba(201,162,75,.09); border:1px solid var(--line-strong); border-radius:12px; padding:13px 15px; font-size:14.5px; line-height:1.55; color: var(--text); margin: 6px 0 4px; }
.rules-obj b { color: var(--accent-bright); }
.rules-body { margin-top: 6px; }
.rules-sec { padding: 13px 0; border-bottom: 1px solid var(--line); }
.rules-sec:last-child { border-bottom: 0; }
.rules-h { font-family:'Playfair Display', serif; font-size: 17px; color: var(--accent-bright); margin-bottom: 5px; }
.rules-p { font-size: 14.5px; line-height: 1.6; color: var(--text-dim); }

/* utility for game modules */
.gridfill { display:grid; gap:10px; }
.kv { display:flex; justify-content:space-between; align-items:center; padding:10px 0; border-bottom:1px solid var(--line); }
.kv:last-child { border-bottom:0; }
.big-num { font-family:'Playfair Display',serif; font-size: 40px; }
.waiting { display:flex; align-items:center; gap:10px; color: var(--text-dim); font-size:14px; }
.pulse { width:8px;height:8px;border-radius:50%; background: var(--accent-bright); animation: pulse 1.1s var(--ease) infinite; }
@keyframes pulse { 0%,100%{opacity:.3; transform:scale(.8);} 50%{opacity:1; transform:scale(1.2);} }

@media (max-width: 360px) {
  .card { width: 50px; height: 74px; font-size: 26px; }
}
