/* Ludo Royale — client web (DA « Bleu Royal »). Vanilla, mobile-first, mono-thème arcade. */
:root {
  --royal-deep: #0b1039; --royal: #1b2a8a; --royal-lite: #3a55d8;
  --gold: #ffcc4d; --gold-deep: #e0a41f;
  --red: #ff5a5f; --green: #34c777; --yellow: #ffc531; --blue: #3d8bff;
  --red-d: #c9333c; --green-d: #1c8f52; --yellow-d: #cf9414; --blue-d: #2360c8;
  --ink: #eaeeff; --panel: rgba(255,255,255,.10); --panel-line: rgba(255,255,255,.16);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  background: radial-gradient(120% 90% at 50% -10%, #33409e 0%, var(--royal) 34%, var(--royal-deep) 78%) fixed;
}
.bokeh { position: fixed; inset: 0; z-index: 0; pointer-events: none; }

.app { position: relative; z-index: 1; max-width: 640px; margin: 0 auto; padding: 1rem; min-height: 100%; display: flex; flex-direction: column; }

/* --- Logo 3D couronné --- */
.logo { text-align: center; margin: .4rem 0 1.2rem; }
.crown { display: block; font-size: clamp(1.5rem, 5vw, 2.2rem); line-height: 1;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,.4)); animation: bob 3.4s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-7px) rotate(3deg); } }
.logo h1 {
  margin: .1rem 0 0; font-weight: 900; letter-spacing: -1px;
  font-size: clamp(2rem, 8.5vw, 3.4rem); line-height: .95;
  background: linear-gradient(180deg, #fff6da 0%, var(--gold) 46%, var(--gold-deep) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 1px 0 #b9860f, 0 2px 0 #a8790d, 0 3px 0 #977011, 0 4px 0 #866312,
    0 6px 1px rgba(0,0,0,.28), 0 10px 22px rgba(0,0,0,.45);
}
.logo p { margin: .5rem 0 0; opacity: .78; font-size: .9rem; }

.screen { display: none; }
.screen.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card {
  background: linear-gradient(180deg, rgba(255,255,255,.12), rgba(255,255,255,.04));
  border: 1px solid var(--panel-line); border-radius: 24px; padding: 1.3rem;
  box-shadow: 0 22px 50px rgba(4,8,40,.5), inset 0 1px 0 rgba(255,255,255,.22);
  backdrop-filter: blur(6px);
}
label { font-weight: 700; display: block; margin: 0 0 .35rem; opacity: .92; }
input[type=text] {
  width: 100%; font: inherit; font-weight: 600; padding: .7rem .9rem;
  border: 2px solid rgba(255,255,255,.18); border-radius: 14px;
  background: rgba(10,14,50,.5); color: #fff;
}
input[type=text]::placeholder { color: rgba(255,255,255,.45); }
input[type=text]:focus { outline: none; border-color: var(--gold); }

.modes { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; margin: 1rem 0; }
.mode-btn {
  font: inherit; font-weight: 800; cursor: pointer; border: 0; color: #fff;
  border-radius: 18px; padding: .85rem .6rem; position: relative; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; gap: .15rem;
  box-shadow: 0 6px 0 rgba(0,0,0,.28); transition: transform .1s, box-shadow .1s;
}
.mode-btn .em { font-size: 1.5rem; }
.mode-btn small { opacity: .85; font-weight: 500; }
.mode-btn.blitz   { background: linear-gradient(160deg, #ff7a5f, var(--red)); }
.mode-btn.classic { background: linear-gradient(160deg, #ffd76a, var(--yellow-d)); }
.mode-btn.teams   { background: linear-gradient(160deg, #4fe0a0, var(--green-d)); }
.mode-btn.pure    { background: linear-gradient(160deg, #b98cff, #7a45d6); }
.mode-btn.solo    { background: linear-gradient(160deg, #5fa0ff, var(--blue-d)); }
.mode-btn.sel { outline: 3px solid var(--gold); outline-offset: 2px; }
.mode-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,.28); }

.btn {
  font: inherit; font-weight: 900; letter-spacing: .4px; cursor: pointer; border: 0;
  border-radius: 16px; padding: .9rem 1.2rem; width: 100%; color: #2a2000;
  background: linear-gradient(180deg, #ffe38a, var(--gold)); box-shadow: 0 7px 0 var(--gold-deep);
  transition: transform .06s, box-shadow .06s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 3px 0 var(--gold-deep); }
.btn.alt { color: #fff; background: linear-gradient(180deg, #6fa0ff, var(--blue)); box-shadow: 0 7px 0 var(--blue-d); }
.btn.alt:active { box-shadow: 0 3px 0 var(--blue-d); }
.btn.ghost { color: #fff; background: rgba(255,255,255,.12); box-shadow: 0 6px 0 rgba(0,0,0,.28); }
.btn.ghost:active { box-shadow: 0 2px 0 rgba(0,0,0,.28); }
.btn:disabled { opacity: .5; cursor: default; box-shadow: none; transform: none; }

.waiting { text-align: center; padding: 1.5rem 0; }
.spinner {
  width: 46px; height: 46px; margin: 0 auto 1rem; border-radius: 50%;
  border: 6px solid rgba(255,255,255,.18); border-top-color: var(--gold); animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Écran de jeu --- */
.players { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: center; margin-bottom: .7rem; }
.chip {
  display: flex; align-items: center; gap: .4rem; background: rgba(255,255,255,.12); border-radius: 999px;
  padding: .3rem .7rem; font-weight: 600; font-size: .85rem; border: 2px solid transparent;
  box-shadow: 0 3px 10px rgba(4,8,40,.3);
}
.chip.turn { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(255,204,77,.35), 0 3px 10px rgba(4,8,40,.3); }
.chip .dot { width: 14px; height: 14px; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(0,0,0,.15); }
.chip.off { opacity: .5; }
.chip .bot { font-size: .7rem; background: var(--gold); color: #2a2000; border-radius: 6px; padding: 0 .3rem; font-weight: 800; }

.board-wrap { position: relative; }
.board-frame {
  border-radius: 24px; padding: 12px;
  background: linear-gradient(145deg, #243088, #141c5c);
  box-shadow: 0 26px 60px rgba(3,6,32,.6), inset 0 2px 0 rgba(255,255,255,.18), inset 0 -4px 12px rgba(0,0,0,.4);
  border: 2px solid rgba(255,204,77,.35);
}
#board { width: 100%; height: auto; display: block; border-radius: 15px; touch-action: manipulation; }

.hud { display: flex; align-items: center; gap: .9rem; margin-top: .9rem; min-height: 60px; }

/* --- Dé 3D (cube CSS) --- */
/* drop-shadow porté par .die-scene (PAS .die-cube) : un filter sur un élément
   preserve-3d aplatirait le cube et casserait le rendu 3D. */
.die-scene { width: 60px; height: 60px; flex: 0 0 auto; perspective: 360px; filter: drop-shadow(0 8px 10px rgba(0,0,0,.4)); }
.die-tilt { width: 100%; height: 100%; transform-style: preserve-3d; transform: rotateX(-18deg) rotateY(24deg); }
.die-cube { position: relative; width: 60px; height: 60px; transform-style: preserve-3d;
  transform: rotateX(0deg) rotateY(0deg); }
.die-face {
  position: absolute; width: 60px; height: 60px; border-radius: 14px;
  background: linear-gradient(145deg, #ffffff, #e7ecff);
  box-shadow: inset 0 0 0 1px rgba(26,33,80,.08), inset -6px -6px 10px rgba(26,33,80,.14), inset 5px 5px 8px rgba(255,255,255,.95);
  display: grid; grid-template: repeat(3,1fr)/repeat(3,1fr); padding: 10px; gap: 2px; backface-visibility: hidden;
}
.die-face b { align-self: center; justify-self: center; width: 10px; height: 10px; border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #4a58b8, #141c5c); box-shadow: 0 1px 1px rgba(0,0,0,.3); }
.die-face.f1 { transform: rotateY(0deg) translateZ(30px); }
.die-face.f6 { transform: rotateY(180deg) translateZ(30px); }
.die-face.f2 { transform: rotateY(90deg) translateZ(30px); }
.die-face.f5 { transform: rotateY(-90deg) translateZ(30px); }
.die-face.f3 { transform: rotateX(90deg) translateZ(30px); }
.die-face.f4 { transform: rotateX(-90deg) translateZ(30px); }

.hud-msg { flex: 1; font-weight: 700; }
.hud-msg small { display: block; font-weight: 500; opacity: .65; }
.hud-msg b { color: var(--gold); }

.timer { height: 8px; border-radius: 999px; background: rgba(255,255,255,.14); overflow: hidden; margin-top: .7rem; }
.timer > span { display: block; height: 100%; width: 100%; background: var(--green);
  transform-origin: left; transition: background-color .3s; }

/* --- Bouton son --- */
.mute {
  position: fixed; top: .8rem; right: .8rem; z-index: 40; width: 40px; height: 40px;
  border: 0; border-radius: 50%; background: rgba(255,255,255,.14); color: #fff;
  box-shadow: 0 4px 14px rgba(4,8,40,.35); font-size: 1.1rem; cursor: pointer; line-height: 1; transition: transform .1s;
  backdrop-filter: blur(4px);
}
.mute:active { transform: scale(.9); }

/* --- Confettis --- */
.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 35; }

.toast {
  position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%);
  background: #0b1039; color: #fff; padding: .6rem 1rem; border-radius: 12px; border: 1px solid var(--panel-line);
  font-size: .9rem; opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 20;
}
.toast.show { opacity: .96; }

/* --- Overlays (fin de partie, explication du 6) --- */
.overlay {
  position: fixed; inset: 0; background: rgba(6,10,40,.62); display: none;
  align-items: center; justify-content: center; padding: 1rem; z-index: 30; backdrop-filter: blur(3px);
}
.overlay.show { display: flex; animation: fade .2s ease; }
.six-list { list-style: none; padding: 0; margin: .4rem 0; display: grid; gap: .5rem; }
.six-list li { background: rgba(255,255,255,.08); border: 1px solid var(--panel-line);
  border-radius: 12px; padding: .55rem .8rem; }
.six-list b { color: var(--gold); }
.results { list-style: none; padding: 0; margin: .8rem 0; }
.results li { display: flex; align-items: center; gap: .5rem; padding: .5rem .2rem; border-bottom: 1px solid rgba(255,255,255,.12); }
.results .rank { font-weight: 800; width: 1.7rem; }
.results .elo { margin-left: auto; font-variant-numeric: tabular-nums; opacity: .85; }
.results .up { color: var(--green); }
.results .down { color: var(--red); }
.verify-link { display: inline-block; margin-top: .3rem; color: var(--gold); font-weight: 700; text-decoration: none; }
.foot { text-align: center; opacity: .6; font-size: .8rem; margin-top: auto; padding-top: 1rem; }
.foot a { color: var(--gold); }

@media (prefers-reduced-motion: reduce) { .crown { animation: none; } .die-cube { transition: none; } }
