/*
 * Floppy Couac — habillage. Les couleurs de base et le rem viennent de public/css/app.css.
 * Le vol est un canvas plein écran : ici, on ne règle que son cadre et ce qui se pose dessus
 * (compte à rebours, carte de chute, tableau de la volée). Chaque joueur a sa couleur (--c).
 */

.cp {
  --cp-sky: #d6efff;
  --cp-sky-deep: #9fd3f3;
  --cp-deep: #2d6b93;
  --cp-sun: #fff1b8;
}

.cp-host {
  max-width: 90rem;
  margin: 0 auto;
  padding: 0.5rem 0 1.5rem;
}

.cp-main {
  position: relative;
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
}

.cp-title {
  margin: 0;
  font-size: clamp(1.7rem, 3.4vw, 3.2rem);
  font-weight: 900;
  line-height: 1.12;
  letter-spacing: -0.035em;
  text-align: center;
  overflow-wrap: anywhere;
}

.cp-hint {
  max-width: 42rem;
  margin: 0;
  color: var(--lp-mute);
  font-size: 1rem;
  line-height: 1.6;
  text-align: center;
}

.cp-eyebrow {
  margin: 0;
  color: var(--cp-deep);
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 0.15em;
}

.cp-big {
  font-size: 5rem;
  line-height: 1.1;
}

.cp-big img {
  width: 9rem;
  height: 9rem;
}

/* Le portrait d'un animal volant : son modèle, en image. */
.cp-pic {
  display: block;
  max-width: none;
}

.cp-pic--none {
  display: grid;
  place-items: center;
  color: var(--lp-mute);
  font-weight: 900;
}

.cp-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
}

.cp-count {
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.cp-face {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 0.2rem solid var(--c);
  border-radius: 0.8rem;
  background: #fff;
  font-size: 1.1rem;
  line-height: 1;
  overflow: hidden;
}

.cp-face img {
  width: 2.2rem;
  height: 2.2rem;
}

.cp-clock {
  padding: 0.2rem 1.4rem;
  border: 2px solid var(--lp-ink);
  border-radius: 1.2rem;
  background: var(--cp-sky);
  box-shadow: 4px 5px 0 var(--lp-ink);
  font-size: 3.6rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.cp-clock--small {
  padding: 0.1rem 0.7rem;
  border-width: 1.5px;
  border-radius: 0.7rem;
  box-shadow: none;
  font-size: 1.2rem;
}

/* ---------- choix des animaux ---------- */

.cp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 1rem;
  width: 100%;
  max-width: 62rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cp-grid li {
  display: grid;
  justify-items: center;
  gap: 0.15rem;
  padding: 1rem 0.8rem;
  border: 1px solid #c3d8e6;
  border-radius: 1.3rem;
  background: linear-gradient(160deg, #fbfeff, var(--cp-sky));
  box-shadow: 0 4px 0 var(--c), 0 9px 20px #2d6b9312;
  text-align: center;
}

.cp-grid li.is-waiting {
  border-style: dashed;
  background: #fffdf8;
  box-shadow: none;
  color: var(--lp-mute);
}

.cp-grid__face {
  display: grid;
  place-items: center;
  min-height: 6.5rem;
  font-size: 3rem;
  line-height: 1.15;
}

.cp-grid__face img {
  width: 6.5rem;
  height: 6.5rem;
}

.cp-grid b {
  font-size: 1.1rem;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.cp-grid li > span:last-child {
  color: var(--lp-mute);
  font-size: 0.85rem;
}

.cp-animals {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
  width: 100%;
}

.cp-animal {
  display: grid;
  justify-items: center;
  gap: 0.1rem;
  min-width: 0;
  padding: 0.6rem 0.3rem;
  border: 1.5px solid #bcd3e3;
  border-radius: 1.1rem;
  background: linear-gradient(160deg, #fbfeff, var(--cp-sky));
  box-shadow: 0 3px 0 #b3cbdc, 0 6px 14px #2d6b930d;
  color: var(--lp-ink);
  font: inherit;
  font-size: 0.8rem;
  touch-action: manipulation;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.cp-animal__face img {
  width: 4.1rem;
  height: 4.1rem;
}

.cp-animal b {
  max-width: 100%;
  overflow: hidden;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cp-animal[aria-pressed="true"] {
  border-color: var(--lp-ink);
  background: linear-gradient(145deg, #fff6d0, #ffe08a);
  box-shadow: 0 3px 0 var(--lp-ink);
  transform: translateY(-2px);
}

@media (hover: hover) {
  .cp-animal:not(:disabled):hover {
    border-color: #6f9fbf;
    transform: translateY(-3px);
  }
}

.cp-animal:disabled {
  border-style: dashed;
  box-shadow: none;
  color: var(--lp-mute);
}

.cp-animal:disabled .cp-animal__face {
  opacity: 0.35;
  filter: grayscale(0.6);
}

.cp-animal:focus-visible {
  outline: 0.2em solid var(--lp-purple);
  outline-offset: 0.15em;
}

/* ---------- le vol : la page devient le ciel ---------- */

.lp-html:has(.lp-stage .cp--fly),
.lp-body:has(.lp-stage .cp--fly) {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

.lp-body .lp-phone:has(.lp-stage > .cp--fly),
.lp-body .lp-host:has(.lp-stage > .cp--fly) {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  margin: 0;
  padding: 0;
}

.lp-body .lp-host:has(.lp-stage > .cp--fly) .lp-endbar,
.lp-body .lp-host:has(.lp-stage > .cp--fly) .lp-top > :not(.lp-top__tools),
.lp-body .lp-phone:has(.lp-stage > .cp--fly) .lp-me > :not(.lp-iconbtn) {
  display: none;
}

.lp-body .lp-phone:has(.lp-stage > .cp--fly) .lp-stage,
.lp-body .lp-host:has(.lp-stage > .cp--fly) .lp-stage,
.lp-body .lp-stage > .cp--fly {
  width: 100%;
  max-width: none;
  height: 100%;
  min-height: 0;
  margin: 0;
  padding: 0;
}

.lp-body .lp-phone:has(.lp-stage > .cp--fly) .lp-me,
.lp-body .lp-host:has(.lp-stage > .cp--fly) .lp-top {
  position: absolute;
  top: max(0.5rem, env(safe-area-inset-top));
  right: max(0.6rem, env(safe-area-inset-right));
  z-index: 6;
  height: auto;
  gap: 0.4rem;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
}

.lp-body .lp-phone:has(.lp-stage > .cp--fly) .lp-me .lp-iconbtn {
  width: 34px;
  height: 34px;
  min-height: 0;
  opacity: 0.85;
}

.cp-fly {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #c6e9f8;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.cp-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.cp-center {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 3;
  max-width: 86%;
  padding: 0.5rem 1.1rem;
  border: 2px solid var(--lp-ink);
  border-radius: 1rem;
  background: rgba(255, 253, 248, 0.95);
  box-shadow: 3px 4px 0 var(--lp-ink);
  font-size: 1.6rem;
  font-weight: 900;
  line-height: 1.3;
  text-align: center;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.cp-center.is-count {
  padding: 0.5rem 2rem;
  font-size: 7rem;
  line-height: 1.1;
}

.cp-center[hidden],
.cp-down[hidden],
.cp-board__row[hidden] {
  display: none;
}

/* Sur le téléphone, le message se pose sous l'animal : il ne cache pas les piliers qui arrivent. */
.cp-phone .cp-center {
  top: 64%;
  width: max-content;
  max-width: 82%;
  padding: 0.4rem 0.9rem;
  font-size: 1.05rem;
}

.cp-phone .cp-center.is-count {
  top: 40%;
  padding: 0.4rem 1.8rem;
  font-size: 4.5rem;
}

/* La carte de chute : la distance du vol, et qui vole encore. */
.cp-down {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 4;
  display: grid;
  justify-items: center;
  gap: 0.25rem;
  width: min(20rem, calc(100% - 2rem));
  padding: 1rem 1.2rem 1.1rem;
  border: 2px solid var(--lp-ink);
  border-radius: 1.3rem;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: 4px 5px 0 var(--lp-ink);
  text-align: center;
  transform: translate(-50%, -50%);
  animation: cp-pop 260ms ease-out;
}

.cp-down strong {
  font-size: 1.5rem;
  font-weight: 900;
}

.cp-down__meters {
  font-size: 3.4rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}

.cp-down p {
  margin: 0;
  font-weight: 800;
  line-height: 1.4;
}

.cp-down .cp-down__small {
  color: var(--lp-mute);
  font-size: 0.85rem;
  font-weight: 700;
}

/* Grand écran : le numéro du vol en haut à gauche, la volée en haut à droite. */
.cp-chips {
  position: absolute;
  top: max(0.9rem, env(safe-area-inset-top));
  left: max(1rem, env(safe-area-inset-left));
  z-index: 3;
  display: flex;
  gap: 0.5rem;
  pointer-events: none;
}

.cp-chip {
  padding: 0.25rem 0.85rem;
  border: 1.5px solid var(--lp-ink);
  border-radius: 2rem;
  background: rgba(255, 253, 248, 0.92);
  font-size: clamp(0.9rem, 1.4vw, 1.3rem);
  font-weight: 900;
}

.cp-board {
  position: absolute;
  top: calc(max(0.9rem, env(safe-area-inset-top)) + 3rem);
  right: max(1rem, env(safe-area-inset-right));
  z-index: 3;
  display: flex;
  width: clamp(12rem, 19vw, 18rem);
  flex-direction: column;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
  pointer-events: none;
}

.cp-board__row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.7rem 0.25rem 0.3rem;
  border: 1.5px solid var(--lp-ink);
  border-radius: 1rem;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: 0 3px 0 var(--c);
  font-size: clamp(0.85rem, 1.25vw, 1.15rem);
  transition: opacity 300ms ease;
}

.cp-board__row .cp-face {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 0.65rem;
}

.cp-board__row .cp-face img {
  width: 1.9rem;
  height: 1.9rem;
}

.cp-board__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cp-board__state {
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  white-space: nowrap;
}

.cp-board__row.is-down {
  border-color: #b9aec4;
  box-shadow: none;
  opacity: 0.78;
}

.cp-board__row.is-down .cp-board__state {
  color: var(--lp-mute);
}

.cp-stop {
  position: absolute;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 3;
}

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

.cp-results {
  display: grid;
  gap: 0.55rem;
  width: 100%;
  max-width: 44rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cp-results li {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.5rem 1rem 0.5rem 0.7rem;
  border: 1px solid var(--lp-line);
  border-radius: 0.9rem;
  background: #fff;
}

.cp-results li.is-first {
  border-color: var(--lp-ink);
  background: #fff7db;
  box-shadow: 2px 3px 0 var(--lp-amber-deep);
}

.cp-results li.is-me {
  outline: 0.18rem solid var(--lp-purple);
  outline-offset: 0.1rem;
}

.cp-results__rank {
  flex: none;
  width: 2.3rem;
  font-weight: 900;
}

.cp-results__name {
  flex: 1;
  min-width: 0;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.cp-results__detail {
  color: var(--lp-mute);
  font-size: 0.85rem;
  white-space: nowrap;
}

.cp-results__gain {
  padding: 0.1rem 0.55rem;
  border-radius: 1rem;
  background: var(--cp-sky);
  color: var(--cp-deep);
  font-size: 0.85rem;
  font-weight: 900;
  white-space: nowrap;
}

.cp-results b {
  min-width: 3.8rem;
  font-weight: 900;
  text-align: right;
  white-space: nowrap;
}

/* ---------- téléphone ---------- */

.cp-phone .cp-title {
  font-size: 1.6rem;
}

.cp-phone .cp-results li {
  gap: 0.45rem;
  padding: 0.45rem 0.6rem;
}

.cp-phone .cp-results__detail {
  display: none;
}

@media (max-height: 640px) {
  .cp-phone .cp-animal__face img {
    width: 3.2rem;
    height: 3.2rem;
  }
}

@media (min-width: 560px) {
  .cp-animals {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@keyframes cp-pop {
  from { opacity: 0; transform: translate(-50%, -46%) scale(0.92); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

@media (prefers-reduced-motion: reduce) {
  .cp-down,
  .cp-animal,
  .cp-board__row {
    animation: none;
    transition: none;
  }
}

/* ---------- mode solo (screen.php + solo.js) : une page à part, sans salle ---------- */

.cps {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 0 1.25rem 1.25rem;
}

.cps-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 4.2rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--lp-line);
}

.cps-brand {
  color: #28364b;
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: -0.05em;
  text-decoration: none;
}

.cps-back {
  padding: 0.75rem 0;
  color: var(--lp-mute);
  font-size: 0.85rem;
  font-weight: 800;
  text-decoration: none;
}

.cps-back:hover {
  color: var(--lp-purple);
}

/* Rien à côté du jeu : le ciel prend tout l'écran sous la barre de navigation. */
.cps-game {
  display: grid;
  flex: 1;
  min-height: 0;
}

.cps-scene {
  position: relative;
  height: calc(100dvh - 6.45rem);
  min-height: 22rem;
  overflow: hidden;
  border: 1.5px solid var(--lp-ink);
  border-radius: 1.2rem;
  background: #c6e9f8;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.cps-scene .cp-center {
  top: 62%;
  width: max-content;
  max-width: 86%;
  font-size: 1.15rem;
}

/* Le choix de l'animal, en bas du ciel, seulement avant le décollage. */
.cps-pick {
  position: absolute;
  right: 0.6rem;
  bottom: 0.7rem;
  left: 0.6rem;
  z-index: 3;
  display: flex;
  gap: 0.4rem;
  justify-content: safe center;
  padding: 0.35rem;
  overflow-x: auto;
  border: 1.5px solid var(--lp-ink);
  border-radius: 1rem;
  background: rgba(255, 253, 248, 0.94);
  scrollbar-width: thin;
}

.cps-pick[hidden],
.cps-over[hidden] {
  display: none;
}

.cps-pick__animal {
  display: grid;
  flex: none;
  place-items: center;
  width: 3.4rem;
  height: 3.4rem;
  padding: 0.15rem;
  border: 1.5px solid #bcd3e3;
  border-radius: 0.8rem;
  background: linear-gradient(160deg, #fbfeff, var(--cp-sky));
  touch-action: manipulation;
}

.cps-pick__animal img {
  width: 100%;
  height: 100%;
}

.cps-pick__animal[aria-pressed="true"] {
  border-color: var(--lp-ink);
  background: linear-gradient(145deg, #fff6d0, #ffe08a);
  box-shadow: 0 2px 0 var(--lp-ink);
}

.cps-pick__animal:focus-visible {
  outline: 0.2em solid var(--lp-purple);
  outline-offset: 0.1em;
}

.cps-over .lp-btn {
  margin-top: 0.6rem;
}

.cps-over__best {
  color: #b5541c;
}

@media (max-width: 860px), (orientation: portrait) {
  .cps { padding-inline: 0.8rem; padding-bottom: 0.8rem; }
  .cps-nav { height: 3.7rem; margin-bottom: 0.7rem; }
  .cps-scene { height: calc(100dvh - 5.2rem); min-height: 20rem; }
  .cps-pick { justify-content: flex-start; }
  .cps-pick__animal { width: 3rem; height: 3rem; }
}
