/* =========================================================
   Kigoht's Casino — styles
   ========================================================= */
:root {
  --gold: #d4af37;
  --gold2: #f3d27a;
  --ink: #f5ecd7;
  --serif: 'Playfair Display', Georgia, serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; overflow: hidden; background: #0a0408; color: var(--ink); font-family: Inter, system-ui, sans-serif; }
body { font-variant-numeric: lining-nums; }   /* chiffres alignés partout, même en Playfair */
button { font: inherit; cursor: pointer; }

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
body.no3d #scene { display: none; }
body.no3d {
  background:
    radial-gradient(ellipse at 50% 20%, #6a1a2c 0%, transparent 60%),
    repeating-linear-gradient(90deg, #ffffff05 0 2px, transparent 2px 60px),
    #12040a;
}

/* Fondu au changement de page */
body.leaving::after { content: ''; position: fixed; inset: 0; z-index: 500; background: #0a0408; opacity: 0; animation: fadein .18s forwards; pointer-events: none; }
@keyframes fadein { to { opacity: 1; } }

/* ---------- Chargement ---------- */
#loader {
  position: fixed; inset: 0; z-index: 200; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  background: radial-gradient(ellipse at center, #2a0812, #0a0408 70%);
  transition: opacity .25s ease; font-family: var(--serif); font-size: 20px; color: var(--gold2); letter-spacing: 1px;
}
/* le jeton qui tourne n'apparaît que si le chargement dure vraiment */
#loader > * { opacity: 0; animation: loaderShow .3s ease .9s forwards; }
@keyframes loaderShow { to { opacity: 1; } }
#loader.done { opacity: 0; pointer-events: none; }
.loader-chip {
  width: 72px; height: 72px; border-radius: 50%;
  background: radial-gradient(circle, #b71c1c 0 50%, transparent 51%), repeating-conic-gradient(#b71c1c 0 22.5deg, #fff 22.5deg 45deg);
  box-shadow: 0 0 30px #d4af3766; animation: spin 1.4s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- HUD ---------- */
#hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 60; display: flex; align-items: center; gap: 12px;
  padding: 14px 22px; pointer-events: none; background: linear-gradient(#000000b0, transparent);
}
#hud > * { pointer-events: auto; }
.brand { font-family: var(--serif); font-size: 28px; font-weight: 800; color: var(--gold2); text-shadow: 0 0 18px #d4af3770; margin-right: auto; }
.brand span { color: #fff; }
.balance {
  display: flex; align-items: center; gap: 9px; padding: 8px 18px; border-radius: 999px;
  background: #000000a0; border: 1px solid #d4af3790; font-weight: 800; font-size: 18px; color: var(--gold2);
}
.balance.bump { animation: bump .45s; }
@keyframes bump { 50% { transform: scale(1.14); box-shadow: 0 0 22px #f3d27a88; } }
.coin { width: 20px; height: 20px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff6c8, #d4af37 45%, #8a6a12); box-shadow: 0 0 8px #d4af37aa; }
.icon-btn { width: 42px; height: 42px; border-radius: 50%; border: 1px solid #d4af3790; background: #000000a0; font-size: 18px; }
.refill { padding: 8px 16px; border-radius: 999px; border: none; background: linear-gradient(#f3d27a, #c8961f); color: #2b1700; font-weight: 800; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px #f3d27a33; } }

/* ---------- Lobby ---------- */
#lobby-ui {
  position: fixed; left: 0; right: 0; bottom: 26px; z-index: 10; display: flex; flex-direction: column; align-items: center; gap: 12px;
  transition: opacity .4s; pointer-events: none;
}
#lobby-ui > * { pointer-events: auto; }
body.in-game #lobby-ui, body.flying #lobby-ui { opacity: 0; }
body.in-game #lobby-ui > *, body.flying #lobby-ui > * { pointer-events: none; }
.hint { font-size: 13px; letter-spacing: 3px; text-transform: uppercase; color: #f5ecd7cc; text-shadow: 0 2px 6px #000; }
.game-buttons { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.game-btn {
  display: flex; align-items: center; gap: 10px; padding: 14px 34px; border-radius: 14px;
  font-family: var(--serif); font-size: 21px; font-weight: 800; color: var(--gold2);
  background: linear-gradient(#2a0a14e6, #12040ae6); border: 2px solid var(--gold);
  box-shadow: 0 10px 30px #000a, inset 0 0 20px #d4af3722; transition: transform .2s, background .2s, color .2s;
}
.game-btn:hover { transform: translateY(-3px); background: linear-gradient(#f3d27a, #c8961f); color: #2b1700; }
.gb-icon { font-size: 22px; }
/* Salon bleu (2e salle) */
.salon-btn { border-color: #5fb4ff; color: #9cd0ff; box-shadow: 0 10px 30px #000a, inset 0 0 20px #5fb4ff22; }
.salon-btn:hover { background: linear-gradient(#9cd0ff, #3a7fd6); color: #071a3a; }
.salon-back { display: none; }
body.in-salon .game-buttons, body.in-salon .hint { display: none; }
body.in-salon .salon-back { display: flex; }
body.no3d .salon-btn, body.no3d .salon-back { display: none; }
.disclaimer { font-size: 11px; color: #f5ecd780; text-shadow: 0 1px 3px #000; }
body.no3d #lobby-ui { top: 0; bottom: 0; justify-content: center; gap: 26px; }
body.no3d .hint { font-size: 0; }
body.no3d .hint::before { content: 'Choisis ta table'; font-family: var(--serif); font-size: 40px; letter-spacing: 1px; text-transform: none; color: var(--gold2); }
body.no3d .game-btn { flex-direction: column; font-size: 30px; padding: 46px 70px; }
body.no3d .gb-icon { font-size: 56px; }

#tooltip {
  position: fixed; z-index: 40; pointer-events: none; padding: 9px 14px; border-radius: 10px;
  background: #12060aee; border: 1px solid var(--gold); font-size: 13px; color: #f5ecd7cc;
  transform: translate(18px, 18px); opacity: 0; transition: opacity .15s; white-space: nowrap; box-shadow: 0 8px 24px #000a;
}
#tooltip.show { opacity: 1; }
#tooltip b { display: block; font-family: var(--serif); font-size: 18px; color: var(--gold2); }

#toast {
  position: fixed; left: 50%; top: 82px; z-index: 300; padding: 12px 22px; border-radius: 12px;
  background: #12060af2; border: 1px solid var(--gold); color: var(--ink); font-weight: 600;
  transform: translate(-50%, -16px); opacity: 0; transition: .25s; pointer-events: none; box-shadow: 0 10px 30px #000;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

#perf {
  position: fixed; left: 12px; bottom: 12px; z-index: 70; padding: 10px 14px; border-radius: 10px;
  background: #000000d0; border: 1px solid #d4af3780; font: 12px/1.6 ui-monospace, Consolas, monospace; color: #e8e8e8;
  white-space: pre; pointer-events: none;
}
#perf b { color: var(--gold2); }
#perf .bad { color: #ff8a8a; font-weight: 700; }

/* ---------- Fenêtres de jeu ---------- */
.game-overlay {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  padding: 76px 16px 16px; background: radial-gradient(ellipse at center, #0b0306c0, #050103f5);
  opacity: 0; transition: opacity .35s;
}
.game-overlay.show { opacity: 1; }
.game-panel {
  position: relative; width: min(1220px, 100%); max-height: 100%; overflow: auto;
  padding: 18px 24px; border-radius: 26px;
  background:
    radial-gradient(ellipse at 50% 35%, #1a8048 0%, #0d5530 55%, #062a18 100%);
  border: 12px solid #3b1d0c;
  box-shadow: inset 0 0 0 2px var(--gold), inset 0 0 80px #0008, 0 30px 90px #000;
  transform: scale(.95); transition: transform .35s;
}
.game-overlay.show .game-panel { transform: none; }
.game-header { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; }
.game-header h2 { font-family: var(--serif); font-size: 28px; color: var(--gold2); margin-right: auto; text-shadow: 0 2px 6px #0008; }

.btn {
  padding: 10px 18px; border-radius: 10px; border: 1px solid #d4af3799; background: #00000055; color: var(--ink); font-weight: 600;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover:not(:disabled) { background: #000000a0; border-color: var(--gold2); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .38; cursor: not-allowed; }
.btn.primary { background: linear-gradient(#f3d27a, #c8961f); color: #2b1700; border-color: #f3d27a; font-weight: 800; padding: 12px 28px; box-shadow: 0 4px 14px #0007; }
.btn.primary:hover:not(:disabled) { background: linear-gradient(#ffe39a, #d9a52a); }

.game-footer { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; margin-top: 14px; padding-top: 14px; border-top: 1px solid #d4af3740; }
.chipbar { display: flex; gap: 8px; flex-wrap: wrap; }
.bet-info { font-size: 15px; }
.bet-info b { color: var(--gold2); font-size: 21px; margin-left: 4px; }
.actions { display: flex; gap: 10px; margin-left: auto; flex-wrap: wrap; }

/* ---------- Jetons ---------- */
.chip {
  --c: #c62828; --s: #fff; --t: #fff;
  position: relative; width: 54px; height: 54px; border-radius: 50%; border: none; flex: 0 0 auto;
  background: radial-gradient(circle, var(--c) 0 54%, transparent 55%), repeating-conic-gradient(var(--c) 0 22.5deg, var(--s) 22.5deg 45deg);
  box-shadow: 0 3px 0 #0007, inset 0 0 0 2px #0003;
  color: var(--t); font-weight: 800; font-size: 13px; display: grid; place-items: center;
  transition: transform .15s, box-shadow .15s, opacity .15s;
}
.chip::after { content: ''; position: absolute; inset: 9px; border-radius: 50%; border: 2px dashed #ffffff90; pointer-events: none; }
button.chip:hover { transform: translateY(-3px); }
.chip.selected { transform: translateY(-7px); box-shadow: 0 0 0 3px var(--gold2), 0 10px 16px #000a; }
.chip.disabled { opacity: .32; }
.chip.sm { width: 32px; height: 32px; font-size: 10px; box-shadow: 0 2px 0 #0008, 0 4px 8px #0006; }
.chip.sm::after { inset: 5px; border-width: 1px; }

.msg { min-height: 28px; margin-top: 12px; text-align: center; font-weight: 700; font-size: 18px; color: var(--gold2); text-shadow: 0 2px 6px #0009; }
.msg.win { color: #a8ffb0; }
.msg.lose { color: #ffaaaa; }

/* ---------- Roulette ---------- */
.rl-main { display: flex; gap: 26px; align-items: center; }
.rl-wheel-wrap { position: relative; flex: 0 0 auto; width: min(360px, 100%); aspect-ratio: 1; }
#rl-wheel { width: 100%; height: 100%; display: block; filter: drop-shadow(0 18px 28px #000b); }
.rl-result {
  position: absolute; left: 50%; top: 50%; width: 86px; height: 86px; margin: -43px 0 0 -43px; border-radius: 50%;
  display: grid; place-items: center; font: 800 40px var(--serif); color: #fff;
  border: 3px solid var(--gold2); box-shadow: 0 0 30px #000, 0 0 0 6px #0005;
  transform: scale(0); transition: transform .45s cubic-bezier(.2, 1.6, .4, 1);
}
.rl-result.show { transform: scale(1); }
.rl-result.red, .rl-history .red { background: #c62828; }
.rl-result.black, .rl-history .black { background: #141414; }
.rl-result.green, .rl-history .green { background: #1b8a3a; }
.rl-board-wrap { flex: 1; min-width: 0; overflow-x: auto; padding: 12px; }
.rl-board {
  display: grid; min-width: 640px;
  grid-template-columns: 48px repeat(12, minmax(38px, 1fr)) 52px;
  grid-template-rows: repeat(3, 56px) 46px 46px;
  border: 2px solid #f3e7c0cc; border-radius: 6px;
}
.rl-cell {
  position: relative; display: grid; place-items: center; cursor: pointer; user-select: none;
  border: 1px solid #f3e7c088; font-weight: 800; font-size: 17px; color: #fff;
  transition: filter .15s, box-shadow .15s;
}
.rl-cell.num.red { background: #b71c1c; }
.rl-cell.num.black { background: #151515; }
.rl-cell.green { background: #1b8a3a; font-size: 22px; }
.rl-cell.outside { color: #f3e7c0; font-size: 14px; letter-spacing: .5px; text-transform: uppercase; }
.rl-cell::before { content: ''; position: absolute; inset: 0; background: #fff; opacity: 0; transition: opacity .15s; pointer-events: none; }
.rl-cell:hover:not(:has(.hs:hover))::before, .rl-cell.hl::before { opacity: .2; }
.rl-cell:hover:not(:has(.hs:hover)) { box-shadow: inset 0 0 0 2px #ffffffaa; }
.rl-cell.hl { box-shadow: inset 0 0 0 2px var(--gold2); }
.rl-cell.winner { animation: winpulse .55s 5 alternate; }
@keyframes winpulse { to { box-shadow: inset 0 0 0 5px #fff, inset 0 0 26px var(--gold2); } }
/* Zones cheval / carré */
.hs { position: absolute; z-index: 3; cursor: pointer; }
.hs::after { content: ''; position: absolute; inset: 0; z-index: -1; border-radius: 6px; background: var(--gold2); opacity: 0; transition: opacity .12s; box-shadow: 0 0 10px var(--gold2); }
.hs:hover::after { opacity: .85; }
.hs.split-v { top: 16%; bottom: 16%; right: -8px; width: 16px; }
.hs.split-v.left { right: auto; left: -8px; }
.hs.split-h { left: 16%; right: 16%; top: -8px; height: 16px; }
.hs.corner { top: -10px; right: -10px; width: 20px; height: 20px; z-index: 4; }
.hs.corner::after { border-radius: 50%; }
.chip.xs { width: 24px; height: 24px; font-size: 9px; box-shadow: 0 2px 0 #0008, 0 3px 6px #0008; }
.chip.xs::after { inset: 4px; border-width: 1px; }
.rl-cell .stack { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.rl-cell .stack .chip { animation: drop .2s ease-out; }
@keyframes drop { from { transform: translateY(-10px) scale(1.2); opacity: 0; } }
.diamond { display: inline-block; width: 30px; height: 20px; clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.diamond.red { background: #e53935; }
.diamond.black { background: #111; }
.rl-tip { font-size: 12px; opacity: .7; margin-top: 8px; }
.rl-history { display: flex; gap: 6px; align-items: center; }
.rl-history span { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; border: 1px solid #ffffff40; }
.rl-history span:first-child { width: 38px; height: 38px; font-size: 16px; border: 2px solid var(--gold2); }

/* ---------- Blackjack ---------- */
.bj-rules { font-size: 12px; opacity: .75; }
.bj-table { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; min-height: 470px; padding: 8px 0; }
.bj-shoe { position: absolute; right: 6px; top: 4px; font-size: 12px; opacity: .65; }
.bj-label { text-align: center; text-transform: uppercase; letter-spacing: 3px; font-size: 13px; font-weight: 600; opacity: .9; margin-bottom: 8px; }
.score { display: inline-block; min-width: 34px; padding: 2px 10px; border-radius: 999px; background: #000000b0; color: #fff; font-weight: 800; letter-spacing: 0; text-align: center; font-size: 14px; }
.bj-label .score { margin-left: 6px; }
.cards { display: flex; justify-content: center; min-height: 126px; perspective: 800px; }
.cards .card + .card { margin-left: -40px; }
.bj-center { text-align: center; }
.bj-felt-text { font-family: var(--serif); letter-spacing: 4px; text-transform: uppercase; font-size: 14px; color: #f3d27a90; margin-bottom: 6px; }
.bj-msg { min-height: 36px; font-family: var(--serif); font-size: 25px; font-weight: 800; color: var(--gold2); text-shadow: 0 2px 8px #000; }
.bj-msg.win { color: #a8ffb0; }
.bj-msg.lose { color: #ffaaaa; }
.bj-hands { display: flex; gap: 30px; justify-content: center; flex-wrap: wrap; min-height: 190px; }
.hand { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 16px; border: 2px solid transparent; transition: .25s; }
.hand.active { border-color: var(--gold2); background: #00000030; box-shadow: 0 0 24px #f3d27a40; }
.hand-info { display: flex; align-items: center; gap: 8px; }
.tag { padding: 3px 10px; border-radius: 6px; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; color: #fff; }
.tag.win, .tag.bj { background: #2e7d32; }
.tag.lose, .tag.bust { background: #9e1f1f; }
.tag.push { background: #555; }
.bet-spot {
  width: 130px; height: 130px; margin-top: 26px; border-radius: 50%; border: 3px solid #f3e7c0b0;
  display: grid; place-items: center; text-transform: uppercase; letter-spacing: 3px; font-size: 13px; color: #f3e7c0b0;
  box-shadow: inset 0 0 20px #0004;
}

.card {
  position: relative; flex: 0 0 auto; width: 86px; height: 122px; border-radius: 9px;
  background: linear-gradient(160deg, #ffffff, #efe9dc); color: #151515; box-shadow: 0 4px 12px #0008;
}
.card.red { color: #c62828; }
.card .corner { position: absolute; display: flex; flex-direction: column; align-items: center; line-height: 1; }
.card .corner b { font-size: 18px; font-weight: 800; }
.card .corner i { font-style: normal; font-size: 15px; }
.card .tl { top: 6px; left: 7px; }
.card .br { bottom: 6px; right: 7px; transform: rotate(180deg); }
.card .pip { position: absolute; inset: 0; display: grid; place-items: center; font-size: 46px; }
.card .pip.face { font-family: var(--serif); font-size: 40px; font-weight: 800; display: flex; align-items: center; justify-content: center; gap: 2px; }
.card .pip.face small { font-size: 26px; }
.card.back { background: repeating-linear-gradient(45deg, #8b1424 0 6px, #a51c30 6px 12px); border: 4px solid #fff; }
.card.back::after {
  content: 'K'; position: absolute; inset: 8px; border: 2px solid #f3d27a; border-radius: 5px;
  display: grid; place-items: center; color: #f3d27a; font: 800 30px var(--serif);
}
.card.deal { animation: deal .45s cubic-bezier(.2, .8, .3, 1) both; }
@keyframes deal { from { transform: translate(340px, -260px) rotate(-35deg); opacity: 0; } }
.card.flip { animation: flip .5s ease both; }
@keyframes flip { from { transform: rotateY(90deg); } }

@media (max-width: 920px) {
  .rl-main { flex-direction: column; }
  .rl-wheel-wrap { width: min(300px, 80vw); }
  .brand { font-size: 20px; }
  .game-panel { padding: 12px; border-width: 6px; }
  .actions { margin-left: 0; }
  .card { width: 66px; height: 94px; }
  .card .pip { font-size: 34px; }
  .cards .card + .card { margin-left: -30px; }
}

/* ---------- Compte joueur dans le HUD ---------- */
.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 14px; border-radius: 999px; background: #000000a0; border: 1px solid #d4af3760; }
.user-name { font-weight: 700; font-size: 14px; color: var(--ink); white-space: nowrap; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.btn.small { padding: 6px 12px; font-size: 13px; border-radius: 999px; text-decoration: none; display: inline-flex; align-items: center; }
@media (max-width: 760px) { .user-name { display: none; } }
