/* PiggyBank 產品皮：舞台、零用錢倒數、消費卡、Q 彈。不改共用殼幾何。 */

.hall.is-invite #pig-home,
.hall.is-booting #pig-home,
.hall.is-invite #photo-rail,
.hall.is-booting #photo-rail {
  display: none !important;
}

.boot-mark,
.boot-wait {
  display: none;
}
.hall.is-booting .profile {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.hall.is-booting .boot-mark {
  display: block;
  width: min(240px, 58vw);
  margin: 0 auto 6px;
}
.hall.is-booting .boot-pig {
  display: block;
  width: 100%;
  height: auto;
  transform-origin: 50% 88%;
  animation: piggy-breathe 3.8s ease-in-out infinite;
}
.hall.is-booting .boot-wait {
  display: block;
  width: min(220px, 64vw);
  margin: 18px auto 0;
}

.invite-wait-bar {
  position: relative;
  overflow: hidden;
  border-radius: 9px;
  background: var(--rose-soft);
}
.invite-wait-bar::after {
  content: "";
  display: block;
  height: 100%;
  width: 42%;
  border-radius: inherit;
  background: var(--rose);
  animation: piggy-wait-slide 1.1s ease-in-out infinite;
}
@keyframes piggy-wait-slide {
  0% { transform: translateX(-80%); }
  100% { transform: translateX(240%); }
}

.hall.with-feed:not(.is-invite):not(.is-booting) .profile,
.hall.with-feed:not(.is-invite):not(.is-booting) .tag-board {
  display: none !important;
}

#pig-home {
  position: relative;
  z-index: 2;
  width: min(720px, calc(100% - 32px));
  max-width: 100%;
  min-width: 0;
  margin: 0 auto 48px;
  padding: 4px 0 24px;
  display: flex;
  flex-direction: column;
  touch-action: pan-y;
  align-items: center;
  overflow: hidden;
}

.piggy-overview {
  position: relative;
  overflow: visible;
  text-align: center;
  width: 100%;
  flex: 0 0 auto;
}
.piggy-overview .money-hero {
  width: 100%;
}
button.money-hero {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  color: var(--money, var(--rose));
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.money-hero {
  margin: 8px 0 0;
  color: var(--money, var(--rose));
  font-size: clamp(45px, 13.6vw, 83px);
  overflow-wrap: anywhere;
  font-weight: 650;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.12em;
}
.money-num {
  position: relative;
  font-size: 1em;
}
.money-coin {
  position: fixed;
  width: 36px;
  height: 36px;
  margin: 0;
  pointer-events: none;
  z-index: 90;
  opacity: 1;
}
.money-coin.is-on {
  animation: coin-rise 0.9s linear forwards;
}
.money-coin-face {
  display: block;
  width: 36px;
  height: 36px;
  background-image: url("./icons/coin-sheet.png");
  background-repeat: no-repeat;
  background-size: 288px 36px;
  background-position: 0 0;
  image-rendering: pixelated;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.18));
}
.money-coin.is-on .money-coin-face {
  animation: coin-spin 0.9s steps(7) forwards;
}
@keyframes coin-spin {
  from { background-position: 0 0; }
  to { background-position: -252px 0; }
}
@keyframes coin-rise {
  0% { transform: translateY(6px); opacity: 1; }
  16% { transform: translateY(-48px); opacity: 1; }
  48% { transform: translateY(-96px); opacity: 1; }
  78% { transform: translateY(-128px); opacity: 1; }
  100% { transform: translateY(-148px); opacity: 0; }
}
.gate-pad.is-sealed {
  pointer-events: none;
}
.money-withdraw {
  margin: 6px 0 0;
  color: var(--mute);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.pig-track {
  flex: 1 1 auto;
  align-self: stretch;
  min-width: 0;
  min-height: 0;
  display: flex;
  width: 100%;
  transition: transform 0.46s cubic-bezier(0.22, 0.8, 0.24, 1);
}
.pig-pager.is-dragging .pig-track {
  transition: none;
}
.pig-page {
  flex: 0 0 100%;
  width: 100%;
  min-width: 0;
  min-height: 100%;
  box-sizing: border-box;
}
.pig-page[data-page="bank"] {
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: visible;
  padding-top: 8px;
}
.pig-page[data-page="ledger"] {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.page-dots {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  height: 28px;
}
.page-dots span {
  display: block;
  flex: 0 0 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line);
}
.page-dots span.is-on {
  background: var(--rose);
}

#active-pig {
  display: flex;
  justify-content: center;
  width: 100%;
  margin: 0;
  overflow: visible;
}
.pig-stage {
  position: relative;
  width: min(330px, calc(100vw - 104px), 87vw);
  overflow: visible;
  --pig-foot-y: 88%;
  --pig-coin-y: 22%;
}
button.pig-say {
  position: absolute;
  z-index: 8;
  top: 0;
  left: 0;
  max-width: 78%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  font: inherit;
  color: inherit;
}
.pig-say.play-line {
  display: flex;
  font-size: 15px;
  line-height: 1.35;
}
.pig-say .play-bubble {
  position: relative;
  display: block;
  min-width: 0;
  padding: 10px 14px;
  border-radius: 18px;
  border-bottom-right-radius: 6px;
  background: var(--rose, #ff6b9d);
  color: #fff;
  word-break: break-word;
}
.pig-say .play-bubble p {
  margin: 0;
}
.pig-say.is-bonus .play-bubble {
  isolation: isolate;
  overflow: hidden;
  padding: var(--apply-ring);
  background-color: var(--rose, #ff6b9d);
  background-image: var(--ring-conic-210);
}
.pig-say.is-bonus .play-bubble::before {
  content: "";
  position: absolute;
  z-index: 0;
  left: 50%;
  top: 50%;
  width: 200vw;
  height: 200vw;
  border-radius: 0;
  background: var(--ring-conic-0);
  animation: tag-apply-spin 2.4s linear infinite;
  pointer-events: none;
}
.pig-say.is-bonus .play-bubble::after {
  content: "";
  position: absolute;
  z-index: 1;
  inset: var(--apply-ring);
  border-radius: 14px;
  border-bottom-right-radius: 4px;
  background: var(--rose, #ff6b9d);
  pointer-events: none;
}
.pig-say.is-bonus .play-bubble p {
  position: relative;
  z-index: 2;
  display: block;
  padding: 10px 14px;
}
.pig-say.is-bonus .pig-dot {
  display: none;
}
.pig-dot {
  position: absolute;
  top: -5px;
  right: -5px;
  z-index: 2;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ff3b30;
  box-shadow: 0 0 0 2px #fff;
}
.pig-say[hidden] {
  display: none !important;
}
.pig-ground {
  position: absolute;
  left: 22%;
  right: 22%;
  top: var(--pig-foot-y);
  bottom: auto;
  height: 7%;
  border-radius: 50%;
  background: color-mix(in srgb, var(--ink) 12%, transparent);
  filter: blur(5px);
  z-index: 0;
  pointer-events: none;
  transform: translateY(-40%);
}
.pig-block {
  position: relative;
  z-index: 1;
  width: 100%;
  border-radius: 0;
  touch-action: manipulation;
  background: transparent;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  overflow: visible;
  transform-origin: 50% var(--pig-foot-y);
}
.pig-block.is-harvesting {
  cursor: pointer;
}
.pig-art {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  pointer-events: none;
  transform-origin: 50% var(--pig-foot-y);
  animation: piggy-breathe 3.8s ease-in-out infinite;
}
.pig-block.is-full {
  box-shadow: none;
  background: transparent;
}
.pig-block.is-full .pig-art {
  filter: drop-shadow(0 0 10px color-mix(in srgb, var(--rose) 50%, transparent));
}
.pig-label {
  color: var(--mute);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
}
.pig-value {
  color: var(--ink);
  font-size: clamp(22px, 6vw, 32px);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
}
.pig-coins {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: visible;
}
.pig-coin {
  position: absolute;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: url("./icons/coin.png") center / contain no-repeat;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.18));
}
.pig-coin.is-dropping {
  left: 50%;
  top: -12%;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  margin: 0;
  background: url("./icons/coin.png") center / contain no-repeat;
  box-shadow: none;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.18));
  transform: translateX(-50%);
  animation: piggy-feed-in 0.32s ease-in forwards;
}

#pig-progress,
.pig-label,
.pig-value {
  display: none;
}

.pig-allowance {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 8px auto 0;
  width: 100%;
  flex: 0 0 auto;
}
.allow-caption {
  margin: 0;
  color: var(--mute);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.claim-go.ins-icon {
  width: 60px;
  height: 60px;
  flex: 0 0 60px;
}
.claim-go .ins-face {
  inset: 4.5px;
}
.claim-go .ins-face img {
  width: 70%;
  height: 70%;
  object-fit: contain;
  display: block;
}
.rail-feed .ins-face img {
  width: 72%;
  height: 72%;
  object-fit: contain;
  display: block;
}
.claim-go:disabled {
  opacity: 0.42;
  cursor: default;
  pointer-events: none;
}
.claim-go.is-ready .ins-ring {
  box-shadow: none;
  background: var(--ring-conic-210);
}
.claim-go.is-ready:not(:disabled) .ins-ring {
  animation: ins-spin 2.4s linear infinite;
}

#ledger.news-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(720px, 100%);
  margin: 18px auto 48px;
  background: transparent;
}
#ledger,
#ledger * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
button.news-row {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 14px 12px;
  border: 0;
  border-radius: 14px;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink);
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
button.news-row:active { background: #f6f6f6; }
.news-row strong {
  display: block;
  overflow: hidden;
  height: 1.35em;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
}
.news-row > span {
  display: block;
  margin-top: 6px;
  color: var(--mute);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.news-empty { color: var(--mute); font-size: 14px; }

#exchange-tray {
  padding: 8px 4px 16px;
  min-height: 120px;
}
#exchange-tray .err {
  text-align: center;
}
#exchange-tray .money-hero {
  margin: 4px 0 0;
  font-size: clamp(36px, 9vw, 56px);
}
#exchange-tray .gate-pad {
  margin-top: 12px;
}
#exchange-tray .gate-key.ex-bag {
  display: grid;
  place-items: center;
  padding: 0;
}
#exchange-tray .gate-key.ex-bag svg {
  width: 28px;
  height: 28px;
  display: block;
  pointer-events: none;
}
#exchange-tray .gate-key.ex-bag:disabled {
  opacity: 0.35;
  pointer-events: none;
}
.ex-stage {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ex-note { color: var(--mute); font-size: 13px; line-height: 1.45; }
.ex-pigs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.ex-pigs .tile { aspect-ratio: 1 / 1; border-radius: 14px; }
.ex-qr {
  display: block;
  width: min(240px, 70%);
  margin: 12px auto;
  background: #fff;
}
.act-pin .gate-pad { margin-top: 8px; }

.pig-block.is-feeding .pig-art,
.pig-block.is-hit-1 .pig-art,
.pig-block.is-hit-2 .pig-art,
.pig-block.is-hit-3 .pig-art,
.pig-block.is-hit-4 .pig-art,
.pig-block.is-hit-5 .pig-art {
  animation: piggy-squash 0.42s cubic-bezier(0.22, 1.4, 0.36, 1);
}
.pig-block.is-hit-1 { --squash: 0.94; }
.pig-block.is-hit-2 { --squash: 0.9; }
.pig-block.is-hit-3 { --squash: 0.86; }
.pig-block.is-hit-4 { --squash: 0.82; }
.pig-block.is-hit-5 { --squash: 0.76; }
.pig-block.is-hit-5 .pig-art { animation-name: piggy-squash-hard; }
@keyframes piggy-breathe {
  0%, 100% { transform: scale(1, 1); }
  50% { transform: scale(1.012, 1.04); }
}
@keyframes piggy-squash {
  0% { transform: scale(1, 1); }
  35% { transform: scale(1.022, var(--squash, 0.9)); }
  100% { transform: scale(1, 1); }
}
@keyframes piggy-squash-hard {
  0% { transform: scale(1, 1); }
  40% { transform: scale(1.04, 0.8); }
  100% { transform: scale(1, 1); }
}

@keyframes piggy-feed-in {
  0% { top: -18%; opacity: 0; }
  12% { top: -10%; opacity: 1; }
  70% { top: var(--pig-coin-y, 22%); opacity: 1; }
  100% { top: var(--pig-coin-y, 22%); opacity: 0; }
}

.pig-block.is-harvesting .pig-coin {
  animation: piggy-float 1.6s ease-in-out infinite;
}
@keyframes piggy-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.pig-block.is-shattered .pig-art {
  animation: piggy-shatter 0.7s ease-out forwards;
}
@keyframes piggy-shatter {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.2) rotate(8deg); opacity: 0; }
}
.pig-block.is-shattered .pig-coin {
  animation: piggy-scatter 0.8s ease-out forwards;
}
@keyframes piggy-scatter {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx, 48px), var(--dy, -80px)) scale(0.4); opacity: 0; }
}

.pig-block.is-hit-1,
.pig-block.is-hit-2,
.pig-block.is-hit-3,
.pig-block.is-hit-4,
.pig-block.is-hit-5 {
  background: transparent;
}

@media (prefers-reduced-motion: reduce) {
  .pig-block,
  .pig-art,
  .pig-block.is-feeding .pig-art,
  .pig-block.is-full .pig-art,
  .pig-block.is-harvesting,
  .pig-block.is-hit-1 .pig-art,
  .pig-block.is-hit-2 .pig-art,
  .pig-block.is-hit-3 .pig-art,
  .pig-block.is-hit-4 .pig-art,
  .pig-block.is-hit-5 .pig-art,
  .pig-block.is-shattered .pig-art,
  .pig-coin,
  .pig-coin.is-dropping,
  .money-coin,
  .money-coin-face,
  .claim-go.is-ready:not(:disabled) .ins-ring,
  .boot-pig,
  .invite-wait-bar::after,
  .pig-say.is-bonus .play-bubble::before {
    animation: none !important;
    transform: none !important;
  }
  .pig-block.is-feeding,
  .pig-block.is-harvesting,
  .pig-block.is-hit-5,
  .pig-block.is-shattered,
  .pig-block.is-full {
    background: transparent;
  }
  .pig-progress-bar span { transition: width 0.2s linear; }
}

html.reduce-motion .pig-block,
html.reduce-motion .pig-art,
html.reduce-motion .pig-coin,
html.reduce-motion .pig-coin.is-dropping,
html.reduce-motion .money-coin,
html.reduce-motion .money-coin-face,
html.reduce-motion .claim-go.is-ready .ins-ring,
html.reduce-motion .pig-say.is-bonus .play-bubble::before {
  animation: none !important;
  transform: none !important;
}

html[data-theme="melody"] {
  --bg: #fff5f7;
  --void: #fff5f7;
  --card: #ffffff;
  --ink: #5a3040;
  --mute: #b07a8a;
  --line: #f3cdd6;
  --rose: #ff6b9d;
  --accent: #ff6b9d;
  --accent-press: #e85a8c;
  --rose-soft: #ffb7c5;
  --on-accent: #fff;
  --tile-void: #fff0f4;
  --pick-veil: rgba(255, 107, 157, 0.28);
  --ring-1: #fff5f7;
  --ring-2: #ffb7c5;
  --ring-3: #ff6b9d;
  --ring-4: #e85a8c;
  --ring-5: #c94a7a;
  --money: #ff7eae;
}

html[data-theme="kuromi"] {
  --bg: #f8f3fc;
  --void: #f8f3fc;
  --card: #ffffff;
  --ink: #5c4570;
  --mute: #9a86aa;
  --line: #eadcf4;
  --rose: #b57edc;
  --accent: #b57edc;
  --accent-press: #9b64c4;
  --rose-soft: #eddcf6;
  --on-accent: #fff;
  --tile-void: #f6eefb;
  --pick-veil: rgba(181, 126, 220, 0.32);
  --ring-1: #f8f3fc;
  --ring-2: #eddcf6;
  --ring-3: #ddb8ef;
  --ring-4: #b57edc;
  --ring-5: #9b64c4;
  --money: #8d4fb0;
}

html[data-theme="cinnamoroll"] {
  --bg: #f0f8ff;
  --void: #f0f8ff;
  --card: #ffffff;
  --ink: #3a5f74;
  --mute: #7aa0b4;
  --line: #cfe6f1;
  --rose: #7ec8e3;
  --accent: #7ec8e3;
  --accent-press: #5aaecb;
  --rose-soft: #a8d8f0;
  --on-accent: #16384a;
  --tile-void: #e7f4fb;
  --pick-veil: rgba(126, 200, 227, 0.32);
  --ring-1: #f0f8ff;
  --ring-2: #a8d8f0;
  --ring-3: #7ec8e3;
  --ring-4: #5aaecb;
  --ring-5: #3a5f74;
  --money: #6eb6dc;
}

#actBody {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#actBody > .gate-dots,
#actBody > .gate-pad {
  align-self: center;
  flex: 0 0 auto;
}
#actBody > .mode-bar {
  justify-content: center;
}
#actBody > .err { margin: 0; }
#actBody > label { margin: 4px 0 0; }
.theme-picks {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin: 4px 0 8px;
}
button.theme-pick {
  width: 100%;
  min-height: 84px;
  margin: 0;
  padding: 18px 16px;
  border: 0;
  border-radius: 18px;
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink);
  font-size: 18px;
  font-weight: 650;
  letter-spacing: 0.02em;
  text-align: center;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
button.theme-pick[data-theme="melody"] {
  background: #fff5f7;
  color: #5a3040;
  box-shadow: inset 0 0 0 1px #f3cdd6;
}
button.theme-pick[data-theme="kuromi"] {
  background: #f8f3fc;
  color: #5c4570;
  box-shadow: inset 0 0 0 1px #eadcf4;
}
button.theme-pick[data-theme="cinnamoroll"] {
  background: #f0f8ff;
  color: #3a5f74;
  box-shadow: inset 0 0 0 1px #cfe6f1;
}
button.theme-pick.is-on {
  box-shadow: inset 0 0 0 3px var(--rose);
}
.pig-guides {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
}
.pig-guides.is-on {
  pointer-events: auto;
}
.pig-guide {
  position: absolute;
  left: 0;
  right: 0;
  height: 28px;
  margin-top: -14px;
  cursor: ns-resize;
  touch-action: none;
}
.pig-guide::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 3px;
  transform: translateY(-50%);
  box-shadow: 0 0 0 1px #fff;
}
.pig-guide[data-guide="coin"]::before { background: #f5a623; }
.pig-guide[data-guide="foot"]::before { background: #007aff; }
.pig-guide span {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  pointer-events: none;
}
.pig-guide[data-guide="coin"] span { color: #b36b00; }
.pig-guide[data-guide="foot"] span { color: #007aff; }
.pig-guides:not(.is-on) { display: none; }

html.has-rail #ledger {
  padding-right: 56px;
}
html.has-rail #pig-home {
  padding-right: 52px;
}

@media (orientation: portrait) {
  .hall.with-feed:not(.is-invite):not(.is-booting) {
    height: 100vh;
    height: 100svh;
    max-height: 100svh;
    overflow: hidden;
    overscroll-behavior: none;
  }
  .hall.with-feed:not(.is-invite):not(.is-booting) .home-head {
    flex: 0 0 auto;
  }
  .hall.with-feed:not(.is-invite):not(.is-booting) #pig-home {
    flex: 1 1 auto;
    min-height: 0;
    width: min(720px, 100%);
    margin: 0 auto;
    padding: 0;
    overflow: hidden;
    justify-content: flex-start;
  }
  .hall.with-feed:not(.is-invite):not(.is-booting) .pig-page {
    height: 100%;
    min-height: 0;
  }
  .hall.with-feed:not(.is-invite):not(.is-booting) #active-pig {
    flex: 0 1 auto;
    min-height: 0;
    justify-content: center;
  }
  .hall.with-feed:not(.is-invite):not(.is-booting) .pig-stage,
  .hall.with-feed:not(.is-invite):not(.is-booting) .pig-art {
    max-height: calc(100svh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 24rem);
  }
  .hall.with-feed:not(.is-invite):not(.is-booting) .pig-art {
    width: 100%;
    height: auto;
    object-fit: contain;
    object-position: center top;
  }
  .hall.with-feed:not(.is-invite):not(.is-booting) .money-hero {
    margin: 4px 0 0;
    font-size: clamp(38px, 11.2vw, 64px);
  }
  .hall.with-feed:not(.is-invite):not(.is-booting) .pig-allowance {
    margin-top: 4px;
    gap: 6px;
  }
}

@media (min-width: 600px) and (pointer: coarse) and (orientation: portrait) {
  html.has-rail #ledger {
    padding-right: 88px;
  }
  html.has-rail #pig-home {
    padding-right: 80px;
  }
}

