/* vdl- : dice launcher modal. Prefix isolated. */
.vdl-overlay {
  position: fixed;
  inset: 0;
  background: transparent;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 12px;
  box-sizing: border-box;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.vdl-overlay[hidden] { display: none; }

.vdl-dialog {
  background: #fbfaf7;
  color: #26232e;
  border-radius: 14px;
  box-shadow: 0 18px 48px rgba(20, 15, 40, 0.35);
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px 18px 16px;
  box-sizing: border-box;
  outline: none;
  border: 1px solid #e2ddd3;
  position: fixed;
  pointer-events: auto;
  margin: auto;
  width: calc(100% - 24px);
}

.vdl-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.vdl-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  letter-spacing: 0.01em;
}
.vdl-close {
  border: 1px solid #d8d2c6;
  background: #fff;
  color: #26232e;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.vdl-close:hover { background: #f1ece1; }
.vdl-close:focus-visible { outline: 2px solid #4a5bd6; outline-offset: 2px; }

.vdl-section { margin-bottom: 14px; }
.vdl-section-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #5a5566;
  margin-bottom: 6px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.vdl-gauge-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.vdl-gauge-head .vdl-section-label { margin-bottom: 6px; }
.vdl-count {
  font-size: 12px;
  font-weight: 700;
  color: #5a5566;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f1ece1;
  border: 1px solid #e2ddd3;
  letter-spacing: 0.02em;
}
.vdl-count[data-full="1"] {
  background: #fdecea;
  color: #8a1f16;
  border-color: #f3c4bd;
}

/* Rail 3D */
.vdl-rail {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 4px;
  height: 100px;
  padding: 14px 6px 10px;
  box-sizing: border-box;
  border-radius: 12px;
  background: linear-gradient(180deg, #f4f0e8 0%, #ece5d8 40%, #ded4c0 100%);
  border: 1px solid #d8d2c6;
  perspective: 500px;
  overflow: visible;
}

.vdl-cell {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  position: relative;
}

.vdl-tick {
  position: relative;
  width: 100%;
  max-width: 44px;
  height: 44px;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.18);
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--nd-color) 30%, #ffffff) 0%,
      var(--nd-color) 55%,
      color-mix(in srgb, var(--nd-color) 70%, #000000) 100%);
  color: #ffffff;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  box-sizing: border-box;
  transform-style: preserve-3d;
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
  box-shadow:
    0 3px 0 color-mix(in srgb, var(--nd-color) 45%, #000000),
    0 6px 10px rgba(0,0,0,0.2),
    inset 0 1px 0 rgba(255,255,255,0.35),
    inset 0 -2px 0 rgba(0,0,0,0.25);
  text-shadow: 0 1px 0 rgba(0,0,0,0.35);
}
.vdl-tick[data-nd="10"] { color: #ffffff; }
.vdl-tick[data-nd="2"],
.vdl-tick[data-nd="3"],
.vdl-tick[data-nd="4"] { color: #ffffff; }

.vdl-tick .vdl-tick-face {
  display: block;
  line-height: 1;
}

.vdl-tick:hover:not(:disabled) {
  transform: translateY(-2px) rotateX(-6deg);
}
.vdl-tick:active:not(:disabled) {
  transform: translateY(1px) rotateX(2deg);
  box-shadow:
    0 1px 0 color-mix(in srgb, var(--nd-color) 45%, #000000),
    0 2px 4px rgba(0,0,0,0.2),
    inset 0 1px 0 rgba(255,255,255,0.3);
}
.vdl-tick:focus-visible {
  outline: 2px solid #4a5bd6;
  outline-offset: 2px;
}
.vdl-tick[aria-pressed="true"] {
  filter: saturate(1.1) brightness(0.95);
  box-shadow:
    0 1px 0 color-mix(in srgb, var(--nd-color) 40%, #000000),
    inset 0 2px 6px rgba(0,0,0,0.35),
    inset 0 -1px 0 rgba(255,255,255,0.15);
  transform: translateY(2px) rotateX(0deg);
}
.vdl-tick:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  filter: grayscale(0.35);
}
.vdl-tick[aria-pressed="true"]:disabled {
  opacity: 1;
  filter: saturate(1.1) brightness(0.95);
  cursor: pointer;
}

/* Marqueurs / jalons 3D */
.vdl-marks {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}

.vdl-mark {
  --nd-color: #4a5bd6;
  position: absolute;
  bottom: 66px;
  left: calc((var(--nd-position) - 1.5) / 9 * (100% - 12px) + 6px);
  width: 30px;
  height: 30px;
  margin-left: -15px;
  transform-style: preserve-3d;
  perspective: 400px;
  pointer-events: auto;
  padding:0;
  border:0;
  background:transparent;
  cursor:pointer;
  opacity: 0;
}
.vdl-mark.is-placed {
  opacity: 1;
  animation: vdl-drop 560ms cubic-bezier(.16,1,.3,1) forwards;
}
.vdl-mark.is-removing {
  animation: vdl-lift 380ms cubic-bezier(.4,0,.6,1) forwards;
}
.vdl-mark-body {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  color: #ffffff;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,0.25);
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--nd-color) 50%, #ffffff) 0%,
      var(--nd-color) 55%,
      color-mix(in srgb, var(--nd-color) 65%, #000000) 100%);
  box-shadow:
    0 4px 0 color-mix(in srgb, var(--nd-color) 40%, #000000),
    0 8px 12px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.4),
    inset 0 -2px 0 rgba(0,0,0,0.3);
  text-shadow: 0 1px 0 rgba(0,0,0,0.4);
  transform: rotateX(-14deg);
}

@keyframes vdl-drop {
  0%   { transform: translateY(-50px) rotateX(-45deg) scale(0.85); opacity: 0; }
  60%  { transform: translateY(4px)   rotateX(-14deg) scale(1.06); opacity: 1; }
  80%  { transform: translateY(-2px)  rotateX(-14deg) scale(1); }
  100% { transform: translateY(0)     rotateX(-14deg) scale(1); opacity: 1; }
}
@keyframes vdl-lift {
  0%   { transform: translateY(0)     rotateX(-14deg) scale(1);   opacity: 1; }
  60%  { transform: translateY(-22px) rotateX(-22deg) scale(1.05); opacity: 0.85; }
  100% { transform: translateY(-46px) rotateX(-30deg) scale(0.85); opacity: 0; }
}

/* Raison du jet */
.vdl-reason-wrap { margin-bottom: 14px; }
.vdl-reason {
  width: 100%;
  box-sizing: border-box;
  margin-top: 4px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid #d8d2c6;
  background: #ffffff;
  color: #26232e;
  font: inherit;
  font-size: 13px;
}
.vdl-reason:focus-visible {
  outline: 2px solid #4a5bd6;
  outline-offset: 2px;
}

/* Modes — toujours 5 en une rangée à partir de 320px */
.vdl-modes {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
}
.vdl-mode {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 52px;
  min-width: 0;
  padding: 6px 3px;
  border-radius: 10px;
  border: 1px solid #d8d2c6;
  background: #fff;
  color: #26232e;
  cursor: pointer;
  font: inherit;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.1;
  text-align: center;
  box-sizing: border-box;
  overflow: hidden;
}
.vdl-mode:hover:not(:disabled) { background: #f1ece1; }
.vdl-mode:focus-visible { outline: 2px solid #4a5bd6; outline-offset: 2px; }
.vdl-mode:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: #f4f0e8;
}
.vdl-mode .vdl-mode-label {
  display: block;
  word-break: break-word;
  hyphens: auto;
}
.vdl-mode .vdl-mode-dice {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  color: #4a5bd6;
}
.vdl-mode:disabled .vdl-mode-dice { color: #948ea0; }
.vdl-mode svg { display: block; }

.vdl-error {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fdecea;
  color: #8a1f16;
  border: 1px solid #f3c4bd;
  font-size: 13px;
  font-weight: 600;
}
.vdl-error[hidden] { display: none; }

/* Mobile : 320px / 390px sans scroll horizontal */
@media (max-width: 420px) {
  .vdl-dialog { padding: 14px 12px 12px; }
  .vdl-rail {
    height: 100px;
    padding: 12px 4px 8px;
    gap: 2px;
  }
  .vdl-tick {
    height: 44px;
    min-height: 44px;
    max-width: none;
    border-radius: 6px;
    font-size: 12px;
  }
  .vdl-mode {
    min-height: 52px;
    padding: 4px 2px;
    font-size: 9.5px;
    gap: 2px;
  }
  .vdl-mode .vdl-mode-dice svg { width: 10px; height: 10px; }
}

@media (max-width: 340px) {
  .vdl-mode { font-size: 9px; }
  .vdl-mode-label { letter-spacing: -0.01em; }
}

/* reduced motion : relief conservé, mouvements supprimés */
@media (prefers-reduced-motion: reduce) {
  .vdl-tick { transition: none; }
  .vdl-tick:hover:not(:disabled) { transform: none; }
  .vdl-tick:active:not(:disabled) { transform: none; }
  .vdl-mark.is-placed {
    animation: none;
    opacity: 1;
    transform: none;
  }
  .vdl-mark.is-removing {
    animation: none;
    opacity: 0;
  }
  .vdl-mark-body { transform: none; }
}

.vdl-dialog::backdrop { background: rgba(35,48,68,.35); }


/* Rail continu de difficulté : la couleur reste visible entre les jalons. */
.vdl-rail::before{content:"";position:absolute;left:6px;right:6px;top:17px;height:20px;border-radius:7px;background:linear-gradient(90deg,#299f59 0%,#e5d52f 25%,#ef9730 50%,#db3935 75%,#171719 100%);border:1px solid #0003;box-shadow:0 4px 0 #35352d,inset 0 2px 1px #ffffff75,0 7px 10px #0002;transform:rotateX(18deg);transform-origin:50% 100%}
.vdl-mark{bottom:53px}.vdl-mark-body{background-color:var(--nd-color)}
.vdl-mark[data-nd="2"] .vdl-mark-body,.vdl-mark[data-nd="3"] .vdl-mark-body,.vdl-mark[data-nd="4"] .vdl-mark-body,.vdl-mark[data-nd="5"] .vdl-mark-body,.vdl-mark[data-nd="6"] .vdl-mark-body,.vdl-mark[data-nd="7"] .vdl-mark-body{color:#1f261e;text-shadow:0 1px 0 #ffffff55}

/* Avantage : dés verts ; désavantage : dés rouges, avec la mention dessous. */
.vdl-mode.vdl-mode-good .vdl-mode-dice { color: #2f8f4a; }
.vdl-mode.vdl-mode-bad .vdl-mode-dice { color: #c0392b; }
.vdl-mode.vdl-mode-good { border-color: #a9d3b4; }
.vdl-mode.vdl-mode-bad { border-color: #e2b0aa; }
.vdl-mode .vdl-mode-hint { display: block; font-size: 10px; font-weight: 700; }
.vdl-mode.vdl-mode-good .vdl-mode-hint { color: #2f8f4a; }
.vdl-mode.vdl-mode-bad .vdl-mode-hint { color: #c0392b; }

/* Répartition des jets dans la fenêtre de jet (panneau partagé : jets-statistique.js). */
.vdl-stats-btn { margin-top: 12px; width: 100%; border: 1px solid #cfc8b9; border-radius: 10px; background: #fff; color: #26232e; }
.vdl-stats-panel.panel { margin: 10px 0 0; padding: 12px; box-shadow: none; }
.vdl-stats-panel h2 { font-size: 14px; }

/* Intégrée à la page Dés (ctx.host) : la fenêtre de jet prend la place de la colonne de gauche, sans fond ni croix. */
.vdl-overlay.vdl-inline { position: static; inset: auto; display: block; padding: 0; z-index: auto; pointer-events: auto; }
.vdl-inline .vdl-dialog { position: static; display: block; max-width: none; max-height: none; width: auto; margin: 0; box-shadow: none; overflow: visible; }
.vdl-inline .vdl-header { display: none; }
