/* Écran téléphone des apprenants. */

html,
body {
  height: 100%;
  overscroll-behavior: none;
}

body {
  transition: background-color 260ms var(--ease-out);
}

body[data-tone='good'] {
  background: var(--good-soft);
}
body[data-tone='bad'] {
  background: var(--bad-soft);
}
body[data-tone='warn'] {
  background: var(--warn-soft);
}
body[data-tone='gold'] {
  background: var(--opt-3);
}

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 34rem;
  margin: 0 auto;
  padding: calc(0.9rem + env(safe-area-inset-top, 0px)) calc(1.1rem + env(safe-area-inset-right, 0px))
    calc(1.1rem + env(safe-area-inset-bottom, 0px)) calc(1.1rem + env(safe-area-inset-left, 0px));
}

.screen--center {
  align-items: center;
  justify-content: center;
  gap: 1rem;
  text-align: center;
}

.screen--form {
  gap: 2.2rem;
  padding-top: calc(1.4rem + env(safe-area-inset-top, 0px));
}

/* ----------------------------------------------------- rejoindre la partie */

.join {
  display: grid;
  gap: 1rem;
  margin-top: 8vh;
}

.title {
  font-size: clamp(1.9rem, 8.4vw, 2.7rem);
}

.title--question {
  font-size: clamp(1.4rem, 6.2vw, 2rem);
  line-height: 1.12;
}

.eyebrow {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.lead {
  font-size: 1.1rem;
  color: var(--ink-soft);
  text-wrap: balance;
}

.lead strong {
  color: var(--ink);
}

.input--pin,
.input--name {
  min-height: 68px;
  border-radius: 16px;
  font-size: 1.7rem;
  font-weight: 800;
  text-align: center;
  letter-spacing: -0.01em;
}

.input--pin {
  font-size: 2.2rem;
  letter-spacing: 0.06em;
}

.form-error {
  padding: 0.65rem 0.9rem;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: var(--bad-soft);
  font-weight: 600;
}

/* ------------------------------------------------------------ en-tête joueur */

.me {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.8rem;
}

.me__name {
  max-width: 60%;
  overflow: hidden;
  padding: 0.3em 0.8em;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--card);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.me__score {
  font-size: 1.15rem;
  font-weight: 800;
}

.me__score small {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-soft);
}

/* -------------------------------------------------------------------- scène */

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  min-height: 0;
  /* Entrée sans passer par l'invisible : si l'animation ne démarre pas, le contenu reste lisible. */
  animation: settle-in 260ms var(--ease-out);
}

@keyframes settle-in {
  from {
    transform: translateY(12px);
  }
}

@keyframes stamp-in {
  from {
    transform: scale(0.6);
  }
}

.stage--center {
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  padding-bottom: 8vh;
  text-align: center;
}

.qhead {
  display: grid;
  gap: 0.55rem;
}

.qhead__text {
  font-size: clamp(1.15rem, 5vw, 1.45rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.hint {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink-soft);
}

/* -------------------------------------------------------------------- chrono */

.timer {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.timer__track {
  flex: 1;
  height: 12px;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--card);
}

.timer__fill {
  height: 100%;
  background: var(--ink);
  transform-origin: left center;
  will-change: transform;
}

.timer--hurry .timer__fill {
  background: var(--accent);
}

.timer__label {
  min-width: 3.2ch;
  font-weight: 800;
  text-align: right;
}

.timer--idle {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-soft);
}

/* ------------------------------------------------------------------ réponses */

.opts {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 0;
  padding-bottom: 6px;
}

.opt {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-height: 64px;
  max-height: 132px;
  padding: 0.7rem 0.95rem;
  border: var(--border);
  border-radius: 18px;
  background: var(--opt);
  color: var(--ink);
  font-size: 1.12rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 5px 0 var(--ink);
  -webkit-touch-callout: none;
  transition:
    transform 100ms var(--ease-out),
    box-shadow 100ms var(--ease-out);
}

.opt:active,
.opt[aria-pressed='true'] {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--ink);
}

.opt__text {
  flex: 1;
  overflow-wrap: anywhere;
}

.opt__tick {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--card);
}

.opt__tick .mark {
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  color: transparent;
  animation: none;
}

.opt__tick .mark svg {
  width: 18px;
  height: 18px;
}

.opt[aria-pressed='true'] .opt__tick {
  background: var(--ink);
}

.opt[aria-pressed='true'] .opt__tick .mark {
  color: var(--paper);
}

.opt--static {
  flex: none;
  width: 100%;
  min-height: 56px;
  cursor: default;
  box-shadow: 0 1px 0 var(--ink);
}

.opt--static:active {
  transform: none;
}

.picked {
  display: grid;
  gap: 0.6rem;
  width: 100%;
}

.quote {
  width: 100%;
  padding: 0.9rem 1rem;
  border: var(--border);
  border-radius: 16px;
  background: var(--card);
  font-size: 1.1rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.answer-form {
  display: grid;
  gap: 0.6rem;
}

.answer-text {
  min-height: 132px;
  border-radius: 16px;
  font-size: 1.15rem;
  font-weight: 600;
}

.answer-form__foot {
  display: flex;
  justify-content: flex-end;
  font-size: 0.86rem;
}

/* ----------------------------------------------------------------- résultats */

.mark {
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
  border: var(--border);
  border-radius: 50%;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 5px 0 var(--ink);
  animation: stamp-in 380ms var(--ease-spring);
}

.mark svg {
  width: 52px;
  height: 52px;
}

body[data-tone='good'] .mark {
  background: var(--good);
  color: #fff;
}

body[data-tone='bad'] .mark {
  background: var(--bad);
  color: #fff;
}

.points {
  padding: 0.3em 0.9em;
  border: var(--border);
  border-radius: 999px;
  background: var(--card);
  font-size: 1.5rem;
  font-weight: 800;
}

.rank {
  font-size: clamp(4.5rem, 26vw, 7.5rem);
  font-weight: 800;
  line-height: 0.9;
  letter-spacing: -0.05em;
  animation: stamp-in 420ms var(--ease-spring);
}

/* -------------------------------------------------------------------- bandeau */

.banner {
  position: fixed;
  left: 50%;
  bottom: calc(0.9rem + env(safe-area-inset-bottom, 0px));
  z-index: 10;
  width: max-content;
  max-width: calc(100vw - 2rem);
  padding: 0.6rem 1rem;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.92rem;
  font-weight: 600;
  transform: translateX(-50%);
}

@media (min-height: 760px) {
  .opt {
    font-size: 1.2rem;
  }
}
