html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #1f1d3d;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

#game {
  display: block;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  touch-action: none;
}

#title {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 16vh;
  pointer-events: none;
  color: #f4ecd8;
  font-family: "Avenir Next", "Century Gothic", "Futura", system-ui, sans-serif;
  text-align: center;
  opacity: 1;
  transition: opacity 1.6s ease;
}

#title[hidden] { display: none; }
#title.gone { opacity: 0; }

#title h1 {
  margin: 0;
  font-weight: 300;
  font-size: clamp(34px, 8vw, 72px);
  letter-spacing: 0.42em;
  margin-right: -0.42em;
  text-transform: uppercase;
}

#title p {
  margin: 1.2em 0 0;
  font-weight: 400;
  font-size: clamp(11px, 1.6vw, 15px);
  letter-spacing: 0.3em;
  opacity: 0.75;
}

/* — bouton et écran de réglages — */
#gear {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 244, 215, 0.4);
  background: rgba(22, 20, 44, 0.38);
  color: #fff4d7;
  cursor: pointer;
}
#gear svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  display: block;
  margin: auto;
}
#gear:focus-visible, #settings button:focus-visible, #settings input:focus-visible {
  outline: 2px solid #ffd682;
  outline-offset: 2px;
}

#settings {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(14, 13, 34, 0.62);
  font-family: "Avenir Next", "Century Gothic", "Futura", system-ui, sans-serif;
  color: #f4ecd8;
}
#settings[hidden] { display: none; }

#settings .panel {
  width: min(420px, 100%);
  max-height: 100%;
  overflow-y: auto;
  box-sizing: border-box;
  padding: 22px 22px 18px;
  border-radius: 22px;
  background: #2a2750;
  border: 1px solid rgba(255, 244, 215, 0.16);
  box-shadow: 0 24px 60px rgba(8, 7, 24, 0.5);
}
#settings h2 {
  margin: 0 0 14px;
  font-weight: 300;
  font-size: 22px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}
#settings .row, #settings .group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 48px;
  font-size: 15px;
}
#settings .group {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  margin: 10px 0 12px;
}
#settings input[type="range"] {
  flex: 0 1 190px;
  accent-color: #ffd682;
  height: 28px;
}
#settings input[type="checkbox"] {
  width: 24px;
  height: 24px;
  accent-color: #ffd682;
}
#settings button {
  min-height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 244, 215, 0.28);
  background: rgba(255, 255, 255, 0.05);
  color: inherit;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
#settings .seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 6px;
}
#settings button[aria-pressed="true"], #settings button[aria-current="true"] {
  background: #ffd682;
  border-color: #ffd682;
  color: #2a2344;
  font-weight: 600;
}
#settings .chapters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 6px;
}
#settings button:disabled {
  opacity: 0.38;
  cursor: default;
}
#settings .actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
#settings .actions button { flex: 1; }
#settings .primary {
  background: #f4ecd8;
  border-color: #f4ecd8;
  color: #2a2344;
  font-weight: 600;
}
#settings .armed {
  background: #e0607a;
  border-color: #e0607a;
  color: #fff;
}
