:root {
      --board-w: 1280;
      --board-h: 720;
    }

    /* --- Page --- */
    body {
      margin: 0;
      background: #111;
      display: grid;
      place-items: center;
      min-height: 100vh;
      font-family: Arial, sans-serif;
    }

    /* --- Conteneur du plateau --- */
    .board {
      position: relative;
      width: min(96vw, calc((var(--board-w) / var(--board-h)) * 92vh));
      aspect-ratio: calc(var(--board-w) / var(--board-h));
      border-radius: 14px;
      overflow: hidden;
      box-shadow: 0 10px 35px rgba(0,0,0,.45);
      background: #222;
    }

    /* --- Image de fond --- */
    .bg {
      position: absolute;
      inset: 0;
      width: 100%;
      height: 100%;
      object-fit: cover;
      user-select: none;
      pointer-events: none;
    }

    /* --- Canvas transparent par-dessus --- */
    canvas {
      position: absolute;
      inset: 0;
      width: 100%;
      height: 100%;
      display: block;
      background: transparent;
      pointer-events: none;
    }

    /* --- Mini panneau info --- */
    .ui {
      position: fixed;
      left: 12px;
      bottom: 12px;
      background: rgba(0,0,0,.65);
      color: #fff;
      padding: 8px 10px;
      border-radius: 8px;
      font-size: 12px;
      line-height: 1.4;
    }

#dice,
#superDice {
  position: absolute;
  left: 49%;
  transform: translateX(-50%);
  font-size: 60px;
  cursor: pointer;
  z-index: 100;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: transform 0.12s ease;
}

#dice { top: 80px; }
#superDice { top: 150px; } /* 70px en dessous, ajustable */

#dice:active,
#superDice:active {
  transform: translateX(-50%) scale(0.92);
}

#dice:focus {
  outline: none;
}


/* ===== État désactivé du super dé ===== */
#superDice.is-disabled {
  opacity: 0.35;
  filter: grayscale(0.9) saturate(0.6);
  cursor: not-allowed;
  pointer-events: none;
  transform: translateX(-50%) scale(0.96);
}

/* Optionnel : petit cadenas visuel */
#superDice.is-disabled::after {
  content: "🔒";
  position: absolute;
  right: -10px;
  top: -8px;
  font-size: 18px;
}

.base {
  width: 12px;
  height: 12px;
  background: var(--player-color, black);
  border-radius: 50%;
  position: absolute;
  left: 0;
  top: 0;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.65);
}

.player {
  position: absolute;
  transform: translate(-50%, -50%);
  transition: left 0.35s ease, top 0.35s ease;
  /* pointer-events: none; */
}

.arm {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: left center;
  transform: rotate(var(--arm-angle, 0rad));
}

.line {
  position: absolute;
  left: 0;
  top: 50%;
  height: 3px;
  width: 80px; /* avant 40 */
  background: color-mix(in srgb, var(--player-color, black) 75%, black 25%);
  transform: translateY(-50%);
  border-radius: 999px;
}

.flag {
  position: absolute;
  top: 50%;
  left: var(--flag-offset, 80px); /* avant 40 */
  transform-origin: left center;
  transform: translateY(-50%) rotate(calc(-1 * var(--arm-angle, 0rad)));
  cursor: grab;
}

.flag:active {
  cursor: grabbing;
}

/* zone animée */
.flag-inner {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 12px; /* avant 2 6 */
  background: var(--player-color, #FFC0CB);
  color: white;
  border-radius: 8px;
  animation: wave 2.5s ease-in-out infinite;
  box-shadow: 0 4px 12px rgba(0,0,0,0.22);
}

.flag-label {
  font-size: 16px; /* avant 12 */
  font-weight: 700;
  letter-spacing: 0.2px;
}

/* animation façon "flag qui ondule" */
@property --wave-tilt {
  syntax: "<angle>";
  inherits: true;
  initial-value: 0deg;
}

.flag-inner {
  --wave-tilt: 0deg;
  transform: rotate(var(--wave-tilt));
}

.flag-label {
  display: inline-block;
  transform: rotate(calc(-1 * var(--wave-tilt)));
}

@keyframes wave {
  0%   { --wave-tilt: 0deg; }
  25%  { --wave-tilt: 2deg; }
  50%  { --wave-tilt: 0deg; }
  75%  { --wave-tilt: -2deg; }
  100% { --wave-tilt: 0deg; }
}

* {
  -webkit-tap-highlight-color: transparent;
}

 * {
  -webkit-tap-highlight-color: transparent;
} 

.legend-panel {
  position: absolute;
  bottom: 14px;
  right: 14px;
  max-width: min(420px, 88%);
  padding: 14px 18px;
  border-radius: 16px;
  background: rgba(10, 15, 28, 0.62);
  color: #f7f7f8;
  font-size: 13px;
  line-height: 1.45;
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(7px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: auto;
}

.legend-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.legend-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.legend-subtitle {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.6;
}

.legend-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  opacity: 0.9;
}

.legend-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  color: #111;
  background: rgba(255, 255, 255, 0.75);
}

/* Couleurs de pastille */
.legend-item[data-type="musique"]     .legend-dot { background: rgba(255, 221, 100, 0.85); }
.legend-item[data-type="litterature"] .legend-dot { background: rgba(170, 214, 255, 0.85); }
.legend-item[data-type="histoire"]    .legend-dot { background: rgba(196, 233, 186, 0.85); }
.legend-item[data-type="peinture"]    .legend-dot { background: rgba(252, 190, 190, 0.85); }

.legend-item[data-type="replay"] .legend-dot {
  background: rgba(255, 215, 0, 0.9);
  color: #332200;
}
.legend-item[data-type="minus4"] .legend-dot,
.legend-item[data-type="minus3"] .legend-dot {
  background: rgba(0, 0, 0, 0.85);
  color: #fefefe;
}
.legend-item[data-type="final"] .legend-dot {
  background: linear-gradient(135deg, rgba(255, 120, 120, 0.9), rgba(255, 225, 162, 0.9));
  color: #2c1300;
}

.legend-count {
  font-weight: 600;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.90);
}

.legend-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

.legend-button {
  all: unset;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease;
}

.legend-button:hover {
  background: rgba(255, 255, 255, 0.22);
}

.legend-button:active {
  transform: translateY(1px);
}

.legend-button-icon {
  font-size: 14px;
}

/* --- START PAD --- */
.start-pad {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,.55), rgba(255,255,255,.12) 45%, rgba(0,0,0,.15) 100%);
  border: 2px solid rgba(255,255,255,.65);
  box-shadow:
    0 10px 24px rgba(0,0,0,.35),
    inset 0 2px 10px rgba(255,255,255,.25);
  backdrop-filter: blur(6px);
  /*z-index: 10;*/
  
  display: grid;
  place-items: center;
  color: #fff;
  /*color:#800080;*/
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  font-size: 10px;
  pointer-events: none;
}

.start-pad::before {
  content: "Départ";
  opacity: .9;
}

/* option : anneau externe */
.start-pad::after {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 1px dashed rgba(255,255,255,.45);
  opacity: .8;
}

#player1 {
  --arm-angle: -1.5708rad; /* -90° = vertical */
}

#player2 .flag-inner {
  
  background: #2563eb; /* bleu */
}

#player2 {
  --arm-angle: -1.5708rad; /* -90° = vertical */
  
}

/* Empêche toute sélection/halo parasite sur le pion/drapeau */
.player,
.player * {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.flag,
.flag-inner,
.flag-label {
  -webkit-tap-highlight-color: transparent;
}

/* Si un focus natif apparaît */
.flag:focus,
.flag-inner:focus,
.flag-label:focus {
  outline: none !important;
}


.qmodal.hidden { display: none; }

.qmodal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background: rgba(8, 12, 24, 0.55);
  backdrop-filter: blur(3px);
}

.qmodal-card {
  /*
  width: min(980px, 94vw);
  max-height: 90vh;
  */
  width: clamp(1100px, 94vw, 1400px);
  max-height: 98vh;
  
  overflow: auto;
  border-radius: 18px;
  padding: 18px;
  color: #f4f7ff;
  box-shadow: 0 24px 60px rgba(0,0,0,.45);
  position: relative;
}

@media (max-width: 900px){
  .qmodal-card{
    width: 96vw;
    max-height: 94vh;
    padding: 14px;
  }
}

.qmodal-card.glass {
  background: linear-gradient(160deg, rgba(20,30,54,.55), rgba(18,22,38,.45));
  border: 1px solid rgba(255,255,255,.28);
  backdrop-filter: blur(10px);
}

.qmodal-card.glass::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(130deg, rgba(255,255,255,.55), rgba(255,215,120,.45), rgba(255,255,255,.25));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.qmodal-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}





.qbadge {
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.28);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  text-transform: capitalize;
}

.qprompt {
  margin: 10px 0 14px;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.35;
}


.qgrid {
  display: grid;
  grid-template-columns: 0.75fr 1.5fr 0.75fr; /* centre ~50% */
  gap: 16px;
  align-items: stretch;
}

.qcol {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 12px;
  padding: 12px;
}

.qcol-title {
  margin: 0 0 10px;
  font-size: 14px;
  opacity: .95;
}

.qblock { display: flex; flex-direction: column; gap: 8px; }

#qDirectInput {
  border: 1px solid rgba(255,255,255,.25);
  background: rgba(0,0,0,.25);
  color: #fff;
  border-radius: 8px;
  padding: 10px;
}

.qbtn {
  border: 1px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.12);
  color: #fff;
  border-radius: 10px;
  padding: 9px 12px;
  cursor: pointer;
}

.qbtn-primary {
  background: linear-gradient(135deg, #ffd76a, #ffbe55);
  color: #2d1e00;
  border: none;
  font-weight: 700;
}

.qmedia-wrap {
  min-height: 180px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(0,0,0,.2);
  border: 1px dashed rgba(255,255,255,.25);
  padding: 8px;
}

.qcol-center .qmedia-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
}

.qmedia-wrap img, .qmedia-wrap audio {
  max-width: 100%;
  border-radius: 8px;
}

.qchoices { display: grid; gap: 8px; margin-top: 8px; }
.qchoice {
  border: 1px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.08);
  color: #fff;
  border-radius: 8px;
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
}
.qchoice.selected {
  outline: 2px solid #ffd45e;
  background: rgba(255,212,94,.2);
}

.qfeedback {
  min-height: 26px;
  margin-top: 12px;
  font-weight: 700;
}

@media (max-width: 900px) {
  .qgrid { grid-template-columns: 1fr; }
}

/* --- Parchemin texte dans la zone centrale --- */
.q-parchment {
  width: 100%;
  max-width: 640px;
  color: #3b2b1a;
  background:
    radial-gradient(circle at 20% 10%, rgba(255,255,255,.45), transparent 40%),
    radial-gradient(circle at 80% 90%, rgba(120,85,45,.08), transparent 35%),
    linear-gradient(180deg, #f4e7c8 0%, #ead8b0 100%);
  border: 1px solid rgba(110, 78, 38, 0.35);
  border-radius: 10px;
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.25),
    inset 0 10px 18px rgba(255,255,255,.12),
    0 8px 18px rgba(0,0,0,.18);
  padding: 14px 16px;
  position: relative;
}

.q-parchment::before,
.q-parchment::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(92,64,32,.35), transparent);
}
.q-parchment::before { top: 34px; }
.q-parchment::after  { bottom: 10px; }

.q-parchment-title {
  font-family: "Segoe Script", "Lucida Handwriting", cursive;
  font-size: 20px;
  line-height: 1.1;
  margin: 0 0 10px;
  color: #5a3b1d;
  text-align: center;
  letter-spacing: .3px;
}

.q-parchment-body {
  font-family: "Georgia", "Times New Roman", serif;
  font-size: 18px;
  line-height: 1.55;
  margin: 0;
  color: #2f2418;
  text-wrap: pretty;
}

/* petit label discret */
.q-parchment-chip {
  display: inline-block;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #6a4b2a;
  background: rgba(255,255,255,.35);
  border: 1px solid rgba(106,75,42,.25);
  border-radius: 999px;
  padding: 3px 8px;
  margin-bottom: 8px;
}

.mode-btn{
  position:absolute;
  top:18px;
  right:18px;
  z-index:120;
  border:1px solid rgba(255,255,255,.35);
  background:rgba(20,30,50,.55);
  color:#fff;
  padding:8px 12px;
  border-radius:10px;
  font-weight:700;
  cursor:pointer;
  backdrop-filter: blur(6px);
}
.mode-btn.is-locked{
  opacity:.45;
  cursor:not-allowed;
  filter:grayscale(.4);
}

.dice-range-info{
  position:absolute;
  top:240px;              /* ajuste selon ton layout */
  left:49%;
  transform:translateX(-50%);
  z-index:110;
  padding:6px 10px;
  border-radius:999px;
  font-size:12px;
  font-weight:700;
  color:#fff;
  background:rgba(15,22,38,.55);
  border:1px solid rgba(255,255,255,.25);
  backdrop-filter: blur(5px);
  letter-spacing:.02em;
}

.amodal.hidden { display: none; }
.amodal{
  position: fixed; inset: 0; z-index: 10000;
  display: grid; place-items: center;
  background: rgba(8,12,24,.55);
  backdrop-filter: blur(3px);
}
.amodal-card{
  width: min(760px, 92vw);
  max-height: 86vh; overflow: auto;
  border-radius: 16px;
  padding: 18px;
  color: #f4f7ff;
  background: linear-gradient(160deg, rgba(20,30,54,.55), rgba(18,22,38,.45));
  border: 1px solid rgba(255,255,255,.28);
  box-shadow: 0 24px 60px rgba(0,0,0,.45);
}
.aresult{ font-size: 20px; font-weight: 800; margin: 8px 0 10px; }
.acorrect{ font-weight: 700; color: #ffe08a; }
.aexplanation{ line-height: 1.5; opacity: .95; }
.aactions{ display: flex; justify-content: flex-end; margin-top: 14px; }

.player { z-index: 20; }

.player.is-active {
  z-index: 40;
}

.player.is-active .base {
  box-shadow: 0 0 0 6px rgba(255,255,255,.22), 0 0 18px rgba(255,230,120,.9);
  animation: activePulse 1.2s ease-in-out infinite;
}

.player.is-active .flag-inner {
  box-shadow: 0 0 0 2px rgba(255,255,255,.35), 0 0 16px rgba(255,220,120,.75);
  animation: activeGlow 1.2s ease-in-out infinite;
}

@keyframes activePulse {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}

@keyframes activeGlow {
  0%,100% { filter: brightness(1); }
  50% { filter: brightness(1.18); }
}

.summit-progress-wrap{
  margin: 8px 0 14px;
}

.summit-progress-text{
  font-weight: 700;
  margin-bottom: 6px;
  color: #f6f1d3;
  text-shadow: 0 1px 2px rgba(0,0,0,.35);
}

.summit-progress-track{
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.2);
  border: 1px solid rgba(255,255,255,.35);
  overflow: hidden;
}

.summit-progress-fill{
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffd54a, #ffb300);
  box-shadow: 0 0 10px rgba(255, 196, 0, .45);
  transition: width .35s ease;
}

.summit-hud{
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 12000;
  min-width: 240px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(20,24,36,.55);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,.28);
  color: #fff;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.summit-hud-title{ font-weight: 800; font-size: 14px; }
.summit-hud-theme{ opacity: .9; margin-top: 2px; font-size: 13px; }
.summit-hud-text{ margin: 6px 0 6px; font-weight: 700; }
.hidden{ display:none !important; } /* si pas déjà présent */

.start-grid{display:grid;grid-template-columns:1fr 1fr;gap:16px}
.color-row{display:flex;gap:8px;flex-wrap:wrap;margin-top:8px}
.color-dot{
  width:28px;height:28px;border-radius:50%;border:2px solid #fff4;cursor:pointer;
}
.color-dot.selected{outline:3px solid #fff;transform:scale(1.08)}

.welcome-card{
  max-width: 760px;
  text-align: center;
  animation: popIn .35s ease;
}

.welcome-title{
  margin: 0 0 6px;
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1.1;
  color: #ffe7a3;
  text-shadow: 0 2px 10px rgba(0,0,0,.35);
}

.welcome-sub{
  margin: 0 0 14px;
  font-weight: 700;
  font-size: clamp(16px, 2vw, 24px);
  color: #f4f7ff;
}

.welcome-text{
  margin: 0 auto 18px;
  max-width: 62ch;
  font-size: clamp(15px, 1.4vw, 20px);
  color: #ffffff;
}

.welcome-actions{
  display: flex;
  justify-content: center;
}

@keyframes popIn{
  from{ transform: translateY(8px) scale(.98); opacity: 0; }
  to{ transform: translateY(0) scale(1); opacity: 1; }
}