/* game.css — socle commun des jeux intégrés (Bordeaux Games) */

:root {
  --bg: #1a1a2e;
  --panel: #16213e;
  --panel-2: #1e2b4d;
  --ink: #eee;
  --ink-dim: #a9b1c9;
  --accent: #FFB347;
  --rouge: #8B1A2B;
  --vert: #2D8B4E;
  --line: rgba(255, 255, 255, .1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* une règle `display` explicite bat le `[hidden]{display:none}` du navigateur —
   sans ceci, masquer .d-keep ou .g-bar via l'attribut hidden reste sans effet */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: .7rem .6rem 1rem;
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
}

.g-head {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: .45rem;
}
.g-head h1 { font-size: 1.15rem; letter-spacing: .01em; }
.g-head p { font-size: .82rem; color: var(--ink-dim); }

.g-status {
  min-height: 1.5em;
  font-size: .9rem;
  color: var(--accent);
  text-align: center;
  margin: .35rem 0 .45rem;
  font-weight: 700;
}
.g-status.win { color: var(--vert); }

.g-btn {
  font: inherit;
  font-weight: 700;
  padding: .5rem 1.05rem;
  background: var(--rouge);
  color: #fff;
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
  transition: filter .15s, transform .08s;
}
.g-btn:hover:not(:disabled) { filter: brightness(1.18); }
.g-btn:active:not(:disabled) { transform: translateY(1px); }
.g-btn:disabled { opacity: .4; cursor: not-allowed; }
.g-btn.ghost { background: transparent; border-color: var(--line); color: var(--ink-dim); }
.g-btn.ghost:hover:not(:disabled) { color: var(--ink); border-color: var(--accent); }

.g-bar { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: center; margin-top: .55rem; }

/* --- plateau de dés --- */
.d3d-stage {
  width: 100%;
  max-width: 560px;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% 0%, #223059 0%, var(--panel) 62%, #101a33 100%);
  border: 1px solid var(--line);
  position: relative;
}
.d3d-stage canvas { display: block; width: 100%; height: 100%; }

/* couche « appuyer pour jouer » : three.js n'est chargé qu'après ce clic */
.d3d-boot {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  background: rgba(16, 26, 51, .82);
  cursor: pointer;
  text-align: center;
  padding: 1rem;
}
.d3d-boot span { font-size: .82rem; color: var(--ink-dim); max-width: 30ch; }
.d3d-boot.is-hidden { display: none; }

/* repli sans WebGL */
.d3d-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .7rem;
  flex-wrap: wrap;
  height: 100%;
}
.d3d-die2d {
  position: relative;
  width: 54px;
  height: 54px;
  background: #f6f1e4;
  border-radius: 10px;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .16);
}
.d3d-die2d.is-held { outline: 3px solid var(--accent); }
.d3d-die2d i {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--rouge);
  transform: translate(-50%, -50%);
}

/* --- rangée de dés cliquables (garder / relancer) --- */
.d-keep { display: flex; gap: .45rem; justify-content: center; flex-wrap: wrap; margin-top: .5rem; }
.d-keep button {
  font: inherit;
  font-weight: 800;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border: 2px solid transparent;
  background: var(--panel-2);
  color: var(--ink);
  cursor: pointer;
  font-size: 1.05rem;
}
.d-keep button[aria-pressed="true"] {
  border-color: var(--accent);
  background: #2a2038;
  color: var(--accent);
}

/* --- tableaux (scores) --- */
.g-table { width: 100%; max-width: 560px; border-collapse: collapse; font-size: .84rem; margin-top: .6rem; }
.g-table th, .g-table td { padding: .28rem .45rem; border-bottom: 1px solid var(--line); text-align: left; }
.g-table th { color: var(--ink-dim); font-weight: 700; }
.g-table td.num, .g-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.g-table tr.tot td { font-weight: 800; color: var(--accent); border-bottom: none; }
.g-table button.pick {
  font: inherit;
  border: none;
  background: var(--vert);
  color: #fff;
  border-radius: 5px;
  padding: .1rem .5rem;
  cursor: pointer;
  font-weight: 700;
}
.g-table button.pick:disabled { background: #2b3350; color: var(--ink-dim); cursor: not-allowed; }

.g-log {
  max-width: 560px;
  width: 100%;
  font-size: .78rem;
  color: var(--ink-dim);
  margin-top: .5rem;
  max-height: 4.6em;
  overflow-y: auto;
  line-height: 1.5;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
