@font-face {
  font-family: "FuLuLingGanHeCha";
  src: url("./assets/FuLuLingGanHeChaTi-2.ttf?v=20260630-2") format("truetype");
  font-display: swap;
  font-style: normal;
  font-weight: normal;
}

:root {
  --paper: #fcf9ec;
  --ink: #191919;
  --muted: #7f7b70;
  --accent: #f54c4c;
  --accent-soft: #fff0dd;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.18);
  --side-pad: clamp(28px, 7vw, 34px);
  --bottom-safe: max(env(safe-area-inset-bottom), 18px);
  --top-safe: max(env(safe-area-inset-top), 18px);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100svh;
  display: grid;
  place-items: center;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  overflow: hidden;
}

button {
  border: 0;
  font: inherit;
  cursor: pointer;
}

.shell {
  width: 100vw;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 0;
}

.phone {
  position: relative;
  width: 100vw;
  min-height: 100svh;
  overflow: hidden;
  background: var(--paper);
}

.status-bar {
  position: absolute;
  inset: 0 0 auto;
  z-index: 20;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 19px;
  font-size: 11px;
  color: var(--ink);
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  padding: calc(var(--top-safe) + 24px) var(--side-pad) calc(var(--bottom-safe) + 18px);
}

.screen.is-active {
  display: flex;
}

.loading-screen {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.logo-title {
  display: block;
  width: 104px;
  height: auto;
  object-fit: contain;
  object-position: center;
  align-self: center;
  position: relative;
  top: 4px;
  margin: -10px 0 98px;
  transform-origin: 50% 55%;
  animation: logo-breathe 1500ms ease-in-out infinite;
}

.mascot {
  color: var(--ink);
}

.mascot-entry {
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  transform-origin: 50% 58%;
  animation: mascot-breathe 1500ms ease-in-out infinite;
}

.mascot img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.mascot-large {
  width: 174px;
  height: 174px;
}

.mascot-game {
  position: absolute;
  left: 50%;
  top: 58%;
  width: 146px;
  height: 146px;
  transform: translate(-50%, -50%);
  z-index: 3;
  transform-origin: 50% 64%;
  animation: mascot-wobble 1300ms ease-in-out infinite;
}

.primary,
.secondary,
.ghost {
  width: 100%;
  min-height: 52px;
  border-radius: 16px;
  font-size: 15px;
  font-weight: 800;
}

.primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 8px 18px rgba(245, 76, 76, 0.18);
}

.secondary,
.ghost {
  background: white;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(245, 76, 76, 0.1);
}

.game-screen {
  flex-direction: column;
}

.game-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
}

.icon-btn {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: transparent;
  color: #807a6c;
  font-size: 30px;
  line-height: 1;
}

.timer {
  color: var(--accent);
  font-size: 20px;
  font-weight: 800;
}

.timer b {
  font-size: 24px;
}

.prompt {
  margin: 26px 0 0;
  text-align: center;
  font-size: 15px;
  line-height: 1.35;
  font-weight: 800;
}

.arena {
  position: relative;
  flex: 1;
  min-height: min(54svh, 480px);
}

.word-field {
  position: absolute;
  inset: 0 0 0;
  z-index: 2;
}

.word {
  position: absolute;
  min-width: 26px;
  min-height: 26px;
  display: grid;
  place-items: center;
  color: var(--ink);
  font-family: "FuLuLingGanHeCha", sans-serif !important;
  font-weight: normal;
  font-size: var(--size, 28px);
  line-height: 1;
  letter-spacing: 0;
  text-shadow: none;
  opacity: 0;
  transform: translate(calc(-50% + var(--from-x, 0%)), calc(-50% + var(--from-y, 0%))) rotate(-8deg) scale(0.22);
  animation: mouth-pop 720ms cubic-bezier(.18, 1.18, .28, 1) forwards, floaty 1600ms ease-in-out 720ms infinite;
}

.word.is-burst {
  z-index: 8;
  animation: burst 560ms cubic-bezier(.12, .85, .22, 1) forwards;
  color: var(--accent);
}

.word.is-burst::before,
.word.is-burst::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 34px;
  height: 34px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0.2);
  opacity: 0.85;
  animation: burst-ring 520ms ease-out forwards;
}

.word.is-burst::after {
  width: 22px;
  height: 22px;
  animation-delay: 80ms;
}

.shard {
  position: absolute;
  width: var(--w, 10px);
  height: var(--h, 4px);
  border-radius: 2px;
  background: var(--accent);
  left: var(--x);
  top: var(--y);
  transform: rotate(var(--r));
  animation: shard 520ms ease-out forwards;
  pointer-events: none;
  z-index: 4;
}

.score-strip {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  height: 38px;
  font-size: 14px;
  font-weight: 800;
}

.score-strip strong {
  font-size: 28px;
}

.bottom {
  margin-top: 12px;
}

.ghost {
  margin-top: 12px;
}

.hidden {
  display: none;
}

.final-screen {
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.final-screen .final-label,
.final-screen .score-ring {
  transform: translateY(-92px);
}

.final-label {
  margin: 0 0 42px;
  font-size: 18px;
  font-weight: 800;
}

.score-ring {
  width: 188px;
  height: 188px;
  border: 3.5px solid var(--accent);
  border-radius: 50%;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  background: var(--paper);
  box-shadow: 0 16px 34px rgba(245, 76, 76, 0.18), 0 0 0 12px rgba(255, 239, 208, 0.75);
}

.score-ring strong {
  font-size: 76px;
  line-height: 0.9;
}

.score-ring span {
  font-size: 18px;
  font-weight: 800;
}

.actions {
  position: absolute;
  left: var(--side-pad);
  right: var(--side-pad);
  bottom: calc(var(--bottom-safe) + 18px);
  display: grid;
  gap: 12px;
}

.phone.shaking .mascot-game {
  animation: shake 170ms linear 2;
}

@keyframes mouth-pop {
  0% {
    opacity: 0;
    filter: blur(2px);
    transform: translate(calc(-50% + var(--from-x, 0%)), calc(-50% + var(--from-y, 0%))) rotate(-8deg) scale(0.22);
  }
  45% {
    opacity: 0.72;
  }
  100% {
    opacity: 1;
    filter: blur(0);
    transform: translate(-50%, -50%) rotate(var(--rot, 0deg)) scale(1);
  }
}

@keyframes pop {
  to {
    transform: translate(-50%, -50%) rotate(var(--rot, 0deg)) scale(1);
  }
}

@keyframes floaty {
  50% {
    translate: 0 -5px;
  }
}

@keyframes mascot-breathe {
  0%, 100% {
    transform: translateY(36px) scale(1);
  }
  50% {
    transform: translateY(36px) scale(1.105);
  }
}

@keyframes logo-breathe {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.085);
  }
}

@keyframes mascot-wobble {
  0%, 100% {
    transform: translate(-50%, -50%) rotate(-1.2deg) scale(1);
  }
  50% {
    transform: translate(-50%, -50%) rotate(1.5deg) scale(1.025);
  }
}

@keyframes burst {
  0% {
    opacity: 1;
    filter: blur(0);
    transform: translate(-50%, -50%) rotate(var(--rot, 0deg)) scale(1);
  }
  36% {
    opacity: 1;
    filter: blur(0);
    transform: translate(-50%, -50%) rotate(calc(var(--rot, 0deg) + 8deg)) scale(1.35);
  }
  to {
    opacity: 0;
    filter: blur(2.5px);
    transform: translate(-50%, -50%) rotate(calc(var(--rot, 0deg) + 24deg)) scale(2.15);
  }
}

@keyframes burst-ring {
  to {
    opacity: 0;
    transform: translate(-50%, -50%) scale(2.2);
  }
}

@keyframes shard {
  0% {
    opacity: 1;
    transform: rotate(var(--r)) scale(1);
  }
  to {
    opacity: 0;
    translate: var(--dx) var(--dy);
    transform: rotate(calc(var(--r) + 90deg)) scale(0.35);
  }
}

@keyframes shake {
  0%, 100% {
    transform: translate(-50%, -50%);
  }
  25% {
    transform: translate(calc(-50% - 5px), -50%) rotate(-3deg);
  }
  75% {
    transform: translate(calc(-50% + 5px), -50%) rotate(2deg);
  }
}

@media (min-width: 700px) {
  .shell {
    width: min(100vw, 440px);
    padding: 22px;
  }

  .phone {
    width: min(100%, 402px);
    min-height: auto;
    aspect-ratio: 402 / 874;
    box-shadow: var(--shadow);
  }
}
