/* La Chasse à l'Ami — néobrutalisme cartoon. Animations limitées à transform et opacity. */

@font-face {
  font-family: 'Lilita One';
  src: url('/fonts/LilitaOne-Regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Space Grotesk';
  src: url('/fonts/SpaceGrotesk-Regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Space Grotesk';
  src: url('/fonts/SpaceGrotesk-Bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

:root {
  --ink: #111;
  --paper: #fff8e7;
  --yellow: #ffd93d;
  --pink: #ff6fb5;
  --blue: #2f6bff;
  --green: #8bf13c;
  --orange: #ff8a1f;
  --red: #ff1f3d;
  --mint: #1fd6a0;
  --border: 4px solid var(--ink);
  --shadow: 6px 6px 0 var(--ink);
  --shadow-sm: 4px 4px 0 var(--ink);
  --radius: 14px;
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --font-display: 'Lilita One', 'Arial Rounded MT Bold', 'Arial Black', system-ui, sans-serif;
  --font-body: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.4;
  color: var(--ink);
  background-color: var(--yellow);
  background-image: radial-gradient(rgba(0, 0, 0, 0.12) 1.5px, transparent 1.6px);
  background-size: 22px 22px;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#app {
  max-width: 520px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

h1, h2, h3, legend, .btn {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0.01em;
}
h2 { font-size: 1.8rem; margin: 0; }
h3 { margin: 0; font-size: 1.3rem; }

.screen {
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: screen-in 0.35s var(--spring) both;
}
@keyframes screen-in {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .btn { flex: 1 1 0; }

.card {
  background: #fff;
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.topbar { display: flex; align-items: center; gap: 12px; }
.lead { margin: 0; font-weight: 700; }
.hint { margin: 0; font-size: 0.95rem; }

/* ───────── Boutons (effet ressort) ───────── */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  min-width: 48px;
  padding: 10px 18px;
  font-size: 1.25rem;
  color: var(--ink);
  background: #fff;
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.25s var(--spring);
  touch-action: manipulation;
  user-select: none;
}
.btn:active:not(:disabled) {
  transform: translate(4px, 4px);
  box-shadow: 2px 2px 0 var(--ink);
  transition-duration: 0.05s;
}
.btn:focus-visible { outline: 4px dashed var(--blue); outline-offset: 4px; }
.btn:disabled {
  background: #ddd;
  color: #666;
  box-shadow: var(--shadow-sm);
  cursor: not-allowed;
}
.btn-big { min-height: 68px; font-size: 1.6rem; }
.btn-small { min-height: 48px; font-size: 1rem; }
.btn-icon { width: 52px; padding: 0; font-size: 1.6rem; }
.btn-pink { background: var(--pink); }
.btn-blue { background: var(--blue); color: #fff; }
.btn-green { background: var(--green); }
.btn-yellow { background: var(--yellow); }
.btn-orange { background: var(--orange); }
.btn-red { background: var(--red); color: #fff; }
.btn-ghost { background: transparent; box-shadow: none; border-style: dashed; }

/* ───────── Accueil ───────── */
.screen-home { align-items: stretch; text-align: center; padding-top: 4vh; }
.logo {
  width: min(78%, 320px);
  height: auto;
  margin: 0 auto;
  animation: logo-bob 3s ease-in-out infinite;
}
@keyframes logo-bob {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-8px) rotate(2deg); }
}
.title { font-size: 2.4rem; margin: 0; text-shadow: 3px 3px 0 #fff; }
.tagline { margin: 0 0 8px; font-weight: 700; font-size: 1.1rem; }
.rules { text-align: left; }
.rules summary { font-family: var(--font-display); font-size: 1.25rem; cursor: pointer; min-height: 32px; }
.rules ol { margin: 10px 0 0; padding-left: 22px; }
.rules li { margin: 6px 0; }

/* ───────── Formulaires ───────── */
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-family: var(--font-display); font-size: 1.3rem; padding: 0; }
.input {
  font: 700 1.3rem var(--font-body);
  padding: 12px 14px;
  min-height: 56px;
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  background: #fff;
  color: var(--ink);
  width: 100%;
}
.input:focus { outline: 4px solid var(--blue); outline-offset: 2px; }
.input-code {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 2.2rem;
  letter-spacing: 0.3em;
  text-align: center;
  text-transform: uppercase;
}
.form-error {
  margin: 0;
  padding: 12px 14px;
  background: var(--red);
  color: #fff;
  font-weight: 700;
  border: var(--border);
  border-radius: var(--radius);
  animation: shake 0.4s both;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

/* Grille de personnages */
.char-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 12px; }
.char-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px 6px;
  min-height: 48px;
  background: var(--tint, #fff);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  font: 700 0.9rem var(--font-body);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.25s var(--spring);
}
.char-card .char-img { width: 64px; height: 64px; }
.char-card[aria-pressed='true'] {
  background: var(--c);
  transform: translate(-2px, -2px) scale(1.04);
  box-shadow: var(--shadow);
}
.char-card[aria-pressed='true'] .char-img { animation: wobble 1.2s ease-in-out infinite; }
.char-card:disabled { cursor: not-allowed; opacity: 0.35; filter: grayscale(1); }
.char-card:disabled::after {
  content: 'Pris';
  position: absolute;
  top: 34%;
  transform: rotate(-12deg);
  background: var(--ink);
  color: #fff;
  padding: 2px 8px;
  border-radius: 6px;
}
@keyframes wobble {
  0%, 100% { transform: rotate(-5deg); }
  50% { transform: rotate(5deg) translateY(-3px); }
}

/* Difficultés */
.diff-list { display: flex; flex-direction: column; gap: 10px; }
.diff {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 2px;
  padding: 12px 14px;
  min-height: 56px;
  background: #fff;
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  color: var(--ink);
  font: 400 1rem var(--font-body);
}
.diff strong { font: 400 1.4rem var(--font-display); }
.diff[aria-pressed='true'] { background: var(--mint); }
.diff:disabled { background: #e9e9e9; color: #777; }
.badge {
  position: absolute;
  top: -12px;
  right: 12px;
  padding: 2px 10px;
  background: var(--pink);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 999px;
  font: 400 0.95rem var(--font-display);
  transform: rotate(4deg);
}

.stepper { display: flex; align-items: center; gap: 18px; }
.stepper-value { font: 400 2.6rem var(--font-display); min-width: 2ch; text-align: center; }

/* ───────── Autorisations ───────── */
.perm-list { display: flex; flex-direction: column; gap: 14px; }
.perm { display: flex; flex-direction: column; gap: 10px; }
.perm-head { display: flex; align-items: center; gap: 10px; }
.perm-head h3 { flex: 1; }
.perm-icon { font-size: 1.6rem; }
.perm-detail { margin: 0; }
.pill {
  padding: 3px 10px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.85rem;
  background: #eee;
  white-space: nowrap;
}
.pill[data-state='ok'] { background: var(--green); }
.pill[data-state='pending'] { background: var(--yellow); }
.pill[data-state='bad'] { background: var(--red); color: #fff; }
.perm[data-state='ok'] { background: #effce4; }
.privacy {
  margin: 0;
  padding: 12px 14px;
  background: var(--ink);
  color: #fff;
  border-radius: var(--radius);
  font-weight: 700;
}
.perm-help { background: #ffe4f1; }
.perm-help h4 { margin: 0 0 6px; font-family: var(--font-display); font-weight: 400; font-size: 1.2rem; }
.perm-help ul { margin: 0; padding-left: 20px; }

/* ───────── Salon ───────── */
.code-card { display: flex; flex-direction: column; align-items: center; gap: 10px; background: var(--pink); }
.code-label { font-weight: 700; }
.code-big {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: clamp(2.6rem, 13vw, 4rem);
  letter-spacing: 0.12em;
  line-height: 1;
  padding: 10px 14px;
  background: #fff;
  border: var(--border);
  border-radius: var(--radius);
  user-select: all;
}
.code-card .row { width: 100%; }
.code-link { color: var(--ink); font-weight: 700; word-break: break-all; }
.section-title { display: flex; justify-content: space-between; font-family: var(--font-display); font-weight: 400; }
.self-check { background: var(--orange); display: flex; flex-direction: column; gap: 10px; }
.self-check p { margin: 0; font-weight: 700; }

.player-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.player {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 64px;
  padding: 8px 12px;
  background: var(--tint, #fff);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  color: var(--ink);
  font: inherit;
  text-align: left;
  animation: pop-in 0.4s var(--spring) both;
}
button.player { cursor: pointer; }
.player .char-img { width: 48px; height: 48px; flex: none; }
.player-name { flex: 1; font-weight: 700; font-size: 1.1rem; overflow: hidden; text-overflow: ellipsis; }
.player-name small { display: block; font-weight: 400; font-size: 0.8rem; }
.player.is-prey { background: var(--red); color: #fff; }
.player.offline { opacity: 0.55; }
.lights { display: flex; flex-direction: column; gap: 4px; }
.light {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
  padding: 1px 7px 1px 4px;
  background: #fff;
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 999px;
}
.light::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--red);
}
.light.on::before { background: var(--green); }
@keyframes pop-in {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: none; }
}

.seg { display: flex; gap: 10px; }
.seg-opt { flex: 1; position: relative; }
.seg-opt input { position: absolute; opacity: 0; pointer-events: none; }
.seg-opt span {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 56px;
  padding: 8px;
  border: var(--border);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-sm);
  font-weight: 700;
  cursor: pointer;
}
.seg-opt input:checked + span { background: var(--blue); color: #fff; }
.seg-opt input:focus-visible + span { outline: 4px dashed var(--ink); outline-offset: 3px; }
.waiting { text-align: center; font-weight: 700; }

/* ───────── Révélation ───────── */
.screen-reveal { min-height: 80dvh; justify-content: center; }
.reveal-card {
  text-align: center;
  padding: 28px 18px;
  border: var(--border);
  border-radius: 24px;
  box-shadow: 10px 10px 0 var(--ink);
  background: var(--blue);
  color: #fff;
  animation: reveal-in 0.9s var(--spring) both;
}
.reveal-card.is-prey { background: var(--red); }
.reveal-img .char-img { width: 150px; height: 150px; animation: wobble 1.4s ease-in-out infinite; }
.reveal-kicker { margin: 8px 0 0; font-weight: 700; font-size: 1.2rem; }
.reveal-title { font-size: clamp(2.6rem, 13vw, 4rem); line-height: 1; text-shadow: 4px 4px 0 var(--ink); }
.reveal-sub { font-weight: 700; font-size: 1.2rem; }
@keyframes reveal-in {
  0% { opacity: 0; transform: scale(0.2) rotate(-20deg); }
  60% { opacity: 1; transform: scale(1.08) rotate(4deg); }
  100% { transform: none; }
}

/* ───────── Fuite ───────── */
.screen-flee { min-height: 80dvh; justify-content: center; text-align: center; align-items: center; }
.flee-title { font-size: clamp(3rem, 16vw, 5rem); text-shadow: 5px 5px 0 #fff; }
.countdown {
  font: 400 clamp(4.5rem, 28vw, 8rem) var(--font-display);
  line-height: 1;
  padding: 16px 26px;
  background: #fff;
  border: var(--border);
  border-radius: 24px;
  box-shadow: 10px 10px 0 var(--ink);
}
.countdown.tick { animation: tick-pop 0.35s var(--spring); }
@keyframes tick-pop {
  from { transform: scale(1.12); }
  to { transform: scale(1); }
}
.flee-sub { margin: 0; font-weight: 700; font-size: 1.2rem; }
.screen-flee.is-hunter { background: transparent; }

/* ───────── Radar ───────── */
.hud-top { display: flex; justify-content: space-between; gap: 10px; }
.chip, .zone-chip {
  padding: 6px 12px;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  font-weight: 700;
  font-size: 1.05rem;
}
.chip-timer { font-family: var(--font-display); font-size: 1.4rem; font-weight: 400; }
.out-banner {
  padding: 12px;
  text-align: center;
  font: 400 1.4rem var(--font-display);
  color: #fff;
  background: var(--red);
  border: var(--border);
  border-radius: var(--radius);
  animation: blink 0.8s steps(2, jump-none) infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
.self-lost { padding: 10px 12px; background: var(--orange); border: var(--border); border-radius: var(--radius); font-weight: 700; }

.target { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--tint, #fff); }
.target .char-img { width: 56px; height: 56px; }
.target-text { display: flex; flex-direction: column; }
.target-text strong { font: 400 1.6rem var(--font-display); }

.radar {
  position: relative;
  width: min(84vw, 380px);
  aspect-ratio: 1;
  margin: 4px auto;
  border: 5px solid var(--ink);
  border-radius: 50%;
  box-shadow: 8px 8px 0 var(--ink);
  overflow: hidden;
  background: #1b1b2f;
  isolation: isolate;
}
.radar-layers, .radar-layer, .radar-rings, .radar-pulse, .radar-rose, .radar-arrow { position: absolute; inset: 0; }
.radar-layer { opacity: 0; transition: opacity 0.6s ease; }
.radar-layer.on { opacity: 1; }
.radar-rings {
  background:
    radial-gradient(circle, transparent 23%, rgba(0, 0, 0, 0.35) 23.6%, transparent 24.6%),
    radial-gradient(circle, transparent 46%, rgba(0, 0, 0, 0.35) 46.6%, transparent 47.6%),
    linear-gradient(transparent 49.6%, rgba(0, 0, 0, 0.25) 49.6%, rgba(0, 0, 0, 0.25) 50.4%, transparent 50.4%),
    linear-gradient(90deg, transparent 49.6%, rgba(0, 0, 0, 0.25) 49.6%, rgba(0, 0, 0, 0.25) 50.4%, transparent 50.4%);
}
.radar-pulse {
  border-radius: 50%;
  border: 6px solid #fff;
  opacity: 0;
  transform: scale(0.1);
}
.radar-rose { will-change: transform; }
.rose-n {
  position: absolute;
  top: 6px;
  left: 50%;
  margin-left: -14px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  font: 400 1rem var(--font-display);
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 50%;
}
.radar-arrow { inset: 18%; will-change: transform; filter: drop-shadow(4px 4px 0 var(--ink)); }
.radar.is-lost .radar-arrow { opacity: 0.2; }

.signal { display: flex; align-items: center; gap: 16px; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 56px; }
.bar {
  width: 18px;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}
.bar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--lvl, var(--ink));
  opacity: 0;
  transition: opacity 0.3s;
}
.bar.on::after { opacity: 1; }
.signal-label { font: 400 1.9rem var(--font-display); line-height: 1.05; }
.signal.is-lost .signal-label { color: #777; }
.danger {
  padding: 10px 12px;
  text-align: center;
  font: 400 1.3rem var(--font-display);
  background: var(--orange);
  border: var(--border);
  border-radius: var(--radius);
}
.danger.zero { background: #fff; }

.btn-touch {
  min-height: 96px;
  font-size: 2.6rem;
  color: #fff;
  background: var(--red);
  box-shadow: 8px 8px 0 var(--ink);
  animation: touch-bounce 0.9s var(--spring) infinite alternate;
}
@keyframes touch-bounce {
  from { transform: scale(0.96); }
  to { transform: scale(1.04); }
}
.touch-pending { text-align: center; font-weight: 700; background: var(--yellow); }

/* ───────── Modal touche ───────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(17, 17, 17, 0.7);
}
.modal-card { width: min(440px, 100%); text-align: center; background: var(--yellow); animation: reveal-in 0.5s var(--spring) both; }
.modal-img .char-img { width: 96px; height: 96px; }
.modal-q { font: 400 1.7rem var(--font-display); margin: 8px 0; }
.modal-timer { font: 400 3rem var(--font-display); margin-bottom: 12px; }

/* ───────── Résultats ───────── */
.screen-results { position: relative; text-align: center; }
.result-card { position: relative; z-index: 1; background: var(--green); animation: reveal-in 0.9s var(--spring) both; }
.result-card.lose { background: #cfd6e6; }
.result-kicker { margin: 0; font: 400 1.5rem var(--font-display); }
.result-title { font-size: clamp(2.2rem, 11vw, 3.4rem); line-height: 1.05; margin: 6px 0; }
.result-img .char-img { width: 130px; height: 130px; animation: wobble 1.4s ease-in-out infinite; }
.result-reason { font-weight: 700; margin: 6px 0; }
.result-duration { margin: 0; }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 60; }
.confetto { position: absolute; top: -20px; width: 12px; height: 18px; border: 2px solid var(--ink); border-radius: 3px; }

/* ───────── Bandeaux ───────── */
.conn-banner, .toast {
  position: fixed;
  left: 50%;
  z-index: 80;
  width: min(92vw, 480px);
  margin-left: calc(min(92vw, 480px) / -2);
  padding: 10px 14px;
  text-align: center;
  font-weight: 700;
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.conn-banner { top: max(8px, env(safe-area-inset-top)); background: var(--orange); }
.toast { bottom: max(16px, env(safe-area-inset-bottom)); background: #fff; animation: pop-in 0.3s var(--spring) both; }

/* ───────── Mouvement réduit ───────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .out-banner { animation: none; }
}

/* Bandeau de réactivation des capteurs (après rechargement en partie) */
.sensor-banner {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 70;
  max-width: 496px;
  margin: 0 auto;
}
