/* Page de tirage */

.fx {
  position: fixed;
  inset: 0;
  z-index: 6;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  /* Les livres latéraux sortent de l'écran : sans ça, les mobiles dézooment la page. */
  overflow-x: clip;
  min-height: 100vh;
  min-height: 100dvh;
}

.main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.topbar-actions {
  display: flex;
  gap: 10px;
}

.icon-btn .icon-off,
.icon-btn[aria-pressed='false'] .icon-on {
  display: none;
}

.icon-btn[aria-pressed='false'] .icon-off {
  display: block;
}

.backdrop .lamp {
  opacity: 0.85;
}

body.is-spinning .backdrop .lamp {
  opacity: 1;
}

body.is-revealed .backdrop .ambient {
  opacity: 0.3;
  transform: scale(1);
}

/* ---------- Introduction et catégories ---------- */

.intro {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 0 16px;
  text-align: center;
  transition: opacity 0.5s var(--ease-out);
}

body.is-spinning .intro {
  opacity: 0.35;
  pointer-events: none;
}

.eyebrow {
  margin: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(1.05rem, 1.2vw + 0.6rem, 1.4rem);
  color: rgb(var(--parchment-rgb) / 0.74);
  font-variation-settings: 'opsz' 36, 'SOFT' 100;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: min(1100px, 100%);
}

.tag-btn {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgb(var(--ink-2-rgb) / 0.5);
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.2s, border-color 0.2s, background-color 0.2s, box-shadow 0.3s;
}

.tag-btn span {
  font-size: 0.72rem;
  color: var(--faint);
}

.tag-btn:hover {
  color: var(--parchment);
  border-color: var(--line-strong);
}

.tag-btn.is-active {
  border-color: rgb(var(--gold-light-rgb) / 0.55);
  background: linear-gradient(180deg, rgb(var(--gold-light-rgb) / 0.2), rgb(var(--gold-rgb) / 0.1));
  color: var(--gold-light);
  box-shadow: 0 0 22px -6px rgb(var(--gold-rgb) / 0.55);
}

.tag-btn.is-active span {
  color: rgb(var(--gold-light-rgb) / 0.7);
}

.count {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--faint);
}

/* ---------- Scène ---------- */

.scene {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: calc(var(--top, 46px) + var(--card-h, 300px) * 1.3);
}

.track {
  position: absolute;
  left: 0;
  right: 0;
  top: var(--top);
  height: var(--card-h);
  perspective: var(--perspective);
  perspective-origin: 50% 50%;
  transition: opacity 0.22s ease;
}

.track.is-swapping {
  opacity: 0;
}

.track.is-empty {
  display: none;
}

.card {
  position: absolute;
  left: 50%;
  top: 0;
  width: var(--card-w);
  height: var(--card-h);
  margin-left: calc(var(--card-w) / -2);
  will-change: transform, opacity;
}

.book {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 3px 8px 8px 3px;
  background: var(--ink-3);
  box-shadow: 0 30px 50px -18px rgba(0, 0, 0, 0.85), 0 4px 10px rgba(0, 0, 0, 0.45);
}

.book .cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  -webkit-user-select: none;
}

/* Reliure : pli de la couverture côté tranche */
.book::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.5) 0%,
    rgba(255, 255, 255, 0.2) 1.4%,
    rgba(0, 0, 0, 0.28) 3%,
    rgba(255, 255, 255, 0.07) 5%,
    transparent 10%
  );
}

.book::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
  pointer-events: none;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.07),
    inset -2px 0 3px rgba(255, 255, 255, 0.08),
    inset 0 -50px 60px -50px rgba(0, 0, 0, 0.4);
}

.sheen {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -100%;
  z-index: 3;
  width: 300%;
  pointer-events: none;
  background: linear-gradient(
    100deg,
    transparent 38%,
    rgba(255, 250, 235, 0.17) 46%,
    rgba(255, 250, 235, 0.05) 52%,
    transparent 60%
  );
}

.shade {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: #05060a;
  opacity: 0;
  pointer-events: none;
}

.reflection {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 40%;
  margin-top: 6px;
  overflow: hidden;
  border-radius: 3px 8px 0 0;
  opacity: 0.24;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.85), transparent 80%);
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.85), transparent 80%);
}

.reflection img {
  width: 100%;
  height: var(--card-h);
  object-fit: cover;
  transform: scaleY(-1);
}

.floor {
  position: absolute;
  left: 50%;
  top: calc(var(--top) + var(--card-h) + 3px);
  width: min(1100px, 94vw);
  height: 1px;
  transform: translateX(-50%);
  background: radial-gradient(closest-side, rgb(var(--gold-light-rgb) / 0.4), transparent);
  pointer-events: none;
}

.floor::after {
  content: '';
  position: absolute;
  left: 15%;
  right: 15%;
  top: -40px;
  height: 80px;
  background: radial-gradient(closest-side, rgb(var(--lamp-rgb) / 0.07), transparent);
}

/* Halo et rayons derrière le livre gagnant */
.halo {
  position: absolute;
  left: 50%;
  top: calc(var(--top) + var(--card-h) / 2);
  width: 0;
  height: 0;
  opacity: var(--reveal, 0);
  pointer-events: none;
}

.halo-glow,
.halo-rays {
  position: absolute;
  border-radius: 50%;
}

.halo-glow {
  left: calc(var(--card-h) * -1);
  top: calc(var(--card-h) * -1);
  width: calc(var(--card-h) * 2);
  height: calc(var(--card-h) * 2);
  background: radial-gradient(closest-side, rgb(var(--accent-rgb) / 0.42), rgb(var(--accent-rgb) / 0.1) 55%, transparent 100%);
}

.halo-rays {
  left: calc(var(--card-h) * -1.2);
  top: calc(var(--card-h) * -1.2);
  width: calc(var(--card-h) * 2.4);
  height: calc(var(--card-h) * 2.4);
  background: repeating-conic-gradient(
    from 0deg,
    rgb(var(--accent-rgb) / 0.13) 0deg 2.5deg,
    transparent 2.5deg 12deg,
    rgb(var(--gold-light-rgb) / 0.08) 12deg 13.5deg,
    transparent 13.5deg 24deg
  );
  -webkit-mask-image: radial-gradient(closest-side, #000 15%, rgba(0, 0, 0, 0.45) 45%, transparent 90%);
  mask-image: radial-gradient(closest-side, #000 15%, rgba(0, 0, 0, 0.45) 45%, transparent 90%);
  animation: rays 60s linear infinite paused;
}

body.is-revealed .halo-rays {
  animation-play-state: running;
}

@keyframes rays {
  to {
    transform: rotate(1turn);
  }
}

/* Ruban marque-page : la languette qui « claque » à chaque livre */
.ribbon {
  position: absolute;
  left: 50%;
  top: 0;
  z-index: 5;
  width: 24px;
  height: calc(var(--top) + 34px);
  margin-left: -12px;
  transform-origin: 50% 0;
  filter: drop-shadow(0 6px 5px rgba(0, 0, 0, 0.55));
  pointer-events: none;
}

.ribbon-band {
  position: absolute;
  inset: 0;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% calc(100% - 10px), 0 100%);
  background: linear-gradient(90deg, #4a0e17 0%, #8a2333 30%, #b5405a 48%, #8a2333 66%, #520f1a 100%);
}

.ribbon-band::before {
  content: '';
  position: absolute;
  top: 10px;
  bottom: 14px;
  left: 4px;
  right: 4px;
  border-left: 1px dashed rgb(var(--gold-light-rgb) / 0.5);
  border-right: 1px dashed rgb(var(--gold-light-rgb) / 0.5);
}

.ribbon-clasp {
  position: absolute;
  top: 0;
  left: -8px;
  right: -8px;
  height: 10px;
  border-radius: 2px 2px 6px 6px;
  background: linear-gradient(180deg, #f6e2b4, #c99a4c 60%, #8d6629);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.45);
}

/* ---------- Résultat ---------- */

.result {
  position: absolute;
  z-index: 4;
  left: calc(50% + var(--shift) + var(--card-w) * 0.56 + 64px);
  top: calc(var(--top) + var(--card-h) / 2);
  width: var(--result-w);
  /* Centré sur l'affiche, sans jamais remonter au-dessus de la scène quand le texte est long */
  translate: 0 max(-50%, calc(6px - var(--top) - var(--card-h) / 2));
}

.result.is-leaving {
  animation: fade-out 0.3s ease forwards;
}

.result-kicker {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 12px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--gold);
  animation: rise 0.7s var(--ease-out) 0.2s both;
}

.result-kicker::before {
  content: '';
  width: 30px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold));
}

.result-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.9rem, 2.4vw + 0.7rem, 3.1rem);
  line-height: 1.05;
  letter-spacing: -0.015em;
  color: var(--title-color);
  font-variation-settings: 'opsz' 144, 'SOFT' 30;
  text-wrap: balance;
}

.result-title .w {
  display: inline-block;
  white-space: nowrap;
}

.result-title .ch {
  display: inline-block;
  animation: char-in 0.8s var(--ease-out) both;
  animation-delay: calc(0.3s + var(--i) * 24ms);
}

.result-author {
  margin: 12px 0 0;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.18rem;
  color: rgb(var(--parchment-rgb) / 0.8);
  font-variation-settings: 'opsz' 24, 'SOFT' 100;
  animation: rise 0.7s var(--ease-out) var(--after, 0.8s) both;
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 16px;
  animation: rise 0.7s var(--ease-out) calc(var(--after, 0.8s) + 0.1s) both;
}

.result-meta:empty {
  display: none;
}

.result-desc {
  display: -webkit-box;
  margin: 18px 0 0;
  overflow: hidden;
  color: rgb(var(--parchment-rgb) / 0.72);
  font-size: 0.94rem;
  line-height: 1.65;
  white-space: pre-line;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  animation: rise 0.8s var(--ease-out) calc(var(--after, 0.8s) + 0.2s) both;
}

.result-desc:empty {
  display: none;
}

.result-desc.is-open {
  display: block;
  max-height: 38vh;
  overflow-y: auto;
  padding-right: 6px;
  -webkit-line-clamp: unset;
}

.link-btn {
  margin-top: 10px;
  animation: rise 0.8s var(--ease-out) calc(var(--after, 0.8s) + 0.3s) both;
  padding: 0;
  border: 0;
  background: none;
  color: var(--gold-light);
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgb(var(--gold-light-rgb) / 0.4);
  text-underline-offset: 3px;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}

@keyframes char-in {
  from {
    opacity: 0;
    transform: translateY(0.5em) rotate(6deg);
    filter: blur(8px);
  }
}

@keyframes fade-out {
  to {
    opacity: 0;
    transform: translateX(12px);
  }
}

/* ---------- Bibliothèque vide ---------- */

.empty {
  display: grid;
  justify-items: center;
  gap: 10px;
  max-width: 440px;
  margin: auto;
  padding: 40px 20px;
  text-align: center;
  animation: rise 0.8s var(--ease-out) both;
}

.empty-art {
  width: 130px;
  margin-bottom: 8px;
  color: var(--gold);
  opacity: 0.85;
}

.empty h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.8rem;
  font-variation-settings: 'opsz' 96, 'SOFT' 50;
}

.empty p {
  margin: 0 0 14px;
  color: var(--muted);
}

body.is-empty .stage,
body.is-empty .controls,
body.is-empty .tags,
body.is-empty .count {
  display: none;
}

/* ---------- Bouton de tirage ---------- */

.controls {
  position: relative;
  z-index: 3;
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 4px 16px calc(26px + env(safe-area-inset-bottom));
}

.spin-btn {
  --charge: 0;
  position: relative;
  width: 116px;
  height: 116px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.spin-aura {
  position: absolute;
  inset: -34px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(236, 192, 112, calc(0.16 + var(--charge) * 0.5)), transparent 72%);
  pointer-events: none;
}

.gauge {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  transform: rotate(-90deg);
}

.gauge-track {
  fill: none;
  stroke: rgb(var(--gold-light-rgb) / 0.16);
  stroke-width: 2;
}

.gauge-fill {
  fill: none;
  stroke: var(--gold-light);
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  filter: drop-shadow(0 0 5px rgb(var(--gold-light-rgb) / 0.85));
  transition: stroke-dashoffset 0.6s var(--ease-out);
}

.spin-btn.is-charging .gauge-fill {
  transition: none;
}

.spin-face {
  position: absolute;
  inset: 12px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 26%, var(--medal-1) 0%, var(--medal-2) 24%, var(--medal-3) 58%, var(--medal-4) 100%);
  box-shadow:
    inset 0 2px 1px rgba(255, 255, 255, 0.6),
    inset 0 -6px 12px rgb(var(--medal-shade-rgb) / 0.45),
    0 14px 30px -8px rgb(var(--gold-rgb) / 0.55),
    0 0 0 1px rgb(var(--medal-rim-rgb) / 0.35);
  transition: transform 0.28s var(--ease-spring), box-shadow 0.28s, filter 0.3s;
}

.spin-face::before {
  content: '';
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  border: 1px solid rgb(var(--medal-shade-rgb) / 0.32);
  box-shadow: inset 0 1px 0 rgb(var(--medal-rim-rgb) / 0.45), 0 1px 0 rgb(var(--medal-rim-rgb) / 0.35);
}

.spin-label {
  position: relative;
  font-family: var(--font-display);
  font-weight: 650;
  font-size: 1.06rem;
  letter-spacing: 0.03em;
  color: var(--medal-text);
  text-shadow: var(--medal-text-shadow);
  font-variation-settings: 'opsz' 24, 'SOFT' 0;
}

.spin-btn:hover .spin-face {
  transform: translateY(-2px) scale(1.035);
  box-shadow:
    inset 0 2px 1px rgba(255, 255, 255, 0.6),
    inset 0 -6px 12px rgb(var(--medal-shade-rgb) / 0.45),
    0 18px 40px -8px rgb(var(--gold-rgb) / 0.75),
    0 0 0 1px rgb(var(--medal-rim-rgb) / 0.45);
}

.spin-btn.is-pressed .spin-face {
  transform: scale(0.93);
  transition-duration: 0.12s;
}

.spin-btn.is-charging .spin-face {
  animation: buzz 0.07s linear infinite;
}

.spin-btn.is-full .spin-aura {
  animation: full-pulse 0.45s ease-in-out infinite alternate;
}

.spin-btn.is-busy {
  cursor: progress;
}

.spin-btn.is-busy .spin-face {
  filter: saturate(0.6) brightness(0.72);
  transform: scale(0.95);
}

.spin-btn:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

@keyframes buzz {
  0%,
  100% {
    translate: calc(var(--charge) * -1.5px) 0;
  }
  50% {
    translate: calc(var(--charge) * 1.5px) calc(var(--charge) * 0.8px);
  }
}

@keyframes full-pulse {
  to {
    transform: scale(1.14);
    filter: brightness(1.35);
  }
}

.hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--faint);
  transition: opacity 0.3s;
}

body.is-spinning .hint,
body.is-charging .hint {
  opacity: 0;
}

@media (hover: none) {
  .key-hint {
    display: none;
  }
}

/* ---------- Bureau : le livre glisse à gauche, les infos à droite ---------- */

@media (min-width: 900px) {
  .ribbon {
    opacity: calc(1 - var(--reveal, 0));
  }
}

/* ---------- Mobile : infos sous le livre ---------- */

@media (max-width: 899px) {
  .topbar {
    padding-block: 14px;
  }

  .intro {
    gap: 10px;
  }

  .tags {
    flex-wrap: nowrap;
    justify-content: flex-start;
    width: calc(100% + 32px);
    margin: 0 -16px;
    padding: 2px 16px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 16px, #000 calc(100% - 16px), transparent);
    mask-image: linear-gradient(90deg, transparent, #000 16px, #000 calc(100% - 16px), transparent);
  }

  .tags::-webkit-scrollbar {
    display: none;
  }

  /* Centre les catégories quand elles tiennent, défile sinon */
  .tags > :first-child {
    margin-left: auto;
  }

  .tags > :last-child {
    margin-right: auto;
  }

  .scene {
    justify-content: center;
  }

  .stage {
    flex: none;
    height: calc(var(--top) + var(--card-h) * 1.3);
    min-height: 0;
  }

  .result {
    position: static;
    width: auto;
    max-width: 560px;
    margin: 0 auto;
    padding: 0 20px 12px;
    text-align: center;
    translate: none;
  }

  .result-kicker {
    justify-content: center;
  }

  .result-kicker::after {
    content: '';
    width: 30px;
    height: 1px;
    background: linear-gradient(90deg, var(--gold), transparent);
  }

  .result-meta {
    justify-content: center;
  }

  .result-desc {
    -webkit-line-clamp: 4;
    text-align: left;
  }

  .result-desc.is-open {
    max-height: none;
  }

  @keyframes fade-out {
    to {
      opacity: 0;
      transform: translateY(8px);
    }
  }

  /* Le bouton reste à portée de pouce quand le résumé fait défiler la page */
  .controls {
    position: sticky;
    bottom: 0;
    padding-top: 22px;
    background: linear-gradient(180deg, transparent, rgb(var(--ink-rgb) / 0.92) 38%);
  }

  .spin-btn {
    width: 104px;
    height: 104px;
  }

  .spin-face {
    inset: 11px;
  }
}

/* ---------- Filmomancie : affiches, ticket et ampoules de marquise ---------- */

html[data-kind='films'] .book,
html[data-kind='films'] .reflection {
  border-radius: 4px;
}

html[data-kind='films'] .book::before {
  display: none;
}

html[data-kind='films'] .book::after {
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.12),
    inset 0 -60px 60px -50px rgba(0, 0, 0, 0.45);
}

/* Le repère devient un ticket de cinéma */
html[data-kind='films'] .ribbon {
  width: 26px;
  margin-left: -13px;
}

html[data-kind='films'] .ribbon-band {
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 13px), 50% 100%, 0 calc(100% - 13px));
  background: linear-gradient(90deg, #f6d3a0 0 30%, #d8473a 30% 70%, #f6d3a0 70%);
}

html[data-kind='films'] .ribbon-band::before {
  left: 3px;
  right: 3px;
  border-color: rgba(120, 20, 14, 0.45);
}

html[data-kind='films'] .ribbon-clasp {
  background: linear-gradient(180deg, #4a3a38, #1c1212);
}

/* Couronne d'ampoules qui tourne, et s'emballe pendant la charge et le tirage */
html[data-kind='films'] .spin-btn::after {
  content: '';
  position: absolute;
  inset: -13px;
  border-radius: 50%;
  pointer-events: none;
  background: repeating-conic-gradient(rgb(var(--gold-light-rgb)) 0deg 4deg, transparent 4deg 15deg);
  -webkit-mask-image: radial-gradient(closest-side, transparent calc(100% - 5px), #000 calc(100% - 4px), #000 calc(100% - 1px), transparent 100%);
  mask-image: radial-gradient(closest-side, transparent calc(100% - 5px), #000 calc(100% - 4px), #000 calc(100% - 1px), transparent 100%);
  filter: drop-shadow(0 0 4px rgb(var(--gold-light-rgb) / 0.9));
  opacity: 0.75;
  animation: marquee 9s linear infinite;
}

html[data-kind='films'] body:is(.is-charging, .is-spinning) .spin-btn::after {
  opacity: 1;
  animation-duration: 0.8s;
}

@keyframes marquee {
  to {
    transform: rotate(1turn);
  }
}

/* ---------- Seriomancie : bords néon, sol quadrillé et curseur lumineux ---------- */

html[data-kind='series'] .book {
  border-radius: 10px;
  box-shadow:
    0 30px 50px -18px rgba(0, 0, 0, 0.85),
    0 0 0 1px rgb(var(--gold-light-rgb) / 0.22),
    0 0 26px -8px rgb(var(--gold-rgb) / 0.55);
}

html[data-kind='series'] .book::before {
  display: none;
}

html[data-kind='series'] .reflection {
  border-radius: 10px 10px 0 0;
}

/* Sol en perspective façon grille rétro, qui défile pendant le tirage */
html[data-kind='series'] .floor::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  width: 1600px;
  height: 230px;
  transform: translateX(-50%) perspective(260px) rotateX(58deg);
  transform-origin: 50% 0;
  background-image:
    linear-gradient(rgb(var(--gold-light-rgb) / 0.3) 1px, transparent 1px),
    linear-gradient(90deg, rgb(var(--gold-rgb) / 0.4) 1px, transparent 1px);
  background-size: 64px 36px;
  -webkit-mask-image: linear-gradient(180deg, #000, transparent 80%);
  mask-image: linear-gradient(180deg, #000, transparent 80%);
  opacity: 0.55;
}

html[data-kind='series'] body.is-spinning .floor::before {
  animation: grid-run 0.35s linear infinite;
}

@keyframes grid-run {
  to {
    background-position: -64px 0;
  }
}

/* Le repère devient un curseur néon */
html[data-kind='series'] .ribbon {
  filter: drop-shadow(0 0 6px rgb(var(--gold-light-rgb) / 0.9)) drop-shadow(0 0 14px rgb(var(--gold-rgb) / 0.7));
}

html[data-kind='series'] .ribbon-band {
  clip-path: polygon(42% 0, 58% 0, 58% calc(100% - 13px), 100% calc(100% - 13px), 50% 100%, 0 calc(100% - 13px), 42% calc(100% - 13px));
  background: linear-gradient(180deg, rgb(var(--gold-rgb) / 0.2), rgb(var(--gold-light-rgb)));
}

html[data-kind='series'] .ribbon-band::before {
  display: none;
}

html[data-kind='series'] .ribbon-clasp {
  left: 3px;
  right: 3px;
  height: 6px;
  border-radius: 6px;
  background: rgb(var(--gold-light-rgb));
}

/* ---------- Écrans peu hauts : le résultat doit tenir à côté de l'affiche ---------- */

html[data-kind='films'] .result-title {
  font-size: clamp(1.7rem, 1.9vw + 0.7rem, 2.7rem);
  line-height: 1.12;
}

@media (min-width: 900px) and (max-height: 860px) {
  .result-title {
    font-size: clamp(1.6rem, 1.6vw + 0.6rem, 2.3rem);
  }

  .result-kicker {
    margin-bottom: 8px;
  }

  .result-meta {
    margin-top: 10px;
  }

  .result-desc {
    margin-top: 12px;
    font-size: 0.9rem;
    -webkit-line-clamp: 3;
  }
}

/* ---------- Randomancie : cartes à jouer, jeton de casino et éditeur de liste ---------- */

html[data-kind='words'] .book {
  border-radius: 14px;
  box-shadow: 0 30px 50px -18px rgba(0, 0, 0, 0.85), 0 3px 8px rgba(0, 0, 0, 0.4);
}

html[data-kind='words'] .book::before {
  display: none;
}

html[data-kind='words'] .reflection {
  border-radius: 14px 14px 0 0;
}

/* Le repère devient un fanion de feutre vert bordé d'or */
html[data-kind='words'] .ribbon-band {
  background: linear-gradient(90deg, #0c3a28 0%, #1f7a58 45%, #2b9a6f 52%, #13513a 100%);
}

html[data-kind='words'] .ribbon-band::before {
  border-color: rgb(var(--gold-light-rgb) / 0.7);
}

/* Le médaillon prend les encoches d'un jeton de casino */
html[data-kind='words'] .spin-face::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: repeating-conic-gradient(rgba(255, 255, 255, 0.85) 0deg 12deg, transparent 12deg 45deg);
  -webkit-mask-image: radial-gradient(closest-side, transparent calc(100% - 9px), #000 calc(100% - 8px), #000 calc(100% - 2px), transparent 100%);
  mask-image: radial-gradient(closest-side, transparent calc(100% - 9px), #000 calc(100% - 8px), #000 calc(100% - 2px), transparent 100%);
  opacity: 0.75;
  transition: transform 0.6s var(--ease-out);
}

html[data-kind='words'] body.is-charging .spin-face::after {
  transform: rotate(90deg);
}

.text-btn {
  margin-top: -6px;
  padding: 2px 6px;
  border: 0;
  background: none;
  color: var(--gold-light);
  font-size: 0.82rem;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgb(var(--gold-light-rgb) / 0.4);
  text-underline-offset: 3px;
}

.text-btn:hover {
  text-decoration-color: var(--gold-light);
}

body:is(.is-spinning, .is-charging) .text-btn {
  visibility: hidden;
}

.words-dialog {
  width: min(520px, calc(100vw - 24px));
  padding: 0;
  border-radius: 22px;
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, var(--ink-3), var(--ink-2));
  color: var(--parchment);
  box-shadow: 0 40px 120px -30px rgba(0, 0, 0, 0.9);
}

.words-dialog[open] {
  animation: words-in 0.4s var(--ease-spring) both;
}

.words-dialog::backdrop {
  background: rgba(2, 6, 4, 0.7);
  backdrop-filter: blur(5px);
}

@keyframes words-in {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.97);
  }
}

.words-form {
  display: grid;
  gap: 12px;
  padding: 24px;
}

.words-form h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 500;
}

.words-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.words-form textarea {
  width: 100%;
  min-height: 220px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgb(var(--ink-0-rgb) / 0.6);
  color: var(--parchment);
  font-size: 1rem;
  line-height: 1.6;
  resize: vertical;
  outline: none;
}

.words-form textarea:focus {
  border-color: rgb(var(--gold-light-rgb) / 0.55);
  box-shadow: 0 0 0 3px rgb(var(--gold-rgb) / 0.16);
}

.words-foot {
  display: flex;
  align-items: center;
  gap: 8px;
}

.words-count {
  margin-right: auto;
  color: var(--muted);
  font-size: 0.85rem;
}

/* Compteur et « Modifier la liste » sur la même ligne, loin du fanion */
html[data-kind='words'] .intro {
  grid-template-columns: auto auto;
  justify-content: center;
  align-items: center;
  column-gap: 14px;
}

html[data-kind='words'] .intro > :not(.count, .text-btn) {
  grid-column: 1 / -1;
}

html[data-kind='words'] .intro .text-btn {
  margin-top: 0;
}

/* Cinzel est tout en capitales : libellé plus petit pour tenir dans le jeton */
html[data-kind='words'] .spin-label {
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

/* ---------- Gamomancie : cartouches, curseur pixel et bouton d'arcade ---------- */

html[data-kind='games'] .book {
  border-radius: 6px;
  box-shadow:
    0 30px 50px -18px rgba(0, 0, 0, 0.85),
    0 0 0 3px #0b0814,
    0 0 0 5px rgb(var(--gold-rgb) / 0.55);
}

html[data-kind='games'] .book::before {
  display: none;
}

html[data-kind='games'] .reflection {
  border-radius: 6px 6px 0 0;
}

html[data-kind='games'] .result-title {
  font-size: clamp(1.05rem, 1.1vw + 0.55rem, 1.7rem);
  line-height: 1.6;
}

html[data-kind='games'] .result-title .ch {
  /* Les lettres apparaissent d'un coup, sans flou : plus « 8 bits » */
  animation-name: char-pop;
  animation-timing-function: steps(2, end);
  animation-duration: 0.3s;
}

@keyframes char-pop {
  from {
    opacity: 0;
    transform: translateY(0.4em);
  }
}

/* Le repère devient une flèche en pixels */
html[data-kind='games'] .ribbon {
  width: 30px;
  margin-left: -15px;
  filter: drop-shadow(3px 3px 0 rgba(0, 0, 0, 0.65));
}

html[data-kind='games'] .ribbon-band {
  background: var(--gold-light);
  clip-path: polygon(
    40% 0,
    60% 0,
    60% calc(100% - 18px),
    100% calc(100% - 18px),
    100% calc(100% - 13px),
    80% calc(100% - 13px),
    80% calc(100% - 8px),
    65% calc(100% - 8px),
    65% calc(100% - 4px),
    55% calc(100% - 4px),
    55% 100%,
    45% 100%,
    45% calc(100% - 4px),
    35% calc(100% - 4px),
    35% calc(100% - 8px),
    20% calc(100% - 8px),
    20% calc(100% - 13px),
    0 calc(100% - 13px),
    0 calc(100% - 18px),
    40% calc(100% - 18px)
  );
}

html[data-kind='games'] .ribbon-band::before {
  display: none;
}

html[data-kind='games'] .ribbon-clasp {
  left: 6px;
  right: 6px;
  height: 8px;
  border-radius: 0;
  background: var(--gold);
}

/* Gros bouton d'arcade dans son support */
html[data-kind='games'] .spin-face {
  box-shadow:
    inset 0 3px 1px rgba(255, 255, 255, 0.55),
    inset 0 -8px 12px rgb(var(--medal-shade-rgb) / 0.55),
    0 6px 0 #4a0720,
    0 0 0 7px #17111f,
    0 0 0 9px rgb(var(--gold-light-rgb) / 0.55),
    0 16px 34px -8px rgb(var(--gold-rgb) / 0.6);
}

html[data-kind='games'] .spin-btn.is-pressed .spin-face {
  transform: translateY(5px) scale(0.97);
  box-shadow:
    inset 0 3px 1px rgba(255, 255, 255, 0.45),
    inset 0 -6px 10px rgb(var(--medal-shade-rgb) / 0.55),
    0 1px 0 #4a0720,
    0 0 0 7px #17111f,
    0 0 0 9px rgb(var(--gold-light-rgb) / 0.8),
    0 10px 24px -8px rgb(var(--gold-rgb) / 0.6);
}

html[data-kind='games'] .spin-label {
  font-size: 0.72rem;
}

/* « Press start » qui clignote sous le bouton */
html[data-kind='games'] .hint {
  animation: blink 1.1s steps(2, start) infinite;
}

@keyframes blink {
  to {
    visibility: hidden;
  }
}
