/* ============================================
   LEVELS
   The points earned at the end of a game (on the winner card), the full-screen
   celebration when a level is reached and a reward unlocked, and the level
   road: every level with something to unlock and where you are.
   (The rules and the numbers are in shared/level.js, the code in linotte.js.)
   ============================================ */

/* ---------- points earned: one gold badge per thing that paid ---------- */
/* The game's own points, the day's first game, a rewarded ad: each is a gold
   badge that drops in at the top with a cascade of confetti, one below the
   other as they come, so every source of points gets its moment. A party, but
   under the full-screen level-up (98), and passing on its own. */
.points-stack {
  position: fixed;
  top: calc(max(14px, env(safe-area-inset-top, 0px)) + 6px);
  left: 50%;
  z-index: 96;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: max-content;
  max-width: calc(100vw - 32px);
  pointer-events: none;
  transform: translateX(-50%);
}

.points-badge {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 9px 22px;
  border: 1px solid rgba(0, 0, 0, .2);
  border-radius: 999px;
  /* Flat, like the rest of the app: two bands of colour instead of a gradient. */
  background: linear-gradient(180deg, #ffe27a 0 46%, #f2b02a 46% 100%);
  color: var(--ink);
  font-family: "Changa One", sans-serif;
  font-size: 20px;
  line-height: 1.1;
  white-space: nowrap;
  /* A small flat drop and two flat rings stepping out, in place of a blurred glow. */
  box-shadow: 0 6px 0 rgba(0, 0, 0, .22), 0 0 0 5px rgba(255, 216, 77, .38), 0 0 0 11px rgba(255, 196, 40, .2);
  animation: ppIn .7s cubic-bezier(.2, 1.5, .4, 1) both;
}

/* A flat light band sweeping over the badge, and a ring spreading from it. */
.points-badge::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(100deg, transparent 0 42%, rgba(255, 255, 255, .55) 42% 58%, transparent 58% 100%);
  background-size: 250% 100%;
  animation: ppShine 1.3s .3s ease-out both;
}

.points-badge::before {
  content: "";
  position: absolute;
  inset: -2px;
  border: 3px solid rgba(255, 224, 110, .9);
  border-radius: inherit;
  animation: ppRing .9s .15s ease-out both;
}

.points-badge.leaving {
  animation: ppOut .45s cubic-bezier(.5, 0, .9, .4) both;
}

.pp-gain {
  font-weight: normal;
  font-size: 30px;
  color: #1f6b3b;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .55);
  animation: ppGain .6s .2s cubic-bezier(.2, 1.8, .4, 1) both;
}

.pp-text {
  font-size: 17px;
  opacity: .9;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Points lost (an abandoned game): the same flat pill, in red. It doesn't drop in with a
   bounce and shine: it falls fast, hits with a thud (squashed for a moment) and shakes
   itself still, red bits of it fall away (see addPointsBadge), no ring, no shine. */
.points-badge.is-loss {
  background: linear-gradient(180deg, #ff9d92 0 46%, #e4584b 46% 100%);
  color: #4a120c;
  box-shadow: 0 6px 0 rgba(0, 0, 0, .22), 0 0 0 5px rgba(255, 120, 104, .36), 0 0 0 11px rgba(228, 88, 75, .18);
  animation: ppFall .42s cubic-bezier(.55, 0, .9, .5) both, ppThud .65s .42s ease-out both;
}

.points-badge.is-loss::before,
.points-badge.is-loss::after {
  display: none;
}

/* A game worth nothing: the same flat pill in grey, it settles without shine or ring. */
.points-badge.is-zero {
  background: linear-gradient(180deg, #e3e6ea 0 46%, #bcc2ca 46% 100%);
  color: #343a42;
  box-shadow: 0 6px 0 rgba(0, 0, 0, .2), 0 0 0 5px rgba(160, 168, 178, .3), 0 0 0 11px rgba(160, 168, 178, .15);
  animation: ppCalm .4s both;
}
.points-badge.is-zero::before,
.points-badge.is-zero::after {
  display: none;
}

.points-badge.is-zero .pp-gain {
  color: #4a525c;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .5);
  animation: none;
}

.points-badge.is-loss .pp-gain {
  color: #6e1710;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .4);
  animation: ppGainLoss .5s .42s cubic-bezier(.3, 0, .3, 1) both;
}

@keyframes ppFall {
  0% { opacity: 0; transform: translateY(-190%); }
  100% { opacity: 1; transform: none; }
}
@keyframes ppThud {
  0% { transform: scale(1.07, .86); }
  20% { transform: translateX(-8px) rotate(-1.6deg); }
  42% { transform: translateX(7px) rotate(1.2deg); }
  64% { transform: translateX(-4px) rotate(-.6deg); }
  82% { transform: translateX(2px); }
  100% { transform: none; }
}
@keyframes ppGainLoss { from { opacity: 0; transform: scale(1.9); } }

@keyframes ppIn {
  0% { opacity: 0; transform: translateY(-160%) scale(.6); }
  45% { opacity: 1; transform: translateY(8%) scale(1.12); }
  70% { transform: translateY(0) scale(.97); }
  100% { opacity: 1; transform: none; }
}
@keyframes ppOut { to { opacity: 0; transform: translateY(-70%) scale(.9); } }
@keyframes ppShine { from { background-position: 150% 0; } to { background-position: -50% 0; } }
@keyframes ppRing { from { opacity: 1; transform: scale(1); } to { opacity: 0; transform: scale(1.5, 2.1); } }
@keyframes ppGain { from { opacity: 0; transform: scale(.3); } }

@media (prefers-reduced-motion: reduce) {
  .points-badge { animation: ppCalm .4s both; }
  .points-badge.leaving { animation: ppCalmOut .3s both; }
  .points-badge.is-loss { animation: ppCalm .4s both; }
  .points-badge::after, .points-badge::before, .pp-gain { animation: none; }
  .points-badge::before { display: none; }
}
@keyframes ppCalm { from { opacity: 0; } }
@keyframes ppCalmOut { to { opacity: 0; } }

/* ---------- the points screen: the step after the winner card ---------- */
.points-dim {
  position: fixed;
  inset: 0;
  z-index: 94; /* under the confetti (95), which falls between it and the content (96) */
  background: radial-gradient(circle at 50% 34%, rgba(70, 38, 6, .86), rgba(8, 4, 0, .96) 75%);
  backdrop-filter: blur(6px);
  animation: luFade .35s ease-out both;
}

.points-screen {
  position: fixed;
  inset: 0;
  z-index: 96;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(12px, env(safe-area-inset-top, 0px)) 12px max(12px, env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
}

/* The winner card waits out of sight behind the points screen (it is still there for a rematch). */
body.ps-open #winner-overlay {
  visibility: hidden;
}

.points-dim[hidden],
.points-screen[hidden] {
  display: none;
}

.ps-card {
  width: min(100%, 24em);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1em;
  text-align: center;
  color: #fff;
  font-family: "Changa One", sans-serif;
  font-size: 16px;
}

.ps-title {
  margin: 0;
  font-weight: normal;
  font-size: 2em;
  letter-spacing: .04em;
  color: #ffe58a;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .35);
  animation: luRise .5s .1s both;
}

/* The badges, one under the other as they come (see addPointsBadge). */
.ps-badges {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  min-height: 3.5em;
}

/* A Ruthless game: what the opponent gained or lost, under the bar, after the badges. */
.ps-opponent {
  text-align: center;
  font-family: sans-serif;
  font-size: 1.05em;
  color: #fff;
  opacity: 0;
  transition: opacity .4s;
}

.ps-opponent.in {
  opacity: 1;
}

.ps-opponent b {
  color: #ffe58a;
}

.ps-opponent.is-loss b {
  color: #ff9d9d;
}

/* The way to the next level: shown after the badges, then it fills. */
.ps-bar-block {
  width: 100%;
  padding: .7em .9em .8em;
  box-sizing: border-box;
  border: .125em solid rgba(255, 255, 255, .25);
  border-radius: .9em;
  background: rgba(255, 255, 255, .12);
  opacity: 0;
  transform: translateY(.8em);
  transition: opacity .4s, transform .4s;
}

.points-screen.bar-in .ps-bar-block {
  opacity: 1;
  transform: none;
}

.ps-row {
  display: flex;
  align-items: baseline;
  gap: .6em;
  font-size: 1.15em;
  line-height: 1.1;
}

.ps-gain {
  font-size: 1.6em;
  color: #8be0a8;
  animation: psPop .7s cubic-bezier(.2, 1.7, .4, 1) both;
}

@keyframes psPop {
  from { opacity: 0; transform: scale(.3) translateY(1em); }
}

.ps-gain.is-negative {
  color: #ff9c94;
}

.ps-level {
  font-size: .9em;
}

.ps-pts {
  margin-left: auto;
  opacity: .8;
  font-variant-numeric: tabular-nums;
}

.ps-bar {
  height: .65em;
  margin-top: .45em;
  border-radius: .35em;
  background: rgba(0, 0, 0, .35);
  overflow: hidden;
}

.ps-bar > div {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: rgb(232, 185, 35);
  transition: width 1.1s cubic-bezier(.2, .8, .2, 1);
}

.ps-buttons {
  width: 100%;
  animation: luRise .5s .3s both;
}

/* ---------- the celebration ---------- */
.levelup-overlay {
  position: fixed;
  inset: 0;
  z-index: 98; /* above the winner card, the sheets and the toasts; the confetti library draws at 100 */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(12px, env(safe-area-inset-top, 0px)) 12px max(12px, env(safe-area-inset-bottom, 0px));
  background: radial-gradient(circle at 50% 34%, rgba(70, 38, 6, .7), rgba(8, 4, 0, .94) 72%);
  backdrop-filter: blur(6px);
  overflow: hidden;
  animation: luFade .35s ease-out both;
}

.levelup-overlay[hidden] {
  display: none;
}

.lu-card {
  position: relative;
  width: min(100%, 26em);
  max-height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .55em;
  padding: .5em .4em 1em;
  text-align: center;
  color: #fff;
  font-family: "Changa One", sans-serif;
  font-size: 16px;
  -webkit-overflow-scrolling: touch;
}

.lu-kicker {
  font-size: min(1.15em, 4.6vw);
  letter-spacing: .2em;
  padding-left: .2em;
  white-space: nowrap;
  color: rgb(255, 226, 122);
  animation: luDrop .55s .1s cubic-bezier(.2, 1.4, .4, 1) both;
}

/* The badge, in the colour of its tier; light rays turn behind it. */
.lu-badge {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  margin: .5em 0 .3em;
  padding: .06em .65em;
  font-size: 4.2em;
  line-height: 1.1;
  border: .08em solid rgb(255, 226, 122);
  box-shadow: 0 0 0 .06em rgba(0, 0, 0, .35), 0 .12em .4em rgba(0, 0, 0, .55), 0 0 .9em rgba(255, 214, 90, .55);
  text-shadow: 0 .04em 0 rgba(255, 255, 255, .35);
  animation: luPop .9s .15s cubic-bezier(.2, 1.7, .4, 1) both;
}

/* The rays are the overlay's own (the card scrolls and would cut them), put
   on the badge's centre by showLevelUp. */
.lu-rays {
  position: absolute;
  left: var(--ray-x, 50%);
  top: var(--ray-y, 30%);
  width: 220vmax;
  height: 220vmax;
  margin: -110vmax 0 0 -110vmax;
  background: repeating-conic-gradient(from 0deg, rgba(255, 226, 122, .26) 0 7deg, transparent 7deg 22deg);
  -webkit-mask-image: radial-gradient(circle, #000 0, transparent 38%);
  mask-image: radial-gradient(circle, #000 0, transparent 38%);
  animation: luSpin 30s linear infinite;
  pointer-events: none;
}

.lu-card {
  z-index: 1;
}

/* A light sweeping across the badge. */
.lu-badge::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(115deg, transparent 38%, rgba(255, 255, 255, .55) 50%, transparent 62%);
  background-size: 250% 100%;
  animation: luShine 2.6s 1.1s ease-in-out infinite;
  pointer-events: none;
}

.lu-title {
  margin: 0;
  font-size: 2.2em;
  line-height: 1.05;
  font-weight: 400;
  text-shadow: 0 .06em .2em rgba(0, 0, 0, .5);
  animation: luRise .6s .45s both;
}

.lu-sub {
  font-size: 1.1em;
  color: rgb(255, 226, 122);
  animation: luRise .6s .6s both;
}

.lu-sub:empty {
  display: none;
}

.lu-rewards {
  width: 100%;
  margin: .2em 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: .5em;
}

.lu-reward {
  display: grid;
  grid-template-columns: 4.2em minmax(0, 1fr) auto;
  align-items: center;
  gap: .7em;
  padding: .5em .7em;
  border-radius: 1em;
  background: rgba(255, 255, 255, .13);
  border: .12em solid rgba(255, 226, 122, .55);
  text-align: left;
  animation: luReward .6s calc(.8s + var(--i, 0) * .22s) cubic-bezier(.2, 1.5, .4, 1) both;
}

.lu-thumb {
  width: 4.2em;
  height: 4.2em;
  border-radius: .8em;
  background: rgba(255, 255, 255, .85) center / cover no-repeat;
  border: .12em solid rgba(255, 255, 255, .8);
  display: grid;
  place-items: center;
  overflow: hidden;
  animation: luWiggle 2.4s calc(1.6s + var(--i, 0) * .22s) ease-in-out infinite;
}

.lu-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.lu-thumb.is-dice img {
  object-fit: contain;
  padding: .25em;
}

.lu-swatch {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background: var(--badge-bg, #fff);
  color: var(--badge-ink, #3d240c);
  font-size: 1.9em;
}

.lu-reward-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: .1em;
}

.lu-tag {
  font-size: .72em;
  letter-spacing: .12em;
  color: rgb(255, 226, 122);
}

.lu-reward-text b {
  font-weight: 400;
  font-size: 1.25em;
  line-height: 1.1;
}

.lu-use {
  padding: .35em .8em;
  border: var(--btn-border);
  border-radius: .5625em;
  background: rgb(232, 185, 35);
  color: #5f4604;
  font: 1em "Changa One", sans-serif;
  cursor: pointer;
}

.lu-use[disabled] {
  background: rgba(255, 255, 255, .25);
  color: rgba(255, 255, 255, .8);
  border-color: rgba(255, 255, 255, .35);
  cursor: default;
}

.lu-next {
  font-size: .95em;
  color: rgba(255, 255, 255, .8);
  animation: luRise .6s 1.2s both;
}

.lu-next:empty {
  display: none;
}

.lu-buttons {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: .5em;
  margin-top: .3em;
  animation: luRise .6s 1.3s both;
}

/* The same buttons as the rest of the app (see .button and .sheet-btn): the shared
   border, corner, height and colours, the white heading-face text. */
.lu-btn {
  display: flex;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
  /* The sheets' buttons measure their border, corner and height in a 16px em, with the text
     1.35 times larger: the same numbers here, since this button's em is the text's. */
  min-height: 44.8px;
  padding: 0 1em;
  border-radius: 9px;
  border: 3px solid var(--btn-border-color);
  color: #fff;
  font: 21.6px/1 "Changa One", sans-serif;
  cursor: pointer;
}

.lu-btn:focus {
  outline: none;
}

.lu-ok {
  background: rgb(46, 160, 90);
}

.lu-road {
  background: rgb(70, 94, 228);
}

@keyframes luFade { from { opacity: 0; } }
@keyframes luDrop { from { opacity: 0; transform: translateY(-1.4em) scale(1.4); } }
@keyframes luPop { from { opacity: 0; transform: scale(.1) rotate(-30deg); } }
@keyframes luRise { from { opacity: 0; transform: translateY(1em); } }
@keyframes luReward { from { opacity: 0; transform: translateX(-1.5em) scale(.85); } }
@keyframes luSpin { to { transform: rotate(360deg); } }
@keyframes luShine { 0%, 55% { background-position: 150% 0; } 100% { background-position: -50% 0; } }
@keyframes luWiggle { 0%, 70%, 100% { transform: rotate(0); } 76% { transform: rotate(-7deg) scale(1.05); } 84% { transform: rotate(6deg) scale(1.05); } 92% { transform: rotate(-3deg); } }

/* ---------- the road ---------- */
.road-panel {
  width: min(100%, 32em);
  margin: 0 auto;
  /* Starts at the same height and with the same side margins as the islands of
     the other pages (.opt-stack: .8em at the sides). */
  padding: 0 .8em 3em;
  box-sizing: border-box;
  font-size: 16px;
  color: var(--ink);
  text-align: left;
}

.road-list {
  margin: 11.2px 0 0; /* the gap every island has to the next (.7em of 16px) */
  padding: 0;
  list-style: none;
}

.road-stop {
  position: relative;
  display: grid;
  grid-template-columns: 3.8em minmax(0, 1fr);
  gap: .8em;
  padding-bottom: 11.2px; /* the same gap between two cards */
}

/* The road itself: a line from each node down to the next. */
.road-stop::before {
  content: "";
  position: absolute;
  left: calc(1.9em - .22em);
  top: .95em;
  bottom: -.95em;
  width: .44em;
  border-radius: .22em;
  background: repeating-linear-gradient(to bottom, var(--road-todo, rgba(0, 0, 0, .2)) 0 .5em, transparent .5em .9em);
}

/* Done: solid, up to where you are. From "You are here" on, the way ahead is dashed. */
.road-stop.is-reached::before {
  background: var(--road-done, rgb(46, 160, 90));
}

.road-stop.is-you::before {
  background: repeating-linear-gradient(to bottom, var(--road-todo, rgba(0, 0, 0, .2)) 0 .5em, transparent .5em .9em);
}

.road-stop:last-child::before {
  display: none;
}

.road-node {
  position: relative;
  z-index: 1;
  min-width: 3.4em;
  height: 1.9em;
  padding: 0 .4em;
  border-radius: 1em;
  display: grid;
  place-items: center;
  background: #fff;
  border: .15em solid rgba(0, 0, 0, .28);
  font: .95em "Changa One", sans-serif;
  white-space: nowrap;
  color: var(--ink);
  box-sizing: border-box;
}

.road-node[data-tier]:not([data-tier="plain"]) {
  background: var(--badge-bg);
  color: var(--badge-ink);
}

/* Reached: a green frame. The pastille keeps the colour its level's badge has. */
.road-stop.is-reached .road-node {
  border-color: var(--road-done, #1f7a45);
}

.road-stop.is-next .road-node {
  border-color: rgb(232, 185, 35);
}

/* "You are here": the badge in your tier's colour. */
.road-stop.is-you .road-node {
  height: 2.2em;
  min-width: 3.8em;
  background: var(--badge-bg, #fff);
  color: var(--badge-ink, #3d240c);
  border-color: rgb(232, 185, 35);
  box-shadow: 0 0 0 .22em rgba(232, 185, 35, .35);
  animation: roadPulse 2.2s ease-in-out infinite;
}

.road-card {
  align-self: start;
  padding: .55em .8em .65em;
  border-radius: .9em;
  background: rgba(255, 255, 255, .88);
  border: .125em solid rgba(0, 0, 0, .18);
  min-width: 0;
}

.road-stop.is-next .road-card {
  border-color: rgb(232, 185, 35);
  box-shadow: 0 0 0 .15em rgba(232, 185, 35, .4);
}

.road-stop.is-you .road-card {
  background: #fff;
  border-color: rgb(232, 185, 35);
}

.road-card-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .6em;
  font-family: "Changa One", sans-serif;
}

.road-card-top b {
  font-weight: 400;
  font-size: 1.1em;
}

.road-pts {
  font-size: .82em;
  opacity: .7;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.road-gifts {
  margin: .35em 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: .4em;
}

.road-gift {
  display: grid;
  grid-template-columns: 3em minmax(0, 1fr);
  align-items: center;
  gap: .65em;
}

.road-thumb {
  width: 3em;
  height: 3em;
  border-radius: .6em;
  background: rgba(0, 0, 0, .06) center / cover no-repeat;
  border: .1em solid rgba(0, 0, 0, .2);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.road-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.road-thumb.is-dice img {
  object-fit: contain;
  padding: .2em;
}

.road-thumb .lu-swatch {
  font-size: 1.25em;
}

.road-gift-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  font-family: "Changa One", sans-serif;
  line-height: 1.1;
}

.road-gift-text small {
  font: .75em system-ui, sans-serif;
  opacity: .65;
}

.road-bar {
  height: .6em;
  margin-top: .5em;
  border-radius: .3em;
  background: rgba(0, 0, 0, .14);
  overflow: hidden;
}

.road-bar > div {
  height: 100%;
  background: rgb(232, 185, 35);
  border-radius: inherit;
}

.road-note {
  margin-top: .4em;
  font: .85em system-ui, sans-serif;
  opacity: .8;
}

.road-end {
  padding: .4em 0 0 3.8em;
  font: .9em system-ui, sans-serif;
  opacity: .7;
}

/* Not reached yet: a padlock on the level and on each reward's picture. */
.road-stop:not(.is-reached) .road-node::after {
  content: "";
  position: absolute;
  right: -.45em;
  bottom: -.45em;
  width: 1.3em;
  height: 1.3em;
  border-radius: 50%;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233d240c' stroke-width='2.6' stroke-linecap='round'%3E%3Crect x='5' y='11' width='14' height='10' rx='2' fill='%233d240c'/%3E%3Cpath d='M8 11V8a4 4 0 0 1 8 0v3'/%3E%3C/svg%3E") center / 68% no-repeat;
  border: .12em solid rgba(0, 0, 0, .35);
  box-sizing: border-box;
}

.road-stop:not(.is-reached) .road-thumb {
  position: relative;
  overflow: visible;
}

.road-stop:not(.is-reached) .road-thumb::after {
  content: "";
  position: absolute;
  right: -.35em;
  bottom: -.35em;
  width: 1.2em;
  height: 1.2em;
  border-radius: 50%;
  background: rgba(255, 255, 255, .95) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233d240c' stroke-width='2.6' stroke-linecap='round'%3E%3Crect x='5' y='11' width='14' height='10' rx='2' fill='%233d240c'/%3E%3Cpath d='M8 11V8a4 4 0 0 1 8 0v3'/%3E%3C/svg%3E") center / 66% no-repeat;
  border: .1em solid rgba(0, 0, 0, .35);
  box-sizing: border-box;
}

@keyframes roadPulse {
  50% { transform: scale(1.1); }
}

/* "How levels work", discreet, in the title's island: the same modal as the stats' (?). */
.page-heading .road-how {
  display: block;
  margin: .1em auto 0;
  padding: 0 0 0 1.35em;
  border: 0;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Ccircle cx='10' cy='10' r='8.6' fill='none' stroke='%233d240c' stroke-width='1.5'/%3E%3Cpath d='M7.7 7.7a2.4 2.4 0 1 1 3.3 2.2c-.6.3-1 .8-1 1.5v.4' fill='none' stroke='%233d240c' stroke-width='1.6' stroke-linecap='round'/%3E%3Ccircle cx='10' cy='14.4' r='.9' fill='%233d240c'/%3E%3C/svg%3E") left center / 1.05em no-repeat;
  color: var(--ink);
  font: .5em/1.5 "Changa One", sans-serif;
  opacity: .7;
  text-decoration: underline dotted;
  text-underline-offset: .2em;
  cursor: pointer;
}

/* ---------- where to find the road ---------- */
.level-road-btn {
  align-self: center;
  padding: .35em .9em;
  border: var(--btn-border);
  border-radius: .5625em;
  background: rgb(70, 94, 228); /* as LEVEL ROAD on the level screens (.lu-road) */
  color: #fff;
  font: .95em "Changa One", sans-serif;
  cursor: pointer;
}

#account-road {
  align-self: center;
  margin: .2em 0;
}

/* GET PRO in the account: the home's pill, the same (see .home-pro in home.css). */
.get-pro-hero {
  align-self: center;
  height: calc(2.75em / 1.0625 + 2px); /* as the profile pill: a hair taller than the icons */
  padding: 0 1em;
  border-radius: calc(1.375em / 1.0625);
  background: rgb(232, 185, 35);
  border: var(--btn-border);
  border-width: calc(2.75em * 13 / 180.86 / 1.0625); /* the options icon's ring */
  box-sizing: border-box;
  font: 1.0625em "Changa One", sans-serif;
  font-size: calc(var(--home-scale) * 1.0625); /* the home's own size */
  color: #5f4604;
  white-space: nowrap;
  cursor: pointer;
}

.get-pro-hero[hidden] {
  display: none;
}

.get-pro-hero:active {
  transform: translateY(.08em);
}

@media (prefers-reduced-motion: reduce) {
  .levelup-overlay,
  .lu-kicker,
  .lu-badge,
  .lu-rays,
  .lu-badge::after,
  .lu-title,
  .lu-sub,
  .lu-reward,
  .lu-thumb,
  .lu-next,
  .lu-buttons,
  .road-stop .road-node,
  .ps-title,
  .ps-buttons {
    animation: none !important;
  }
}

/* ---------- losing a level ---------- */
/* The same overlay, without the party: dark, the badge cracking and sinking. */
.leveldown-overlay {
  position: fixed;
  inset: 0;
  z-index: 98;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(12px, env(safe-area-inset-top, 0px)) 12px max(12px, env(safe-area-inset-bottom, 0px));
  background: radial-gradient(circle at 50% 34%, rgba(40, 36, 32, .8), rgba(6, 5, 4, .96) 72%);
  backdrop-filter: blur(6px);
  overflow: hidden;
  animation: luFade .5s ease-out both;
}

.leveldown-overlay[hidden] {
  display: none;
}

/* A red flush as the crack runs. */
.leveldown-overlay::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 34%, rgba(214, 40, 40, .5), transparent 65%);
  opacity: 0;
  pointer-events: none;
}

.leveldown-overlay.is-hit::after {
  animation: ldFlush 1.1s ease-out;
}

.ld-card {
  position: relative;
  z-index: 1;
  width: min(100%, 24em);
  max-height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .55em;
  padding: .5em .4em 1em;
  text-align: center;
  color: #fff;
  font-family: "Changa One", sans-serif;
  font-size: 16px;
}

.ld-kicker {
  font-size: min(1.15em, 4.6vw);
  letter-spacing: .2em;
  padding-left: .2em;
  white-space: nowrap;
  color: rgb(255, 150, 140);
  text-shadow: 0 0 .8em rgba(214, 40, 40, .6);
  animation: ldKicker .7s .1s both;
}

.ld-stage {
  position: relative;
  margin: .6em 0 .5em;
  animation: ldAppear .6s .2s both;
}

.ld-stage.is-shaking {
  animation: ldShake .55s cubic-bezier(.36, .07, .19, .97);
}

.ld-badge {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  padding: .06em .65em;
  font-size: 3.8em;
  line-height: 1.1;
  border: .08em solid rgba(255, 255, 255, .6);
  box-shadow: 0 0 0 .06em rgba(0, 0, 0, .35), 0 .12em .4em rgba(0, 0, 0, .55);
  text-shadow: 0 .04em 0 rgba(255, 255, 255, .35);
  transition: transform .8s cubic-bezier(.5, 0, .3, 1), filter .8s;
}

.ld-nums {
  display: inline-grid;
  overflow: hidden;
}

.ld-stage.is-down .ld-badge {
  transform: translateY(.1em) scale(.94);
  filter: saturate(.5) brightness(.82);
}

/* The number: the old one drops out of the bottom, the new one falls in from the top. */
.ld-num {
  grid-area: 1 / 1;
  font-variant-numeric: tabular-nums;
}

.ld-new {
  opacity: 0;
}

.ld-stage.is-down .ld-old {
  opacity: 0;
  animation: ldOut .45s ease-in;
}

.ld-stage.is-down .ld-new {
  opacity: 1;
  animation: ldIn .6s .15s cubic-bezier(.3, 1.6, .5, 1) both;
}

/* The crack, drawn from the top. */
.ld-crack {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: #1a0d03;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  filter: drop-shadow(.6px .6px 0 rgba(255, 255, 255, .45));
  pointer-events: none;
}

.ld-stage.is-cracked .ld-crack {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset .3s ease-in;
}

/* ▼ N: how many levels. */
.ld-chip {
  position: absolute;
  right: -.9em;
  top: -.2em;
  padding: .1em .55em;
  border-radius: 1em;
  background: #c93232;
  border: .12em solid rgba(255, 255, 255, .8);
  color: #fff;
  font-size: 1.1em;
  line-height: 1.2;
  opacity: 0;
  transform: scale(.3);
}

.ld-stage.is-down .ld-chip {
  opacity: 1;
  transform: none;
  transition: opacity .2s .25s, transform .45s .25s cubic-bezier(.3, 1.8, .5, 1);
}

.ld-title {
  margin: 0;
  font-size: 2.2em;
  line-height: 1.05;
  font-weight: 400;
  text-shadow: 0 .06em .2em rgba(0, 0, 0, .5);
  animation: luRise .6s 1.2s both;
}

.ld-sub {
  color: rgba(255, 255, 255, .78);
  animation: luRise .6s 1.4s both;
}

.ld-locked,
.ld-next {
  font-size: .95em;
  color: rgba(255, 255, 255, .82);
  animation: luRise .6s 1.6s both;
}

.ld-locked:empty {
  display: none;
}

.ld-buttons {
  animation-delay: 1.8s;
}

@keyframes ldAppear { from { opacity: 0; transform: translateY(1.2em) scale(.85); } }
@keyframes ldKicker { from { opacity: 0; letter-spacing: .5em; } }
@keyframes ldShake {
  10%, 90% { transform: translateX(-2px) rotate(-1deg); }
  20%, 80% { transform: translateX(4px) rotate(1.5deg); }
  30%, 50%, 70% { transform: translateX(-7px) rotate(-2deg); }
  40%, 60% { transform: translateX(7px) rotate(2deg); }
}
@keyframes ldFlush { 0% { opacity: 0; } 20% { opacity: 1; } 100% { opacity: 0; } }
@keyframes ldOut { to { transform: translateY(130%); } }
@keyframes ldIn { from { transform: translateY(-130%); } }

@media (prefers-reduced-motion: reduce) {
  .leveldown-overlay,
  .leveldown-overlay.is-hit::after,
  .ld-kicker,
  .ld-stage,
  .ld-stage.is-shaking,
  .ld-badge,
  .ld-num,
  .ld-crack,
  .ld-chip,
  .ld-title,
  .ld-sub,
  .ld-locked,
  .ld-next,
  .ld-buttons {
    animation: none !important;
    transition: none !important;
  }
}

/* "Lv " and the number are separate pieces (the number counts): keep the space. */
#lu-pre, #lu-post, #ld-pre, #ld-post {
  white-space: pre;
}
