:root {
  --cream-50: #fffdf7;
  --cream-100: #fff8e8;
  --cream-200: #f8edcf;
  --ink: #493b3d;
  --ink-soft: #766568;
  --yellow: #ffd95a;
  --yellow-deep: #f1b93d;
  --mint: #83d8a3;
  --mint-deep: #53b67b;
  --blue: #7fc6e8;
  --pink: #f49ab5;
  --pink-deep: #e47195;
  --white: #ffffff;
  --board-gap: 4px;
  --ease-pop: cubic-bezier(.2, .8, .2, 1);
  --shadow-soft: 0 18px 50px rgba(109, 83, 62, .14);
  --shadow-board: 0 26px 60px rgba(105, 76, 54, .2), 0 6px 0 #e6c67b;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--cream-100);
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 10%, rgba(255, 217, 90, .28), transparent 25rem),
    radial-gradient(circle at 88% 84%, rgba(131, 216, 163, .24), transparent 27rem),
    linear-gradient(145deg, #fffdf5 0%, #fff6e4 46%, #fdf8e9 100%);
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  text-wrap: pretty;
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
  font: inherit;
}

button:focus-visible {
  outline: 3px solid rgba(73, 59, 61, .4);
  outline-offset: 3px;
}

.ambient-shape {
  position: fixed;
  z-index: -1;
  width: 22rem;
  aspect-ratio: 1;
  border: 1px solid rgba(73, 59, 61, .06);
  border-radius: 43% 57% 65% 35% / 46% 37% 63% 54%;
  pointer-events: none;
}

.ambient-shape--one {
  top: -8rem;
  right: -8rem;
  background: rgba(244, 154, 181, .08);
  transform: rotate(17deg);
}

.ambient-shape--two {
  bottom: -10rem;
  left: -9rem;
  background: rgba(127, 198, 232, .08);
  transform: rotate(-11deg);
}

.app-shell {
  position: relative;
  width: min(100%, 620px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
}

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

.screen.is-active {
  display: flex;
  animation: screen-in 420ms var(--ease-pop) both;
}

.home-screen {
  position: relative;
  flex-direction: column;
  gap: 20px;
}

.home-ribbon {
  align-self: center;
  padding: 7px 12px;
  border: 1px solid rgba(73, 59, 61, .14);
  border-radius: 999px;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, .56);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .18em;
}

.hero-stage {
  position: relative;
  width: min(84vw, 330px);
  aspect-ratio: 1;
  margin: -6px auto -18px;
}

.hero-orbit {
  position: absolute;
  border: 1px dashed rgba(73, 59, 61, .13);
  border-radius: 50%;
}

.hero-orbit--outer {
  inset: 7%;
  animation: orbit-turn 38s linear infinite;
}

.hero-orbit--inner {
  inset: 24%;
  animation: orbit-turn 28s linear infinite reverse;
}

.hero-piece {
  position: absolute;
  width: 25%;
  aspect-ratio: 1;
  border: 5px solid rgba(255, 255, 255, .78);
  border-radius: 26%;
  object-fit: contain;
  box-shadow: 0 10px 24px rgba(91, 68, 53, .14);
  animation: hero-float 3.8s ease-in-out infinite;
}

.hero-piece--yangtao {
  top: 3%;
  left: 15%;
  transform: rotate(-9deg);
}

.hero-piece--yebao {
  top: 5%;
  right: 12%;
  animation-delay: -.9s;
  transform: rotate(8deg);
}

.hero-piece--longbao {
  top: 40%;
  left: 0;
  animation-delay: -1.7s;
  transform: rotate(-7deg);
}

.hero-piece--xiaoqian {
  right: 0;
  bottom: 27%;
  animation-delay: -2.4s;
  transform: rotate(8deg);
}

.hero-piece--xiaoli {
  bottom: 0;
  left: 34%;
  animation-delay: -3s;
  transform: rotate(-3deg);
}

.hero-center-mark {
  position: absolute;
  top: 31%;
  left: 31%;
  display: grid;
  width: 38%;
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid rgba(73, 59, 61, .12);
  border-radius: 43% 57% 48% 52% / 50% 42% 58% 50%;
  background: linear-gradient(145deg, var(--yellow), #ffe996);
  box-shadow: inset 0 0 0 7px rgba(255, 255, 255, .35), 0 14px 26px rgba(155, 111, 36, .18);
  transform: rotate(-5deg);
}

.hero-center-mark span {
  position: absolute;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: clamp(34px, 10vw, 48px);
  font-weight: 900;
  line-height: 1;
}

.hero-center-mark span:first-child {
  transform: translate(-20%, -20%);
}

.hero-center-mark span:last-child {
  transform: translate(24%, 25%);
}

.home-copy {
  position: relative;
  z-index: 1;
  text-align: center;
}

.eyebrow,
.result-kicker {
  margin: 0 0 3px;
  color: var(--pink-deep);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .25em;
}

.home-copy h1 {
  margin: 0;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: clamp(44px, 13vw, 70px);
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -.08em;
  text-shadow: 0 4px 0 rgba(255, 255, 255, .9);
}

.home-lede {
  width: min(100%, 390px);
  margin: 12px auto 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.8;
}

.home-actions {
  display: grid;
  gap: 10px;
}

.primary-button,
.secondary-button,
.text-button,
.icon-button,
.level-card {
  border: 0;
  cursor: pointer;
  transition: transform 160ms var(--ease-pop), box-shadow 160ms ease, opacity 160ms ease;
}

.primary-button {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 13px 18px;
  border: 1px solid rgba(73, 59, 61, .14);
  border-radius: 18px;
  color: var(--ink);
  background: var(--yellow);
  box-shadow: 0 5px 0 var(--yellow-deep), 0 12px 26px rgba(180, 129, 34, .18);
  font-size: 17px;
  font-weight: 900;
}

.primary-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 7px 0 var(--yellow-deep), 0 15px 30px rgba(180, 129, 34, .2);
}

.primary-button:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--yellow-deep);
}

.button-arrow {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, .52);
}

.save-note {
  display: flex;
  justify-content: space-between;
  padding: 0 5px;
  color: var(--ink-soft);
  font-size: 11px;
}

.save-note strong {
  color: var(--ink);
}

.level-select {
  padding: 16px;
  border: 1px solid rgba(73, 59, 61, .1);
  border-radius: 24px;
  background: rgba(255, 255, 255, .6);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(12px);
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-heading h2 {
  margin: 0;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 22px;
}

.section-heading span {
  color: var(--ink-soft);
  font-size: 11px;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}

.level-card {
  position: relative;
  min-height: 82px;
  padding: 12px 8px;
  border: 1px solid rgba(73, 59, 61, .12);
  border-radius: 18px;
  background: var(--white);
  text-align: left;
  box-shadow: 0 3px 0 rgba(73, 59, 61, .1);
}

.level-card:hover:not(:disabled) {
  transform: translateY(-2px) rotate(-1deg);
}

.level-card:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: none;
}

.level-card:disabled {
  cursor: not-allowed;
  opacity: .43;
  filter: grayscale(.45);
}

.level-card__number {
  display: block;
  margin-bottom: 12px;
  color: var(--pink-deep);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .12em;
}

.level-card__name {
  display: block;
  font-size: 13px;
  font-weight: 900;
}

.level-card__stars {
  display: flex;
  gap: 3px;
  margin-top: 7px;
}

.mini-star {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cream-200);
}

.mini-star.is-filled {
  background: var(--yellow-deep);
  box-shadow: 0 0 0 2px rgba(255, 217, 90, .28);
}

.game-screen {
  flex-direction: column;
  justify-content: flex-start;
  gap: 12px;
}

.game-header {
  display: grid;
  grid-template-columns: 44px 44px 58px 1fr 1fr;
  gap: 8px;
  align-items: stretch;
}

.icon-button {
  display: grid;
  width: 44px;
  min-height: 48px;
  place-items: center;
  border: 1px solid rgba(73, 59, 61, .1);
  border-radius: 16px;
  background: rgba(255, 255, 255, .72);
  box-shadow: 0 3px 0 rgba(73, 59, 61, .1);
  font-size: 21px;
  font-weight: 900;
}

.icon-button:active {
  transform: translateY(3px);
  box-shadow: none;
}

.sound-toggle {
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 13px;
}

.sound-toggle.is-muted {
  color: var(--ink-soft);
  background: rgba(255, 255, 255, .5);
  box-shadow: inset 0 0 0 1px rgba(73, 59, 61, .06);
}

.level-chip,
.hud-stat {
  display: flex;
  min-height: 48px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(73, 59, 61, .1);
  border-radius: 16px;
  background: rgba(255, 255, 255, .72);
  box-shadow: 0 3px 0 rgba(73, 59, 61, .1);
}

.level-chip span,
.hud-stat span {
  color: var(--ink-soft);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .12em;
}

.level-chip strong,
.hud-stat strong {
  margin-top: 1px;
  font-size: 17px;
  line-height: 1;
}

.hud-stat--score {
  background: rgba(255, 217, 90, .6);
}

.hud-stat--moves {
  background: rgba(131, 216, 163, .56);
}

.goal-panel {
  display: grid;
  grid-template-columns: minmax(110px, .9fr) minmax(0, 1.5fr);
  gap: 12px;
  align-items: center;
  padding: 11px 13px;
  border: 1px solid rgba(73, 59, 61, .1);
  border-radius: 19px;
  background: rgba(255, 255, 255, .72);
}

.goal-copy {
  min-width: 0;
}

.goal-kicker {
  display: block;
  margin-bottom: 2px;
  color: var(--pink-deep);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .12em;
}

.goal-copy strong {
  display: block;
  font-size: clamp(10px, 3vw, 14px);
  line-height: 1.45;
}

.goal-progress {
  display: flex;
  min-width: 0;
  justify-content: flex-end;
  gap: 6px;
}

.goal-token {
  display: flex;
  min-width: 0;
  flex: 0 1 auto;
  align-items: center;
  gap: 4px;
  padding: 3px 6px 3px 3px;
  border-radius: 999px;
  background: var(--cream-100);
}

.goal-token img {
  width: 25px;
  height: 25px;
  border-radius: 8px;
  object-fit: contain;
}

.goal-token__copy {
  display: flex;
  min-width: 28px;
  flex-direction: column;
  line-height: 1.15;
  white-space: nowrap;
}

.goal-token__copy strong {
  font-size: 8px;
  font-weight: 900;
}

.goal-token__copy small {
  margin-top: 2px;
  color: var(--ink-soft);
  font-size: 9px;
  font-weight: 900;
}

.goal-token.is-complete {
  color: #2b7950;
  background: rgba(131, 216, 163, .32);
}

.score-progress {
  width: 100%;
}

.score-progress__track {
  position: relative;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--cream-200);
}

.score-progress__fill {
  width: var(--progress, 0%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--yellow-deep), var(--pink));
  transition: width 260ms var(--ease-pop);
}

.score-progress__label {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 9px;
  font-weight: 800;
}

.board-stage {
  position: relative;
  width: min(100%, 560px);
  aspect-ratio: 1;
  margin: 5px auto 7px;
}

.board-backplate {
  position: absolute;
  inset: -7px;
  border: 1px solid rgba(73, 59, 61, .12);
  border-radius: 30px;
  background: #f3d989;
  box-shadow: var(--shadow-board);
  transform: rotate(-.6deg);
}

.board {
  position: absolute;
  z-index: 2;
  inset: 0;
  overflow: hidden;
  border: 4px solid rgba(255, 255, 255, .9);
  border-radius: 24px;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, .2) 25%, transparent 25% 75%, rgba(255, 255, 255, .2) 75%),
    #efd682;
  background-size: 25% 25%;
  touch-action: none;
  user-select: none;
  transition: filter 180ms ease, box-shadow 180ms ease;
}

.board-stage::after {
  position: absolute;
  z-index: 8;
  inset: -10px;
  border: 4px solid transparent;
  border-radius: 32px;
  content: "";
  opacity: 0;
  box-shadow: 0 0 0 0 rgba(255, 217, 90, 0);
  pointer-events: none;
}

.board-stage.is-ultimate-active::after,
.board-stage.is-ultimate-hit::after {
  border-color: rgba(255, 255, 255, .94);
  animation: ultimate-edge 620ms ease-out both;
}

.board-stage.is-ultimate-hit {
  animation: ultimate-shake 420ms ease-out both;
}

.board-stage.is-five-speaking .board {
  filter: brightness(.78) saturate(.82);
}

.board.is-busy .tile {
  cursor: wait;
}

.board.is-invalid {
  animation: board-nudge 280ms ease;
}

.board.is-shuffling {
  animation: board-shuffle 520ms var(--ease-pop);
}

.board.is-row-burst::before,
.board.is-col-burst::after {
  position: absolute;
  z-index: 9;
  content: "";
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, white 18% 82%, transparent);
  box-shadow: 0 0 18px var(--yellow), 0 0 6px white;
  pointer-events: none;
}

.board.is-row-burst::before {
  top: calc((var(--burst-row) + .5) * 12.5% - 4px);
  right: 0;
  left: 0;
  height: 8px;
  animation: row-sweep 360ms ease-out both;
}

.board.is-col-burst::after {
  top: 0;
  bottom: 0;
  left: calc((var(--burst-col) + .5) * 12.5% - 4px);
  width: 8px;
  background: linear-gradient(180deg, transparent, white 18% 82%, transparent);
  animation: col-sweep 360ms ease-out both;
}

.board.is-color-burst .board-gloss {
  background: radial-gradient(circle, rgba(255, 255, 255, .92), rgba(255, 216, 96, .35) 36%, transparent 70%);
  animation: color-board-burst 460ms ease-out both;
}

.board-gloss {
  position: absolute;
  z-index: 3;
  inset: 4px;
  border-radius: 21px;
  background: linear-gradient(135deg, rgba(255, 255, 255, .32), transparent 30% 70%, rgba(255, 255, 255, .13));
  pointer-events: none;
}

.tile {
  --r: 0;
  --c: 0;
  position: absolute;
  z-index: 2;
  top: 0;
  left: 0;
  width: 12.5%;
  height: 12.5%;
  margin: 0;
  padding: 2px;
  border: 0;
  background: transparent;
  cursor: grab;
  transform: translate(calc(var(--c) * 100%), calc(var(--r) * 100%));
  transition: transform 180ms var(--ease-pop);
  will-change: transform;
}

.tile:active {
  cursor: grabbing;
}

.tile__shell {
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  overflow: hidden;
  place-items: center;
  border: 1px solid rgba(73, 59, 61, .13);
  border-radius: 20%;
  background: rgba(255, 255, 255, .74);
  box-shadow: 0 2px 0 rgba(73, 59, 61, .11), inset 0 1px 0 rgba(255, 255, 255, .9);
  transition: transform 140ms var(--ease-pop), filter 140ms ease, box-shadow 140ms ease;
}

.tile:hover .tile__shell {
  transform: translateY(-1px) scale(1.03);
  filter: saturate(1.08);
}

.tile.is-selected {
  z-index: 5;
}

.tile.is-selected .tile__shell {
  box-shadow: 0 0 0 3px var(--pink), 0 5px 12px rgba(152, 80, 102, .22);
  transform: scale(1.08) rotate(-2deg);
}

.tile.is-hint .tile__shell {
  animation: hint-pulse 800ms var(--ease-pop) 2;
}

.tile img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.tile[data-special="row"] .tile__shell::after,
.tile[data-special="col"] .tile__shell::after {
  position: absolute;
  inset: 4px;
  border: 2px solid rgba(255, 255, 255, .9);
  border-radius: 16%;
  content: "";
  mix-blend-mode: overlay;
  pointer-events: none;
}

.tile[data-special="row"] .tile__shell::after {
  background: repeating-linear-gradient(0deg, rgba(255, 255, 255, .92) 0 4px, rgba(244, 115, 157, .75) 4px 8px);
}

.tile[data-special="col"] .tile__shell::after {
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, .92) 0 4px, rgba(83, 182, 123, .75) 4px 8px);
}

.tile[data-special="row"] .tile__shell::before,
.tile[data-special="col"] .tile__shell::before {
  position: absolute;
  z-index: 3;
  right: 3px;
  bottom: 3px;
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border: 2px solid white;
  border-radius: 50%;
  color: var(--ink);
  background: var(--yellow);
  box-shadow: 0 2px 5px rgba(73, 59, 61, .24);
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  pointer-events: none;
}

.tile[data-special="row"] .tile__shell::before { content: "横"; }
.tile[data-special="col"] .tile__shell::before { content: "纵"; }

.tile[data-special="row"] img,
.tile[data-special="col"] img {
  position: relative;
  z-index: 1;
  filter: saturate(1.15) contrast(1.05);
}

.tile[data-special="color"] .tile__shell {
  border: 3px solid rgba(255, 255, 255, .9);
  background:
    radial-gradient(circle at 50% 50%, #fff7cb 0 13%, transparent 14%),
    repeating-conic-gradient(from 12deg, var(--pink) 0 18deg, var(--yellow) 18deg 36deg, var(--mint) 36deg 54deg, var(--blue) 54deg 72deg);
  box-shadow: 0 0 0 2px rgba(73, 59, 61, .22), 0 0 18px rgba(244, 154, 181, .7);
  animation: color-orbit 3s linear infinite;
}

.tile[data-special="color"] .tile__shell::before {
  position: absolute;
  z-index: 1;
  inset: 2px;
  border: 3px solid transparent;
  border-radius: 50%;
  content: "";
  background: conic-gradient(var(--pink), var(--yellow), var(--mint), var(--blue), var(--pink)) border-box;
  mask: linear-gradient(#000 0 0) padding-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  animation: ultimate-ring 1.5s linear infinite;
  pointer-events: none;
}

.tile[data-special="color"] .tile__shell::after {
  position: absolute;
  z-index: 4;
  top: 1px;
  right: 1px;
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border: 2px solid white;
  border-radius: 50%;
  content: "全";
  color: var(--ink);
  background: var(--yellow);
  font-family: "STKaiti", "KaiTi", serif;
  font-size: clamp(12px, 3.7vw, 21px);
  font-weight: 900;
  text-shadow: 0 1px 0 white;
}

.tile[data-special="color"] img {
  position: relative;
  z-index: 2;
  display: block;
  width: 78%;
  height: 78%;
  filter: saturate(1.18) drop-shadow(0 0 5px white);
}

.tile.is-clearing .tile__shell {
  animation: tile-pop 240ms var(--ease-pop) both;
}

.tile.is-forging .tile__shell {
  animation: tile-forge 300ms var(--ease-pop) both;
}

.tile.is-ultimate-forging .tile__shell {
  animation: ultimate-forge 460ms var(--ease-pop) both;
}

.tile.is-color-target .tile__shell {
  z-index: 5;
  animation: color-target 420ms ease-out both;
}

.score-float-layer {
  position: absolute;
  z-index: 7;
  inset: 0;
  overflow: hidden;
  border-radius: 24px;
  pointer-events: none;
}

.match-line-layer,
.particle-layer {
  position: absolute;
  z-index: 13;
  inset: 0;
  overflow: hidden;
  border-radius: 24px;
  pointer-events: none;
}

.match-line-layer { z-index: 14; }

.match-line {
  position: absolute;
  max-width: 140px;
  padding: 3px 7px;
  border: 1px solid rgba(255, 255, 255, .9);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 248, 232, .92);
  box-shadow: 0 5px 14px rgba(73, 59, 61, .16);
  font-size: clamp(10px, 2.8vw, 13px);
  font-weight: 900;
  white-space: nowrap;
  animation: match-line-rise 820ms ease-out both;
}

.match-line--note,
.match-line--sun { background: rgba(255, 226, 118, .94); }
.match-line--wave,
.match-line--bubble { background: rgba(190, 235, 248, .94); }
.match-line--spark,
.match-line--tail { background: rgba(251, 198, 215, .94); }

.role-particle {
  position: absolute;
  z-index: 2;
  color: white;
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 0 5px currentColor;
  animation: role-particle-fly 680ms ease-out var(--particle-delay) both;
}

.role-particle--note { color: #f5bd24; }
.role-particle--wave { color: var(--blue); }
.role-particle--sun { color: var(--yellow-deep); }
.role-particle--bubble { color: var(--mint); }
.role-particle--spark { color: var(--pink-deep); }
.role-particle--tail { color: #f29d64; }

.link-beam {
  position: absolute;
  z-index: 1;
  height: 4px;
  border-radius: 999px;
  opacity: 0;
  transform-origin: left center;
  pointer-events: none;
  animation: link-beam-flash 620ms ease-out both;
}

.link-beam--double-c {
  background: linear-gradient(90deg, var(--pink), white, #f29d64);
  box-shadow: 0 0 10px var(--pink);
}

.link-beam--middle-jungle {
  background: linear-gradient(90deg, var(--mint), white, var(--blue));
  box-shadow: 0 0 10px var(--blue);
}

.team-rally-icon {
  --rally-index: 0;
  position: absolute;
  top: 3%;
  left: calc(10% + var(--rally-index) * 23%);
  width: 34px;
  height: 34px;
  border: 2px solid white;
  border-radius: 12px;
  object-fit: contain;
  box-shadow: 0 5px 12px rgba(73, 59, 61, .18);
  animation: rally-icon-pop 760ms var(--ease-pop) both;
}

.score-float {
  position: absolute;
  top: 48%;
  left: 50%;
  padding: 6px 11px;
  border: 2px solid white;
  border-radius: 999px;
  color: var(--ink);
  background: var(--yellow);
  box-shadow: 0 8px 20px rgba(110, 77, 43, .2);
  font-size: 14px;
  font-weight: 900;
  animation: score-rise 760ms var(--ease-pop) both;
}

.combo-banner {
  position: absolute;
  z-index: 24;
  top: 8px;
  left: 50%;
  display: grid;
  width: min(86%, 360px);
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 6px 12px 6px 7px;
  border: 2px solid white;
  border-radius: 16px;
  opacity: 0;
  background: rgba(255, 248, 232, .96);
  box-shadow: 0 10px 28px rgba(110, 70, 81, .2);
  pointer-events: none;
  transform: translate(-50%, -12px) scale(.94);
}

.combo-banner.has-no-avatar {
  grid-template-columns: 1fr;
  text-align: center;
}

.combo-banner img {
  width: 38px;
  height: 38px;
  border: 2px solid white;
  border-radius: 12px;
  object-fit: contain;
  background: var(--cream-100);
  box-shadow: 0 3px 8px rgba(73, 59, 61, .14);
}

.combo-banner > div {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
}

.combo-banner.has-no-avatar > div {
  align-items: center;
}

.combo-banner[data-tier="four"] {
  border-color: rgba(255, 255, 255, .96);
  background: linear-gradient(100deg, rgba(255, 226, 118, .98), rgba(251, 198, 215, .96));
  box-shadow: 0 10px 30px rgba(110, 70, 81, .24), 0 0 0 2px rgba(255, 255, 255, .52);
}

.combo-banner[data-tier="five"] {
  top: 12%;
  width: min(91%, 390px);
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 11px;
  padding: 11px 15px 11px 10px;
  border-width: 3px;
  border-radius: 22px;
  background: radial-gradient(circle at 48% 12%, white, var(--yellow) 30%, var(--pink) 67%, var(--mint));
  box-shadow: 0 18px 52px rgba(110, 70, 81, .34), 0 0 30px rgba(255, 216, 96, .56);
}

.combo-banner[data-tier="five"] img {
  width: 54px;
  height: 54px;
  border-radius: 17px;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .7), 0 0 20px rgba(255, 217, 90, .8);
  animation: ultimate-avatar 720ms var(--ease-pop) both;
}

.combo-banner[data-tier="five"] strong {
  font-size: clamp(21px, 6.5vw, 30px);
  line-height: 1.12;
  text-wrap: pretty;
}

.combo-banner[data-tier="link"] {
  background: linear-gradient(135deg, var(--pink), var(--blue));
}

.combo-banner[data-tier="team"] {
  background: var(--yellow);
  box-shadow: 0 16px 44px rgba(110, 77, 43, .3), 0 0 0 4px rgba(255, 255, 255, .7);
}

.combo-banner.is-visible {
  animation: combo-in 900ms var(--ease-pop) both;
}

.combo-banner strong {
  font-family: "STKaiti", "KaiTi", serif;
  font-size: clamp(16px, 4.8vw, 21px);
  line-height: 1.15;
}

.combo-banner span,
.combo-banner small {
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .12em;
}

.combo-banner small {
  margin-top: 2px;
  color: var(--ink-soft);
}

.aux-feedback {
  position: absolute;
  z-index: 23;
  top: 58px;
  right: 10px;
  max-width: 62%;
  padding: 5px 9px;
  border: 1px solid rgba(255, 255, 255, .9);
  border-radius: 999px;
  opacity: 0;
  color: var(--ink);
  background: rgba(255, 248, 232, .94);
  box-shadow: 0 5px 14px rgba(73, 59, 61, .16);
  font-size: 10px;
  font-weight: 900;
  text-align: right;
  pointer-events: none;
}

.aux-feedback.is-visible {
  animation: aux-feedback-in 820ms ease-out both;
}

.game-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.game-footer p {
  max-width: 54%;
  margin: 0;
  color: var(--ink-soft);
  font-size: 10px;
  line-height: 1.6;
}

.footer-actions {
  display: flex;
  gap: 7px;
}

.secondary-button {
  min-height: 42px;
  padding: 9px 13px;
  border: 1px solid rgba(73, 59, 61, .12);
  border-radius: 14px;
  background: rgba(255, 255, 255, .74);
  box-shadow: 0 3px 0 rgba(73, 59, 61, .1);
  font-size: 11px;
  font-weight: 900;
}

.secondary-button:hover {
  transform: translateY(-1px);
}

.secondary-button:active {
  transform: translateY(3px);
  box-shadow: none;
}

.tutorial-card {
  position: fixed;
  z-index: 30;
  right: 14px;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: 14px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  width: min(calc(100% - 28px), 560px);
  margin: auto;
  padding: 13px;
  border: 1px solid rgba(73, 59, 61, .14);
  border-radius: 20px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 22px 48px rgba(89, 67, 52, .23);
  animation: toast-in 360ms var(--ease-pop) both;
}

.tutorial-card[hidden] {
  display: none;
}

.tutorial-index {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 13px;
  background: var(--yellow);
  font-size: 11px;
  font-weight: 900;
}

.tutorial-card strong {
  display: block;
  font-size: 13px;
}

.tutorial-card p {
  margin: 3px 0 0;
  color: var(--ink-soft);
  font-size: 10px;
}

.tutorial-card button {
  min-height: 38px;
  padding: 8px 12px;
  border: 0;
  border-radius: 12px;
  background: var(--mint);
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
}

.toast {
  position: fixed;
  z-index: 40;
  top: max(18px, env(safe-area-inset-top));
  left: 50%;
  max-width: calc(100% - 36px);
  padding: 10px 15px;
  border: 1px solid rgba(73, 59, 61, .12);
  border-radius: 999px;
  opacity: 0;
  background: rgba(73, 59, 61, .93);
  color: white;
  box-shadow: 0 12px 32px rgba(73, 59, 61, .2);
  font-size: 12px;
  font-weight: 800;
  pointer-events: none;
  transform: translate(-50%, -16px);
}

.toast.is-visible {
  animation: toast-in-out 1900ms var(--ease-pop) both;
}

.result-overlay {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  overflow: auto;
  place-items: center;
  padding: 20px;
  background: rgba(73, 59, 61, .28);
  backdrop-filter: blur(8px);
}

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

.result-card {
  position: relative;
  width: min(100%, 430px);
  overflow: hidden;
  padding: 28px 24px 22px;
  border: 2px solid rgba(255, 255, 255, .9);
  border-radius: 30px;
  background: var(--cream-50);
  box-shadow: 0 30px 80px rgba(73, 59, 61, .28);
  text-align: center;
  animation: result-in 480ms var(--ease-pop) both;
}

.result-burst {
  position: absolute;
  top: -120px;
  left: 50%;
  width: 330px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, rgba(255, 217, 90, .18) 0 10deg, transparent 10deg 20deg);
  pointer-events: none;
  transform: translateX(-50%);
}

.result-card h2 {
  position: relative;
  margin: 0;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 44px;
}

.stars {
  position: relative;
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 2px 0 8px;
}

.result-star {
  position: relative;
  width: 48px;
  height: 48px;
  opacity: .2;
  background: var(--cream-200);
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 94%, 50% 72%, 21% 94%, 32% 57%, 2% 35%, 39% 35%);
  transform: scale(.8);
}

.result-star.is-filled {
  opacity: 1;
  background: var(--yellow);
  filter: drop-shadow(0 5px 0 var(--yellow-deep));
  animation: star-pop 420ms var(--ease-pop) both;
}

.result-star:nth-child(2) {
  width: 58px;
  height: 58px;
  animation-delay: 120ms;
}

.result-star:nth-child(3) {
  animation-delay: 240ms;
}

.result-score {
  display: flex;
  width: 100%;
  flex-direction: column;
  align-items: center;
  padding: 14px;
  border-radius: 20px;
  background: rgba(255, 217, 90, .22);
}

.result-score span {
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .12em;
}

.result-score strong {
  margin: 3px 0 1px;
  font-size: 31px;
}

.result-score small {
  color: var(--pink-deep);
  font-size: 10px;
  font-weight: 900;
}

.harmony-result {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
  padding: 8px;
  border: 1px dashed rgba(73, 59, 61, .18);
  border-radius: 17px;
  background: linear-gradient(90deg, rgba(244, 154, 181, .16), rgba(131, 216, 163, .16));
  font-size: 12px;
  font-weight: 900;
  animation: harmony-glow 1.8s ease-in-out infinite;
}

.harmony-result[hidden] {
  display: none;
}

.harmony-result img {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  object-fit: contain;
}

.result-summary {
  margin: 13px 0 17px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.7;
}

.result-actions {
  display: grid;
  gap: 9px;
}

.result-actions .primary-button,
.result-actions .secondary-button {
  width: 100%;
}

.text-button {
  min-height: 38px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 800;
}

.text-button:hover {
  color: var(--ink);
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes orbit-turn {
  to { transform: rotate(360deg); }
}

@keyframes hero-float {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -7px; }
}

@keyframes board-nudge {
  0%, 100% { translate: 0; }
  25% { translate: -5px 0; }
  60% { translate: 4px 0; }
}

@keyframes board-shuffle {
  0%, 100% { transform: scale(1); filter: none; }
  45% { transform: scale(.94) rotate(-1deg); filter: saturate(.6); }
}

@keyframes flash-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes row-sweep {
  0% { opacity: 0; transform: scaleX(.04); }
  35% { opacity: 1; }
  100% { opacity: 0; transform: scaleX(1); }
}

@keyframes col-sweep {
  0% { opacity: 0; transform: scaleY(.04); }
  35% { opacity: 1; }
  100% { opacity: 0; transform: scaleY(1); }
}

@keyframes color-board-burst {
  0% { opacity: 0; transform: scale(.72) rotate(-5deg); }
  42% { opacity: 1; transform: scale(1.04) rotate(2deg); }
  100% { opacity: 0; transform: scale(1.12); }
}

@keyframes ultimate-edge {
  0% { opacity: 0; transform: scale(.96); box-shadow: 0 0 0 0 rgba(255, 217, 90, 0); }
  34% { opacity: 1; transform: scale(1.01); box-shadow: 0 0 32px 9px rgba(255, 217, 90, .58); }
  100% { opacity: 0; transform: scale(1.025); box-shadow: 0 0 48px 14px rgba(244, 154, 181, 0); }
}

@keyframes ultimate-shake {
  0%, 100% { transform: translate(0); }
  28% { transform: translate(-2px, 1px); }
  52% { transform: translate(2px, -1px); }
  76% { transform: translate(-1px, 0); }
}

@keyframes ultimate-ring {
  to { transform: rotate(360deg); }
}

@keyframes hint-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12) rotate(-2deg); box-shadow: 0 0 0 4px var(--yellow); }
}

@keyframes color-orbit {
  to { filter: hue-rotate(360deg); }
}

@keyframes tile-pop {
  0% { opacity: 1; transform: scale(1); filter: saturate(1); }
  45% { opacity: 1; transform: scale(1.18) rotate(4deg); filter: saturate(1.4) brightness(1.08); }
  100% { opacity: 0; transform: scale(.08) rotate(-16deg); filter: saturate(.4); }
}

@keyframes tile-forge {
  0% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.28) rotate(6deg); filter: brightness(1.35); }
  100% { transform: scale(.4) rotate(-10deg); opacity: 0; }
}

@keyframes ultimate-forge {
  0% { opacity: 1; transform: scale(1); filter: brightness(1); }
  38% { opacity: 1; transform: scale(1.22) rotate(-4deg); filter: brightness(1.45) saturate(1.35); }
  72% { opacity: 1; transform: scale(1.12) rotate(3deg); filter: brightness(1.65); }
  100% { opacity: 0; transform: scale(.35) rotate(-8deg); }
}

@keyframes color-target {
  0% { transform: scale(1); filter: brightness(1); }
  38% { transform: scale(1.13); filter: brightness(1.75) saturate(1.3); box-shadow: 0 0 0 3px white, 0 0 18px var(--yellow); }
  100% { transform: scale(.18); filter: brightness(1.45); opacity: .18; }
}

@keyframes score-rise {
  0% { opacity: 0; transform: translate(-50%, 8px) scale(.72) rotate(-4deg); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -72px) scale(1.08) rotate(2deg); }
}

@keyframes combo-in {
  0% { opacity: 0; transform: translate(-50%, -10px) scale(.9); }
  18%, 76% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -7px) scale(.97); }
}

@keyframes ultimate-avatar {
  0% { transform: scale(.72) rotate(-7deg); filter: brightness(1); }
  36% { transform: scale(1.22) rotate(4deg); filter: brightness(1.38); }
  100% { transform: scale(1); filter: brightness(1.08); }
}

@keyframes match-line-rise {
  0% { opacity: 0; transform: translate(-50%, 2px) scale(.82); }
  18%, 62% { opacity: 1; transform: translate(-50%, -10px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -38px) scale(.96); }
}

@keyframes role-particle-fly {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.45) rotate(0); }
  24% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--particle-x)), calc(-50% + var(--particle-y))) scale(1.1) rotate(32deg); }
}

@keyframes link-beam-flash {
  0% { opacity: 0; transform: rotate(var(--beam-angle, 0)) scaleX(.04); }
  28%, 62% { opacity: 1; transform: rotate(var(--beam-angle, 0)) scaleX(1); }
  100% { opacity: 0; transform: rotate(var(--beam-angle, 0)) scaleX(1); }
}

@keyframes rally-icon-pop {
  0% { opacity: 0; transform: translateY(-16px) scale(.5) rotate(-8deg); }
  26%, 68% { opacity: 1; transform: translateY(0) scale(1) rotate(2deg); }
  100% { opacity: 0; transform: translateY(-5px) scale(.88); }
}

@keyframes aux-feedback-in {
  0% { opacity: 0; transform: translateY(-7px) scale(.9); }
  20%, 72% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-5px) scale(.96); }
}

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

@keyframes toast-in-out {
  0%, 100% { opacity: 0; transform: translate(-50%, -16px); }
  14%, 82% { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes result-in {
  from { opacity: 0; transform: translateY(24px) scale(.92); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes star-pop {
  from { opacity: 0; transform: scale(.2) rotate(-26deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}

@keyframes harmony-glow {
  0%, 100% { box-shadow: 0 0 0 rgba(244, 154, 181, 0); }
  50% { box-shadow: 0 0 22px rgba(244, 154, 181, .22); }
}

@media (min-width: 700px) {
  body {
    padding: 24px;
  }

  .app-shell {
    min-height: calc(100vh - 48px);
    border: 1px solid rgba(73, 59, 61, .1);
    border-radius: 38px;
    background: rgba(255, 250, 238, .56);
    box-shadow: 0 32px 100px rgba(91, 66, 48, .14);
    backdrop-filter: blur(18px);
  }

  .screen {
    min-height: calc(100vh - 48px);
    padding: 28px 32px;
  }

  .hero-stage {
    width: 300px;
  }

  .game-screen {
    gap: 14px;
  }
}

@media (max-width: 380px) {
  .screen {
    padding-right: 12px;
    padding-left: 12px;
  }

  .home-screen {
    gap: 14px;
  }

  .hero-stage {
    width: 260px;
  }

  .home-copy h1 {
    font-size: 44px;
  }

  .goal-panel {
    grid-template-columns: 105px 1fr;
    gap: 6px;
    padding: 8px 9px;
  }

  .goal-token {
    gap: 2px;
    padding-right: 4px;
  }

  .goal-token img {
    width: 22px;
    height: 22px;
  }

  .game-footer p {
    display: none;
  }

  .game-footer,
  .footer-actions {
    width: 100%;
  }

  .footer-actions .secondary-button {
    flex: 1;
  }
}

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