:root {
  --bg: transparent;
  --panel: rgba(15, 18, 25, .85);
  --text: #e9eef7;
  --muted: rgba(233,238,247,.7);
  --accent: #6ee7ff;
  --accent2: #a78bfa;
  --danger: #ff6b6b;
  --ok: #4ade80;

  /* Effets visuels */
  --glow: rgba(110,231,255,.32);
  --shadow: rgba(0,0,0,.45);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans", "Liberation Sans", sans-serif;
}

/* =========================================
   STAGE OBS (ROULETTE)
   ========================================= */

.stage {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 14px;
  padding: 18px;
}

/* --- Conteneur Roulette "Sandwich" --- */
.custom-roulette {
  position: relative;
  /* Dimensions de la roulette (ajuster selon tes images frame/bg) */
  width: 400px;
  height: 400px;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 50%;
    overflow: hidden;
    transform: translateZ(0);
}

/* Couches (Layers) */
.layer-back, .layer-front {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

/* Couche 1 : Fond (Derrière tout) */
.layer-back {
  z-index: 0;
  /* Placeholder si image absente */
  /* background: radial-gradient(circle, #2a2a2a, #000); */
}

/* Couche 3 : Cadre (Devant tout) */
.layer-front {
  z-index: 20;
  /* opacity: 0.5; */


  /* Placeholder debug si image absente */
  /* border: 2px dashed rgba(255,255,255,0.2); */
}

/* Couche 2 : Zone de Spin (Au milieu) */
.layer-spin {
  position: absolute;
  z-index: 10;
  /* Marge interne pour que les items ne sortent pas du cadre */
  /* Ajuste cette valeur selon l'épaisseur de ton cadre 'frame.png' */
  inset: 30px; 
  overflow: hidden;
  display: grid;
  place-items: center;
  /* border: 2px dashed #ff6b6b; */
  

}

.roulette__empty {
  font-size: 14px;
  color: var(--muted);
  text-align: center;
  background: rgba(0, 0, 0, 0.568);
  padding: 8px 12px;
  border-radius: 8px;
}

/* --- Items qui défilent (Ghost & Winner) --- */
.scroll-item {
  position: absolute;
  left: 50%;
  width: 40%;
  height: 40%;
  object-fit: contain;
  
  /* État initial (Haut, invisible) */
  top: -20%;
  transform: translate(-50%, -50%) scale(0.5);
  opacity: 0;
  pointer-events: none;
  /* border: 2px solid red; */
}

/* Animation de chute continue */
.anim-scroll {
  animation: fallThrough 0.6s linear forwards;
}

/* Animation d'arrivée du gagnant */
.anim-winner {
  animation: fallToCenter 0.8s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* Helper pour masquer les fantômes proprement */
.fade-out-ghost {
  /* On ne pause PAS l'animation, on change juste l'opacité */
  transition: opacity 0.2s ease-out !important;
  opacity: 0 !important;
}

/* Flash final */
.winner-pop {
  animation: winPulse 0.3s ease-in-out;
}

/* --- Keyframes --- */

@keyframes fallThrough {
  0% {
    top: -20%;
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 0;
    filter: blur(2px);
  }
  40%, 60% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1); /* Effet loupe */
    filter: blur(0px);
  }
  50% { top: 50%; }
  100% {
    top: 120%;
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 0;
    filter: blur(2px);
  }
}

@keyframes fallToCenter {
  0% {
    top: 0%;
    transform: translate(-50%, -50%) scale(0.6);
    opacity: 0.5;
  }
  60% {
    top: 50%;
    transform: translate(-50%, -50%) scale(1.15);
    opacity: 1;
  }
  100% {
    top: 50%;
    transform: translate(-50%, -50%) scale(1.0);
    opacity: 1;
    filter: drop-shadow(0 0 15px var(--glow));
  }
}

@keyframes winPulse {
  0% { transform: translate(-50%, -50%) scale(1.0); }
  50% { transform: translate(-50%, -50%) scale(1.3); filter: brightness(1.5); }
  100% { transform: translate(-50%, -50%) scale(1.0); }
}

/* =========================================
   UI ELEMENTS (BOUTONS / DEBUG)
   ========================================= */

.btn {
  border: 1px solid rgba(255,255,255,.15);
  background: rgba(20,24,34,.75);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
}
.btn:hover { border-color: rgba(255,255,255,.28); background: rgba(30,36,48,.85); }
.btn:active { transform: translateY(1px); }

.btn--primary {
  background: linear-gradient(135deg, rgba(110,231,255,.22), rgba(167,139,250,.20));
  border-color: rgba(110,231,255,.35);
}

.btn--test {
  opacity: .3;
  margin-top: 10px;
}
.btn--test:hover { opacity: .8; }

.debug {
  font-size: 12px;
  color: rgba(233,238,247,.45);
  user-select: none;
}

/* =========================================
   SETTINGS PAGE (UI CONFIG)
   ========================================= */

.settings {
  min-height: 100%;
  padding: 18px;
  display: grid;
  gap: 14px;
  align-content: start;
  background: radial-gradient(circle at 20% 0%, rgba(110,231,255,.10), transparent 35%),
              radial-gradient(circle at 80% 0%, rgba(167,139,250,.10), transparent 35%),
              rgba(0,0,0,.25);
}

.settings__header, .panel {
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid rgba(255,255,255,.10);
}

.settings__title { margin: 0 0 6px; font-size: 18px; }
.settings__subtitle { margin: 0; color: var(--muted); font-size: 13px; }
.panel__title { margin: 0 0 10px; font-size: 15px; }

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.row--end { justify-content: flex-end; }

.dropzone {
  border: 1px dashed rgba(255,255,255,.22);
  border-radius: 12px;
  padding: 20px;
  color: var(--muted);
  background: rgba(0,0,0,.12);
  text-align: center;
  transition: border-color 0.2s;
}
.dropzone:hover, .dropzone:focus {
  border-color: var(--accent);
  background: rgba(110,231,255,0.05);
}

.hint {
  margin: 10px 0 12px;
  color: rgba(233,238,247,.55);
  font-size: 12px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
}

.card {
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(0,0,0,.18);
  display: flex;
  flex-direction: column;
}

.card__img {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: block;
  object-fit: contain;
  background: rgba(0,0,0,.22);
  padding: 4px;
}

.card__bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px;
  background: rgba(0,0,0,0.3);
  border-top: 1px solid rgba(255,255,255,0.05);
}

.card__meta {
  font-size: 11px;
  color: var(--muted);
}

.card__del {
  border: 1px solid rgba(255,107,107,.2);
  background: rgba(255,107,107,.1);
  color: var(--text);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
}
.card__del:hover { background: rgba(255,107,107,.25); border-color: var(--danger); }

.form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

.field { display: grid; gap: 6px; }
.field__label { font-size: 12px; color: rgba(233,238,247,.70); }
.field__input {
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.3);
  color: var(--text);
  border-radius: 8px;
  padding: 10px;
  font-family: inherit;
}
.field__input:focus { border-color: var(--accent); outline: none; }

.status { margin-top: 10px; font-size: 12px; color: var(--muted); min-height: 18px; }
.status.ok { color: var(--ok); }
.status.err { color: var(--danger); }
