/* triCatial: opening flow (splash, welcome, account, profile). Uses the colours from style.css. */

html.ix-booting body { background: #c8102e; }
html.ix-booting .topbar,
html.ix-booting main { visibility: hidden; }
/* While the opening flow is up the game stays hidden underneath, and the page
   behind it has the flow's own colour: on the iPhone app the first frames can
   leave a strip at the bottom uncovered, and nothing should peek through it. */
html.ix-lock:not(.ix-reveal) :is(.topbar, main, .skip, footer) { visibility: hidden; }
html.ix-lock:not(.ix-reveal), html.ix-lock:not(.ix-reveal) body { background: #efe3cf; }
html.ix-lock[data-theme="dark"]:not(.ix-reveal), html.ix-lock[data-theme="dark"]:not(.ix-reveal) body { background: #1c1814; }
@media (prefers-color-scheme: dark) {
  html.ix-lock:not([data-theme="light"]):not(.ix-reveal), html.ix-lock:not([data-theme="light"]):not(.ix-reveal) body { background: #1c1814; }
}
html.ix-lock.ix-red, html.ix-lock.ix-red body { background: #a20d25; }
html.ix-lock,
html.ix-lock body { overflow: hidden; }

.intro {
  /* The paper and ink colours come from css/pergami.css (light and black parchment). */
  position: fixed; inset: 0; z-index: 100;
  color: var(--text);
  overflow-y: auto; overscroll-behavior: contain;
  background-color: var(--bg);
  background-image: var(--paper-edge), var(--paper-stains), var(--paper-grain), var(--paper-base);
  background-size: 100% 100%, 700px 700px, 260px 260px, 100% 100%;
}

/* On the iPhone home-screen app the clock and battery sit on the parchment: a burnt top edge
   keeps their white letters readable. Elsewhere the inset is 0, so it isn't there. */
.intro::before {
  content: ""; position: fixed; z-index: 3; left: 0; right: 0; top: 0; pointer-events: none;
  height: calc(env(safe-area-inset-top) * 1.7);
  background: linear-gradient(rgba(58, 34, 12, .62), rgba(58, 34, 12, .28) 58%, transparent);
}

/* Bookmark ribbon with the senyera, hanging from the very top edge of the screen
   (behind the clock and battery on an iPhone) like in an old book. */
.intro::after {
  content: ""; position: fixed; z-index: 1; top: 0; right: max(50px, calc(50% - 146px));
  width: 30px; height: calc(env(safe-area-inset-top) + 86px);
  background: linear-gradient(90deg, #f2b705 0 11.1%, #c8102e 11.1% 22.2%, #f2b705 22.2% 33.3%, #c8102e 33.3% 44.4%, #f2b705 44.4% 55.5%, #c8102e 55.5% 66.6%, #f2b705 66.6% 77.7%, #c8102e 77.7% 88.8%, #f2b705 88.8%);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 84%, 0 100%);
  filter: drop-shadow(0 2px 2px rgba(60, 35, 10, .35));
  pointer-events: none;
}
.ix-splash { z-index: 2; }
.ix-screen .ix-head { padding-right: 34px; }
.intro.ix-leaving { animation: ix-leave .42s ease-in both; pointer-events: none; }
.ix-stage { min-height: 100%; }

.ix-screen {
  display: flex; flex-direction: column;
  min-height: 100vh; min-height: 100dvh;
  max-width: 480px; margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) 20px calc(22px + env(safe-area-inset-bottom));
  animation: ix-in .38s cubic-bezier(.2, .8, .2, 1) both;
}
.ix-screen.from-left { animation-name: ix-in-back; }
.ix-screen h1:focus { outline: none; }

/* ---------- Logo (the app icon, built from pieces) ---------- */

.ix-logo { display: block; width: 1em; height: 1em; overflow: visible; filter: drop-shadow(0 .04em .06em rgba(42, 33, 27, .3)); }
.ix-logo.big { font-size: 148px; }
.ix-logo.mid { font-size: 92px; }
.ix-logo .ix-bubble, .ix-logo .ix-bar { transform-box: fill-box; }
.ix-logo .ix-bubble { transform-origin: 20% 100%; }
.ix-logo .ix-bar { transform-origin: 50% 100%; }

/* ---------- Splash ---------- */

.ix-splash {
  position: fixed; inset: 0; overflow: hidden; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  padding: 24px; text-align: center;
  background: radial-gradient(circle at 50% 42%, #e3283f 0, #c8102e 55%, #9d0c23 100%);
  color: #fffaf2;
  -webkit-tap-highlight-color: transparent;
}
.ix-splash::before {
  content: ""; position: absolute; left: 50%; top: 42%; width: 220vmax; height: 220vmax; margin: -110vmax 0 0 -110vmax;
  background: repeating-conic-gradient(rgba(255, 255, 255, .07) 0 9deg, transparent 9deg 18deg);
  animation: ix-spin 40s linear infinite;
}
.ix-splash > * { position: relative; }
.ix-splash .ix-logo { filter: drop-shadow(0 6px 0 rgba(0, 0, 0, .22)); transform-origin: 30% 95%; animation: ix-wobble .8s ease-in-out 1.15s both; }
.ix-splash .ix-bubble { animation: ix-logo-in .7s cubic-bezier(.3, 1.5, .5, 1) .1s both; }
.ix-splash .ix-bar { animation: ix-bar-in .42s cubic-bezier(.3, 1.6, .5, 1) calc(.55s + var(--i) * .08s) both; }
.ix-word { font-family: "Fraunces", Georgia, serif; font-size: clamp(2.6rem, 13vw, 3.6rem); font-weight: 900; letter-spacing: -.035em; line-height: 1; }
.ix-word span { display: inline-block; animation: ix-drop .6s cubic-bezier(.3, 1.6, .5, 1) calc(1s + var(--i) * .045s) both; }
.ix-word .hl { color: #f2b705; }
.ix-tag { font-size: 1.1rem; font-weight: 700; opacity: .92; animation: ix-up .5s ease-out 1.6s both; }
.ix-splash.out { animation: ix-splash-out .32s ease-in both; }

/* ---------- Shared pieces ---------- */

.ix-center { display: flex; flex-direction: column; align-items: center; text-align: center; }
.ix-title { font-family: "Fraunces", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; font-weight: 700; font-size: clamp(1.9rem, 8vw, 2.4rem); line-height: 1.08; letter-spacing: -.01em; margin-top: 6px; }
.ix-title.center, .ix-sub.center { text-align: center; }
.ix-sub { color: var(--muted); margin-top: 8px; }
.ix-head { display: flex; align-items: center; gap: 12px; min-height: 44px; margin-bottom: 10px; }
.ix-back {
  width: 44px; height: 44px; border-radius: 12px; flex: none;
  background: var(--surface); border: 1.5px solid var(--border); font-size: 1.25rem; font-weight: 800;
}
.ix-steps { margin-left: auto; font-weight: 750; font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.ix-link {
  background: none; border: 0; padding: 10px 4px; color: var(--accent);
  font-weight: 750; text-decoration: none;
}
.ix-link.small { padding: 4px 2px; font-size: .9rem; color: var(--muted); }
.ix-footer {
  display: grid; gap: 4px; margin-top: auto;
  padding: 16px 0 calc(2px + env(safe-area-inset-bottom));
}
.ix-footer .ix-link { justify-self: center; }
.ix-note { margin-top: 18px; text-align: center; font-size: .82rem; color: var(--muted); }

.ix-avatar {
  display: grid; place-items: center; flex: none;
  width: 1em; height: 1em; border-radius: 50%;
  background: var(--av); box-shadow: 0 .05em 0 rgba(0, 0, 0, .2), inset 0 -.06em 0 rgba(0, 0, 0, .15);
  font-size: 56px;
}
.ix-avatar { overflow: hidden; }
.ix-avatar svg, .ix-av-option svg { display: block; width: 100%; height: 100%; }
.ix-avatar.xl { font-size: 112px; margin-bottom: 10px; }
.ix-avatar.bump { animation: ix-pop .4s cubic-bezier(.3, 1.8, .5, 1); }
.ix-avatar.bounce { animation: ix-pop .55s cubic-bezier(.3, 1.8, .5, 1) .1s both, ix-bob 2.4s ease-in-out .7s infinite; }

/* ---------- Welcome ---------- */

.ix-brandline { display: flex; align-items: center; justify-content: center; gap: 10px; font-family: "Fraunces", Georgia, serif; font-weight: 800; font-size: 1.35rem; letter-spacing: -.02em; }
.ix-brandline b { color: #c8102e; font-weight: 900; }
.ix-brandline .brand-logo { height: 38px; }
.ix-wordmark { font-family: var(--display); font-weight: 800; font-size: 1.45rem; letter-spacing: -.02em; }
.ix-wordmark b { color: var(--accent); }
.ix-slides {
  display: flex; flex: 1; overflow-x: auto; scroll-snap-type: x mandatory;
  margin: 6px -20px 0; scrollbar-width: none; overscroll-behavior-x: contain;
}
.ix-slides::-webkit-scrollbar { display: none; }
.ix-slides { transition: opacity .5s ease; }
.ix-slides.ix-sliding { scroll-snap-type: none; }
.ix-slides.ix-fade { opacity: 0; }
.ix-slides:focus-visible { outline-offset: -4px; }
.ix-slide {
  flex: 0 0 100%; scroll-snap-align: center; scroll-snap-stop: always;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 10px 30px; text-align: center;
}
.ix-slide h2 { font-family: "Fraunces", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; font-weight: 700; font-size: clamp(1.75rem, 7.6vw, 2.2rem); line-height: 1.1; letter-spacing: -.01em; }
.ix-slide p { color: var(--muted); max-width: 30ch; }
.ix-art { position: relative; width: 230px; height: 230px; margin-bottom: 6px; display: grid; place-items: center; }

.ix-orbit { position: absolute; inset: 0; animation: ix-spin 36s linear infinite; }
.ix-orbit-item { position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px; transform: rotate(calc(var(--i) * 360deg / var(--n, 9))) translateY(-96px); }
.ix-orbit-item > span {
  display: grid; place-items: center; width: 100%; height: 100%;
  transform: rotate(calc(var(--i) * -360deg / var(--n, 9))); animation: ix-counter 36s linear infinite;
}
.ix-orbit-item .rajola { width: 100%; }
.ix-orbit-item .ix-emoji { display: grid; place-items: center; width: 100%; height: 100%; border-radius: 22%; background: var(--surface); border: 1.5px solid var(--border); font-size: 1.35rem; }
.ix-art-1 .ix-logo { animation: ix-bob 3s ease-in-out infinite; }

/* A castell (human tower): the floors go up one by one and come down again. */
.ix-castell { display: flex; flex-direction: column; align-items: center; margin-top: -44px; }
.ix-pis { display: flex; justify-content: center; margin-top: -12px; animation: ix-pis 4.8s ease-out infinite both; }
.ix-pis:nth-child(4) { animation-delay: 0s; }
.ix-pis:nth-child(3) { animation-delay: .45s; }
.ix-pis:nth-child(2) { animation-delay: .9s; }
.ix-pis:nth-child(1) { animation-delay: 1.35s; }
.ix-pis { position: relative; z-index: calc(4 - var(--p)); }
.ix-pis + .ix-pis { margin-top: -31px; }
.ix-pis i { display: block; margin: 0 -6px; }
.ix-pis svg { display: block; width: 42px; height: 72px; overflow: visible; }
.ix-pis .enxaneta svg { width: 35px; height: 60px; }
/* The enxaneta "fa l'aleta": the raised hand waves. */
.ix-pis .aleta { transform-origin: 34.5px 31px; animation: ix-aleta 1.2s ease-in-out infinite; }
.ix-pill {
  position: absolute; bottom: 4px; padding: 6px 16px; border-radius: 99px;
  background: var(--text); color: var(--bg); font-weight: 850; font-size: 1.05rem;
}
.ix-float { position: absolute; font-weight: 900; color: var(--ok); font-size: 1.2rem; animation: ix-rise 2.7s ease-out infinite; }
.ix-float.f1 { left: 14px; top: 90px; }
.ix-float.f2 { right: 22px; top: 50px; animation-delay: .9s; }
.ix-float.f3 { right: 14px; top: 140px; animation-delay: 1.8s; }

/* "Sabies que…?": a scroll with a quill writing on it. */
.ix-scroll { display: flex; flex-direction: column; align-items: center; width: 150px; transform: rotate(-4deg); animation: ix-bob 3.2s ease-in-out infinite; }
.ix-scroll-text {
  display: block; width: 132px; padding: 10px 12px;
  background: linear-gradient(90deg, #e9d2a4, #f6e8c8 18%, #f6e8c8 82%, #e9d2a4);
  font-family: "Fraunces", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; font-style: italic;
  font-size: .78rem; line-height: 1.3; color: #5a3d1e; text-align: left;
  box-shadow: 0 4px 10px rgba(80, 50, 20, .18);
}
.ix-roll {
  display: block; width: 150px; height: 16px; border-radius: 8px;
  background: linear-gradient(to bottom, #c99b5c, #f0d7a6 45%, #b88446);
  box-shadow: 0 2px 3px rgba(80, 50, 20, .3);
}
.ix-quill { position: absolute; left: 136px; top: 112px; font-size: 54px; line-height: 1; animation: ix-write 2.2s ease-in-out infinite; }
.ix-spark {
  position: absolute; font-family: "Fraunces", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-weight: 700; font-size: 2rem; color: #c8102e; animation: ix-rise 3s ease-out infinite;
}
.ix-spark.k1 { left: 30px; top: 60px; }
.ix-spark.k2 { right: 34px; top: 40px; color: #b88a00; animation-delay: 1s; }
.ix-spark.k3 { left: 26px; top: 150px; animation-delay: 2s; }

/* "Defensa la teva comarca": a podium that rises again and again. */
.ix-podium { display: flex; align-items: flex-end; justify-content: center; gap: 8px; height: 200px; }
.ix-step { display: flex; flex-direction: column; align-items: center; width: 70px; }
.ix-step b { margin-top: 6px; font-size: .74rem; line-height: 1.15; text-align: center; color: var(--muted); }
.ix-step.swap .ix-podium-face svg, .ix-step.swap b { animation: ix-swap .4s cubic-bezier(.2, 1.4, .4, 1) both; }
.ix-block {
  display: grid; place-items: start center; width: 100%; padding-top: 6px;
  border-radius: 10px 10px 4px 4px; transform-origin: 50% 100%;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .12), 0 3px 0 rgba(80, 50, 20, .2);
  animation: ix-podium 5s cubic-bezier(.3, 1.4, .5, 1) infinite both;
}
.ix-block i { font-style: normal; font-weight: 900; font-size: 1.4rem; color: rgba(255, 255, 255, .92); text-shadow: 0 1px 2px rgba(0, 0, 0, .3); }
.st1 .ix-block { height: 96px; background: #f2b705; animation-delay: .5s; }
.st2 .ix-block { height: 68px; background: #bfb7aa; animation-delay: .25s; }
.st3 .ix-block { height: 50px; background: #c58b5a; }
.ix-podium-face { display: block; width: 44px; height: 44px; margin-bottom: 4px; animation: ix-bob 2.4s ease-in-out infinite; }
.ix-podium-face svg, .ix-crown svg { display: block; width: 100%; height: 100%; overflow: visible; }
.st1 .ix-podium-face { width: 50px; height: 50px; }
/* The crown floats above the grapes with its own gap, never on top of them. */
.ix-crown { display: block; width: 34px; height: 28px; margin-bottom: 6px; transform-origin: 50% 100%; animation: ix-crown 2.4s ease-in-out infinite; }

.ix-phone { font-size: 80px; line-height: 1; animation: ix-rock 2.4s ease-in-out infinite; }
.ix-art-3 .seat { position: absolute; font-size: 62px; animation: ix-bob 2.4s ease-in-out infinite; }
.ix-art-3 .s0 { left: 10px; top: 14px; }
.ix-art-3 .s1 { right: 10px; top: 14px; animation-delay: .6s; }
.ix-art-3 .s2 { left: 10px; bottom: 14px; animation-delay: 1.2s; }
.ix-art-3 .s3 { right: 10px; bottom: 14px; animation-delay: 1.8s; }

.ix-actions { display: grid; gap: 10px; margin-top: 18px; }
/* The logo's red and yellow, the same in light and dark mode. */
.intro .btn:not(.secondary) { background: #c8102e; color: #efe1c9; box-shadow: 0 4px 0 #8e0b20; } /* old parchment white */
.intro .btn:not(.secondary):active { box-shadow: 0 1px 0 #8e0b20; }
.intro .btn.ix-gold { background: #f2b705; color: #efe1c9; text-shadow: 0 1px 2px rgba(110, 70, 0, .55); box-shadow: 0 4px 0 #b88a00; }
.intro .btn.ix-gold:active { box-shadow: 0 1px 0 #b88a00; }
/* "Play as guest": a quiet greyish blue so it doesn't compete with the two buttons. */
.ix-link.ix-guest { color: #6a7b93; font-weight: 650; text-decoration-color: rgba(106, 123, 147, .35); }
:root[data-theme="dark"] .ix-link.ix-guest { color: #8c9bb0; text-decoration-color: rgba(140, 155, 176, .35); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ix-link.ix-guest { color: #8c9bb0; text-decoration-color: rgba(140, 155, 176, .35); }
}
.ix-actions .ix-link { justify-self: center; }

/* ---------- Forms ---------- */

.ix-social { display: grid; gap: 10px; margin-top: 20px; }
.ix-soc {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; border-radius: 14px; font-weight: 750;
  border: 2px solid var(--border); background: var(--surface);
}
.ix-soc.apple { background: #000; color: #fff; border-color: #000; }
.ix-soc .g {
  font-weight: 900; font-size: 1.15rem;
  background: conic-gradient(from -45deg, #ea4335 0 25%, #fbbc05 0 50%, #34a853 0 75%, #4285f4 0);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.ix-or { display: flex; align-items: center; gap: 12px; margin: 18px 0 2px; color: var(--muted); font-size: .88rem; font-weight: 650; }
.ix-or::before, .ix-or::after { content: ""; flex: 1; height: 1.5px; background: var(--border); }

.ix-form { display: grid; gap: 14px; margin-top: 14px; }
.ix-form.shake { animation: shake .3s; }
.ix-field label, .ix-legend { display: block; margin-bottom: 6px; font-weight: 750; font-size: .95rem; }
.ix-field small { display: block; margin-top: 5px; color: var(--muted); font-size: .85rem; }
.ix-input {
  width: 100%; min-height: 52px; padding: 10px 14px;
  background: var(--surface); border: 2px solid var(--border); border-radius: 14px;
  transition: border-color .12s;
}
.ix-input:focus { border-color: var(--text); }
.ix-input[aria-invalid="true"] { border-color: var(--bad); background: var(--bad-bg); }
.ix-pass { position: relative; }
.ix-pass .ix-input { padding-right: 56px; }
.ix-eye {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 46px; height: 44px; border: 0; background: none; font-size: 1.15rem; border-radius: 10px;
}
.ix-check { display: flex; align-items: flex-start; gap: 10px; font-size: .95rem; cursor: pointer; }
.ix-check input { flex: none; width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--accent); }
.ix-check input[aria-invalid="true"] { outline: 2px solid var(--bad); outline-offset: 2px; }
.ix-docs { margin-top: -8px; padding-left: 32px; color: var(--muted); }
.ix-forgot { margin-top: -8px; text-align: right; }
.ix-error { color: var(--bad); font-weight: 700; font-size: .95rem; }
.ix-error:empty { display: none; }
.ix-switch { margin-top: 14px; text-align: center; color: var(--muted); }
.btn.busy { cursor: progress; opacity: .75; }
.btn.busy::after {
  content: ""; width: 18px; height: 18px; border-radius: 50%;
  border: 3px solid currentColor; border-right-color: transparent; animation: ix-spin .7s linear infinite;
}

/* ---------- Profile ---------- */

.ix-alias-row { display: flex; gap: 8px; }
.ix-dice {
  flex: none; width: 52px; border-radius: 14px; font-size: 1.4rem;
  background: var(--surface-2); border: 2px solid var(--border);
}
.ix-dice.roll { animation: ix-roll .5s cubic-bezier(.3, 1.4, .5, 1); }
.ix-avatars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; justify-items: center; }
.ix-av-option { position: relative; display: block; width: 100%; max-width: 72px; aspect-ratio: 1; }
.ix-av-option input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.ix-av-option span {
  display: grid; place-items: center; width: 100%; height: 100%; border-radius: 50%;
  background: var(--av); overflow: hidden; pointer-events: none;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .2); opacity: .55; transform: scale(.88);
  transition: transform .15s, opacity .15s, box-shadow .15s;
}
.ix-av-option input:checked + span { opacity: 1; transform: scale(1); box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--text); }
.ix-av-option input:focus-visible + span { outline: 3px solid var(--gold); outline-offset: 6px; }

.ix-search { margin-top: 18px; }
/* The list scrolls inside its own box so the buttons below never cover it. */
.ix-screen.ix-comarca { height: 100vh; height: 100dvh; }
.ix-comarques {
  display: flex; flex-wrap: wrap; align-content: flex-start; gap: 8px;
  flex: 1 1 0; min-height: 120px; overflow-y: auto; margin-top: 14px; padding: 4px 2px 18px;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 10px, #000 calc(100% - 22px), transparent);
  mask-image: linear-gradient(to bottom, transparent, #000 10px, #000 calc(100% - 22px), transparent);
}
.ix-chip { position: relative; display: block; }
.ix-chip[hidden] { display: none; }
.ix-chip input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.ix-chip span {
  display: block; padding: 9px 14px; border-radius: 99px; pointer-events: none;
  background: var(--surface-2); border: 2px solid var(--border); font-weight: 650; font-size: .93rem;
}
.ix-chip.outside span { border-style: dashed; }
.ix-chip input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.ix-chip input:focus-visible + span { outline: 3px solid var(--gold); outline-offset: 2px; }
.ix-empty { margin-top: 14px; color: var(--muted); }

/* ---------- Greeting and ready ---------- */

.ix-hello, .ix-ready-body { flex: 1; justify-content: center; cursor: default; }
.ix-hello .ix-sub { font-size: 1.15rem; margin-top: 4px; }
.ix-confetti { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
.ix-confetti i {
  position: absolute; top: -20px; left: var(--x); width: 9px; height: 15px; border-radius: 2px;
  background: var(--c); animation: ix-fall var(--d) cubic-bezier(.3, .6, .6, 1) var(--w) both;
}

/* ---------- Toast ---------- */

.ix-toast {
  position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); z-index: 2;
  width: max-content; max-width: min(90vw, 420px); padding: 12px 18px; border-radius: 14px;
  background: var(--text); color: var(--bg); font-weight: 650; font-size: .95rem; text-align: center;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transform: translate(-50%, 12px); transition: opacity .2s, transform .2s;
}
.ix-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Animations ---------- */

@keyframes ix-in { from { opacity: 0; transform: translateX(28px); } }
@keyframes ix-in-back { from { opacity: 0; transform: translateX(-28px); } }
@keyframes ix-leave { to { opacity: 0; transform: scale(1.04); } }
@keyframes ix-splash-out { to { opacity: 0; transform: scale(1.06); } }
@keyframes ix-logo-in { from { transform: scale(0) rotate(-200deg); } }
@keyframes ix-bar-in { from { transform: scaleY(0); } }
@keyframes ix-pop { from { transform: scale(0); } }
@keyframes ix-wobble { 20% { transform: rotate(-16deg); } 45% { transform: rotate(12deg); } 70% { transform: rotate(-6deg); } }
@keyframes ix-drop { from { opacity: 0; transform: translateY(-70px) rotate(-12deg); } }
@keyframes ix-up { from { opacity: 0; transform: translateY(12px); } }
@keyframes ix-spin { to { transform: rotate(360deg); } }
@keyframes ix-counter { to { rotate: -360deg; } }
@keyframes ix-bob { 50% { translate: 0 -8px; } }
@keyframes ix-swap { from { opacity: 0; scale: .5; } }
@keyframes ix-pis { 0% { opacity: 0; transform: translateY(18px); } 9%, 78% { opacity: 1; transform: none; } 88%, 100% { opacity: 0; transform: translateY(6px); } }
@keyframes ix-aleta { 50% { transform: rotate(-8deg); } }
@keyframes ix-crown { 50% { translate: 0 -8px; rotate: -6deg; } }
@keyframes ix-write { 0%, 100% { transform: translate(0, 0) rotate(0); } 25% { transform: translate(14px, 6px) rotate(8deg); } 50% { transform: translate(-6px, 14px) rotate(-4deg); } 75% { transform: translate(10px, 20px) rotate(6deg); } }
@keyframes ix-podium { 0% { transform: scaleY(0); } 14%, 86% { transform: scaleY(1); } 100% { transform: scaleY(0); } }
@keyframes ix-rise { from { opacity: 0; translate: 0 18px; } 20% { opacity: 1; } 80% { opacity: 1; } to { opacity: 0; translate: 0 -30px; } }
@keyframes ix-rock { 25% { transform: rotate(-12deg); } 75% { transform: rotate(12deg); } }
@keyframes ix-roll { from { transform: rotate(-360deg) scale(.6); } }
@keyframes ix-fall { from { transform: translateY(0) rotate(0); opacity: 1; } to { transform: translateY(110vh) rotate(var(--r)); opacity: .9; } }

/* ---------- Picking a character: it jumps, sparkles and sways while chosen ---------- */
.ix-av-option input:checked + span {
  animation: ix-av-jump .6s cubic-bezier(.3, 1.4, .5, 1), ix-av-glow 1.8s ease-in-out .6s infinite;
}
.ix-av-option input:checked + span svg { transform-origin: 50% 92%; animation: ix-av-sway 1.8s ease-in-out .6s infinite; }
/* A burst of red and gold sparks around the chosen one. */
.ix-av-option::after {
  content: ""; position: absolute; inset: -14px; z-index: 1; pointer-events: none; opacity: 0;
  background:
    radial-gradient(circle, #f2b705 0 3px, transparent 3.5px) 50% 0 / 12px 12px no-repeat,
    radial-gradient(circle, #c8102e 0 3px, transparent 3.5px) 100% 50% / 12px 12px no-repeat,
    radial-gradient(circle, #f2b705 0 3px, transparent 3.5px) 50% 100% / 12px 12px no-repeat,
    radial-gradient(circle, #c8102e 0 3px, transparent 3.5px) 0 50% / 12px 12px no-repeat,
    radial-gradient(circle, #c8102e 0 2.5px, transparent 3px) 12% 12% / 10px 10px no-repeat,
    radial-gradient(circle, #f2b705 0 2.5px, transparent 3px) 88% 12% / 10px 10px no-repeat,
    radial-gradient(circle, #c8102e 0 2.5px, transparent 3px) 88% 88% / 10px 10px no-repeat,
    radial-gradient(circle, #f2b705 0 2.5px, transparent 3px) 12% 88% / 10px 10px no-repeat;
}
.ix-av-option:has(input:checked)::after { animation: ix-av-burst .65s ease-out; }

/* The big character at the top hops in when it changes, then keeps swaying. */
.ix-avatar.preview svg { transform-origin: 50% 92%; animation: ix-av-sway 2.4s ease-in-out infinite; }
.ix-avatar.preview.bump { animation: ix-av-hop .65s cubic-bezier(.3, 1.4, .5, 1); }

@keyframes ix-av-jump {
  0% { transform: scale(.88); }
  25% { transform: translateY(2px) scale(1.1, .86); }
  50% { transform: translateY(-12px) scale(.94, 1.08); }
  75% { transform: translateY(0) scale(1.05, .95); }
  100% { transform: scale(1); }
}
@keyframes ix-av-hop {
  0% { transform: scale(.6) rotate(-10deg); }
  40% { transform: scale(1.12, .9); }
  62% { transform: translateY(-16px) scale(.96, 1.06) rotate(3deg); }
  82% { transform: scale(1.03, .97); }
  100% { transform: none; }
}
@keyframes ix-av-sway { 0%, 100% { transform: rotate(0) scale(1.04); } 25% { transform: rotate(-5deg) scale(1.04); } 75% { transform: rotate(5deg) scale(1.04); } }
@keyframes ix-av-glow {
  0%, 100% { box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--text); }
  50% { box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px #f2b705, 0 0 18px 6px rgba(242, 183, 5, .55); }
}
@keyframes ix-av-burst { 0% { opacity: 1; transform: scale(.55); } 70% { opacity: 1; } 100% { opacity: 0; transform: scale(1.3); } }

/* Welcome: the slides sit low, close to the buttons. */
.ix-welcome .ix-slide { justify-content: flex-end; padding-bottom: 2px; }
.ix-welcome .ix-actions { margin-top: 30px; }

/* ---------- Profile, step 1: the whole screen fits without scrolling down ----------
   The characters sit in two rows that slide sideways, with the edge fading out to
   show that there are more. */
.ix-screen.ix-profile { height: 100vh; height: 100dvh; min-height: 0; overflow-y: auto; }
.ix-profile .ix-avatar.xl { font-size: clamp(72px, 13dvh, 112px); margin-bottom: 6px; }
.ix-profile .ix-form { flex: 1; display: flex; flex-direction: column; gap: 12px; }
.ix-profile fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.ix-profile .ix-legend { display: flex; align-items: baseline; justify-content: space-between; width: 100%; margin-bottom: 0; }
.ix-more { font-size: .82rem; font-weight: 650; color: var(--muted); }
.ix-more b { display: inline-block; animation: ix-nudge 1.6s ease-in-out infinite; }
.ix-profile .ix-avatars {
  grid-template-columns: none; grid-auto-flow: column;
  --size: clamp(64px, 9.6dvh, 86px);
  grid-template-rows: repeat(2, var(--size)); grid-auto-columns: var(--size); gap: 12px 14px;
  margin: -6px -20px 0; padding: 24px 20px 18px; /* room for the jump and sparks of the chosen one */
  overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory; scroll-padding: 0 20px;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 18px, #000 calc(100% - 36px), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 18px, #000 calc(100% - 36px), transparent);
}
.ix-profile .ix-avatars::-webkit-scrollbar { display: none; }
.ix-profile .ix-av-option { width: var(--size); max-width: none; scroll-snap-align: start; }
.ix-profile .ix-error:empty { display: none; }
.ix-profile .ix-form > .btn { margin-top: auto; }
@keyframes ix-nudge { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(4px); } }

/* Short phones: a smaller picture at the top and no hint under the alias. */
@media (max-height: 720px) {
  .ix-profile .ix-head { margin-bottom: 2px; }
  .ix-profile .ix-sub { margin-top: 4px; font-size: .92rem; }
  .ix-profile .ix-field small { display: none; }
  .ix-profile .ix-avatars { --size: 64px; padding-block: 22px 14px; }
}
