/* Direction artistique : une géode fendue au fond d'une galerie de mine.
   Extérieur = roche brute (basalte, terre), intérieur = cristaux (améthyste, quartz, citrine),
   éclairage = lampe de mineur chaude. */
:root {
  --bg: #0d0a08;
  --bg2: #15110d;
  --surface: #1b1612;
  --surface-solid: #1d1814;
  --surface-2: #2a221c;
  --border: rgba(255, 214, 170, 0.10);
  --border-strong: rgba(255, 214, 170, 0.22);
  --text: #f3ebe1;
  --muted: #b3a593;
  --faint: #7d6f60;
  --accent: #ffbf3c;   /* citrine / lampe */
  --accent-2: #9d6bff; /* améthyste */
  --cyan: #7fe3ff;     /* quartz */
  --danger: #ff5a4f;
  --ok: #63d69a;
  --radius: 8px;
  --display: 'Alfa Slab One', 'Rockwell', Georgia, serif;
  --ui: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 .88 0 0 0 0 .75 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --chip: polygon(12px 0, calc(100% - 18px) 0, 100% 9px, 100% calc(100% - 14px), calc(100% - 9px) 100%, 16px 100%, 0 calc(100% - 11px), 0 13px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  font-synthesis: none;
}
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

/* ---------- fond ---------- */
.bg {
  position: fixed; inset: 0; z-index: -1; overflow: hidden;
  background: var(--noise), linear-gradient(180deg, #14100c 0%, #0d0a08 55%, #0a0806 100%);
}
/* halo de la lampe de mineur + lueur d'améthyste au fond de la galerie */
.bg-glow { position: absolute; border-radius: 50%; filter: blur(80px); pointer-events: none; }
.bg-glow.a { width: 70vmax; height: 50vmax; top: -22vmax; left: -18vmax; background: radial-gradient(closest-side, rgba(255, 168, 60, .28), transparent); animation: lamp 7s ease-in-out infinite; }
.bg-glow.b { width: 60vmax; height: 50vmax; bottom: -26vmax; right: -16vmax; background: radial-gradient(closest-side, rgba(140, 90, 255, .22), transparent); }
@keyframes lamp { 0%, 100% { opacity: .9; } 45% { opacity: 1; } 50% { opacity: .82; } 55% { opacity: .97; } }
/* strates de roche en bas de l'écran */
.strata { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 34vh; min-height: 200px; opacity: .55; }
/* poussière / éclats de cristal qui scintillent */
.sparkle { position: absolute; width: 3px; height: 3px; border-radius: 50%; background: #ffe7b8; box-shadow: 0 0 6px 1px rgba(255, 210, 140, .8); opacity: 0; animation: twinkle 5s ease-in-out infinite; }
.sparkle.v { background: #e2d2ff; box-shadow: 0 0 6px 1px rgba(170, 130, 255, .9); }
.sparkle.q { background: #d6f6ff; box-shadow: 0 0 6px 1px rgba(127, 227, 255, .9); }
@keyframes twinkle { 0%, 100% { opacity: 0; transform: scale(.6); } 50% { opacity: .9; transform: scale(1.2); } }

/* ---------- barre du haut ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; padding: 12px clamp(16px, 4vw, 36px);
  position: sticky; top: 0; z-index: 20;
  background: var(--noise), linear-gradient(180deg, #1c1611, #120e0b);
  border-bottom: 1px solid rgba(255, 190, 120, .14);
  box-shadow: 0 1px 0 #000, 0 10px 30px -18px #000;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--display); font-weight: 400; letter-spacing: 0.14em; font-size: 20px; color: #f6e7d2; text-shadow: 0 2px 0 #000; }
.brand-mark { width: 30px; height: 30px; filter: drop-shadow(0 0 10px rgba(157, 107, 255, .65)); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.net { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); box-shadow: 0 0 0 3px rgba(255,255,255,.04); }
.net.on { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.net.off { background: var(--danger); box-shadow: 0 0 10px var(--danger); }

main { max-width: 1280px; margin: 0 auto; padding: clamp(16px, 3vw, 32px) clamp(16px, 4vw, 36px) 80px; }

/* ---------- boutons ---------- */
/* bouton « pierre » : bloc de roche biseauté */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: 7px; border: 1px solid rgba(255, 214, 170, .18);
  background: var(--noise), linear-gradient(180deg, #3b3029, #29211b);
  box-shadow: inset 0 1px 0 rgba(255, 235, 210, .13), inset 0 -3px 0 rgba(0, 0, 0, .38), 0 2px 0 #000;
  cursor: pointer; font-weight: 600; letter-spacing: .01em; color: #f3e6d6;
  transition: transform .12s ease, filter .2s, border-color .2s, box-shadow .2s, opacity .2s;
  white-space: nowrap; text-decoration: none; position: relative;
}
.btn:hover:not(:disabled) { border-color: rgba(255, 214, 170, .4); transform: translateY(-1px); filter: brightness(1.08); }
.btn:active:not(:disabled) { transform: translateY(1px); box-shadow: inset 0 1px 0 rgba(255, 235, 210, .08), inset 0 -1px 0 rgba(0, 0, 0, .38); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
/* boutons « cristal » : citrine (action principale) et améthyste */
.btn.primary {
  background: linear-gradient(155deg, #fff0b8 0%, #ffcf5a 22%, #f4a321 48%, #c9740c 72%, #ffd36a 100%);
  color: #2b1600; border-color: rgba(255, 236, 180, .7); text-shadow: 0 1px 0 rgba(255, 255, 255, .35);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7), inset 0 -3px 0 rgba(110, 50, 0, .35), 0 0 0 1px #000, 0 8px 28px -8px rgba(255, 170, 40, .75);
}
.btn.violet {
  background: linear-gradient(155deg, #efe4ff 0%, #b892ff 22%, #8150f0 50%, #4b2499 76%, #c3a2ff 100%);
  color: #fff; border-color: rgba(225, 205, 255, .6); text-shadow: 0 1px 1px rgba(40, 0, 90, .6);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .55), inset 0 -3px 0 rgba(30, 0, 70, .4), 0 0 0 1px #000, 0 8px 28px -8px rgba(140, 90, 255, .75);
}
.btn.primary::after, .btn.violet::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(115deg, transparent 0 38%, rgba(255, 255, 255, .28) 38% 46%, transparent 46% 100%);
}
.btn.danger { background: transparent; box-shadow: none; color: #ff8a80; border-color: rgba(255, 90, 79, .45); }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.small { padding: 7px 13px; font-size: 13.5px; border-radius: 6px; }
.btn.big { padding: 16px 26px; font-size: 16.5px; border-radius: 8px; }
.btn.ok { background: rgba(61, 220, 151, .15); border-color: rgba(61, 220, 151, .5); color: #7ff2bf; }
.btn .k { font-size: 11px; opacity: .6; border: 1px solid currentColor; border-radius: 5px; padding: 0 5px; }

input.field {
  width: 100%; padding: 13px 15px; border-radius: 6px; border: 1px solid rgba(255, 214, 170, .16);
  background: #0c0907; box-shadow: inset 0 2px 6px rgba(0, 0, 0, .7); outline: none; transition: border-color .2s, box-shadow .2s;
}
input.field:focus { border-color: var(--accent); box-shadow: inset 0 2px 6px rgba(0, 0, 0, .7), 0 0 0 3px rgba(255, 191, 60, .2); }
input.code-input { font-family: var(--display); letter-spacing: .35em; text-transform: uppercase; text-align: center; font-size: 20px; font-weight: 400; color: var(--accent); }

/* dalle de pierre aux coins ébréchés */
.card {
  background: var(--noise), linear-gradient(180deg, #231c17 0%, #1a1511 60%, #16120e 100%);
  border: 1px solid var(--border); border-radius: 4px; padding: 22px;
  box-shadow: inset 0 1px 0 rgba(255, 228, 196, .07), inset 0 -2px 0 rgba(0, 0, 0, .35);
  clip-path: var(--chip);
}
.label { font-size: 12px; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); font-weight: 600; margin-bottom: 8px; display: block; }
.muted { color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
h1, h2, h3 { font-family: var(--display); margin: 0; letter-spacing: .02em; font-weight: 400; color: #f6e7d2; }
h2 { font-size: 20px; }
h3 { font-size: 15px; }

/* ---------- accueil ---------- */
.hero { display: grid; grid-template-columns: 1.05fr 1fr; gap: clamp(24px, 4vw, 56px); align-items: center; padding: clamp(10px, 4vw, 40px) 0 30px; }
.hero h1 { font-size: clamp(44px, 7.4vw, 96px); line-height: .98; letter-spacing: .01em; color: #e9d9c3; text-shadow: 0 3px 0 #000, 0 0 40px rgba(255, 170, 70, .12); }
/* texte « cristal » : facettes d'améthyste, de quartz et de citrine */
.hero h1 .shine {
  background: linear-gradient(100deg, #c9a6ff 0%, #8a5cf0 18%, #e6dbff 30%, #7fe3ff 46%, #d9f7ff 54%, #ffcf5a 70%, #b98aff 86%, #c9a6ff 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent; background-size: 220% 100%; text-shadow: none;
  filter: drop-shadow(0 3px 0 #000) drop-shadow(0 0 18px rgba(157, 107, 255, .35)); animation: shine 10s linear infinite;
}
@keyframes shine { to { background-position: -220% 0; } }
.hero p.lead { font-size: clamp(16px, 1.6vw, 19px); color: #cdbfae; max-width: 520px; margin: 18px 0 26px; }
.hero-art { position: relative; aspect-ratio: 12 / 10; }
.hero-art svg { width: 100%; height: 100%; overflow: visible; }
.hero-art svg.geode { position: absolute; inset: -6% -5%; width: 110%; height: 112%; z-index: 0; filter: drop-shadow(0 20px 40px rgba(0, 0, 0, .7)); }
.hero-art svg.board { position: relative; z-index: 1; transform: scale(.8); filter: drop-shadow(0 10px 24px rgba(0, 0, 0, .9)); }
.pill-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.pill { font-size: 12.5px; padding: 5px 11px; border-radius: 4px; border: 1px solid rgba(255, 214, 170, .2); color: #e4d4bf; background: linear-gradient(180deg, #2c241e, #211a15); box-shadow: inset 0 1px 0 rgba(255, 235, 210, .08); }

.home-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-top: 10px; }

.scoreboard { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.scoreboard li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px; background: rgba(255,255,255,.03); border: 1px solid transparent; font-size: 14px; transition: opacity .2s; }
.scoreboard li.you { border-color: var(--border-strong); }
.scoreboard li.turn { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(244, 192, 44, .12); }
.scoreboard li.out { opacity: .45; }
.scoreboard li.winner { border-color: var(--accent); background: linear-gradient(135deg, rgba(244,192,44,.2), rgba(244,192,44,.04)); }
.scoreboard .av { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #120c20; flex-shrink: 0; }
.scoreboard .sb-name { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scoreboard .sb-stat { font-size: 13px; color: var(--muted); white-space: nowrap; }
.scoreboard .sb-stat b { color: var(--text); font-family: var(--display); }
.rules-list { margin: 10px 0 0; padding-left: 18px; color: #d5cfe8; font-size: 14px; display: flex; flex-direction: column; gap: 6px; }
.home-actions .card { display: flex; flex-direction: column; gap: 12px; }
.home-actions .card p { margin: 0; color: var(--muted); font-size: 14px; flex: 1; }
/* pastille hexagonale façon cristal taillé */
.card-icon {
  width: 46px; height: 50px; display: grid; place-items: center; font-size: 20px;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  background: linear-gradient(150deg, #d9c6ff 0%, #9d6bff 40%, #4b2499 100%);
}
.home-actions .card:nth-child(2) .card-icon { background: linear-gradient(150deg, #e9fbff 0%, #7fe3ff 40%, #1f7f9c 100%); }
.home-actions .card:nth-child(3) .card-icon { background: linear-gradient(150deg, #fff0b8 0%, #ffbf3c 40%, #a35f06 100%); }
.home-actions .card:nth-child(4) .card-icon { background: linear-gradient(150deg, #ffd0c9 0%, #e8344a 45%, #7a1220 100%); }
.name-row { max-width: 420px; margin-bottom: 18px; }

.howto { margin-top: 44px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.howto .step { padding: 18px; border-radius: 4px; border: 1px solid rgba(255, 214, 170, .1); background: linear-gradient(180deg, rgba(255, 220, 180, .035), transparent); position: relative; }
.howto .step::before { content: ''; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; background: linear-gradient(180deg, var(--accent), #8a4b06); border-radius: 2px; }
.howto .num { font-family: var(--display); font-size: 12px; color: var(--accent); letter-spacing: .14em; }
.howto .num::before { content: 'NIVEAU '; }
.howto h3 { margin: 6px 0; }
.howto p { margin: 0; font-size: 13.5px; color: var(--muted); }

/* ---------- salle ---------- */
.room-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.code-badge { display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px; border-radius: 6px; background: var(--noise), linear-gradient(180deg, #2a221c, #1b1612); border: 1px solid var(--border-strong); box-shadow: inset 0 1px 0 rgba(255, 235, 210, .08); }
.code-badge .code { font-family: var(--display); font-size: 22px; letter-spacing: .28em; color: var(--accent); text-shadow: 0 0 14px rgba(255, 191, 60, .35); }
.players { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.player-chip { display: flex; align-items: center; gap: 9px; padding: 7px 14px 7px 8px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-weight: 600; font-size: 14px; }
.player-chip .av { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #120c20; }
.player-chip .st { font-weight: 500; font-size: 12.5px; color: var(--muted); }
.player-chip .st.ok { color: var(--ok); }
.player-chip.turn { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(244, 192, 44, .15); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--faint); }
.dot.on { background: var(--ok); }
.vs { font-family: var(--display); color: var(--faint); font-size: 13px; }

.setup-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr); gap: 22px; align-items: start; }
.play-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr); gap: 22px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; }

.board-card { padding: 16px; }
.board-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.board-wrap { position: relative; }
svg.board { width: 100%; height: auto; display: block; touch-action: none; user-select: none; -webkit-user-select: none; }
svg.board.small { touch-action: auto; }
.board .cell-bg { fill: #120f1d; }
.board .gridline { stroke: rgba(190, 175, 255, .12); stroke-width: .025; }
.board .gridline-top { stroke: rgba(0, 0, 0, .28); stroke-width: .03; pointer-events: none; }
.board .frame { fill: none; stroke: rgba(190, 175, 255, .45); stroke-width: .05; }
.board .lbl circle { fill: #1c1730; stroke: rgba(190, 175, 255, .3); stroke-width: .04; transition: fill .2s, stroke .2s; }
.board .lbl text { font-family: var(--ui); font-weight: 700; font-size: .36px; fill: #cfc8ea; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.board .lbl.click { cursor: pointer; }
.board .lbl.click:hover circle { stroke: var(--accent); stroke-width: .07; fill: #2a2245; }
.board .lbl.armed circle { stroke: var(--accent); stroke-width: .09; animation: pulse 1s ease-in-out infinite; }
.board .lbl.res text { fill: #120c1a; }
.board .lbl.res.dark text { fill: #fff; }
.board .lbl.hl circle { stroke: #fff; stroke-width: .1; }
.board .lbl .num, .board .lbl.res .num, .board .lbl.res.dark .num { font-size: .22px; fill: #fff; font-weight: 700; }
.board .lbl .numbg { fill: #0b0912; stroke: rgba(255,255,255,.4); stroke-width: .02; }
@keyframes pulse { 50% { stroke-opacity: .3; } }
.board .gem { cursor: grab; transition: opacity .2s; }
.board .gem.ro { cursor: default; }
.board .gem.guess polygon.body { stroke-dasharray: .12 .08; }
.board .gem.bad polygon.body { stroke: var(--danger) !important; stroke-width: .09 !important; stroke-dasharray: .15 .1; }
.board .ghost { pointer-events: none; opacity: .7; }
.board .ghost.invalid polygon.body { stroke: var(--danger); stroke-width: .08; }
.board .mark { font-size: .55px; text-anchor: middle; dominant-baseline: central; fill: rgba(255,255,255,.55); pointer-events: none; font-weight: 700; }
.board .probe-cell { stroke-width: .05; fill-opacity: .25; pointer-events: none; }
.board .wave { fill: none; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.board .wave.anim { animation: draw var(--dur, 1s) linear var(--delay, 0s) both; }
@keyframes draw { from { stroke-dashoffset: var(--len); } to { stroke-dashoffset: 0; } }
.board .burst { pointer-events: none; animation: burst .7s ease-out var(--delay, 0s) both; transform-box: fill-box; transform-origin: center; }
@keyframes burst { from { opacity: 1; transform: scale(.2); } to { opacity: 0; transform: scale(2.4); } }
.board .cellhit { fill: transparent; }
.board.tool-mark .cellhit, .board.tool-probe .cellhit { cursor: crosshair; }
.board.tool-mark .cellhit:hover, .board.tool-probe .cellhit:hover { fill: rgba(255,255,255,.06); }

.tray { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; min-height: 64px; }
.tray-item { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 10px 6px; border-radius: 12px; border: 1px solid var(--border); background: rgba(255,255,255,.03); cursor: grab; touch-action: none; user-select: none; transition: border-color .2s, background .2s; }
.tray-item:hover { border-color: var(--border-strong); background: rgba(255,255,255,.06); }
.tray-item svg { width: 58px; height: 38px; overflow: visible; }
.tray-item span { font-size: 11.5px; color: var(--muted); }
.tray-empty { color: var(--faint); font-size: 13px; align-self: center; }
.hint { font-size: 12.5px; color: var(--faint); margin-top: 10px; }
.hint b { color: var(--muted); font-weight: 600; }

.errors { margin: 10px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.errors li { font-size: 13px; color: #ff9aac; padding-left: 18px; position: relative; }
.errors li::before { content: '!'; position: absolute; left: 0; top: 1px; width: 13px; height: 13px; border-radius: 50%; background: var(--danger); color: #fff; font-size: 9.5px; font-weight: 800; display: grid; place-items: center; }
.valid-ok { color: var(--ok); font-size: 13.5px; font-weight: 600; margin-top: 10px; }

.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; max-height: 380px; overflow: auto; padding-right: 4px; }
.preset { border: 1px solid var(--border); border-radius: 12px; padding: 8px; background: rgba(255,255,255,.02); cursor: pointer; text-align: left; transition: border-color .2s, transform .12s; }
.preset:hover { border-color: var(--accent-2); transform: translateY(-1px); }
.preset svg { width: 100%; height: auto; display: block; border-radius: 6px; }
.preset .pn { font-size: 12.5px; font-weight: 600; margin-top: 6px; display: block; }
.preset .pl { font-size: 11px; color: var(--muted); }
.lvl-Facile { color: var(--ok) !important; } .lvl-Moyen { color: var(--accent) !important; } .lvl-Difficile { color: #ff7a9a !important; }

.opt { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.opt:last-child { border-bottom: 0; }
.opt small { display: block; color: var(--muted); font-size: 12.5px; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 10px; overflow: hidden; flex-shrink: 0; }
.seg button { border: 0; background: transparent; padding: 7px 12px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--accent-2); color: #fff; }
.seg button:disabled { cursor: default; }

.waiting { text-align: center; padding: 26px 10px; }
.waiting .big-code { font-family: var(--display); font-weight: 800; font-size: clamp(36px, 7vw, 58px); letter-spacing: .25em; color: var(--accent); text-shadow: 0 0 30px rgba(244,192,44,.35); margin: 8px 0 14px; padding-left: .25em; }
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.2); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; display: inline-block; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }

.banner { padding: 14px 18px; border-radius: 14px; border: 1px solid var(--border-strong); background: var(--surface); display: flex; align-items: center; gap: 12px; }
.banner.mine { border-color: rgba(244, 192, 44, .6); background: linear-gradient(135deg, rgba(244,192,44,.16), rgba(244,192,44,.04)); }
.banner.final { border-color: rgba(255, 84, 112, .6); background: linear-gradient(135deg, rgba(255,84,112,.18), rgba(255,84,112,.04)); }
.banner .b-title { font-family: var(--display); font-weight: 700; font-size: 15.5px; }
.banner .b-sub { font-size: 13px; color: var(--muted); }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.fire-bar { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: rgba(244,192,44,.08); border: 1px solid rgba(244,192,44,.35); }

.journal { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 340px; overflow: auto; }
.journal li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: rgba(255,255,255,.03); border: 1px solid transparent; font-size: 14px; cursor: default; }
.journal li:hover { border-color: var(--border-strong); }
.journal li.new { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: rgba(244,192,44,.25); } }
.journal .n { font-family: var(--display); font-size: 11px; color: var(--faint); width: 22px; }
.journal .route { font-weight: 700; min-width: 70px; }
.journal .route .arrow { color: var(--faint); margin: 0 4px; }
.swatch { width: 16px; height: 16px; border-radius: 5px; border: 1px solid rgba(255,255,255,.3); flex-shrink: 0; }
.swatch.none { background: transparent; border-style: dashed; border-color: rgba(255,255,255,.45); }
.blocks { display: inline-flex; gap: 3px; flex-shrink: 0; }
.mix-table { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; font-size: 13.5px; }
.mix-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mix-name { min-width: 92px; color: #e4def5; }
.mix-eq { color: var(--faint); }
details .mix-table { grid-template-columns: 1fr; }
@media (max-width: 560px) { .mix-table { grid-template-columns: 1fr; } }
.journal .cname { color: #d7d0ee; }
.journal-empty { color: var(--faint); font-size: 13.5px; padding: 8px 0; }

.legend { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px 14px; font-size: 13px; }
.legend div { display: flex; align-items: center; gap: 8px; }
.legend small { color: var(--faint); }

.emotes { display: flex; gap: 6px; flex-wrap: wrap; }
.emotes button { background: rgba(255,255,255,.04); border: 1px solid var(--border); border-radius: 10px; padding: 5px 9px; cursor: pointer; font-size: 17px; transition: transform .12s; }
.emotes button:hover { transform: scale(1.12); }
.emote-float { position: fixed; z-index: 60; font-size: 54px; pointer-events: none; animation: floatup 1.8s ease-out forwards; font-family: var(--display); font-weight: 800; color: var(--accent); }
@keyframes floatup { from { opacity: 0; transform: translateY(20px) scale(.6); } 15% { opacity: 1; transform: translateY(0) scale(1.1); } to { opacity: 0; transform: translateY(-120px) scale(1); } }

.stats { display: flex; gap: 10px; }
.stat { flex: 1; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.03); border: 1px solid var(--border); }
.stat b { font-family: var(--display); font-size: 20px; display: block; }
.stat span { font-size: 12px; color: var(--muted); }

/* ---------- toasts / modale ---------- */
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(92vw, 460px); pointer-events: none; }
.toast { pointer-events: auto; padding: 12px 18px; border-radius: 12px; background: #231d38; border: 1px solid var(--border-strong); box-shadow: 0 10px 40px -10px #000; font-weight: 500; animation: tin .25s ease-out; text-align: center; }
.toast.err { border-color: rgba(255,84,112,.6); background: #2c1424; }
.toast.good { border-color: rgba(61,220,151,.6); background: #12291f; }
@keyframes tin { from { opacity: 0; transform: translateY(10px); } }

.modal { position: fixed; inset: 0; z-index: 80; background: rgba(5, 3, 10, .72); backdrop-filter: blur(6px); display: grid; place-items: center; padding: 16px; animation: fadein .2s; }
@keyframes fadein { from { opacity: 0; } }
.modal-box { width: min(760px, 100%); max-height: 90vh; overflow: auto; background: var(--surface-solid); border: 1px solid var(--border-strong); border-radius: 20px; padding: clamp(18px, 3vw, 30px); box-shadow: 0 30px 90px -20px #000; }
.modal-box.wide { width: min(1100px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.close { background: transparent; border: 0; font-size: 26px; cursor: pointer; color: var(--muted); line-height: 1; }
.rules h3 { margin: 18px 0 6px; color: var(--accent); font-size: 14px; }
.rules p, .rules li { color: #d5cfe8; font-size: 14.5px; }
.rules ul { padding-left: 20px; margin: 6px 0; }
.rules .gems { display: flex; gap: 14px; flex-wrap: wrap; }
.rules .gems div { display: flex; flex-direction: column; align-items: center; font-size: 12px; color: var(--muted); gap: 4px; }
.rules .gems svg { width: 70px; height: 46px; overflow: visible; }

.result-title { font-family: var(--display); font-size: clamp(30px, 5vw, 48px); font-weight: 800; text-align: center; margin: 4px 0 4px; }
.result-title.win { background: linear-gradient(100deg, #ffd34d, #ff9a3d); -webkit-background-clip: text; background-clip: text; color: transparent; }
.result-title.lose { color: #ff8da0; }
.result-title.draw { color: var(--cyan); }
.result-sub { text-align: center; color: var(--muted); margin-bottom: 18px; }
.reveal { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.reveal h3 { margin-bottom: 6px; font-size: 13.5px; }

.confetti { position: fixed; top: -10px; width: 9px; height: 14px; z-index: 90; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); } }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .home-actions { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; }
  .hero-art { max-width: 520px; width: 100%; margin: 0 auto; order: -1; aspect-ratio: 12 / 9; }
  .home-actions { grid-template-columns: 1fr; }
  .howto { grid-template-columns: 1fr 1fr; }
  .setup-grid, .play-grid { grid-template-columns: 1fr; }
  .reveal { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .howto { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .board-card { padding: 10px; }
  .code-badge .code { font-size: 18px; }
  .btn.big { padding: 14px 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}

/* =====================================================================
   Habillage « mine / géode » des composants de jeu
   ===================================================================== */
/* plateau : sol de caverne, cadre de roche, repères en pierre */
.board .frame { stroke: #5a4636; stroke-width: .12; }
.board .frame-outer { fill: none; stroke: #000; stroke-width: .3; opacity: .55; }
.board .frame-light { fill: none; stroke: rgba(255, 210, 160, .22); stroke-width: .03; }
.board .gridline { stroke: rgba(255, 228, 196, .09); stroke-width: .025; }
.board .gridline-top { stroke: rgba(0, 0, 0, .3); }
.board .lbl circle { fill: #2a221c; stroke: rgba(255, 214, 170, .28); stroke-width: .04; }
.board .lbl text { fill: #e6d6c1; }
.board .lbl.click:hover circle { stroke: var(--accent); fill: #3a2e24; }
.board .lbl .numbg { fill: #120e0b; stroke: rgba(255, 214, 170, .45); }
.board .mark { fill: rgba(255, 230, 200, .6); }

/* panneaux de jeu */
.player-chip, .scoreboard li, .journal li, .stat, .tray-item, .preset, .banner {
  border-radius: 5px;
  background: linear-gradient(180deg, rgba(255, 225, 190, .05), rgba(255, 225, 190, .015));
  border: 1px solid rgba(255, 214, 170, .09);
}
.player-chip { border-radius: 999px; background: var(--noise), linear-gradient(180deg, #2a221c, #1d1814); }
.player-chip.turn, .scoreboard li.turn { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 191, 60, .14), 0 0 22px -6px rgba(255, 191, 60, .6); }
.scoreboard li.winner { background: linear-gradient(135deg, rgba(255, 191, 60, .22), rgba(255, 191, 60, .04)); border-color: var(--accent); }
.tray-item:hover, .preset:hover { border-color: rgba(255, 191, 60, .45); background: linear-gradient(180deg, rgba(255, 191, 60, .1), rgba(255, 191, 60, .02)); }
.preset svg { border-radius: 3px; box-shadow: 0 0 0 1px #000, 0 4px 12px -4px #000; }
.stat b { color: var(--accent); text-shadow: 0 0 12px rgba(255, 191, 60, .3); font-weight: 400; }
.banner { padding: 14px 18px; }
.banner.mine { border-color: rgba(255, 191, 60, .55); background: radial-gradient(120% 140% at 0% 0%, rgba(255, 180, 60, .22), rgba(255, 180, 60, .03) 70%); }
.banner.final { border-color: rgba(255, 90, 79, .6); background: radial-gradient(120% 140% at 0% 0%, rgba(255, 90, 79, .22), rgba(255, 90, 79, .03) 70%); }
.banner .b-title { font-weight: 400; letter-spacing: .02em; }
.journal .n { font-family: var(--display); font-weight: 400; }
.seg { border-radius: 6px; border-color: rgba(255, 214, 170, .2); background: #0f0c09; box-shadow: inset 0 2px 5px rgba(0, 0, 0, .6); }
.seg button.on { background: linear-gradient(155deg, #c3a2ff, #8150f0 55%, #4b2499); color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45); }
.waiting .big-code { font-weight: 400; color: var(--accent); text-shadow: 0 3px 0 #000, 0 0 34px rgba(255, 191, 60, .45); }
.label { color: #c4a87e; letter-spacing: .18em; }
.howto h3, .home-actions h2 { color: #f6e7d2; }

/* fenêtres et notifications */
.modal { background: radial-gradient(ellipse at 50% 30%, rgba(30, 22, 16, .7), rgba(5, 3, 2, .9)); }
.modal-box {
  border-radius: 6px; border: 1px solid rgba(255, 214, 170, .2);
  background: var(--noise), linear-gradient(180deg, #241d18, #17120e);
  box-shadow: inset 0 1px 0 rgba(255, 228, 196, .08), 0 40px 100px -20px #000;
}
.toast { border-radius: 6px; background: var(--noise), linear-gradient(180deg, #2c241e, #1f1914); border-color: rgba(255, 214, 170, .22); }
.toast.err { background: linear-gradient(180deg, #3a1714, #26100e); border-color: rgba(255, 90, 79, .6); }
.toast.good { background: linear-gradient(180deg, #16301f, #0f2016); border-color: rgba(99, 214, 154, .6); }
.result-title { font-weight: 400; text-shadow: 0 3px 0 #000; }
.result-title.win { background: linear-gradient(100deg, #fff0b8, #ffbf3c 40%, #f08a1c 70%, #ffd36a); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 3px 0 #000); text-shadow: none; }
.result-title.draw { color: var(--cyan); }
.confetti { clip-path: polygon(50% 0, 100% 40%, 75% 100%, 25% 100%, 0 40%); border-radius: 0 !important; }
.emote-float { font-family: var(--display); color: var(--accent); text-shadow: 0 3px 0 #000; }
.net.on { background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.glint { opacity: 0; transform-box: fill-box; transform-origin: center; animation: glint 4.5s ease-in-out infinite; }
@keyframes glint { 0%, 70%, 100% { opacity: 0; transform: scale(.4) rotate(0deg); } 80% { opacity: 1; transform: scale(1) rotate(20deg); } }
.btn.primary, .btn.violet { font-weight: 700; }
.board .gridline { stroke: rgba(255, 228, 196, .16); stroke-width: .03; }

/* minerais : éclat qui scintille sur les pierres, grille plus discrète par-dessus */
.board .gem-glint { transform-box: fill-box; transform-origin: center; animation: gemglint 6s ease-in-out infinite; }
.board .pieces .gem:nth-child(2n) .gem-glint { animation-delay: 1.7s; }
.board .pieces .gem:nth-child(3n) .gem-glint { animation-delay: 3.4s; }
@keyframes gemglint { 0%, 100% { opacity: .15; transform: scale(.5); } 50% { opacity: .95; transform: scale(1) rotate(25deg); } }
.board .gridline-top { stroke: rgba(0, 0, 0, .16); }
/* petits blocs de couleur = éclats de pierre taillée (octogone + facettes) */
.blocks .swatch {
  width: 17px; height: 17px; border: 0; border-radius: 0;
  clip-path: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%);
  background-image: linear-gradient(135deg, rgba(255, 255, 255, .6) 0 22%, rgba(255, 255, 255, .12) 22% 48%, rgba(0, 0, 0, .12) 48% 72%, rgba(0, 0, 0, .42) 72%);
}
.blocks .swatch.none { clip-path: none; border: 1px dashed rgba(255, 255, 255, .45); border-radius: 4px; background-image: none; }
/* éclats de minerai brut (remplace les pierres taillées) */
.blocks .swatch {
  width: 18px; height: 17px;
  clip-path: polygon(18% 4%, 60% 0, 95% 20%, 100% 62%, 80% 97%, 32% 100%, 3% 78%, 0 32%);
  background-image:
    radial-gradient(circle at 70% 72%, rgba(20, 12, 8, .55) 0 9%, transparent 10%),
    radial-gradient(circle at 28% 62%, rgba(20, 12, 8, .45) 0 7%, transparent 8%),
    radial-gradient(circle at 62% 30%, rgba(255, 255, 255, .9) 0 5%, transparent 6%),
    linear-gradient(120deg, rgba(255, 255, 255, .5) 0 18%, rgba(255, 255, 255, .1) 18% 40%, rgba(0, 0, 0, .1) 40% 58%, rgba(255, 255, 255, .22) 58% 66%, rgba(0, 0, 0, .4) 66%);
}
