:root {
  --fond: rgba(15, 15, 16, 0.72);
  --trait: rgba(255, 255, 255, 0.16);
  --texte: #f6efe2;
  --doux: #c9b995;
  --accent: #e8c68d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0f0f10;
  color: var(--texte);
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#scene:active { cursor: grabbing; }

button {
  font: inherit;
  color: var(--texte);
  background: var(--fond);
  border: 1px solid var(--trait);
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  white-space: nowrap;
}
button:hover { border-color: rgba(255, 255, 255, 0.4); }
button.actif { background: var(--accent); color: #17130c; border-color: var(--accent); }

.bandeau {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 14px 0;
  pointer-events: none;
}
.bandeau > * { pointer-events: auto; }

.marque {
  background: var(--fond);
  border: 1px solid var(--trait);
  border-radius: 14px;
  padding: 9px 14px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  line-height: 1.25;
}
.marque strong { display: block; letter-spacing: 0.14em; font-size: 15px; }
.marque span { font-size: 12px; color: var(--doux); }

.actions { display: flex; gap: 8px; }
#btn-aide { width: 40px; padding: 9px 0; text-align: center; }

/* Pile des commandes du bas : le curseur, puis les points de vue ou la barre des clichés */
.bas {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}
.bas > * { pointer-events: auto; }

.vues {
  width: 100%;
  display: flex;
  gap: 8px;
  padding: 10px 14px calc(14px + env(safe-area-inset-bottom));
  overflow-x: auto;
  scrollbar-width: none;
}
/* Centré quand tout tient, défilable depuis le premier bouton sinon */
.vues > :first-child { margin-left: auto; }
.vues > :last-child { margin-right: auto; }
.vues::-webkit-scrollbar { display: none; }

.tour {
  width: min(560px, calc(100vw - 28px));
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--fond);
  border: 1px solid var(--trait);
  border-radius: 999px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 13px;
  color: var(--doux);
}
.tour output { min-width: 40px; text-align: right; color: var(--texte); font-variant-numeric: tabular-nums; }
.tour input {
  flex: 1;
  min-width: 0;
  height: 28px;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  touch-action: none;
  cursor: ew-resize;
}
.tour input::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.28); }
.tour input::-moz-range-track { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.28); }
.tour input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  margin-top: -10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #17130c;
}
.tour input::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #17130c;
}

.manette {
  position: fixed;
  left: 22px;
  bottom: calc(132px + env(safe-area-inset-bottom));
  width: 108px;
  height: 108px;
  border-radius: 50%;
  background: rgba(15, 15, 16, 0.4);
  border: 1px solid var(--trait);
  display: none;
  touch-action: none;
}
.pouce {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  background: rgba(232, 198, 141, 0.85);
}

.aide {
  position: fixed;
  top: 76px;
  right: 14px;
  width: min(330px, calc(100vw - 28px));
  background: rgba(15, 15, 16, 0.9);
  border: 1px solid var(--trait);
  border-radius: 14px;
  padding: 14px 18px;
  display: none;
  font-size: 14px;
  line-height: 1.5;
}
.aide.ouvert { display: block; }
.aide h2 { margin: 0 0 6px; font-size: 15px; color: var(--accent); font-weight: 600; }
.aide ul { margin: 0; padding-left: 18px; }
.aide p { margin: 10px 0 0; font-size: 12px; color: var(--doux); }
.aide .doigt { display: none; }

button.special { border-color: var(--accent); color: var(--accent); }

/* ----- Clichés photo ----- */
.photo {
  width: 100%;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 12px calc(14px + env(safe-area-inset-bottom));
}
body.cliche .photo { display: flex; }
body.cliche .vues, body.cliche .manette { display: none; }

.photo-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px;
  background: var(--fond);
  border: 1px solid var(--trait);
  border-radius: 999px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.photo-nav button {
  width: 42px;
  height: 42px;
  padding: 0 0 3px;
  font-size: 24px;
  line-height: 1;
  border: 0;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  flex: none;
}
.photo-titre { min-width: 0; text-align: center; padding: 0 8px; line-height: 1.25; }
.photo-titre strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(60vw, 360px);
}
.photo-titre span { font-size: 11.5px; color: var(--doux); }
.photo-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.photo-actions button { padding: 8px 13px; font-size: 13.5px; }

#scene.fondu { animation: apparaitre 0.45s ease; }
@keyframes apparaitre { from { opacity: 0.1; } to { opacity: 1; } }

.galerie {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  flex-direction: column;
  background: rgba(12, 12, 13, 0.95);
}
.galerie.ouvert { display: flex; }
.galerie header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 16px 10px;
}
.galerie h2 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: 0.08em; }
.galerie-corps {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px calc(28px + env(safe-area-inset-bottom));
  -webkit-overflow-scrolling: touch;
}
.galerie h3 {
  margin: 18px 0 9px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}
.vignettes { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 10px; }
.vignette {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  border-radius: 12px;
  background: #1b1b1d;
  text-align: left;
  white-space: normal;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.vignette img { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; background: #232325; }
.vignette span { padding: 7px 10px 9px; font-size: 12.5px; line-height: 1.3; }

.chargement {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: #0f0f10;
  color: var(--doux);
  letter-spacing: 0.08em;
  transition: opacity 0.6s ease;
  padding: 24px;
  text-align: center;
}
.chargement.fini { opacity: 0; pointer-events: none; }

@media (pointer: coarse) {
  .manette { display: block; }
  body.maquette .manette { display: none; }
  .aide .doigt { display: list-item; }
  .aide .souris { display: none; }
  button { padding: 10px 15px; }
}
