:root {
  --ink: #1b1440;
  --paper: #fffaf2;
  --accent: #ff4f7b;
  --accent2: #ffd23f;
  --accent3: #3ecfff;
  --shadow: 0 4px 0 var(--ink);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #6a5cff;
  color: var(--ink);
  font-family: "Nunito", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.sky {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 50% 62%, rgba(255, 255, 255, .55) 0, rgba(255, 255, 255, 0) 38%),
    linear-gradient(180deg, #6a5cff 0%, #b06bff 45%, #ff9ad5 100%);
  transition: filter .4s;
}
body.disco .sky { animation: disco 0.5s steps(1) infinite; }
body.rage .sky { filter: hue-rotate(-60deg) saturate(1.6) brightness(.9); }
@keyframes disco {
  0% { filter: hue-rotate(0deg); }
  25% { filter: hue-rotate(90deg); }
  50% { filter: hue-rotate(180deg); }
  75% { filter: hue-rotate(270deg); }
}

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

.top {
  position: fixed;
  top: 0; left: 0; right: 0;
  padding: 14px 16px 0;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  pointer-events: none;
}
.top h1 {
  margin: 0;
  font-family: "Luckiest Guy", cursive;
  font-weight: 400;
  font-size: clamp(40px, 8vw, 68px);
  line-height: .9;
  color: var(--accent2);
  -webkit-text-stroke: 3px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 5px 0 var(--ink);
  transform: rotate(-4deg);
  letter-spacing: 1px;
}
.top h1 span {
  font-size: .5em;
  color: var(--accent3);
  margin-left: 4px;
  vertical-align: top;
}
.top .tag {
  margin: 8px 0 0;
  font-weight: 800;
  color: var(--paper);
  text-shadow: 0 2px 0 rgba(0, 0, 0, .25);
  font-size: 14px;
  max-width: 180px;
}
.top .round { margin-left: auto; pointer-events: auto; }

button {
  font: inherit;
  font-weight: 800;
  color: var(--ink);
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 8px 14px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .08s, box-shadow .08s, background .2s;
}
button:hover { background: #fff; transform: translateY(-1px); }
button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
button:focus-visible, input:focus-visible { outline: 3px solid var(--accent3); outline-offset: 2px; }
button.round {
  width: 48px; height: 48px;
  padding: 0;
  border-radius: 50%;
  font-size: 22px;
}

.controls {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: 0 16px max(14px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}
.moves {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  pointer-events: auto;
}
.moves button { font-size: 15px; }
.moves button[data-mood="dance"] { background: var(--accent2); }
.moves button[data-seq="anniv"] { background: var(--accent); color: #fff; }
.moves button[data-seq="rap"] { background: var(--accent3); }
.moves button[data-mood="angry"] { background: #ff8a7a; }

.chat {
  display: flex;
  gap: 8px;
  width: min(640px, 100%);
  pointer-events: auto;
}
.chat input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-weight: 700;
  font-size: 16px;
  padding: 10px 14px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
}
.chat .send { background: var(--accent); color: #fff; }
.mic.listening { background: var(--accent); animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }

.bubble {
  position: fixed;
  left: 0; top: 0;
  width: max-content;   /* sinon la largeur est bridée par la position « left » */
  max-width: min(340px, calc(100vw - 32px));
  padding: 12px 16px;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 20px;
  box-shadow: var(--shadow);
  font-weight: 800;
  font-size: 17px;
  line-height: 1.3;
  pointer-events: none;
  transform: translate(-50%, -100%);
  transition: opacity .2s;
  z-index: 5;
}
.bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -13px;
  width: 18px; height: 18px;
  background: #fff;
  border-right: 3px solid var(--ink);
  border-bottom: 3px solid var(--ink);
  transform: translateX(-50%) rotate(45deg);
}
.bubble.hidden { opacity: 0; }
.bubble.small { font-size: 13px; padding: 8px 12px; border-radius: 16px; }
.bubble.side { transform: translate(0, -50%); }
.bubble.side::after { left: -12px; top: 50%; bottom: auto; transform: translateY(-50%) rotate(135deg); }
.bubble.thinking { color: #7a6fb0; font-style: italic; }
.bubble.dots { display: flex; gap: 6px; padding: 14px 18px; }
.bubble.dots span {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: #7a6fb0;
  animation: dot 0.9s ease-in-out infinite;
}
.bubble.dots span:nth-child(2) { animation-delay: .15s; }
.bubble.dots span:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-6px); opacity: 1; } }

.start {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(27, 20, 64, .55);
  backdrop-filter: blur(3px);
  z-index: 10;
  padding: 16px;
}
.start.gone { display: none; }
.start .card {
  background: var(--paper);
  border: 4px solid var(--ink);
  border-radius: 24px;
  box-shadow: 0 8px 0 var(--ink);
  padding: 26px 30px;
  text-align: center;
  max-width: 360px;
}
.start h2 { font-family: "Luckiest Guy", cursive; font-weight: 400; font-size: 30px; margin: 6px 0; }
.start p { margin: 0 0 18px; font-weight: 700; }
.start .zzz { font-size: 44px; animation: float 2s ease-in-out infinite; }
.start button { font-size: 20px; background: var(--accent2); padding: 12px 22px; }
.start input {
  width: 100%;
  font: inherit; font-weight: 700; font-size: 18px;
  padding: 10px 14px; margin-bottom: 14px;
  border: 3px solid var(--ink); border-radius: 14px;
  background: #fff; color: var(--ink);
}
.pwd-actions { display: flex; gap: 10px; justify-content: center; }
.pwd-actions button { font-size: 17px; padding: 10px 16px; }
.pwd-actions button[type="button"] { background: var(--paper); }
.start .small { font-size: 12px; color: #6b6390; margin: 12px 0 0; }
@keyframes float { 50% { transform: translateY(-8px); } }

.loading {
  position: fixed;
  inset: auto 0 45% 0;
  text-align: center;
  font-weight: 800;
  color: #fff;
  z-index: 11;
}
.loading.gone { display: none; }

@media (max-width: 560px) {
  .top .tag { display: none; }
  /* boutons sur une seule ligne qu'on fait défiler */
  .moves {
    flex-wrap: nowrap;
    justify-content: flex-start;
    width: calc(100% + 32px);
    margin: 0 -16px;
    padding: 2px 16px 7px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .moves::-webkit-scrollbar { display: none; }
  .moves button { flex: 0 0 auto; font-size: 14px; padding: 6px 11px; }
  .bubble { font-size: 15px; max-width: calc(100vw - 24px); }
}
