* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
}

body {
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  background: #1e2b4c;
  color: #fff;
  overflow: hidden;
  transition: background .6s;
}

body.light {
  background: #fff;
}

img {
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 14px 0 18px;
  overflow-x: hidden;
  overflow-y: auto;
  opacity: 0;
  pointer-events: none;
  transition: opacity .4s;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
}

.stage {
  position: relative;
  flex: none;
  width: min(100vw, 520px, calc((100dvh - 110px) * .8));
  aspect-ratio: 1080 / 1350;
  overflow: hidden;
  container-type: inline-size;
}

.base {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.layer {
  position: absolute;
  pointer-events: none;
}

.layer img {
  width: 100%;
  height: 100%;
}

.below {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: min(100vw, 520px);
  margin-top: 14px;
  padding: 0 18px;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 14px 30px;
  background: #ef4f93;
  color: #fff;
  font: 700 16px/1 inherit;
  font-family: inherit;
  letter-spacing: .02em;
  box-shadow: 0 4px 0 #b8336d;
  cursor: pointer;
  transition: transform .1s;
}

.btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #b8336d;
}

.spin { animation: spin 16s linear infinite; }
.spin-reverse { animation: spin 22s linear infinite reverse; }
.beat { animation: beat 1.5s ease-in-out infinite; }
.beat.slow { animation-duration: 2.2s; animation-delay: .4s; }
.bounce { animation: bounce 2.4s ease-in-out infinite; }
.bounce.delay { animation-delay: 1.2s; }
.pulse { animation: pulse 2.6s ease-in-out infinite; }
.twinkle { animation: twinkle 2.4s ease-in-out infinite; }
.twinkle.delay { animation-delay: 1.2s; }
.swing { animation: swing 2.6s ease-in-out infinite alternate; }

.pale.play { animation: fadeOut 1.5s .7s ease-in forwards; }
.blur.play { animation: fadeOut 2.6s 1.6s ease-in-out forwards; }
.caption.play { animation: wipe 1.6s 2.6s ease-in-out forwards; }

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes beat {
  0%, 60%, 100% { transform: scale(1); }
  14% { transform: scale(1.18); }
  28% { transform: scale(1.03); }
  42% { transform: scale(1.12); }
}

@keyframes bounce {
  0%, 55%, 100% { transform: scale(1); }
  15% { transform: scale(1.11); }
  28% { transform: scale(1.02); }
  40% { transform: scale(1.06); }
}

@keyframes pulse {
  50% { transform: scale(1.045); }
}

@keyframes twinkle {
  0%, 100% { transform: scale(.85) rotate(0); }
  50% { transform: scale(1.25) rotate(45deg); }
}

@keyframes swing {
  from { transform: rotate(-8deg); }
  to { transform: rotate(8deg); }
}

@keyframes fadeOut {
  to { opacity: 0; }
}

@keyframes wipe {
  from { clip-path: inset(0 0 0 0); }
  to { clip-path: inset(0 0 0 100%); }
}

.field {
  position: absolute;
  z-index: 8;
  border: 0;
  outline: 0;
  background: transparent;
  color: #262626;
  font-family: "Courier New", Courier, monospace;
  font-weight: 700;
  letter-spacing: -.03em;
  caret-color: #1a1aa8;
  resize: none;
}

.field::placeholder {
  color: #8d9bb8;
  font-weight: 400;
}

.field:focus {
  border-radius: 4px;
  background: rgba(255, 255, 255, .4);
}

#inputName {
  left: 46.4%;
  top: 47.5%;
  width: 22.6%;
  height: 3.7%;
  font-size: 3.3cqw;
}

#inputReason {
  left: 48.3%;
  top: 53.4%;
  width: 20.8%;
  height: 9.4%;
  font-size: 2.35cqw;
  line-height: 1.15;
}

.softkey {
  position: absolute;
  top: 63.2%;
  z-index: 8;
  height: 3.8%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  cursor: pointer;
}

#keyOptions {
  left: 30.8%;
  width: 11%;
}

#keyNext {
  left: 43%;
  width: 14%;
  color: #fff;
  font: 700 3.1cqw/1 "Arial Narrow", "Roboto Condensed", sans-serif;
  letter-spacing: .02em;
}

#keyNext span {
  padding: .25em .6em;
  border: 1.5px solid rgba(255, 255, 255, .85);
  border-radius: 4px;
  animation: blink 1.2s steps(2) infinite;
}

#keyBack {
  left: 61%;
  width: 8.6%;
}

@keyframes blink {
  50% { background: rgba(255, 255, 255, .28); }
}

#quizImage {
  transition: opacity .25s;
}

.photo {
  position: absolute;
  z-index: 7;
  width: 26.3%;
  height: 26.8%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  transform-origin: 49% 10.5%;
}

.p1 { left: 21.3%; top: 25.93%; }
.p2 { left: 52.41%; top: 25.93%; }
.p3 { left: 21.3%; top: 53.48%; }
.p4 { left: 52.41%; top: 53.48%; }

.photo img {
  width: 100%;
  height: 100%;
  transform-origin: 49% 10.5%;
  transition: transform .2s, filter .25s;
}

.photo.enter {
  animation: drop .7s cubic-bezier(.25, 1.5, .45, 1) both;
  animation-delay: var(--delay);
}

.photo.enter img {
  animation: hang var(--speed) ease-in-out infinite alternate;
  animation-delay: calc(var(--delay) + .7s);
}

.photo.picked {
  z-index: 9;
  animation: jump .55s cubic-bezier(.3, 1.6, .5, 1) both;
}

.photo.picked img {
  filter: drop-shadow(0 0 .9cqw #ff4f9a) drop-shadow(0 0 2.5cqw rgba(255, 79, 154, .8));
}

.photo.dim {
  opacity: .45;
  transform: scale(.92);
  transition: opacity .3s, transform .3s;
}

.photo.leave {
  animation: fall .45s ease-in both;
  animation-delay: var(--out);
}

@media (hover: hover) {
  .photo:hover img {
    transform: scale(1.06);
  }
}

@keyframes drop {
  from {
    opacity: 0;
    transform: translateY(-25%) rotate(var(--tilt)) scale(.5);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes hang {
  from { transform: rotate(calc(var(--angle) * -1)); }
  to { transform: rotate(var(--angle)); }
}

@keyframes jump {
  40% { transform: translateY(-9%) scale(1.12) rotate(-4deg); }
  70% { transform: translateY(0) scale(1.06) rotate(3deg); }
  100% { transform: scale(1.07); }
}

@keyframes fall {
  to {
    opacity: 0;
    transform: translateY(40%) rotate(var(--tilt)) scale(.7);
  }
}

.counter {
  color: #f7b6cf;
  font-size: 13px;
  letter-spacing: .08em;
}

.dots {
  display: flex;
  gap: 8px;
}

.dots i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .3);
  transition: background .3s, transform .3s;
}

.dots i.now {
  background: #ff6fae;
  transform: scale(1.35);
}

.dots i.done {
  background: #f7b6cf;
}

.bar-track {
  position: absolute;
  left: 30.28%;
  top: 71.63%;
  z-index: 5;
  width: 38.9%;
  height: 2.67%;
  border-radius: 999px;
  background: #e9bbcb;
}

.bar-fill {
  position: absolute;
  left: 30.65%;
  top: 71.93%;
  z-index: 5;
  width: 0;
  height: 2.07%;
  border-radius: 999px;
  background: #1800ad;
  overflow: hidden;
}

.bar-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .45), transparent);
  animation: shine 1.1s linear infinite;
}

.bar-fill.run {
  animation: fill 5.4s cubic-bezier(.45, .05, .35, 1) forwards;
}

@keyframes shine {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}

@keyframes fill {
  0% { width: 0; }
  18% { width: 7%; }
  30% { width: 11%; }
  45% { width: 17%; }
  58% { width: 20%; }
  72% { width: 27%; }
  86% { width: 33%; }
  100% { width: 38.15%; }
}

.loading-text {
  color: #f7b6cf;
  font-size: 15px;
  letter-spacing: .02em;
}

.slip {
  width: 100%;
  padding: 14px 16px;
  border: 2px dashed #ef8db5;
  border-radius: 14px;
  background: #fff6f9;
  color: #5a2440;
  font-size: 14px;
  line-height: 1.45;
  box-shadow: 0 3px 0 #e9bbcb;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .5s, transform .5s;
}

.slip .label {
  color: #c2416f;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.slip .value {
  margin-bottom: 6px;
  color: #2b1a24;
  font-family: "Courier New", monospace;
  font-weight: 700;
  word-break: break-word;
}

.slip .value:last-child {
  margin-bottom: 0;
}

.fade {
  opacity: 0;
  transition: opacity .5s .2s;
}

.slip.show,
.fade.show {
  opacity: 1;
  transform: none;
}

.done {
  color: #f7b6cf;
  font-size: 14px;
  text-align: center;
}

[hidden] {
  display: none !important;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 9;
  max-width: 90vw;
  padding: 11px 18px;
  border-radius: 999px;
  background: #ef4f93;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
  opacity: 0;
  transform: translate(-50%, 20px);
  transition: .3s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.music {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: #ef4f93;
  color: #fff;
  font-size: 20px;
  box-shadow: 0 3px 0 #b8336d;
  cursor: pointer;
}

.music.show {
  display: flex;
}

.music.playing span {
  animation: note 1.2s ease-in-out infinite;
}

.music.muted {
  background: #9b8fa5;
  box-shadow: 0 3px 0 #6e6478;
}

.music.muted span {
  text-decoration: line-through;
}

@keyframes note {
  50% { transform: translateY(-3px) rotate(-8deg); }
}

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