:root {
  color-scheme: dark;
  --bg: #17223b;
  --ink: #fffaf0;
  --muted: #d8e8ff;
  --line: rgba(255,255,255,.28);
  --panel: rgba(24,34,70,.9);
  --accent: #ffd447;
  --good: #4fe38e;
  --bad: #ff5d7a;
  --blue: #55c7ff;
  --pink: #ff7ac8;
  --purple: #8b7cff;
  --kid-font: "Trebuchet MS", "Comic Sans MS", "Arial Rounded MT Bold", ui-rounded, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--kid-font);
  letter-spacing: 0;
}

button, input, select {
  font: inherit;
}

button {
  border: 0;
  min-height: 48px;
  border-radius: 18px;
  padding: 0 16px;
  color: var(--ink);
  background: rgba(255,255,255,.16);
  touch-action: manipulation;
  font-weight: 900;
  line-height: 1.1;
  box-shadow: 0 8px 0 rgba(0,0,0,.24), 0 16px 26px rgba(0,0,0,.18);
  transition: transform .16s ease, box-shadow .16s ease, filter .16s ease;
}

button[hidden] {
  display: none;
}

button:active {
  transform: translateY(4px) rotate(-1deg);
  box-shadow: 0 4px 0 rgba(0,0,0,.24), 0 10px 20px rgba(0,0,0,.16);
}

button:hover {
  filter: brightness(1.08) saturate(1.08);
}

button span {
  margin-right: 6px;
}

input, select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0 14px;
  color: var(--ink);
  background: rgba(255,255,255,.13);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.12);
}

input {
  text-transform: uppercase;
}

select {
  appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, var(--ink) 50%) calc(100% - 20px) 21px / 7px 7px no-repeat,
    linear-gradient(135deg, var(--ink) 50%, transparent 50%) calc(100% - 14px) 21px / 7px 7px no-repeat,
    rgba(255,255,255,.08);
}

.app {
  min-height: 100dvh;
  background:
    linear-gradient(135deg, rgba(255,122,200,.24) 0 18%, transparent 18% 100%),
    linear-gradient(315deg, rgba(85,199,255,.22) 0 20%, transparent 20% 100%),
    linear-gradient(180deg, #29386d 0%, #17223b 52%, #10282d 100%);
}

#home {
  position: relative;
  isolation: isolate;
  height: 100dvh;
  gap: 12px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
}

#home::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 10px 10px, rgba(255,212,71,.34) 0 3px, transparent 4px),
    radial-gradient(circle at 32px 28px, rgba(255,122,200,.28) 0 3px, transparent 4px),
    linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px);
  background-size: 52px 52px, 58px 58px, 44px 44px, 44px 44px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.85), transparent 78%);
  animation: playground-drift 14s linear infinite;
}

.screen {
  display: none;
  min-height: 100dvh;
  padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
}

.screen.active {
  display: flex;
  flex-direction: column;
  animation: screen-pop .32s cubic-bezier(.2,1.25,.38,1) both;
}

.brand {
  margin-top: calc(42px + 2dvh);
}

.install-app {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 12px;
  z-index: 2;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(24,34,70,.78);
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  backdrop-filter: blur(12px);
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mark {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 16px;
  background: linear-gradient(135deg, #ffd447, #ff8a4b 52%, #ff7ac8);
  color: #17223b;
  font-size: 25px;
  line-height: 1;
  box-shadow: 0 12px 34px rgba(0,0,0,.28), 0 0 0 4px rgba(255,255,255,.08);
  animation: mascot-wiggle 2.4s ease-in-out infinite;
}

h1, h2, p { margin: 0; }

h1 {
  font-size: clamp(34px, 10vw, 48px);
  line-height: 1;
  color: #fff9d8;
  font-family: "Chewy", "Comic Sans MS", "Arial Rounded MT Bold", var(--kid-font);
  font-weight: 400;
  text-shadow:
    0 4px 0 rgba(0,0,0,.28),
    0 0 24px rgba(255,212,71,.28),
    2px 2px 0 #ff7ac8,
    -2px -2px 0 #55c7ff;
  transform-origin: left bottom;
  animation: title-bounce .72s cubic-bezier(.2,1.25,.38,1) both, title-wiggle 3s ease-in-out infinite;
}

.brand p {
  max-width: 28rem;
  margin-top: 12px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.35;
}

.brand-note {
  margin-top: 8px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}

.fun-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.fun-strip span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  gap: 6px;
  border: 1px solid rgba(255,255,255,.24);
  border-radius: 18px;
  padding: 9px 8px;
  background: linear-gradient(135deg, rgba(255,255,255,.22), rgba(255,255,255,.1));
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(0,0,0,.16);
  animation: happy-hop 2.8s ease-in-out infinite;
}

.fun-strip span:nth-child(2) {
  animation-delay: .18s;
}

.fun-strip span:nth-child(3) {
  animation-delay: .36s;
}

.fun-strip b {
  font-size: 17px;
  line-height: 1;
}

.role-preview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 6px;
}

.role-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 12px;
  background: rgba(255,255,255,.13);
  box-shadow: 0 12px 28px rgba(0,0,0,.18);
  animation: card-float 3.4s ease-in-out infinite;
}

.role-chip:nth-child(2) {
  animation-delay: .4s;
}

.role-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 14px;
  font-size: 22px;
  line-height: 1;
}

.wolf-chip .role-icon {
  background: rgba(247,201,72,.24);
}

.sheep-chip .role-icon {
  background: rgba(57,217,138,.24);
}

.role-chip strong,
.role-chip small {
  display: block;
  min-width: 0;
}

.role-chip strong {
  font-size: 14px;
}

.role-chip small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

h2 {
  font-size: 24px;
  line-height: 1.1;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 16px;
  background: var(--panel);
  backdrop-filter: blur(16px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18);
}

#home .panel {
  margin-top: 2px;
  box-shadow: 0 24px 70px rgba(0,0,0,.34);
}

.center {
  margin: auto 0;
  text-align: center;
}

.center p {
  margin: 12px 0 20px;
  color: var(--muted);
}

.center button + button {
  margin-top: 10px;
}

.field span,
.label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.field + .field {
  margin-top: 12px;
}

.creator-options {
  margin-top: 12px;
}

.actions {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.join-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.join-row button {
  background: linear-gradient(135deg, var(--blue), var(--purple));
  color: #fff;
  white-space: normal;
}

.join-row input[hidden] + button {
  grid-column: 1 / -1;
}

.primary {
  background: linear-gradient(135deg, #ffd447, #ffef7a 52%, #ffb84b);
  color: #17223b;
  font-weight: 900;
  box-shadow: 0 10px 0 rgba(116,76,0,.58), 0 18px 34px rgba(0,0,0,.24);
  animation: button-pulse 2.2s ease-in-out infinite;
}

.primary:active {
  transform: translateY(3px);
  box-shadow: 0 7px 0 rgba(114,77,14,.5), 0 14px 28px rgba(0,0,0,.22);
}

.danger {
  display: none;
  background: var(--bad);
  font-weight: 800;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.home-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.home-stats span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 10px 8px;
  background: rgba(255,255,255,.08);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.home-stats b {
  font-weight: 900;
}

.lobby-list {
  display: grid;
  gap: 8px;
  max-height: 36dvh;
  overflow: auto;
  margin: 0 0 16px;
  text-align: left;
}

.lobby-player {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 10px 12px;
  background: rgba(255,255,255,.08);
}

.lobby-player strong,
.lobby-player span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lobby-player span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.topbar > div {
  min-width: 0;
}

.topbar strong {
  display: block;
  font-size: 36px;
  letter-spacing: .14em;
  color: var(--accent);
  text-shadow: 0 3px 0 rgba(0,0,0,.28);
  animation: code-glow 1.8s ease-in-out infinite alternate;
}

.code-mascots {
  margin: 2px 0 4px;
  font-size: 24px;
  line-height: 1;
}

.code-help {
  max-width: 24rem;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.lobby-share-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.share-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 14px;
  white-space: nowrap;
}

.icon-button {
  width: 48px;
  padding: 0;
  font-size: 24px;
  border-radius: 16px;
}

.role-badge {
  align-self: center;
  margin: 0 0 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 16px;
  color: var(--accent);
  background: rgba(0,0,0,.24);
  font-weight: 900;
  text-transform: uppercase;
  animation: badge-bob 1.6s ease-in-out infinite;
}

.timer.big {
  margin: 0 0 20px;
  text-align: center;
  font-size: clamp(64px, 25vw, 120px);
  font-weight: 900;
  line-height: .9;
  color: var(--accent);
  text-shadow: 0 5px 0 rgba(0,0,0,.24);
}

#countdown h2,
#countdown p {
  text-align: center;
}

#countdown.active {
  justify-content: center;
}

#countdown h2 {
  font-size: clamp(30px, 9vw, 44px);
}

#countdown p {
  max-width: 34rem;
  margin: 14px auto 0;
  color: var(--muted);
  font-size: clamp(19px, 5.2vw, 27px);
  font-weight: 900;
  line-height: 1.25;
}

#countdown.urgent {
  background:
    radial-gradient(circle at 50% 42%, rgba(255,90,95,.2), transparent 28%),
    linear-gradient(160deg, rgba(255,90,95,.16), rgba(16,24,32,0) 58%);
  animation: countdown-alert .72s ease-in-out infinite alternate;
}

#countdown.urgent .timer.big {
  color: var(--bad);
  text-shadow:
    0 0 18px rgba(255,90,95,.72),
    0 0 42px rgba(247,201,72,.34);
  animation: countdown-pop .72s ease-in-out infinite alternate;
}

#countdown.urgent h2 {
  color: var(--accent);
}

.game-screen {
  position: relative;
  padding: 0;
  overflow: hidden;
  background: #05080a;
}

#camera,
.camera-fallback {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-fallback {
  display: none;
  place-items: center;
  color: var(--muted);
  background: #101820;
}

.hud {
  position: absolute;
  left: 12px;
  right: 12px;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.hud.top {
  top: max(12px, env(safe-area-inset-top));
}

.hud > div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 10px;
  background: rgba(0,0,0,.48);
  backdrop-filter: blur(14px);
}

.hud strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.arrow-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.arrow-layer.signal-jammed::before,
.arrow-layer.signal-jammed::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.arrow-layer.signal-jammed::before {
  background:
    repeating-linear-gradient(0deg, rgba(255,90,95,.2) 0 2px, transparent 2px 9px),
    repeating-linear-gradient(90deg, rgba(69,170,242,.16) 0 1px, transparent 1px 11px);
  mix-blend-mode: screen;
  opacity: .72;
  animation: signal-noise .24s steps(2, end) infinite;
}

.arrow-layer.signal-jammed::after {
  inset: 10%;
  border: 1px solid rgba(255,90,95,.34);
  border-radius: 999px;
  background:
    radial-gradient(circle, transparent 0 34%, rgba(255,90,95,.18) 35% 36%, transparent 37% 100%),
    conic-gradient(from 0deg, transparent 0 24deg, rgba(247,201,72,.26) 25deg 31deg, transparent 32deg 360deg);
  filter: blur(.6px);
  opacity: .8;
  animation: signal-radar .9s linear infinite;
}

.fog-layer {
  position: absolute;
  inset: -18%;
  z-index: 2;
  display: none;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 36%, rgba(245,247,244,.52), transparent 22%),
    radial-gradient(circle at 74% 28%, rgba(245,247,244,.38), transparent 26%),
    radial-gradient(circle at 54% 72%, rgba(245,247,244,.46), transparent 24%),
    linear-gradient(110deg, rgba(245,247,244,.28), rgba(16,24,32,.24));
  filter: blur(16px);
  opacity: .82;
  animation: fog-drift 5.8s ease-in-out infinite alternate;
}

.fog-layer.active {
  display: block;
}

.direction-arrow {
  position: relative;
  z-index: 1;
  display: none;
  width: min(34vw, 150px);
  height: min(34vw, 150px);
  place-items: center;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,.7);
  color: var(--accent);
  background: rgba(0,0,0,.34);
  font-size: min(21vw, 92px);
  line-height: 1;
  text-shadow: 0 3px 18px rgba(0,0,0,.8);
  transition: transform .2s ease;
  animation: arrow-breathe 1.1s ease-in-out infinite;
}

.distance-big {
  position: absolute;
  z-index: 1;
  top: 26%;
  display: none;
  min-width: min(68vw, 260px);
  border: 1px solid rgba(255,255,255,.42);
  border-radius: 20px;
  padding: 10px 16px;
  background: rgba(0,0,0,.62);
  color: var(--ink);
  font-size: clamp(42px, 16vw, 76px);
  font-weight: 900;
  line-height: 1;
  text-align: center;
  text-shadow: 0 3px 18px rgba(0,0,0,.75);
  backdrop-filter: blur(10px);
}

.distance-big.active {
  display: block;
}

.distance-big[aria-hidden="true"] {
  display: none;
}

.distance-big.trend-closer {
  border-color: rgba(57,217,138,.7);
  color: var(--good);
  box-shadow: 0 0 30px rgba(57,217,138,.18);
}

.distance-big.trend-farther {
  border-color: rgba(247,201,72,.7);
  color: var(--accent);
}

.distance-big.jammed {
  border-color: rgba(255,90,95,.78);
  color: var(--bad);
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,.09) 0 2px, transparent 2px 8px),
    rgba(0,0,0,.7);
  filter: blur(.8px) contrast(1.35);
  text-shadow:
    -5px 0 0 rgba(69,170,242,.55),
    5px 0 0 rgba(255,90,95,.5),
    0 3px 18px rgba(0,0,0,.75);
  animation: distance-scramble .16s steps(2, end) infinite;
}

.arrow-layer.effect-reveal::before,
.arrow-layer.effect-jam::before,
.arrow-layer.effect-miss::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.arrow-layer.effect-reveal::before {
  background: radial-gradient(circle at 50% 38%, rgba(57,217,138,.34), transparent 38%);
  animation: signal-burst .62s ease-out forwards;
}

.arrow-layer.effect-jam::before {
  background:
    repeating-linear-gradient(0deg, rgba(255,90,95,.24) 0 3px, transparent 3px 8px),
    radial-gradient(circle at 50% 35%, rgba(255,90,95,.26), transparent 42%);
  animation: jam-burst .64s steps(3, end) forwards;
}

.arrow-layer.effect-miss::before {
  background: radial-gradient(circle at 50% 38%, rgba(247,201,72,.2), transparent 32%);
  animation: miss-pulse .42s ease-out forwards;
}

.signal-unstable .direction-arrow {
  border-color: rgba(247,201,72,.75);
  filter: blur(.7px) saturate(1.45);
  animation: signal-flicker .34s steps(2, end) infinite;
}

.signal-jammed .direction-arrow {
  color: rgba(255,90,95,.95);
  border-color: rgba(255,90,95,.76);
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,.08) 0 3px, transparent 3px 9px),
    rgba(0,0,0,.42);
  filter: blur(2.2px) contrast(1.65) saturate(1.8);
  opacity: .9;
  animation: signal-scramble .14s steps(2, end) infinite;
}

.signal-jammed .distance-label {
  border: 1px solid rgba(255,90,95,.62);
  color: var(--bad);
  background: rgba(0,0,0,.72);
}

.distance-label {
  position: absolute;
  z-index: 1;
  top: 52%;
  max-width: calc(100% - 36px);
  border-radius: 999px;
  padding: 8px 13px;
  background: rgba(0,0,0,.56);
  color: var(--ink);
  font-weight: 800;
  text-align: center;
}

.distance-label.trend-closer {
  border: 1px solid rgba(57,217,138,.62);
  color: var(--good);
  background: rgba(0,0,0,.68);
  box-shadow: 0 0 24px rgba(57,217,138,.18);
}

.distance-label.trend-farther {
  border: 1px solid rgba(247,201,72,.62);
  color: var(--accent);
  background: rgba(0,0,0,.64);
}

.quiz-card {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(82px + env(safe-area-inset-bottom));
  z-index: 3;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 13px;
  background: rgba(16,24,32,.9);
  backdrop-filter: blur(16px);
  box-shadow: 0 18px 40px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.16);
  animation: quiz-slide-up .28s cubic-bezier(.2,1.2,.36,1) both;
}

.quiz-card.wrong-vibrate {
  animation: wrong-vibrate .34s ease-in-out both;
}

.quiz-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

#quizQuestion {
  font-weight: 800;
  line-height: 1.25;
}

.answers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.answers button {
  min-height: 44px;
  padding: 8px 10px;
  font-size: 14px;
  line-height: 1.15;
  background: linear-gradient(135deg, rgba(85,199,255,.42), rgba(255,122,200,.34));
}

.answers button.answer-good {
  color: #092516;
  background: linear-gradient(135deg, #4fe38e, #b8ff73);
  box-shadow: 0 8px 0 rgba(11,86,43,.62), 0 14px 24px rgba(0,0,0,.22);
}

.answers button.answer-bad {
  color: #fffaf0;
  background: linear-gradient(135deg, #ff5d7a, #ff8a4b);
  box-shadow: 0 8px 0 rgba(112,14,33,.62), 0 14px 24px rgba(0,0,0,.22);
}

.bottom-actions {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 4;
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
}

.bottom-actions button {
  min-width: 0;
}

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  top: calc(16px + env(safe-area-inset-top));
  z-index: 10;
  display: none;
  border-radius: 18px;
  padding: 12px 14px;
  background: rgba(24,34,70,.92);
  color: var(--ink);
  text-align: center;
  border: 1px solid var(--line);
  box-shadow: 0 18px 34px rgba(0,0,0,.26);
}

.toast.show {
  display: block;
  animation: toast-pop .24s cubic-bezier(.2,1.35,.42,1) both;
}

.confetti-layer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  overflow: hidden;
  pointer-events: none;
}

.confetti-layer.active {
  display: block;
}

.confetti-layer i {
  position: absolute;
  left: var(--x);
  top: -16px;
  width: 9px;
  height: 15px;
  border-radius: 2px;
  opacity: .95;
  animation: confetti-fall var(--duration) cubic-bezier(.18,.78,.35,1) var(--delay) forwards;
}

@keyframes confetti-fall {
  to {
    transform: translate3d(var(--drift), 110dvh, 0) rotate(var(--spin));
    opacity: 0;
  }
}

@keyframes playground-drift {
  to { background-position: 52px 52px, -58px 58px, 44px 44px, -44px 44px; }
}

@keyframes screen-pop {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes title-bounce {
  0% { opacity: 0; transform: translateY(-10px) rotate(-2deg) scale(.94); }
  68% { opacity: 1; transform: translateY(2px) rotate(1deg) scale(1.03); }
  100% { opacity: 1; transform: translateY(0) rotate(0) scale(1); }
}

@keyframes mascot-wiggle {
  0%, 100% { transform: rotate(-3deg) scale(1); }
  45% { transform: rotate(5deg) scale(1.06); }
  60% { transform: rotate(-2deg) scale(1.03); }
}

@keyframes happy-hop {
  0%, 100% { transform: translateY(0) rotate(0); }
  45% { transform: translateY(-4px) rotate(-1deg); }
}

@keyframes card-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@keyframes button-pulse {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-2px) scale(1.015); }
}

@keyframes code-glow {
  from { text-shadow: 0 3px 0 rgba(0,0,0,.28), 0 0 10px rgba(255,212,71,.18); }
  to { text-shadow: 0 3px 0 rgba(0,0,0,.28), 0 0 24px rgba(255,212,71,.5); }
}

@keyframes badge-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes arrow-breathe {
  0%, 100% { box-shadow: 0 0 0 rgba(255,212,71,0); }
  50% { box-shadow: 0 0 34px rgba(255,212,71,.34); }
}

@keyframes quiz-slide-up {
  from { opacity: 0; transform: translateY(18px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toast-pop {
  from { opacity: 0; transform: translateY(-12px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes fog-drift {
  from { transform: translate3d(-4%, -1%, 0) scale(1.02); }
  to { transform: translate3d(4%, 2%, 0) scale(1.08); }
}

@keyframes signal-flicker {
  0% { opacity: .72; text-shadow: -3px 0 0 rgba(69,170,242,.52), 3px 0 0 rgba(255,90,95,.46); }
  100% { opacity: 1; text-shadow: 3px 0 0 rgba(69,170,242,.52), -3px 0 0 rgba(255,90,95,.46); }
}

@keyframes signal-scramble {
  0% { opacity: .48; transform: translateX(-6px) scale(1.05); text-shadow: -12px 0 0 rgba(69,170,242,.75), 9px 0 0 rgba(255,90,95,.7); }
  50% { opacity: 1; transform: translateX(5px) scale(.96); text-shadow: 11px 0 0 rgba(69,170,242,.66), -8px 0 0 rgba(255,90,95,.74); }
  100% { opacity: .62; transform: translateX(-3px) scale(1.02); text-shadow: -7px 0 0 rgba(69,170,242,.7), 13px 0 0 rgba(255,90,95,.64); }
}

@keyframes distance-scramble {
  0% { transform: translateX(-4px) skewX(-2deg); opacity: .72; }
  50% { transform: translateX(5px) skewX(2deg); opacity: 1; }
  100% { transform: translateX(-2px) skewX(-1deg); opacity: .84; }
}

@keyframes signal-burst {
  from { opacity: .95; transform: scale(.8); }
  to { opacity: 0; transform: scale(1.45); }
}

@keyframes jam-burst {
  0% { opacity: .9; transform: translateX(-8px); }
  40% { opacity: .72; transform: translateX(7px); }
  100% { opacity: 0; transform: translateX(0); }
}

@keyframes miss-pulse {
  from { opacity: .7; transform: scale(.95); }
  to { opacity: 0; transform: scale(1.16); }
}

@keyframes signal-noise {
  0% { transform: translate3d(-3%, -2%, 0); opacity: .52; }
  50% { transform: translate3d(4%, 1%, 0); opacity: .82; }
  100% { transform: translate3d(1%, 3%, 0); opacity: .62; }
}

@keyframes signal-radar {
  to { transform: rotate(360deg) scale(1.03); }
}

@keyframes countdown-alert {
  from { box-shadow: inset 0 0 0 rgba(255,90,95,0); }
  to { box-shadow: inset 0 0 80px rgba(255,90,95,.2); }
}

@keyframes countdown-pop {
  from { transform: scale(1); }
  to { transform: scale(1.05); }
}

@keyframes title-wiggle {
  0%, 100% { transform: rotate(-1deg); }
  50% { transform: rotate(1.4deg) translateY(-1px); }
}

@keyframes wrong-vibrate {
  0%, 100% { transform: translateX(0) rotate(0); }
  12% { transform: translateX(-8px) rotate(-1deg); }
  24% { transform: translateX(7px) rotate(1deg); }
  36% { transform: translateX(-6px) rotate(-1deg); }
  48% { transform: translateX(5px) rotate(1deg); }
  60% { transform: translateX(-3px) rotate(-.6deg); }
  72% { transform: translateX(2px) rotate(.4deg); }
}

@media (max-height: 700px) {
  #home {
    gap: 9px;
  }

  .brand {
    margin-top: 38px;
  }

  h1 {
    font-size: clamp(31px, 9vw, 44px);
  }

  .brand p {
    margin-top: 7px;
    font-size: 14px;
  }

  .brand-note,
  .role-chip small,
  .hint {
    font-size: 12px;
  }

  .role-chip {
    padding: 9px;
  }

  .panel {
    padding: 12px;
  }

  .actions {
    margin-top: 12px;
  }
}

@media (max-width: 380px) {
  .join-row {
    grid-template-columns: 1fr;
  }
}

@media (orientation: landscape) {
  .app::before {
    content: "Tourne ton smartphone en portrait";
    position: fixed;
    inset: 0;
    z-index: 99;
    display: grid;
    place-items: center;
    padding: 24px;
    background: #101820;
    color: var(--ink);
    text-align: center;
    font-size: 24px;
    font-weight: 900;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .001ms !important;
  }
}
