:root {
  --brand: #121212;
  --brand-dark: #000000;
  --brand-light: #f4f0e4;
  --accent: #bbac86;
  --success: #2c6e49;
  --border: #ddd6c4;
  --error: #b3261e;
  --bg: #ffffff;
}

* { box-sizing: border-box; }

html {
  background: #d1b18b;
}

body {
  margin: 0;
  font-family: system-ui, sans-serif;
  color: #222;
  background: #d1b18b url("../images/fond.jpg") center top / cover no-repeat fixed;
  min-height: 100vh;
}

.backdrop-loutre {
  position: fixed;
  right: -70px;
  bottom: -50px;
  width: 360px;
  opacity: 0.11;
  filter: sepia(35%);
  pointer-events: none;
  z-index: 0;
}

.hero-band {
  position: relative;
  width: 100%;
  height: 100px;
  background-image: url("../images/bandeau.png");
  background-repeat: repeat-x;
  background-size: auto 100%;
  background-position: center;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28);
}

.site-logo-wrap {
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translate(-50%, -50%);
  width: 104px;
  height: 104px;
  z-index: 2;
}
.site-logo-wrap::before {
  content: "";
  position: absolute;
  inset: -22px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 0, 0, 0.62) 0%, rgba(0, 0, 0, 0.38) 42%, rgba(0, 0, 0, 0) 70%);
  z-index: 0;
}
.site-logo {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.35));
}

.page {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  padding: 0 1rem 2.5rem;
  margin-top: 64px;
}

.bandeau {
  height: 30px;
  margin: 1rem auto 1.1rem;
  background-image: url("../images/bandeau.png");
  background-repeat: repeat-x;
  background-size: auto 100%;
  background-position: center;
}
.bandeau-bottom {
  transform: scaleX(-1);
}

#app {
  background: rgba(255, 253, 247, 0.95);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 16px 34px rgba(35, 26, 8, 0.2);
  padding: 1.5rem 1.25rem 1.75rem;
}

@media (max-width: 380px) {
  .backdrop-loutre { display: none; }
  .site-logo-wrap { width: 88px; height: 88px; }
}

.progress {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 1.5rem;
}
.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.question-image, .explication-image {
  width: 100%;
  border-radius: 14px;
  margin-bottom: 1rem;
}

h1.question-text {
  font-size: 1rem;
  line-height: 1.4;
}

.choix-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 1rem;
}

button.choix {
  padding: 0.85rem 1.1rem;
  font-size: 1rem;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: #fff;
  text-align: left;
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.15s ease, background 0.15s ease;
}
button.choix:active {
  transform: scale(0.98);
  background: var(--brand-light);
  border-color: var(--brand);
}

input.reponse-libre {
  width: 100%;
  padding: 0.8rem 1rem;
  font-size: 1rem;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  margin-top: 1rem;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input.reponse-libre:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(18, 18, 18, 0.1);
}

.slider-wrap {
  margin-top: 1.5rem;
  text-align: center;
}
.slider-value {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--brand);
  margin: 0 0 1rem;
}
input.slider-jours {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 999px;
  background: var(--border);
  outline: none;
}
input.slider-jours::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background-color: var(--brand-light);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2 L12 14' stroke='%23121212' stroke-width='1.5' stroke-linecap='round'/%3E%3Cpath d='M12 3 L18 13 L12 13 Z' fill='%23bbac86'/%3E%3Cpath d='M4 16c2 3 14 3 16 0l-2-2H6z' fill='%23121212'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 70%;
  border: 2px solid var(--brand);
  cursor: pointer;
}
input.slider-jours::-moz-range-thumb {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background-color: var(--brand-light);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2 L12 14' stroke='%23121212' stroke-width='1.5' stroke-linecap='round'/%3E%3Cpath d='M12 3 L18 13 L12 13 Z' fill='%23bbac86'/%3E%3Cpath d='M4 16c2 3 14 3 16 0l-2-2H6z' fill='%23121212'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 70%;
  border: 2px solid var(--brand);
  cursor: pointer;
}

.assoc-wrap {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 2.5rem;
  margin-top: 1.5rem;
  touch-action: none;
}
.assoc-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.assoc-col {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  min-width: 0;
}
.assoc-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.assoc-gauche .assoc-item { justify-content: space-between; }
.assoc-droite .assoc-item { justify-content: flex-start; }
.assoc-label {
  font-size: 0.92rem;
  line-height: 1.3;
  word-break: break-word;
}
.assoc-circle {
  width: 26px;
  height: 26px;
  min-width: 26px;
  border-radius: 50%;
  border: 2px solid var(--brand);
  background: #fff;
  transition: transform 0.1s ease, background 0.15s ease;
}
.assoc-item.connected .assoc-circle {
  background: var(--accent);
  border-color: var(--brand);
}
.assoc-item:active .assoc-circle {
  transform: scale(0.9);
}

.categorie-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  margin-top: 1.5rem;
}
.categorie-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  padding: 0.7rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: #fff;
}
.categorie-item[hidden] {
  display: none;
}
.categorie-label {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.95rem;
  word-break: break-word;
}
.categorie-feedback {
  font-size: 1.2rem;
  font-weight: 700;
  min-width: 1.2em;
  text-align: center;
}
.categorie-feedback.correct { animation: bounce 0.4s ease; color: var(--success); }
.categorie-feedback.incorrect { animation: shake 0.35s ease; color: var(--error); }
.categorie-buttons {
  display: flex;
  gap: 0.5rem;
  flex: 1 1 100%;
}
button.categorie-btn {
  flex: 1 1 0;
  padding: 0.55rem 0.7rem;
  font-size: 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--brand-light);
  cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}
button.categorie-btn:active {
  transform: scale(0.97);
}
button.categorie-btn:disabled {
  cursor: default;
}
button.categorie-btn.correct {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}
button.categorie-btn.incorrect {
  background: var(--error);
  border-color: var(--error);
  color: #fff;
}
.categorie-item.answered button.categorie-btn:not(.correct):not(.incorrect) {
  opacity: 0.45;
}

.numero-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 1.5rem;
}
.numero-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.6rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: #fff;
}
.numero-label {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.95rem;
  word-break: break-word;
}
input.numero-input {
  width: 4.5rem;
  padding: 0.55rem 0.6rem;
  font-size: 1rem;
  text-align: center;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input.numero-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(18, 18, 18, 0.1);
}

.numero-reveal {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: 1rem 0;
  text-align: left;
}
.numero-reveal-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: #fff;
}
.numero-reveal-label {
  flex: 1 1 auto;
  min-width: 0;
  word-break: break-word;
}
.numero-reveal-value {
  font-weight: 600;
  min-width: 1.5em;
  text-align: center;
}
.numero-reveal-feedback {
  font-size: 1.2rem;
  font-weight: 700;
  min-width: 1.2em;
  text-align: center;
}
.numero-reveal-feedback.correct { animation: bounce 0.4s ease; color: var(--success); }
.numero-reveal-feedback.incorrect { animation: shake 0.35s ease; color: var(--error); }
.numero-reveal-item.revealed { border-color: var(--brand); }

button.primary {
  width: 100%;
  padding: 0.9rem;
  font-size: 1rem;
  font-weight: 600;
  margin-top: 1.5rem;
  color: white;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease;
}
button.primary:active {
  transform: scale(0.97);
  background: var(--brand-dark);
}
button.primary:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}

button:focus-visible {
  outline: 2px solid var(--brand-dark);
  outline-offset: 2px;
}

.correction {
  text-align: center;
  animation: pop-in 0.3s ease both;
}
.correction .icon { font-size: 3rem; display: inline-block; }
.correction.correct .icon { animation: bounce 0.5s ease; color: var(--success); }
.correction.proche .icon { animation: bounce 0.5s ease; color: var(--accent); }
.correction.incorrect .icon { animation: shake 0.4s ease; color: var(--error); }

@keyframes pop-in {
  0% { opacity: 0; transform: translateY(6px); }
  100% { opacity: 1; transform: translateY(0); }
}
@keyframes bounce {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

.score-final {
  text-align: center;
  animation: pop-in 0.3s ease both;
}
.score-final .code {
  font-size: 1.5rem;
  font-weight: 600;
  background: var(--brand-light);
  border: 1.5px solid var(--accent);
  padding: 0.85rem;
  border-radius: 14px;
  margin: 1rem 0;
  letter-spacing: 0.04em;
}
.score-final .winner-banner {
  display: inline-block;
  padding: 0.6rem 1rem;
  border-radius: 14px;
  background: var(--accent);
  color: var(--brand);
  font-weight: 600;
  margin: 0.5rem 0;
}

.email-form {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
input.email {
  padding: 0.8rem 1rem;
  font-size: 1rem;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input.email:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(18, 18, 18, 0.1);
}

.message { padding: 0.7rem 0.9rem; border-radius: 12px; margin-top: 0.8rem; }
.message.success { background: var(--brand-light); }
.message.error { background: #fbeaea; color: var(--error); }

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

body.has-staff-footer {
  padding-top: 3.5rem;
}

.staff-footer {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  z-index: 3;
  padding: calc(0.6rem + env(safe-area-inset-top)) 1rem 0.6rem;
  background: rgba(18, 18, 18, 0.92);
  text-align: center;
}
.staff-footer .staff-btn {
  width: 100%;
  max-width: 480px;
  padding: 0.6rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--brand);
  background: var(--accent);
  border: none;
  border-radius: 999px;
  cursor: pointer;
}
.staff-footer .staff-btn:disabled {
  opacity: 0.5;
  cursor: default;
}
