:root {
  --ink: #2a1b2f;
  --paper: #fff5cf;
  --cream: #ffe8a7;
  --red: #f24f5f;
  --pink: #ff8da1;
  --yellow: #ffd14d;
  --green: #53c66e;
  --mint: #58d9c2;
  --blue: #4e8fe8;
  --purple: #9a6cf0;
  --brown: #9b5a38;
  --dark: #171326;
  --shadow: #171326;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100svh;
  display: grid;
  place-items: center;
  overflow-x: hidden;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    #1a1728;
  background-size: 16px 16px;
  color: var(--ink);
  font-family:
    "Malgun Gothic",
    "Apple SD Gothic Neo",
    system-ui,
    sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.game-shell {
  position: relative;
  width: min(100vw, 460px);
  min-height: 100svh;
  overflow: hidden;
  background: #ffeeb8;
  border-left: 4px solid #000;
  border-right: 4px solid #000;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.07), 0 20px 60px rgba(0, 0, 0, 0.45);
  image-rendering: pixelated;
}

.screen {
  min-height: 100svh;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.screen-store,
.screen-title,
.screen-intro {
  background:
    linear-gradient(180deg, #7edbe4 0 30%, transparent 30%),
    linear-gradient(90deg, #e44f58 0 16px, transparent 16px 32px),
    #ffe8a7;
  background-size: 100% 100%, 32px 20px, auto;
}

.menu-art-screen {
  position: relative;
  isolation: isolate;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}

.menu-art-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: rgba(255, 248, 217, 0.08);
  pointer-events: none;
}

.menu-art-screen > * {
  position: relative;
  z-index: 1;
}

.menu-title-screen {
  background-image: url("assets/ui/menu_title_tanghulu_shop.png");
}

.title-fruit-rain {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
}

.title-fruit-drop {
  position: absolute;
  left: var(--left);
  top: -52px;
  width: var(--size);
  height: var(--size);
  display: grid;
  place-items: center;
  transform: translateX(-50%);
  animation: title-fruit-fall var(--duration) linear var(--delay) infinite;
  image-rendering: pixelated;
  will-change: transform;
  filter: drop-shadow(0 3px 0 rgba(31, 24, 48, 0.45));
}

.title-fruit-drop img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  pointer-events: none;
}

.title-sparkle-drop {
  position: absolute;
  left: var(--left);
  top: -36px;
  width: var(--size);
  height: var(--size);
  transform: translateX(-50%);
  animation: title-sparkle-fall var(--duration) linear var(--delay) infinite;
  pointer-events: none;
  will-change: transform, opacity;
}

.title-sparkle-drop::before,
.title-sparkle-drop::after {
  content: "";
  position: absolute;
  inset: 0;
  background: #ffd14d;
  box-shadow: 0 0 0 2px #1f1830;
}

.title-sparkle-drop::before {
  transform: rotate(45deg) scale(0.72);
}

.title-sparkle-drop::after {
  inset: 35% -35%;
  transform: rotate(45deg);
  background: #fff8d9;
}

.sparkle-1::before {
  background: #ff8da1;
}

.sparkle-2::before {
  background: #fff8d9;
}

.menu-howto-screen {
  background-image: url("assets/ui/menu_howto_board.png");
  overflow: hidden;
}

.menu-settings-screen {
  background-image: url("assets/ui/menu_settings_shop.png");
}

.pixel-panel {
  border: 4px solid #1f1830;
  background: var(--paper);
  box-shadow: 0 6px 0 #1f1830;
}

.top-skip {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 10;
}

.pixel-button {
  min-height: 44px;
  padding: 10px 14px;
  border: 3px solid #1f1830;
  color: #1f1830;
  background: var(--yellow);
  box-shadow: 0 4px 0 #1f1830;
  font-weight: 900;
  letter-spacing: 0;
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.12s ease;
}

.pixel-button:active {
  transform: translateY(4px);
  box-shadow: 0 0 0 #1f1830;
}

.pixel-button:hover {
  filter: brightness(1.04);
}

.pixel-button.secondary {
  background: #fff5cf;
}

.pixel-button.green {
  background: #71dd88;
}

.pixel-button.red {
  background: #ff7b7b;
}

.pixel-button.blue {
  background: #83c7ff;
}

.pixel-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: 0 4px 0 #1f1830;
}

.title-logo {
  margin: 8px -10px 0;
  padding: 0;
  text-align: center;
}

.title-logo img {
  display: block;
  width: min(100%, 430px);
  height: auto;
  margin: 0 auto;
  image-rendering: pixelated;
  filter: drop-shadow(0 5px 0 #1f1830);
}

.title-logo p {
  display: inline-block;
  margin: -6px 0 0;
  padding: 5px 10px;
  border: 3px solid #1f1830;
  background: rgba(255, 247, 215, 0.94);
  box-shadow: 0 4px 0 #1f1830;
  font-size: 0.92rem;
  font-weight: 900;
}

.storefront {
  position: relative;
  min-height: 330px;
  border: 4px solid #1f1830;
  background:
    linear-gradient(180deg, transparent 0 26%, #ffd14d 26% 32%, transparent 32%),
    linear-gradient(90deg, #e64d57 0 20px, #fff7d7 20px 40px);
  background-size: auto, 40px 78px;
  overflow: hidden;
  box-shadow: 0 6px 0 #1f1830;
}

.storefront::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 78px;
  height: 116px;
  background: #ffe8a7;
  border-top: 4px solid #1f1830;
  border-bottom: 4px solid #1f1830;
}

.store-sign {
  position: absolute;
  left: 34px;
  right: 34px;
  top: 96px;
  padding: 8px 10px;
  border: 3px solid #1f1830;
  background: #fff5cf;
  text-align: center;
  font-weight: 900;
  box-shadow: 0 4px 0 #1f1830;
}

.store-counter {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 24px;
  height: 78px;
  border: 4px solid #1f1830;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.22) 0 8px, transparent 8px 20px),
    #b96d41;
  box-shadow: 0 6px 0 #1f1830;
}

.stick-row {
  position: absolute;
  left: 34px;
  right: 34px;
  bottom: 104px;
  display: flex;
  justify-content: space-around;
}

.tang-stick {
  width: 12px;
  height: 74px;
  background: #8f5130;
  border: 2px solid #1f1830;
  position: relative;
}

.tang-stick::before,
.tang-stick::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 24px;
  height: 24px;
  transform: translateX(-50%);
  border: 3px solid #1f1830;
  background: var(--red);
}

.tang-stick::before {
  top: -8px;
}

.tang-stick::after {
  top: 18px;
  background: var(--purple);
}

.title-actions {
  display: grid;
  justify-items: center;
  gap: 4px;
  margin-top: auto;
  padding-bottom: 2px;
}

.title-image-button {
  width: min(92%, 304px);
  padding: 0;
  border: 0;
  background: transparent;
  filter: drop-shadow(0 4px 0 rgba(31, 24, 48, 0.22));
  transition: transform 0.08s ease, filter 0.12s ease;
}

.title-image-button:hover {
  filter: brightness(1.04) drop-shadow(0 4px 0 rgba(31, 24, 48, 0.22));
}

.title-image-button:active {
  transform: translateY(4px);
  filter: drop-shadow(0 0 0 rgba(31, 24, 48, 0));
}

.title-image-button img {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
}

.title-links {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-bottom: 6px;
  font-size: 0.66rem;
  font-weight: 900;
}

.title-links a {
  padding: 4px 7px;
  border: 2px solid #1f1830;
  background: rgba(255, 247, 215, 0.9);
  color: #1f1830;
  text-decoration: none;
  box-shadow: 0 2px 0 #1f1830;
}

.dialogue-zone {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 18px;
  min-height: 156px;
  padding: 14px;
  display: grid;
  align-content: start;
  gap: 10px;
}

.dialogue-tag {
  display: inline-block;
  width: fit-content;
  padding: 5px 10px;
  border: 3px solid #1f1830;
  background: #83c7ff;
  font-weight: 900;
}

.dialogue-text {
  min-height: 58px;
  font-size: 1.05rem;
  line-height: 1.55;
  font-weight: 800;
}

.dialogue-hint {
  color: #75523c;
  font-size: 0.82rem;
  font-weight: 900;
  text-align: right;
}

.intro-scene {
  position: relative;
  flex: 1;
  min-height: 420px;
  border: 4px solid #1f1830;
  background:
    radial-gradient(circle at 50% 30%, #fff5cf 0 54px, transparent 56px),
    linear-gradient(180deg, #90e2e9 0 46%, #ffd77a 46% 57%, #b96d41 57%);
  box-shadow: 0 6px 0 #1f1830;
  overflow: hidden;
}

.intro-poster {
  position: absolute;
  left: 28px;
  top: 36px;
  width: 118px;
  height: 148px;
  border: 4px solid #1f1830;
  background:
    linear-gradient(90deg, #f24f5f 0 22px, transparent 22px),
    linear-gradient(180deg, #1f1830 0 26px, #ffe8a7 26px 100%);
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.18);
}

.intro-poster::after {
  content: "CONCERT";
  position: absolute;
  left: 8px;
  right: 8px;
  top: 44px;
  color: #1f1830;
  font-size: 0.92rem;
  font-weight: 900;
  text-align: center;
}

.intro-phone {
  position: absolute;
  right: 42px;
  top: 76px;
  width: 94px;
  height: 142px;
  border: 5px solid #1f1830;
  background: #fff5cf;
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.18);
}

.intro-phone::before,
.intro-phone::after {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  height: 12px;
  background: #f24f5f;
  border: 2px solid #1f1830;
}

.intro-phone::before {
  top: 36px;
}

.intro-phone::after {
  top: 60px;
  background: #83c7ff;
}

.help-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.help-list li {
  padding: 9px;
  border: 3px solid #1f1830;
  background: #fffbea;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.36;
}

.howto-card {
  flex: 1;
  min-height: 0;
  padding: 12px;
  display: grid;
  align-content: start;
  gap: 10px;
  background: rgba(255, 245, 207, 0.96);
}

.howto-page-head {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
}

.howto-page-head span {
  padding: 4px 7px;
  border: 3px solid #1f1830;
  background: #58d9c2;
  box-shadow: 0 3px 0 #1f1830;
  font-size: 0.62rem;
  font-weight: 900;
}

.howto-page-head strong {
  color: #1f1830;
  font-size: 1rem;
  line-height: 1.1;
}

.howto-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.howto-nav .pixel-button,
.menu-howto-screen > .pixel-button {
  min-height: 42px;
}

.howto-nav .pixel-button:disabled {
  opacity: 0.55;
  transform: none;
  filter: grayscale(0.45);
}

.screen-heading {
  width: fit-content;
  margin: 4px 0 0;
  padding: 8px 12px;
  border: 4px solid #1f1830;
  background: rgba(255, 247, 215, 0.94);
  box-shadow: 0 5px 0 #1f1830;
  font-size: 1.65rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.settings-list {
  display: grid;
  gap: 12px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
}

.setting-name {
  display: grid;
  gap: 3px;
  font-weight: 900;
}

.setting-name span {
  font-size: 0.78rem;
  color: #705037;
}

.toggle-button {
  min-width: 82px;
  background: #ff7b7b;
}

.toggle-button.is-on {
  background: #71dd88;
}

.game-screen {
  position: relative;
  min-height: 100svh;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.16) 0 3px, transparent 3px 18px),
    linear-gradient(180deg, #ff8da1 0 24%, #ffd14d 24% 34%, #f24f5f 34% 44%, #ffe8a7 44% 100%);
  background-size: 18px 18px, auto;
}

.game-screen.fever {
  color: #fff8d5;
  background:
    linear-gradient(90deg, rgba(255, 209, 77, 0.22) 0 2px, transparent 2px 34px),
    radial-gradient(circle at 25% 18%, #ffd14d 0 24px, transparent 26px),
    radial-gradient(circle at 76% 20%, #ff8da1 0 22px, transparent 24px),
    linear-gradient(180deg, #39132f 0 45%, #f24f5f 45% 56%, #171326 56% 100%);
  background-size: 34px 34px, auto, auto, auto;
}

.stage-clear-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.16) 0 6px, transparent 6px 18px),
    rgba(31, 24, 48, 0.48);
  animation: stage-clear-fade 2.2s steps(5, end);
  pointer-events: all;
}

.stage-clear-card {
  width: min(360px, 92%);
  padding: 18px 14px 16px;
  display: grid;
  gap: 8px;
  border: 5px solid #1f1830;
  background: #fff5cf;
  color: #1f1830;
  box-shadow:
    0 6px 0 #1f1830,
    0 0 0 5px #ff5f88,
    0 0 0 9px #ffd14d;
  text-align: center;
  font-weight: 900;
  transform-origin: center;
  animation: stage-clear-pop 0.54s steps(4, end), stage-clear-pulse 0.7s steps(2, end) 0.55s infinite;
}

.stage-clear-card strong {
  display: block;
  color: #f24f5f;
  font-size: clamp(1.25rem, 7vw, 2rem);
  line-height: 1.08;
  text-shadow:
    2px 0 #1f1830,
    -2px 0 #1f1830,
    0 2px #1f1830,
    0 -2px #1f1830;
}

.stage-clear-card span {
  font-size: 0.78rem;
}

.stage-clear-kicker {
  justify-self: center;
  padding: 5px 9px;
  border: 3px solid #1f1830;
  background: #ffd14d;
  box-shadow: 0 3px 0 #1f1830;
  color: #1f1830;
}

.hud {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.hud-card {
  min-height: 54px;
  min-width: 0;
  padding: 6px 3px;
  border: 3px solid #1f1830;
  background:
    linear-gradient(180deg, #fff8d9 0 58%, #ffd77a 58% 100%);
  color: #1f1830;
  box-shadow: 0 3px 0 #1f1830;
  text-align: center;
  font-weight: 900;
}

.hud-label {
  display: block;
  margin-bottom: 2px;
  color: #b83d50;
  font-size: 0.6rem;
}

.hud-value {
  display: block;
  font-size: clamp(0.68rem, 2.6vw, 0.94rem);
  white-space: nowrap;
}

.stage-strip {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border: 3px solid #1f1830;
  background:
    linear-gradient(90deg, #ff6d8c 0 28%, #ffd14d 28% 72%, #ff6d8c 72% 100%);
  color: #1f1830;
  box-shadow: 0 3px 0 #1f1830;
  font-size: 0.74rem;
  font-weight: 900;
}

.stage-progress-label {
  min-width: 0;
  overflow: hidden;
  text-align: right;
  text-overflow: clip;
  white-space: nowrap;
}

.hud-title-button {
  min-height: 24px;
  padding: 3px 7px;
  border: 2px solid #1f1830;
  background: #fff1c2;
  color: #1f1830;
  box-shadow: 0 2px 0 #1f1830;
  font-size: 0.6rem;
  font-weight: 900;
  line-height: 1;
}

.hud-title-button:active {
  transform: translateY(2px);
  box-shadow: 0 0 0 #1f1830;
}

.fever-meter {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 3px solid #1f1830;
  background: #fff1c2;
  color: #1f1830;
  box-shadow: 0 3px 0 #1f1830;
  font-weight: 900;
}

.meter-track {
  height: 16px;
  border: 3px solid #1f1830;
  background: #ffcfbc;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0%;
  background:
    linear-gradient(90deg, #f24f5f 0 34%, #ffd14d 34% 66%, #ff8da1 66% 100%);
  transition: width 0.16s linear;
}

.playfield {
  --playfield-bg: url("assets/ui/game_shop_interior_playfield.png");
  position: relative;
  flex: 0 0 clamp(238px, 28svh, 262px);
  min-height: 238px;
  border: 4px solid #1f1830;
  background: var(--playfield-bg) center / cover no-repeat;
  box-shadow:
    inset 0 0 0 4px rgba(255, 141, 161, 0.45),
    0 5px 0 #b83d50;
  overflow: hidden;
  isolation: isolate;
}

.fever .playfield {
  --playfield-bg: url("assets/ui/game_fever_playfield.png");
}

.playfield::before {
  display: none;
}

.fever .playfield::before {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.18) 0 8px, transparent 8px 18px),
    #58325c;
}

.counter-foreground {
  position: absolute;
  left: 12px;
  right: 12px;
  top: auto;
  bottom: 0;
  height: 58px;
  z-index: 4;
  background: url("assets/ui/counter_foreground.png") center bottom / 100% 100% no-repeat;
  image-rendering: pixelated;
  pointer-events: none;
}

.customer-line {
  position: absolute;
  left: 7px;
  right: 7px;
  top: 6px;
  bottom: 34px;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
  gap: 4px;
}

.customer-order-card {
  --customer-scale: 1;
  --customer-y: 0px;
  position: relative;
  min-width: 0;
  height: 178px;
  padding: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  justify-items: center;
  align-items: end;
  border: 0;
  background: transparent;
  color: #1f1830;
  transform-origin: center bottom;
  transition: transform 0.08s ease, filter 0.12s ease;
}

.customer-order-card:disabled {
  cursor: default;
}

.customer-order-card.is-selected {
  transform: translateY(-5px);
  filter: drop-shadow(0 0 0 #fff) drop-shadow(0 0 7px rgba(255, 209, 77, 0.95));
}

.customer-order-card.is-urgent .order-card-bubble {
  animation: bubble-flash 0.42s steps(2, end) infinite;
}

.order-card-bubble {
  position: relative;
  z-index: 6;
  width: max-content;
  max-width: 100%;
  padding: 4px 3px 5px;
  border: 3px solid #1f1830;
  background: #fff1c2;
  box-shadow: 0 3px 0 #1f1830;
}

.order-card-bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -9px;
  width: 10px;
  height: 10px;
  transform: translateX(-50%) rotate(45deg);
  border-right: 3px solid #1f1830;
  border-bottom: 3px solid #1f1830;
  background: inherit;
}

.customer-order-card.is-selected .order-card-bubble {
  background: #ffd14d;
}

.order-card-bubble.fail {
  background: #ff9eb0;
  animation: bubble-flash 0.42s steps(2, end);
}

.order-items {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 3px;
}

.order-card-bubble .asset-token.tiny {
  width: 20px;
  height: 20px;
  border-width: 2px;
  box-shadow: 0 2px 0 #1f1830;
  font-size: 0.62rem;
}

.order-card-bubble .order-items {
  max-width: 74px;
  flex-wrap: wrap;
  row-gap: 2px;
}

.order-card-bubble .order-arrow {
  font-size: 0.7rem;
}

.order-arrow {
  font-weight: 900;
}

.patience-meter {
  height: 9px;
  margin-top: 5px;
  border: 2px solid #1f1830;
  background: #ffe1a1;
  overflow: hidden;
}

.patience-fill {
  height: 100%;
  width: 100%;
  background:
    linear-gradient(90deg, #ffd14d 0 58%, #ff8da1 58% 100%);
  transition: width 0.08s linear;
}

.customer-order-card.is-urgent .patience-fill {
  background: #f24f5f;
}

.customer-card {
  position: relative;
  width: 72px;
  height: 92px;
  display: grid;
  place-items: center;
  margin-top: 8px;
  z-index: 2;
}

.customer-order-card .character-asset {
  position: absolute;
  inset: 0;
  transform: translateY(var(--customer-y)) scale(var(--customer-scale));
  transform-origin: center bottom;
}

.customer-order-card .customer-fallback {
  transform: scale(0.72);
  transform-origin: center bottom;
}

.customer-order-card.success .customer-card {
  animation: customer-pop 0.5s steps(3, end);
}

.customer-order-card.fail .customer-card {
  animation: customer-shake 0.38s steps(2, end);
}

.customer-sparkle {
  position: absolute;
  inset: -8px;
  display: none;
  pointer-events: none;
}

.customer-order-card.success .customer-sparkle {
  display: block;
  background:
    linear-gradient(90deg, transparent 0 28%, #ffd14d 28% 33%, transparent 33%),
    linear-gradient(180deg, transparent 0 52%, #fff 52% 56%, transparent 56%);
  animation: sparkle 0.5s steps(2, end);
}

.asset-token {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border: 3px solid #1f1830;
  background: #fff1c2;
  box-shadow: 0 3px 0 #1f1830;
  color: #1f1830;
  font-weight: 900;
  overflow: hidden;
}

.asset-token.tiny {
  width: 34px;
  height: 34px;
  font-size: 0.86rem;
}

.asset-img {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.asset-loaded > .asset-img {
  display: block;
}

.asset-loaded > .asset-fallback {
  display: none;
}

.asset-loaded > .customer-fallback,
.asset-loaded > .made-fallback {
  display: none;
}

.fruit-strawberry {
  background: #ffd5dc;
}

.fruit-grape {
  background: #dfd3ff;
}

.fruit-pineapple {
  background: #ffe991;
}

.fruit-orange {
  background: #ffd0a1;
}

.fruit-kiwi {
  background: #c9ee74;
}

.fruit-mango {
  background: #ffc45f;
}

.fruit-blueberry {
  background: #b8c7ff;
}

.coating-sugar {
  background: #f6fbff;
}

.coating-choco {
  background: #b67a55;
}

.coating-strawberry {
  background: #ffb7c3;
}

.coating-rainbow {
  background: linear-gradient(90deg, #ff7b7b 0 25%, #ffd14d 25% 50%, #58d9c2 50% 75%, #9a6cf0 75%);
}

.coating-yogurt {
  background: #fffef0;
}

.coating-caramel {
  background: #d99847;
}

.coating-mint {
  background: #a7f0d6;
}

.customer-sprite {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 2;
}

.customer-fallback,
.made-fallback {
  position: relative;
  width: 92px;
  height: 118px;
  display: grid;
  place-items: start center;
  padding-top: 16px;
  border: 4px solid #1f1830;
  background: #ffcf77;
  color: #1f1830;
  box-shadow: 0 5px 0 #1f1830;
  font-size: 2rem;
  font-weight: 900;
}

.customer-fallback::before,
.made-fallback::before {
  content: "";
  position: absolute;
  left: 24px;
  top: 55px;
  width: 44px;
  height: 42px;
  border: 4px solid #1f1830;
  background: #83c7ff;
}

.customer-fallback::after,
.made-fallback::after {
  content: "";
  position: absolute;
  left: 18px;
  bottom: -14px;
  width: 18px;
  height: 18px;
  background: #1f1830;
  box-shadow: 36px 0 0 #1f1830;
}

.customer-farmer .customer-fallback::before,
.customer-dancer .customer-fallback::before {
  background: #71dd88;
}

.customer-office .customer-fallback::before,
.customer-police .customer-fallback::before,
.customer-knight .customer-fallback::before {
  background: #5d6a82;
}

.customer-magician .customer-fallback::before,
.customer-pirate .customer-fallback::before {
  background: #ff9cc4;
}

.customer-hero .customer-fallback::before,
.customer-astronaut .customer-fallback::before {
  background: #9a6cf0;
}

.customer-rocket .customer-fallback::before,
.customer-firefighter .customer-fallback::before {
  background: #ff7b7b;
}

.customer-office {
  --customer-scale: 1;
  --customer-y: 0px;
}

.made-fallback {
  width: 62px;
  height: 76px;
  padding-top: 7px;
  font-size: 1.3rem;
  background: #ffd14d;
}

.made-fallback::before {
  left: 15px;
  top: 36px;
  width: 30px;
  height: 25px;
  background: #f24f5f;
}

.made-fallback::after {
  left: 12px;
  bottom: -10px;
  width: 12px;
  height: 12px;
  box-shadow: 25px 0 0 #1f1830;
}

.input-panel {
  display: grid;
  gap: 8px;
  padding: 8px;
  border: 4px solid #1f1830;
  background:
    linear-gradient(180deg, #fff5cf 0 56%, #ffe096 100%);
  box-shadow:
    inset 0 0 0 3px rgba(255, 95, 136, 0.26),
    0 4px 0 #b83d50;
}

.input-group {
  display: grid;
  gap: 7px;
}

.input-label {
  display: flex;
  justify-content: space-between;
  color: #b83d50;
  font-size: 0.78rem;
  font-weight: 900;
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(var(--button-count, 4), minmax(0, 1fr));
  gap: 5px;
}

.icon-button {
  min-width: 0;
  min-height: 49px;
  padding: 4px 2px;
  display: grid;
  place-items: center;
  gap: 2px;
  border: 3px solid #1f1830;
  background: #fff7d7;
  box-shadow: 0 3px 0 #1f1830;
  font-size: 0.56rem;
  font-weight: 900;
  color: #1f1830;
  line-height: 1.05;
  overflow: hidden;
}

.icon-button.is-selected {
  background: #ffd14d;
  transform: translateY(2px);
  box-shadow: 0 1px 0 #1f1830;
}

.icon-button .asset-token {
  width: 30px;
  height: 30px;
  border-width: 2px;
  box-shadow: 0 2px 0 #1f1830;
}

.item-button-label {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-align: center;
  text-overflow: clip;
  white-space: nowrap;
}

.selected-strip {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  flex-wrap: nowrap;
  padding: 6px;
  border: 3px solid #1f1830;
  background: #fff1c2;
  overflow: hidden;
}

.selected-empty {
  display: block;
  width: 100%;
  color: #b83d50;
  font-size: 0.72rem;
  font-weight: 900;
  text-align: center;
}

.slot {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 3px dashed #8f6d55;
  background: #fff5cf;
  color: #8f6d55;
  font-weight: 900;
}

.action-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: center;
  gap: 8px;
}

.action-row .pixel-button {
  min-height: 40px;
  padding-block: 8px;
}

.action-image-button {
  --action-button-height: 52px;
  min-width: 0;
  height: var(--action-button-height);
  min-height: 0;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  filter: drop-shadow(0 3px 0 rgba(31, 24, 48, 0.26));
  transition: transform 0.08s ease, filter 0.12s ease, opacity 0.12s ease;
}

.action-image-button img {
  display: block;
  width: auto;
  height: var(--action-button-height);
  max-width: none;
  max-height: none;
  object-fit: contain;
  image-rendering: pixelated;
  pointer-events: none;
}

.action-image-button:active:not(:disabled) {
  transform: translateY(3px);
  filter: drop-shadow(0 0 0 rgba(31, 24, 48, 0));
}

.action-image-button:disabled {
  cursor: default;
  opacity: 0.55;
  filter: grayscale(0.45);
}

.feedback-line {
  min-height: 22px;
  color: #b83d50;
  font-size: 0.78rem;
  font-weight: 900;
  text-align: center;
}

.ending-stats {
  display: grid;
  gap: 9px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border: 3px solid #1f1830;
  background: #fffbea;
  font-weight: 900;
}

.rank-card {
  padding: 14px;
  text-align: center;
}

.rank-name {
  margin: 6px 0;
  color: #d92e45;
  font-size: 1.35rem;
  font-weight: 900;
}

.ending-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: auto;
}

.shake-screen {
  animation: screen-shake 0.34s steps(2, end);
}

@keyframes customer-pop {
  0% {
    transform: translateY(0);
  }
  35% {
    transform: translateY(-16px);
  }
  70% {
    transform: translateY(4px);
  }
  100% {
    transform: translateY(0);
  }
}

@keyframes customer-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-9px);
  }
  50% {
    transform: translateX(9px);
  }
  75% {
    transform: translateX(-5px);
  }
}

@keyframes bubble-flash {
  0%,
  100% {
    filter: none;
  }
  50% {
    filter: saturate(1.6);
  }
}

@keyframes sparkle {
  0% {
    opacity: 0;
    transform: scale(0.85);
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: scale(1.12);
  }
}

@keyframes title-fruit-fall {
  0% {
    opacity: 0;
    transform: translate(-50%, -60px) rotate(-18deg);
  }
  8% {
    opacity: 1;
  }
  55% {
    transform: translate(calc(-50% + var(--drift)), 48svh) rotate(155deg);
  }
  92% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% - var(--drift)), 108svh) rotate(340deg);
  }
}

@keyframes title-sparkle-fall {
  0% {
    opacity: 0;
    transform: translate(-50%, -40px) scale(0.7) rotate(0deg);
  }
  12%,
  82% {
    opacity: 1;
  }
  45% {
    transform: translate(calc(-50% + var(--drift)), 42svh) scale(1.08) rotate(180deg);
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% - var(--drift)), 108svh) scale(0.7) rotate(360deg);
  }
}

@keyframes screen-shake {
  0%,
  100% {
    transform: translate(0, 0);
  }
  20% {
    transform: translate(-4px, 3px);
  }
  40% {
    transform: translate(4px, -3px);
  }
  60% {
    transform: translate(-3px, -2px);
  }
  80% {
    transform: translate(3px, 2px);
  }
}

@keyframes stage-clear-pop {
  0% {
    opacity: 0;
    transform: translateY(18px) scale(0.9);
  }
  65% {
    opacity: 1;
    transform: translateY(-4px) scale(1.04);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes stage-clear-pulse {
  0%,
  100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.12);
  }
}

@keyframes stage-clear-fade {
  0% {
    opacity: 0;
  }
  12%,
  88% {
    opacity: 1;
  }
  100% {
    opacity: 0.84;
  }
}

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

  .game-shell {
    min-height: min(820px, calc(100svh - 48px));
    height: min(820px, calc(100svh - 48px));
  }

  .screen,
  .game-screen {
    min-height: 100%;
  }
}

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

  .game-screen {
    padding: 7px;
  }

  .hud {
    gap: 4px;
  }

  .hud-card {
    min-height: 48px;
    padding: 5px 2px;
  }

  .hud-label {
    font-size: 0.52rem;
  }

  .hud-value {
    font-size: 0.66rem;
  }

  .stage-strip {
    font-size: 0.66rem;
    padding-inline: 6px;
  }

  .button-grid {
    gap: 3px;
  }

  .icon-button {
    min-height: 45px;
    font-size: 0.5rem;
    padding-inline: 1px;
  }

  .icon-button .asset-token {
    width: 26px;
    height: 26px;
  }

  .selected-strip {
    gap: 4px;
  }

  .asset-token {
    width: 37px;
    height: 37px;
  }

  .action-image-button {
    --action-button-height: 46px;
  }

  .customer-line {
    left: 5px;
    right: 5px;
    top: 5px;
    bottom: 31px;
    gap: 2px;
  }

  .customer-order-card {
    height: 168px;
  }

  .order-card-bubble {
    padding-inline: 3px;
  }

  .order-card-bubble .asset-token.tiny {
    width: 18px;
    height: 18px;
  }

  .order-card-bubble .order-items {
    max-width: 66px;
  }

  .customer-card {
    width: 66px;
    height: 84px;
  }

  .customer-order-card .customer-fallback {
    transform: scale(0.64);
  }
}
