/* ==========================================================================
   SCOPE COPENHAGEN INSPIRED MINIMALIST HEADER & 3-BRAND ATMOSPHERE ENGINE
   1. 群絕棧 (Tarot): 黑白古風水墨感風格 (Classical Oriental Ink-Wash Black & White)
   2. 群絕棧Crystal: 星屑の海・水晶星河與流星 (Sea of Stardust: #0b1838, #4d4177, #3a60a0, #88a5e0, #c8ddf5)
   3. 萌織夢 (Meng): 虹を閉じこめて・琉璃糖與蕾絲碎花 (Twinkle Veil: #9f99d1, #86bada, #dbaad7, #f6beb0, #ffe3b3)
   ========================================================================== */
:root {
  /* Default Theme: 群絕棧 (Tarot & Main Hub) - 黑白古風水墨意境主調 */
  --bg-main: #F4F2EC;
  --bg-subtle: #E8E5DC;
  --bg-surface: rgba(251, 250, 247, 0.92);
  --bg-pill: #111111;
  --text-pill: #F4F2EC;
  --text-primary: #111111;
  --text-secondary: #4A4845;
  --accent-primary: #111111;
  --accent-secondary: #33312E;
  --accent-soft: #E6E3DA;
  --border-color: #CFCBC0;
  --header-bg: rgba(244, 242, 236, 0.92);
  --shadow-soft: 0 12px 32px -10px rgba(17, 17, 17, 0.1);
  --shadow-hover: 0 22px 44px -12px rgba(17, 17, 17, 0.24);
  --top-btn-gradient: linear-gradient(135deg, #0D0D0D 0%, #3D3B38 100%);
  --top-btn-text: #F4F2EC;
}

/* Theme: 群絕棧Crystal (Cyun Crystal) - 星屑の海 (Cosmic Ink × Twilight Plum × Deep Sky × Milky Glow) */
body.theme-crystal {
  --bg-main: #0b1838;
  --bg-subtle: #14224a;
  --bg-surface: rgba(24, 38, 78, 0.82);
  --bg-pill: #c8ddf5;
  --text-pill: #0b1838;
  --text-primary: #f2f7fd;
  --text-secondary: #c8ddf5;
  --accent-primary: #c8ddf5;
  --accent-secondary: #88a5e0;
  --accent-soft: #263868;
  --border-color: #3a60a0;
  --header-bg: rgba(11, 24, 56, 0.9);
  --shadow-soft: 0 14px 36px -10px rgba(7, 13, 32, 0.7);
  --shadow-hover: 0 22px 48px -10px rgba(136, 165, 224, 0.42);
  --top-btn-gradient: linear-gradient(135deg, #3a60a0 0%, #4d4177 50%, #88a5e0 100%);
  --top-btn-text: #ffffff;
}

/* Theme: 萌織夢 (Meng JrMeng) - 虹を閉じこめて (Dreamy Lilac × Crystal Blue × Fairy Pink × Peach × Honey Milk) */
body.theme-meng {
  --bg-main: #FFFDFB;
  --bg-subtle: #FBF6FF;
  --bg-surface: rgba(255, 255, 255, 0.9);
  --bg-pill: #9f99d1;
  --text-pill: #FFFFFF;
  --text-primary: #4A3E6D;
  --text-secondary: #7A6EA3;
  --accent-primary: #9f99d1;
  --accent-secondary: #dbaad7;
  --accent-soft: #FDF4F8;
  --border-color: #dbaad7;
  --header-bg: rgba(255, 253, 251, 0.92);
  --shadow-soft: 0 14px 34px -10px rgba(159, 153, 209, 0.25);
  --shadow-hover: 0 22px 46px -10px rgba(219, 170, 215, 0.48);
  --top-btn-gradient: linear-gradient(135deg, #9f99d1 0%, #86bada 35%, #dbaad7 70%, #f6beb0 100%);
  --top-btn-text: #FFFFFF;
}

body {
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: 'Noto Sans TC', sans-serif;
  overflow-x: hidden;
  transition: background-color 0.55s ease, color 0.55s ease;
}

/* Ambient Background Layers for the 3 Brands */
body.theme-tarot-ink {
  background-image:
    radial-gradient(ellipse at 15% 10%, rgba(17, 17, 17, 0.08) 0%, transparent 45%),
    radial-gradient(ellipse at 85% 35%, rgba(17, 17, 17, 0.05) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 95%, rgba(17, 17, 17, 0.09) 0%, transparent 55%),
    repeating-linear-gradient(90deg, rgba(17, 17, 17, 0.012) 0px, rgba(17, 17, 17, 0.012) 1px, transparent 1px, transparent 24px);
}
body.theme-crystal {
  background-image:
    radial-gradient(ellipse at 20% 18%, rgba(77, 65, 119, 0.58) 0%, transparent 48%),
    radial-gradient(ellipse at 82% 26%, rgba(58, 96, 160, 0.52) 0%, transparent 50%),
    radial-gradient(ellipse at 52% 85%, rgba(136, 165, 224, 0.25) 0%, transparent 55%),
    radial-gradient(1.5px 1.5px at 18% 32%, #c8ddf5 60%, transparent 100%),
    radial-gradient(2px 2px at 68% 18%, #ffffff 55%, transparent 100%),
    radial-gradient(1.5px 1.5px at 84% 62%, #88a5e0 60%, transparent 100%),
    radial-gradient(1px 1px at 38% 76%, #c8ddf5 60%, transparent 100%);
}
body.theme-meng {
  background-image:
    radial-gradient(ellipse at 14% 18%, rgba(159, 153, 209, 0.22) 0%, transparent 45%),
    radial-gradient(ellipse at 86% 22%, rgba(134, 186, 218, 0.22) 0%, transparent 46%),
    radial-gradient(ellipse at 24% 82%, rgba(246, 190, 176, 0.24) 0%, transparent 48%),
    radial-gradient(ellipse at 82% 84%, rgba(255, 227, 179, 0.28) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(219, 170, 215, 0.16) 0%, transparent 60%);
}

/* Scope Copenhagen Style Navigation Link */
.scope-nav-link {
  position: relative;
  letter-spacing: 0.14em;
  transition: color 0.3s ease, opacity 0.3s ease;
}
.scope-nav-link::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -6px;
  width: 100%;
  height: 1.5px;
  background-color: var(--accent-primary);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.scope-nav-link.active::after,
.scope-nav-link:hover::after {
  transform: scaleX(1);
  transform-origin: left;
}

/* Clean Boutique Cards */
.boutique-card {
  background-color: var(--bg-surface);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-soft);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.35s ease, border-color 0.35s ease;
}
.boutique-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-hover);
  border-color: var(--accent-primary);
}

.boutique-panel {
  background-color: var(--bg-surface);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-soft);
}

.btn-brand-primary {
  background-color: var(--accent-primary);
  color: var(--bg-main);
}
body.theme-crystal .btn-brand-primary {
  background: linear-gradient(135deg, #88a5e0 0%, #c8ddf5 100%);
  color: #0b1838;
  font-weight: 700;
  box-shadow: 0 6px 20px -4px rgba(136, 165, 224, 0.5);
}
body.theme-meng .btn-brand-primary {
  background: linear-gradient(135deg, #9f99d1 0%, #86bada 48%, #dbaad7 100%);
  color: #FFFFFF;
  font-weight: 700;
  box-shadow: 0 6px 20px -4px rgba(159, 153, 209, 0.55);
}

/* ==========================================================================
   PORTAL HOVER ANIMATIONS FOR THREE BRANDS
   ========================================================================== */
.portal-card {
  position: relative;
  overflow: hidden;
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.5s ease, border-color 0.4s ease;
}
.portal-card:hover {
  transform: translateY(-8px);
}

/* 1. 群絕棧 Classical Oriental Ink-Wash Portal Hover */
.portal-card-tarot:hover .ink-brush-ring {
  transform: rotate(35deg) scale(1.06);
}
.ink-brush-ring {
  transition: transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}
.ink-mountain-far,
.ink-mountain-near,
.ink-cloud-mist,
.ink-flying-birds {
  transition: transform 0.85s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.85s ease;
}
.portal-card-tarot:hover .ink-mountain-far {
  transform: translateY(-4px) scale(1.04);
}
.portal-card-tarot:hover .ink-mountain-near {
  transform: translateY(-7px) scale(1.07);
}
/* 2. 群絕棧Crystal Sea of Stardust (星屑の海：水晶・星星・流星) Portal Hover */
.portal-card-crystal:hover .mystic-orbit {
  transform: rotate(90deg) scale(1.1);
  filter: drop-shadow(0 0 14px rgba(200, 221, 245, 0.8));
}
.mystic-orbit {
  transition: transform 1s cubic-bezier(0.22, 1, 0.36, 1), filter 0.6s ease;
}
.portal-card-crystal:hover .mystic-star-glow {
  opacity: 1;
  transform: scale(1.3);
}
.mystic-star-glow {
  transition: opacity 0.5s ease, transform 0.6s ease;
}
.crystal-cluster-svg {
  transition: transform 0.65s cubic-bezier(0.22, 1, 0.36, 1), filter 0.65s ease;
}
.portal-card-crystal:hover .crystal-cluster-svg {
  transform: translateY(-6px) scale(1.1);
  filter: drop-shadow(0 0 22px rgba(200, 221, 245, 0.9));
}
/* Shooting Star Line Effect */
.meteor-streak {
  position: absolute;
  width: 68px;
  height: 1.5px;
  background: linear-gradient(90deg, #ffffff 0%, #c8ddf5 35%, rgba(136, 165, 224, 0) 100%);
  border-radius: 999px;
  filter: drop-shadow(0 0 6px #c8ddf5);
  pointer-events: none;
}
.meteor-streak::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 4px;
  border-radius: 9999px;
  background: #ffffff;
  box-shadow: 0 0 8px 2px #c8ddf5;
}
.classical-seal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 6px;
  border: 1.5px solid currentColor;
  border-radius: 2px;
  font-family: 'Noto Serif TC', serif;
  letter-spacing: 0.12em;
}

/* 3. 萌織夢 Twinkle Veil (虹を閉じこめて：琉璃糖・蝴蝶結・緞帶・蕾絲・荷葉邊・小碎花) Portal Hover */
.portal-card-meng:hover .dreamy-ribbon-art {
  transform: translateY(-6px) scale(1.07) rotate(-2deg);
  filter: drop-shadow(0 12px 22px rgba(159, 153, 209, 0.45));
}
.dreamy-ribbon-art {
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.5s ease;
}
.portal-card-meng:hover .sparkle-badge {
  transform: scale(1.25) rotate(18deg);
  opacity: 1;
}
.sparkle-badge {
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.45s ease;
}
.glass-candy-gem {
  transition: transform 0.65s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.5s ease;
}
.portal-card-meng:hover .glass-candy-gem {
  transform: translateY(-7px) rotate(12deg) scale(1.14);
  filter: drop-shadow(0 0 14px rgba(255, 227, 179, 0.9));
}
.lace-scallop-border {
  background-image: radial-gradient(circle at 10px 0, transparent 6px, rgba(255, 255, 255, 0.85) 6.5px);
  background-size: 20px 10px;
}
/* Dreamy Iridescent Soap Bubble (琉璃虹光泡泡) */
.dreamy-bubble {
  border-radius: 9999px;
  background: radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.35) 22%, rgba(134, 186, 218, 0.28) 48%, rgba(219, 170, 215, 0.38) 74%, rgba(255, 227, 179, 0.55) 100%);
  border: 1px solid rgba(255, 255, 255, 0.85);
  box-shadow: inset -3px -3px 8px rgba(159, 153, 209, 0.35), inset 2px 2px 6px rgba(255, 255, 255, 0.9), 0 4px 12px rgba(159, 153, 209, 0.22);
  pointer-events: none;
}
.dreamy-bubble::after {
  content: '';
  position: absolute;
  top: 18%;
  left: 22%;
  width: 26%;
  height: 16%;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.92);
  transform: rotate(-28deg);
}

/* ==========================================================================
   BRAND PAGE TRANSITION OVERLAY ANIMATIONS (古風水墨暈染 / 星夜秘境 / 琉璃糖蕾絲碎花夢境)
   ========================================================================== */
@keyframes inkSpreadTransition {
  0% { transform: scale(0.15) rotate(-5deg); opacity: 0; }
  35% { transform: scale(1.05) rotate(0deg); opacity: 1; }
  70% { transform: scale(1.25) rotate(2deg); opacity: 0.95; }
  100% { transform: scale(1.65) rotate(4deg); opacity: 0; }
}
@keyframes inkScrollUnfold {
  0% { opacity: 0; transform: translateY(18px) scale(0.94); }
  40% { opacity: 1; transform: translateY(0px) scale(1); }
  80% { opacity: 1; transform: translateY(0px) scale(1.02); }
  100% { opacity: 0; transform: translateY(-10px) scale(1.05); }
}
@keyframes crystalStarTransition {
  0% { transform: scale(0.82); opacity: 0; }
  35% { transform: scale(1); opacity: 1; }
  75% { transform: scale(1.04); opacity: 0.96; }
  100% { transform: scale(1.22); opacity: 0; }
}
@keyframes meteorFlyAcross {
  0% { transform: translate(160px, -110px) rotate(-35deg) scale(0.5); opacity: 0; }
  20% { opacity: 1; }
  80% { opacity: 1; }
  100% { transform: translate(-260px, 180px) rotate(-35deg) scale(1.25); opacity: 0; }
}
@keyframes mengBloomTransition {
  0% { transform: scale(0.78) translateY(16px); opacity: 0; }
  35% { transform: scale(1) translateY(0px); opacity: 1; }
  75% { transform: scale(1.03) translateY(-4px); opacity: 0.96; }
  100% { transform: scale(1.18) translateY(-14px); opacity: 0; }
}
@keyframes candyFloatAcross {
  0% { transform: translateY(45px) rotate(-20deg) scale(0.6); opacity: 0; }
  30% { opacity: 1; }
  80% { opacity: 1; }
  100% { transform: translateY(-55px) rotate(25deg) scale(1.15); opacity: 0; }
}
.animate-ink-transition {
  animation: inkSpreadTransition 1.15s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.animate-ink-scroll {
  animation: inkScrollUnfold 1.1s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.animate-crystal-transition {
  animation: crystalStarTransition 1.15s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.animate-meteor-transition {
  animation: meteorFlyAcross 0.95s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.animate-meng-transition {
  animation: mengBloomTransition 1.15s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* ---------- 萌織夢過場：少女夢幻版（無外框，泡泡＋鮮花＋花瓣） ---------- */
.meng-tr-stage {
  animation: mengStageFade 1.65s ease forwards;
  background:
    radial-gradient(circle at 50% 48%, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.55) 22%, transparent 48%),
    radial-gradient(ellipse at 15% 20%, rgba(255, 196, 218, 0.85) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 18%, rgba(227, 204, 255, 0.85) 0%, transparent 50%),
    radial-gradient(ellipse at 20% 85%, rgba(217, 240, 255, 0.85) 0%, transparent 52%),
    radial-gradient(ellipse at 85% 82%, rgba(255, 227, 179, 0.85) 0%, transparent 52%),
    linear-gradient(160deg, #FFE4F0 0%, #F3E4FF 45%, #E4F2FF 75%, #FFF1E0 100%);
}
@keyframes mengStageFade {
  0% { opacity: 0; }
  14% { opacity: 1; }
  82% { opacity: 1; }
  100% { opacity: 0; }
}

/* 泡泡：從左右兩側飄進畫面，再輕輕往上浮 */
.meng-tr-bubble {
  position: absolute;
  animation: mengBubbleIn 1.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes mengBubbleIn {
  0% { transform: translate(var(--fx), var(--fy)) scale(0.55); opacity: 0; }
  20% { opacity: 1; }
  70% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(0, -22px) scale(1.04); opacity: 0.9; }
}

/* 鮮花：旋轉綻放 */
.meng-tr-flower {
  position: absolute;
  animation: mengFlowerBloom 1.2s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  filter: drop-shadow(0 4px 10px rgba(255, 150, 190, 0.35));
}
@keyframes mengFlowerBloom {
  0% { transform: scale(0) rotate(-120deg); opacity: 0; }
  55% { transform: scale(1.12) rotate(8deg); opacity: 1; }
  75% { transform: scale(0.96) rotate(-3deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
.meng-tr-flower-spin {
  animation: mengFlowerSpin 6s linear infinite;
}
@keyframes mengFlowerSpin {
  to { transform: rotate(360deg); }
}

/* 花瓣：從上方飄落 */
.meng-tr-petal {
  position: absolute;
  top: -6%;
  width: 14px;
  height: 18px;
  animation: mengPetalFall 1.6s ease-in both;
}
@keyframes mengPetalFall {
  0% { transform: translate(0, 0) rotate(0deg); opacity: 0; }
  15% { opacity: 1; }
  100% { transform: translate(var(--dx), 105vh) rotate(var(--rot)); opacity: 0.6; }
}

/* 星光閃爍 */
.meng-tr-sparkle {
  position: absolute;
  color: #FFFFFF;
  text-shadow: 0 0 10px rgba(255, 170, 210, 0.95), 0 0 18px rgba(200, 170, 255, 0.8);
  animation: mengSparkle 1.1s ease-in-out both;
}
@keyframes mengSparkle {
  0% { transform: scale(0) rotate(0deg); opacity: 0; }
  45% { transform: scale(1.35) rotate(90deg); opacity: 1; }
  100% { transform: scale(0.9) rotate(160deg); opacity: 0.85; }
}

/* 中央標題：漸層字＋柔光，蝴蝶結彈跳 */
.meng-tr-title {
  animation: mengTitlePop 1.1s cubic-bezier(0.34, 1.56, 0.64, 1) 0.15s both;
}
@keyframes mengTitlePop {
  0% { transform: scale(0.7) translateY(14px); opacity: 0; filter: blur(8px); }
  55% { transform: scale(1.05) translateY(0); opacity: 1; filter: blur(0); }
  100% { transform: scale(1); opacity: 1; filter: blur(0); }
}
.meng-tr-name {
  background: linear-gradient(90deg, #FF8FB8 0%, #C59BFF 50%, #86BADA 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 14px rgba(255, 255, 255, 0.95)) drop-shadow(0 4px 12px rgba(255, 143, 184, 0.35));
}
.meng-tr-en {
  color: #C77DAA;
}
.meng-tr-sub {
  color: #8A78B8;
}
.meng-tr-bow {
  display: inline-block;
  animation: mengBowBounce 0.9s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s both;
}
@keyframes mengBowBounce {
  0% { transform: translateY(-30px) rotate(-25deg) scale(0.4); opacity: 0; }
  60% { transform: translateY(4px) rotate(8deg) scale(1.15); opacity: 1; }
  100% { transform: translateY(0) rotate(0deg) scale(1); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .meng-tr-bubble,
  .meng-tr-flower,
  .meng-tr-flower-spin,
  .meng-tr-petal,
  .meng-tr-sparkle,
  .meng-tr-title,
  .meng-tr-bow {
    animation: none;
  }
  .meng-tr-petal {
    display: none;
  }
}
.animate-candy-float {
  animation: candyFloatAcross 1.05s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* Tarot Card Flip */
.tarot-card-perspective {
  -webkit-perspective: 1400px;
  perspective: 1400px;
}
.tarot-card-inner {
  transition: transform 0.8s cubic-bezier(0.34, 1.45, 0.64, 1);
  -webkit-transform-style: preserve-3d;
  transform-style: preserve-3d;
}
.tarot-card-inner.flipped {
  -webkit-transform: rotateY(180deg);
  transform: rotateY(180deg);
}
.tarot-face {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  -webkit-transform: rotateY(0deg) translateZ(1px);
  transform: rotateY(0deg) translateZ(1px);
  /* iOS Safari 的 backface-visibility 常失效（牌面內有捲動區或陰影時），
     導致翻牌後只看到鏡像正面。改用 visibility 在翻到一半時切換顯示面，所有瀏覽器都可靠。 */
  visibility: visible;
  transition: visibility 0s linear 0.18s;
}
.tarot-back {
  -webkit-transform: rotateY(180deg) translateZ(1px);
  transform: rotateY(180deg) translateZ(1px);
  visibility: hidden;
}
.tarot-card-inner.flipped .tarot-face {
  visibility: hidden;
}
.tarot-card-inner.flipped .tarot-back {
  visibility: visible;
}

/* 78-Card Deck Shuffle & Draw Animations (78張水墨塔羅洗牌與抽牌動畫) */
@keyframes tarotShuffleLeft {
  0%, 100% { transform: translateX(0) translateY(0) rotate(-4deg) scale(1); }
  25% { transform: translateX(-54px) translateY(-10px) rotate(-18deg) scale(1.03); }
  50% { transform: translateX(36px) translateY(6px) rotate(12deg) scale(0.98); }
  75% { transform: translateX(-28px) translateY(-6px) rotate(-10deg) scale(1.02); }
}
@keyframes tarotShuffleRight {
  0%, 100% { transform: translateX(0) translateY(0) rotate(4deg) scale(1); }
  25% { transform: translateX(54px) translateY(-12px) rotate(18deg) scale(1.03); }
  50% { transform: translateX(-36px) translateY(8px) rotate(-12deg) scale(0.98); }
  75% { transform: translateX(28px) translateY(-4px) rotate(10deg) scale(1.02); }
}
@keyframes tarotShuffleCenter {
  0%, 100% { transform: translateY(0) scale(1); }
  30% { transform: translateY(-18px) scale(1.06) rotate(-3deg); }
  60% { transform: translateY(6px) scale(0.97) rotate(3deg); }
  85% { transform: translateY(-24px) scale(1.08) rotate(0deg); }
}
@keyframes tarotCardDrawEmerge {
  0% {
    opacity: 0;
    transform: translateY(48px) scale(0.72) rotateX(18deg);
    filter: blur(4px);
  }
  60% {
    opacity: 1;
    transform: translateY(-8px) scale(1.03) rotateX(0deg);
    filter: blur(0px);
  }
  100% {
    opacity: 1;
    transform: none;
    filter: none;
  }
}
.deck-shuffling .shuffle-card-left {
  animation: tarotShuffleLeft 0.65s cubic-bezier(0.34, 1.56, 0.64, 1) 2;
}
.deck-shuffling .shuffle-card-right {
  animation: tarotShuffleRight 0.65s cubic-bezier(0.34, 1.56, 0.64, 1) 2;
}
.deck-shuffling .shuffle-card-center {
  animation: tarotShuffleCenter 0.65s cubic-bezier(0.34, 1.56, 0.64, 1) 2;
}
.animate-tarot-emerge {
  /* 不使用 forwards：動畫結束後不能殘留 filter/transform，
     否則 iOS Safari 會把內部 3D 翻牌壓平，翻面後只看到鏡像正面 */
  animation: tarotCardDrawEmerge 0.75s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Subtle Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary);
}

/* ==========================================================================
   MOBILE LAYOUT REFINEMENTS (手機版排版優化：換行、字級、間距、按鈕點擊區)
   ========================================================================== */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
button,
a,
select,
input {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* 中文換行：標點不落行首、長網址可斷行、標題避免最後一行只剩一兩個字 */
body {
  line-break: strict;
  overflow-wrap: break-word;
}
h1, h2, h3, h4 {
  text-wrap: balance;
}
p, li {
  text-wrap: pretty;
}
/* 讓 inline-block 片語整組換行（例如：群絕棧・／三大品牌美學空間） */
.keep-phrase {
  display: inline-block;
}

/* ==========================================================================
   CATEGORY TABS (群絕棧／群絕棧Crystal 分類切換按鈕：明顯的實體按鈕樣式)
   ========================================================================== */
.cat-tab-bar {
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}
.cat-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 9999px;
  border: 2px solid var(--accent-primary);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-family: 'Noto Serif TC', serif;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.1em;
  cursor: pointer;
  box-shadow: 0 6px 16px -8px rgba(0, 0, 0, 0.35);
  transition: transform 0.25s ease, box-shadow 0.25s ease, background-color 0.25s ease, color 0.25s ease;
}
.cat-tab i {
  font-size: 13px;
  color: var(--accent-primary);
  transition: color 0.25s ease;
}
.cat-tab:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}
.cat-tab:active {
  transform: translateY(0) scale(0.97);
}
.cat-tab:focus-visible {
  outline: 3px solid var(--accent-secondary);
  outline-offset: 3px;
}
.cat-tab-count {
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 9999px;
  background-color: var(--accent-soft);
  color: var(--text-primary);
  font-family: 'Noto Sans TC', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.5;
}
.cat-tab-count:empty {
  display: none;
}
/* 選取中：實心底色＋外圈光暈 */
.cat-tab.is-active {
  background-color: var(--bg-pill);
  border-color: var(--bg-pill);
  color: var(--text-pill);
  box-shadow: 0 0 0 3px var(--bg-main), 0 0 0 5px var(--bg-pill), 0 10px 24px -8px rgba(0, 0, 0, 0.45);
}
.cat-tab.is-active i {
  color: var(--text-pill);
}
.cat-tab.is-active .cat-tab-count {
  background-color: rgba(255, 255, 255, 0.22);
  color: inherit;
}
body.theme-crystal .cat-tab.is-active {
  background: linear-gradient(135deg, #88a5e0 0%, #c8ddf5 100%);
  box-shadow: 0 0 0 3px var(--bg-main), 0 0 0 5px #88a5e0, 0 10px 26px -6px rgba(136, 165, 224, 0.65);
}
body.theme-crystal .cat-tab.is-active .cat-tab-count {
  background-color: rgba(11, 24, 56, 0.15);
}

/* ==========================================================================
   PRODUCT CAROUSEL (手機與平板：商品改為左右滑動切換)
   ========================================================================== */
.product-swipe-hint,
.product-carousel-nav {
  display: none;
}
/* 入口頁三大品牌卡片：手機／平板改為左右滑動 */
.portal-swipe-hint,
.portal-dots {
  display: none;
}
@media (max-width: 1023px) {
  #portal-cards {
    position: relative; /* 讓卡片的 offsetLeft 以滑動軌道為基準 */
    display: flex;
    gap: 14px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 16px;
    margin-inline: -16px;
    padding: 10px 16px 22px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  #portal-cards::-webkit-scrollbar {
    display: none;
  }
  #portal-cards > .portal-card {
    flex: 0 0 86%;
    scroll-snap-align: center;
  }
  #portal-cards > .portal-card:hover {
    transform: none;
  }
  .portal-swipe-hint {
    display: block;
  }
  .portal-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 2px;
  }
  .portal-dot {
    width: 8px;
    height: 8px;
    border-radius: 9999px;
    background-color: #c9c5bb;
    transition: width 0.3s ease, background-color 0.3s ease;
    cursor: pointer;
  }
  .portal-dot.is-active {
    width: 24px;
    background-color: #111111;
  }
}
/* 入口頁在手機／平板：剛好一個畫面高，不需要上下捲動 */
@media (max-width: 1023px) {
  #entry-portal {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    justify-content: flex-start;
  }
  #entry-portal .portal-topbar {
    flex-shrink: 0;
    padding-top: 10px;
    padding-bottom: 10px;
  }
  #entry-portal .portal-bottombar {
    display: none;
  }
  #entry-portal .portal-main {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: center; /* 卡片不再撐滿整個高度，內容整體垂直置中 */
    margin: 0 auto;
    padding-top: clamp(12px, 2.5vh, 28px);
    padding-bottom: clamp(10px, 2vh, 20px);
  }
  #entry-portal .portal-head {
    flex-shrink: 0;
    margin-bottom: clamp(6px, 1.6vh, 18px);
  }
  #entry-portal .portal-head > p:first-child {
    margin-bottom: 4px;
  }
  #entry-portal .portal-head h1 {
    font-size: clamp(1.35rem, 5.6vw, 2.2rem);
  }
  #entry-portal .portal-subtitle {
    margin-top: 6px;
    font-size: 13px;
  }
  #entry-portal .portal-swipe-hint {
    flex-shrink: 0;
    margin-bottom: 2px;
  }
  #entry-portal #portal-cards {
    flex: 0 1 auto;
    min-height: 0;
    align-items: stretch;
    padding-top: 6px;
    padding-bottom: 12px;
  }
  #entry-portal #portal-cards > .portal-card {
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 16px 18px;
  }
  #entry-portal .portal-card-body {
    flex: 0 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  #entry-portal .portal-badge-row {
    margin-bottom: 10px;
  }
  /* 插畫高度跟著螢幕高度縮放，但有上限，避免卡片被拉得太長 */
  #entry-portal .portal-art {
    flex: 0 1 auto;
    height: clamp(110px, 25vh, 200px);
    min-height: 90px;
    margin-bottom: 12px;
  }
  #entry-portal .portal-card-body > h2 {
    font-size: 1.3rem;
    margin-bottom: 4px;
  }
  #entry-portal .portal-card-body > p {
    font-size: 13px;
    line-height: 1.65;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  #entry-portal .portal-card > div:last-child {
    padding-top: 10px;
  }
  #entry-portal .portal-dots {
    flex-shrink: 0;
  }
}
/* 特別矮的手機（如 iPhone SE）：再省掉副標與英文小標 */
@media (max-width: 1023px) and (max-height: 640px) {
  #entry-portal .portal-subtitle,
  #entry-portal .portal-head > p:first-child {
    display: none;
  }
  #entry-portal .portal-card-body > p {
    -webkit-line-clamp: 2;
  }
}

@media (min-width: 640px) and (max-width: 1023px) {
  #portal-cards {
    margin-inline: -24px;
    padding-inline: 24px;
    scroll-padding-inline: 24px;
  }
  #portal-cards > .portal-card {
    flex-basis: 58%;
  }
}

/* 商品卡統一高度：標題、條列、適用說明都固定行數，完整內容於「詳情」查看 */
.card-clamp-1,
.card-clamp-2,
.card-clamp-3 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-clamp-1 { -webkit-line-clamp: 1; line-clamp: 1; }
.card-clamp-2 { -webkit-line-clamp: 2; line-clamp: 2; }
.card-clamp-3 { -webkit-line-clamp: 3; line-clamp: 3; }
.card-title-block {
  min-height: 2.75rem;
}
.card-title-block h3 {
  min-height: calc(2 * 1.375em);
}
.card-desc {
  min-height: calc(3 * 1.625em);
}
.card-target {
  min-height: calc(2 * 1.625em + 1rem);
}
#product-grid > article {
  height: auto;
}

/* 桌機：四欄排列，最後一排不足四個時置中，避免一邊長一邊短 */
@media (min-width: 1024px) {
  #product-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: stretch;
  }
  #product-grid > article {
    flex: 0 0 calc((100% - 3 * 1.5rem) / 4);
    max-width: calc((100% - 3 * 1.5rem) / 4);
  }
}

@media (max-width: 1023px) {
  #product-grid {
    display: flex;
    align-items: stretch;
    gap: 14px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 16px;
    margin-inline: -16px;
    padding: 8px 16px 18px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  #product-grid::-webkit-scrollbar {
    display: none;
  }
  #product-grid > article {
    flex: 0 0 82%;
    scroll-snap-align: start;
  }
  .product-swipe-hint {
    display: block;
  }
  .product-carousel-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 420px;
    margin: 4px auto 0;
  }
}
@media (min-width: 640px) and (max-width: 1023px) {
  #product-grid {
    margin-inline: -24px;
    padding-inline: 24px;
    scroll-padding-inline: 24px;
  }
  #product-grid > article {
    flex-basis: 44%;
  }
}
.carousel-arrow {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 9999px;
  border: 2px solid var(--accent-primary);
  background-color: var(--bg-surface);
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.carousel-arrow:active {
  transform: scale(0.94);
}
.carousel-arrow:disabled {
  opacity: 0.3;
  cursor: default;
}
.carousel-progress {
  flex: 1;
  height: 4px;
  border-radius: 9999px;
  background-color: var(--border-color);
  overflow: hidden;
}
.carousel-progress span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 9999px;
  background-color: var(--accent-primary);
  transition: width 0.3s ease;
}
.carousel-counter {
  flex-shrink: 0;
  min-width: 46px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}

/* ==========================================================================
   INK LIFE (群絕棧圖卡)：
   1. 墨滴：一滴一滴落在畫布上，從一個小點慢慢暈開、變淡
   2. 竹葉：幾片竹葉隨風從左邊飄過畫面
   3. 飛鳥：竹葉飄過後，鳥群振翅從右邊飛向左邊
   每張圖的 <svg> 以 --ink-span（viewBox 寬度）決定飄過的距離。
   竹葉與飛鳥共用 14 秒的循環，所以會依序出現。
   ========================================================================== */
.ink-drop {
  transform-box: fill-box;
  transform-origin: center;
  opacity: 0;
  animation: inkDropBloom 8s cubic-bezier(0.2, 0.7, 0.3, 1) infinite;
}
.ink-drop-splat {
  transform-box: fill-box;
  transform-origin: center;
  opacity: 0;
  animation: inkDropSplat 8s ease-out infinite;
}
@keyframes inkDropBloom {
  0%   { transform: scale(0.04); opacity: 0; }
  3%   { transform: scale(0.12); opacity: 0.7; }
  35%  { transform: scale(0.95); opacity: 0.3; }
  70%  { transform: scale(1.1); opacity: 0.14; }
  100% { transform: scale(1.16); opacity: 0; }
}
@keyframes inkDropSplat {
  0%, 2% { transform: scale(0); opacity: 0; }
  5%     { transform: scale(1); opacity: 0.55; }
  40%    { transform: scale(1.3); opacity: 0.2; }
  60%, 100% { transform: scale(1.4); opacity: 0; }
}

.ink-drift-leaf {
  transform-box: fill-box;
  transform-origin: center;
  opacity: 0;
  animation: inkLeafDrift 14s linear infinite;
}
@keyframes inkLeafDrift {
  0%   { transform: translate(0, 0) rotate(0deg); opacity: 0; }
  3%   { opacity: 0.8; }
  12%  { transform: translate(calc(var(--ink-span, 240) * 0.35px), -10px) rotate(120deg); }
  24%  { transform: translate(calc(var(--ink-span, 240) * 0.75px), 14px) rotate(230deg); opacity: 0.75; }
  32%  { transform: translate(calc(var(--ink-span, 240) * 1.1px), 26px) rotate(320deg); opacity: 0; }
  100% { transform: translate(calc(var(--ink-span, 240) * 1.1px), 26px) rotate(320deg); opacity: 0; }
}

.ink-bird {
  opacity: 0;
  animation: inkBirdFly 14s linear infinite;
}
.ink-bird-2 { animation-delay: 0.45s; }
.ink-bird-3 { animation-delay: 0.9s; }
@keyframes inkBirdFly {
  0%, 34% { transform: translate(calc(var(--ink-span, 240) * 0.75px), 8px); opacity: 0; }
  38%     { opacity: 0.85; }
  62%     { transform: translate(0, -4px); }
  80%     { opacity: 0.85; }
  86%, 100% { transform: translate(calc(var(--ink-span, 240) * -0.75px), -14px); opacity: 0; }
}
.ink-wing {
  transform-box: fill-box;
  transform-origin: 50% 75%;
  animation: inkWingFlap 0.75s ease-in-out infinite;
}
.ink-bird-2 .ink-wing { animation-duration: 0.9s; animation-delay: -0.3s; }
.ink-bird-3 .ink-wing { animation-duration: 0.68s; animation-delay: -0.5s; }
@keyframes inkWingFlap {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(-0.5); }
}

@media (prefers-reduced-motion: reduce) {
  .ink-drop,
  .ink-drop-splat,
  .ink-drift-leaf,
  .ink-wing {
    animation: none;
  }
  /* 不播放動畫時，鳥停在原位顯示 */
  .ink-bird {
    animation: none;
    opacity: 0.8;
  }
}

@media (max-width: 639px) {
  /* 小字段落在手機上稍微放大、行距拉開，閱讀更舒服 */
  .text-xs.leading-relaxed,
  .leading-relaxed .text-xs {
    font-size: 13px;
    line-height: 1.8;
  }
  p.text-sm,
  .text-sm.leading-relaxed {
    line-height: 1.8;
  }

  /* 大字距的英文小標在手機上收斂，避免一行塞不下而被硬拆 */
  .tracking-widest {
    letter-spacing: 0.08em;
  }
  .tracking-\[0\.28em\],
  .tracking-\[0\.2em\],
  .tracking-\[0\.22em\] {
    letter-spacing: 0.12em;
  }
  .text-center > span.uppercase,
  .space-y-4 > span.uppercase {
    display: inline-block;
    line-height: 1.7;
    text-wrap: balance;
  }

  /* 頂部導覽：品牌切換改成膠囊分段按鈕，選中的品牌實心底色 */
  #brand-switcher {
    flex: 1;
    max-width: 272px;
    gap: 2px;
    padding: 3px;
    margin: 0 10px;
    border-radius: 9999px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-main);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.06);
  }
  #brand-switcher .scope-nav-link {
    flex: 1 1 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 34px;
    padding: 0 4px;
    border-radius: 9999px;
    font-size: 12.5px;
    letter-spacing: 0.02em;
    white-space: nowrap;
    opacity: 1 !important;
    transition: background-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
  }
  #brand-switcher .scope-nav-link::after {
    display: none;
  }
  #brand-switcher .scope-nav-link:not(.active) {
    color: var(--text-secondary) !important;
  }
  #brand-switcher .scope-nav-link.active {
    background-color: var(--bg-pill);
    color: var(--text-pill) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
  }
  .brand-switch-icon {
    font-size: 11px;
    line-height: 1;
  }
  #brand-switcher .scope-nav-link:not(.active) .brand-switch-icon {
    opacity: 0.6;
  }

  /* 分類按鈕：改成等寬格狀排列，圖示在上、文字在下 */
  #tarot-category-tabs.flex,
  #crystal-category-tabs.flex {
    display: grid;
    gap: 8px;
  }
  #tarot-category-tabs.flex {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  #crystal-category-tabs.flex {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
  }
  .cat-tab {
    flex-direction: column;
    gap: 4px;
    padding: 10px 2px 8px;
    border-radius: 18px;
    font-size: 13px;
    letter-spacing: 0.04em;
    white-space: nowrap;
  }
  .cat-tab i {
    font-size: 15px;
  }

  /* 主視覺右側四宮格：縮小內距，讓品名一行放得下 */
  #dynamic-hero-container .grid-cols-2 {
    gap: 10px;
  }
  #dynamic-hero-container .grid-cols-2 > div {
    padding: 12px 8px;
  }
  #dynamic-hero-container .grid-cols-2 .text-sm {
    font-size: 13px;
  }
  #dynamic-hero-container .grid-cols-2 .text-lg {
    font-size: 16px;
  }
  #dynamic-hero-container .grid-cols-2 .text-xs {
    font-size: 11.5px;
    line-height: 1.5;
  }

  /* 商品卡：按鈕點擊區加大 */
  #product-grid article button {
    min-height: 38px;
  }
  #product-grid select {
    min-height: 38px;
  }

  /* 社群牆卡片：標題縮一級，避免與「切換此館」擠在一起 */
  #section-social-wall h3 {
    font-size: 1rem;
    line-height: 1.4;
  }

  /* 數字輸入框避免 iOS 聚焦時自動放大 */
  input[type="number"] {
    font-size: 16px;
  }

  /* 回到頂部按鈕稍微縮小、離邊緣近一點 */
  #back-to-top-btn {
    right: 16px;
    bottom: 16px;
    width: 44px;
    height: 44px;
  }
}
