/* ========================================================
   唐人宇宙小游戏合集 (Tangren Meme Arcade) 样式表
   温馨明亮 · 温暖治愈系国潮潮玩风 · 响应式丝滑动效
   ======================================================== */

:root {
  /* 明亮温馨主色调 */
  --bg-body: #f7f2ea;
  --bg-app: #fffdf9;
  --bg-subtle: #fbf6ee;
  --bg-card: #ffffff;
  --bg-slot-tray: #f2e7d8;
  --bg-slot-item: #e8dbca;

  /* 暖意点缀色 */
  --accent-orange: #ff763b;
  --accent-honey: #f39c12;
  --accent-gold: #f1b722;
  --accent-coral: #ff5252;
  --accent-mint: #20bf6b;
  --accent-teal: #0fbcf9;
  --accent-purple: #9b59b6;

  /* 温暖字体与边框 */
  --text-main: #3d2b1f;
  --text-sub: #8a7768;
  --text-light: #b5a597;
  --border-light: rgba(180, 140, 100, 0.18);
  --border-warm: #ebdccb;
  --border-card: #e6d3bf;
  
  /* 柔和阴影与圆角 */
  --shadow-tile: 0 4px 0 #dec6ae, 0 6px 12px rgba(120, 80, 40, 0.12);
  --shadow-pop: 0 8px 20px rgba(243, 156, 18, 0.25);
  --shadow-app: 0 16px 40px rgba(140, 100, 60, 0.15), 0 2px 8px rgba(0, 0, 0, 0.04);
  --border-radius-sm: 8px;
  --border-radius-md: 14px;
  --border-radius-lg: 20px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background-color: var(--bg-body);
  background-image: 
    radial-gradient(circle at 10% 15%, rgba(255, 180, 120, 0.25) 0%, transparent 45%),
    radial-gradient(circle at 90% 80%, rgba(255, 215, 120, 0.28) 0%, transparent 45%),
    radial-gradient(circle at 50% 50%, rgba(255, 248, 238, 0.6) 0%, transparent 70%);
  color: var(--text-main);
  height: 100vh;
  height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  touch-action: manipulation;
}

#app-container {
  width: 100%;
  max-width: 480px;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--bg-app);
  box-shadow: var(--shadow-app);
  overflow: hidden;
  border-left: 1px solid rgba(220, 195, 170, 0.3);
  border-right: 1px solid rgba(220, 195, 170, 0.3);
}

/* ========================================================
   顶部导航与通用状态栏 (温暖雅致)
   ======================================================== */
header.app-header {
  padding: calc(8px + env(safe-area-inset-top, 0px)) 14px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fffcf8;
  border-bottom: 1.5px solid var(--border-warm);
  flex-shrink: 0;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-title h1 {
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #e67e22, #ff5722);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-badge {
  font-size: 0.65rem;
  background: linear-gradient(135deg, #ff763b, #ff4757);
  color: #fff;
  padding: 2px 7px;
  border-radius: 99px;
  font-weight: 800;
  box-shadow: 0 2px 6px rgba(255, 118, 59, 0.3);
  text-transform: uppercase;
}

/* 顶部全域纯度能量条 */
.header-center-meter {
  display: flex;
  align-items: center;
  gap: 5px;
  background: #f7ecd9;
  border: 1.5px solid #e2cfba;
  padding: 2px 8px;
  border-radius: 99px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.header-center-meter:active {
  transform: scale(0.95);
}

.header-center-meter.flash-up {
  animation: meterPop 0.35s ease-out;
}

@keyframes meterPop {
  0% { transform: scale(1); background: #f7ecd9; }
  50% { transform: scale(1.15); background: #fff3cd; border-color: #f39c12; }
  100% { transform: scale(1); background: #f7ecd9; }
}

.purity-pill-label {
  font-size: 0.62rem;
  font-weight: 800;
  color: #a06734;
}

.purity-pill-val {
  font-size: 0.76rem;
  font-weight: 900;
  color: #c0392b;
  min-width: 28px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.purity-pill-bar {
  width: 38px;
  height: 6px;
  background: #ebdccb;
  border-radius: 99px;
  overflow: hidden;
  position: relative;
}

.purity-pill-fill {
  height: 100%;
  background: linear-gradient(90deg, #f39c12, #e74c3c);
  border-radius: 99px;
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.header-actions {
  display: flex;
  gap: 8px;
}

.btn-icon {
  background: #fbf5ed;
  border: 1.5px solid #ebdccb;
  color: var(--text-main);
  width: 35px;
  height: 35px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 0.95rem;
  box-shadow: 0 2px 4px rgba(150, 100, 60, 0.08);
}

.btn-icon:hover {
  background: #fff;
  border-color: var(--accent-honey);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(243, 156, 18, 0.2);
}

.btn-icon:active {
  transform: scale(0.94);
}

/* 模式切换选项卡 */
nav.mode-nav {
  display: flex;
  padding: 6px 10px;
  gap: 6px;
  background: #fcf6ee;
  border-bottom: 1.5px solid var(--border-warm);
  overflow-x: auto;
  flex-shrink: 0;
}

.nav-tab {
  flex: 1;
  min-width: 76px;
  padding: 7px 4px;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--text-sub);
  background: #f3e9db;
  border: 1px solid transparent;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
}

.nav-tab.active {
  color: #c0392b;
  background: #ffffff;
  border-color: #f5b041;
  box-shadow: 0 3px 8px rgba(230, 126, 34, 0.22);
  transform: translateY(-1px);
}

/* 主展示区 */
main.game-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  min-height: 0;
  background: var(--bg-app);
}

.game-screen {
  display: none !important;
  flex: 1;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.game-screen.active {
  display: flex !important;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.99); }
  to { opacity: 1; transform: scale(1); }
}

/* 顶部状态条 */
.hud-bar {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 6px 12px;
  background: #fdfaf5;
  border-bottom: 1px solid var(--border-warm);
  flex-shrink: 0;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hud-label {
  font-size: 0.62rem;
  color: var(--text-sub);
  font-weight: 700;
  letter-spacing: 0.5px;
}

.hud-value {
  font-size: 1.15rem;
  font-weight: 900;
  color: #d35400;
}

/* ========================================================
   模式 1: 唐了个唐 (堆叠三消)
   ======================================================== */
.match3-board-wrapper {
  flex: 1;
  position: relative;
  width: 100%;
  min-height: 180px;
  overflow: hidden;
  touch-action: manipulation;
  background: radial-gradient(circle at 50% 50%, #fffbf5 0%, #f7ede0 100%);
}

.match3-board {
  position: relative;
  width: 100%;
  height: 100%;
  margin: 0 auto;
}

.t-card {
  position: absolute;
  width: 48px;
  height: 48px;
  border-radius: 9px;
  background: #ffffff;
  border: 1.5px solid #ebdccb;
  box-shadow: var(--shadow-tile);
  cursor: pointer;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.15s, opacity 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.t-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  border-radius: 7px;
}

.t-card.blocked {
  opacity: 0.52;
  filter: grayscale(0.25) contrast(0.92);
  cursor: not-allowed;
  box-shadow: 0 2px 0 #d9c5b0, 0 3px 6px rgba(100, 70, 40, 0.08);
  border-color: #d8c7b4;
}

.t-card:not(.blocked):hover {
  transform: translateY(-3px) scale(1.06);
  box-shadow: 0 6px 0 #dec6ae, 0 10px 18px rgba(243, 156, 18, 0.35);
  border-color: var(--accent-honey);
  z-index: 9999 !important;
}

.t-card:not(.blocked):active {
  transform: translateY(2px) scale(0.96);
  box-shadow: 0 1px 0 #dec6ae;
}

.match3-footer {
  padding: 6px 12px calc(8px + env(safe-area-inset-bottom, 0px));
  background: #fbf5eb;
  border-top: 1.5px solid var(--border-warm);
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex-shrink: 0;
  box-shadow: 0 -4px 16px rgba(140, 90, 40, 0.06);
}

.stash-wrapper {
  background: #f5ebd9;
  border: 1.5px dashed #dabfa1;
  border-radius: var(--border-radius-sm);
  padding: 4px 8px;
}

.stash-title {
  font-size: 0.62rem;
  font-weight: 800;
  color: #a06734;
  margin-bottom: 3px;
}

.stash-container {
  display: flex;
  gap: 8px;
  min-height: 44px;
  align-items: center;
}

.slot-container {
  display: flex;
  justify-content: center;
  gap: 5px;
  padding: 6px;
  background: var(--bg-slot-tray);
  border-radius: var(--border-radius-md);
  border: 2px solid #dfcfbc;
  box-shadow: inset 0 3px 6px rgba(120, 80, 40, 0.12);
  min-height: 54px;
}

.slot-item {
  flex: 1;
  max-width: 48px;
  aspect-ratio: 1;
  border-radius: 8px;
  background: var(--bg-slot-item);
  border: 1.5px solid #d8c8b4;
  box-shadow: inset 0 2px 4px rgba(120, 80, 40, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.slot-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
}

.slot-item.anim-pop {
  animation: slotPop 0.22s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.slot-item.anim-match {
  animation: matchVanish 0.28s ease-in forwards;
}

@keyframes slotPop {
  0% { transform: scale(0.35); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes matchVanish {
  0% { transform: scale(1); filter: brightness(1.2); }
  50% { transform: scale(1.18) rotate(6deg); filter: brightness(1.8); }
  100% { transform: scale(0); opacity: 0; }
}

.match3-tools {
  display: flex;
  justify-content: space-around;
  gap: 8px;
}

.btn-tool {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: #ffffff;
  border: 1.5px solid #ebdccb;
  color: var(--text-main);
  padding: 6px 2px;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 5px rgba(140, 90, 40, 0.08);
}

.btn-tool:hover:not(:disabled) {
  background: #fffdf8;
  border-color: var(--accent-honey);
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(243, 156, 18, 0.25);
}

.btn-tool:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(1);
  box-shadow: none;
}

.tool-icon {
  font-size: 1.15rem;
}

.tool-name {
  font-size: 0.65rem;
  font-weight: 800;
  color: #5c4533;
}

.tool-count {
  font-size: 0.58rem;
  background: linear-gradient(135deg, #ff763b, #ff4757);
  color: #fff;
  padding: 1px 5px;
  border-radius: 99px;
  font-weight: 900;
  box-shadow: 0 2px 4px rgba(255, 71, 87, 0.25);
}

/* ========================================================
   模式 2: 疯狂打唐人
   ======================================================== */
.whack-stats {
  display: flex;
  justify-content: space-around;
  padding: 8px 12px;
  background: #fdfaf5;
  border-bottom: 1px solid var(--border-warm);
  flex-shrink: 0;
}

.whack-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 16px;
  margin: auto 0;
  max-width: 360px;
  align-self: center;
  width: 100%;
}

.whack-hole {
  aspect-ratio: 1;
  background: radial-gradient(circle at 50% 60%, #e2d2be 0%, #c9b49c 80%);
  border-radius: 50% / 35%;
  border: 3.5px solid #baa389;
  box-shadow: inset 0 8px 14px rgba(90, 60, 30, 0.35), 0 4px 8px rgba(120, 80, 40, 0.1);
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.whack-target {
  position: absolute;
  width: 78%;
  height: 78%;
  bottom: -100%;
  left: 11%;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(90, 60, 30, 0.25);
  border: 3px solid #ffb800;
  transition: bottom 0.12s cubic-bezier(0.175, 0.885, 0.32, 1.2);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  pointer-events: none;
}

.whack-target img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.whack-target.up {
  bottom: 12%;
}

.whack-target.golden {
  border-color: #f1c40f;
  box-shadow: 0 0 16px #f1c40f;
  animation: goldPulse 0.5s infinite alternate;
}

.whack-target.bomb {
  border-color: #ff4757;
  box-shadow: 0 0 14px #ff4757;
}

.whack-target.bomb::after {
  content: "💣";
  position: absolute;
  font-size: 1.5rem;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 0 4px #ff0000);
}

.whack-target.hit {
  transform: scale(0.85) rotate(-10deg);
  filter: brightness(1.4);
}

@keyframes goldPulse {
  0% { transform: scale(1); filter: drop-shadow(0 0 4px #f39c12); }
  100% { transform: scale(1.08); filter: drop-shadow(0 0 14px #f1c40f); }
}

.hit-popup {
  position: absolute;
  font-size: 1.15rem;
  font-weight: 900;
  color: #d35400;
  text-shadow: 0 2px 4px rgba(255, 255, 255, 0.9);
  pointer-events: none;
  animation: floatUp 0.5s ease-out forwards;
  z-index: 1000;
}

@keyframes floatUp {
  0% { opacity: 1; transform: translateY(0) scale(0.8); }
  50% { transform: translateY(-22px) scale(1.2); }
  100% { opacity: 0; transform: translateY(-40px) scale(1); }
}

.fever-banner {
  display: none;
  background: linear-gradient(90deg, #ff763b 0%, #ff5252 100%);
  color: #fff;
  text-align: center;
  font-weight: 900;
  font-size: 0.85rem;
  padding: 4px;
  letter-spacing: 2px;
  animation: feverPulse 0.4s infinite alternate;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(255, 82, 82, 0.3);
}

.fever-banner.active {
  display: block;
}

@keyframes feverPulse {
  from { opacity: 0.9; filter: brightness(1); }
  to { opacity: 1; filter: brightness(1.15); }
}

/* ========================================================
   模式 3: 极限翻牌对对碰
   ======================================================== */
.memory-controls {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 8px 14px;
  background: #fdfaf5;
  border-bottom: 1px solid var(--border-warm);
  flex-shrink: 0;
}

.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 12px 16px;
  margin: auto 0;
  perspective: 1000px;
  max-width: 380px;
  align-self: center;
  width: 100%;
}

.memory-card {
  aspect-ratio: 1;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  position: relative;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
  box-shadow: 0 4px 8px rgba(120, 80, 40, 0.12);
}

.memory-card:hover:not(.flipped):not(.matched) {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 6px 14px rgba(243, 156, 18, 0.25);
}

.memory-card.flipped {
  transform: rotateY(180deg);
}

.memory-card.mismatch-shake {
  animation: mismatchShake 0.38s ease-in-out;
}

@keyframes mismatchShake {
  0% { transform: rotateY(180deg) translateX(0); }
  25% { transform: rotateY(180deg) translateX(-4px); }
  50% { transform: rotateY(180deg) translateX(4px); }
  75% { transform: rotateY(180deg) translateX(-3px); }
  100% { transform: rotateY(180deg) translateX(0); }
}

.memory-card.matched {
  transform: rotateY(180deg) scale(0.95);
  cursor: default;
  box-shadow: 0 0 12px rgba(46, 204, 113, 0.6), 0 2px 6px rgba(0,0,0,0.1);
  animation: matchedGlow 0.4s ease-out;
}

@keyframes matchedGlow {
  0% { transform: rotateY(180deg) scale(1.08); filter: brightness(1.3); }
  100% { transform: rotateY(180deg) scale(0.95); filter: brightness(1); }
}

.card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transform: translateZ(1px);
}

.card-face.card-back {
  background: linear-gradient(135deg, #f5ebd9, #e8d9c0);
  border: 2px solid #cfbba3;
  color: #b35400;
  font-size: 1.4rem;
  font-weight: 900;
  box-shadow: inset 0 1px 3px rgba(255, 255, 255, 0.8), inset 0 -2px 4px rgba(120, 80, 40, 0.1);
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

.card-face.card-front {
  transform: rotateY(180deg);
  background: #ffffff;
  border: 2px solid var(--accent-honey);
  box-shadow: inset 0 0 4px rgba(243, 156, 18, 0.2);
}

.memory-card.matched .card-face.card-front {
  border-color: #2ecc71;
  background: #f4fbf7;
}

.card-face.card-front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ========================================================
   模式 4: 唐度大殿 (全新四大玩法系统)
   ======================================================== */
#screen-gallery {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #fbf7f0;
  display: flex;
  flex-direction: column;
}

.tang-grade-card {
  margin: 8px 12px 6px;
  padding: 12px 14px;
  border-radius: var(--border-radius-md);
  background: linear-gradient(135deg, #fffcf5, #fdedd5);
  border: 2px solid #f5b041;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(245, 176, 65, 0.16);
}

.grade-left h3 {
  font-size: 0.78rem;
  font-weight: 800;
  color: #a06734;
}

.grade-badge {
  font-size: 0.58rem;
  background: linear-gradient(135deg, #c0392b, #e74c3c);
  color: #fff;
  padding: 1px 6px;
  border-radius: 99px;
  font-weight: 900;
  box-shadow: 0 2px 4px rgba(192, 57, 43, 0.25);
  letter-spacing: 0.5px;
}

.grade-action-row {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.grade-left .grade-name {
  font-size: 1.25rem;
  font-weight: 900;
  color: #c0392b;
  margin: 1px 0;
}

.grade-left .grade-desc {
  font-size: 0.7rem;
  color: #7f6a58;
}

.grade-score-circle {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 3px solid #f39c12;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(243, 156, 18, 0.2);
}

.grade-score-num {
  font-size: 1.05rem;
  font-weight: 900;
  color: #d35400;
}

.grade-score-unit {
  font-size: 0.52rem;
  font-weight: 800;
  color: var(--text-sub);
}

.btn-sub-action {
  background: linear-gradient(135deg, #f39c12, #d35400);
  border: none;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(211, 84, 0, 0.25);
  transition: all 0.15s;
}

.btn-sub-action.secondary {
  background: #fff;
  border: 1.5px solid #ebdccb;
  color: #7f6a58;
  box-shadow: 0 2px 4px rgba(140, 90, 40, 0.08);
}

.btn-sub-action:active {
  transform: scale(0.95);
}

/* 大殿二级标签栏 */
.hall-sub-nav {
  display: flex;
  padding: 4px 12px;
  gap: 6px;
  background: #f5ebe0;
  border-top: 1px solid var(--border-warm);
  border-bottom: 1.5px solid var(--border-warm);
  flex-shrink: 0;
}

.hall-tab {
  flex: 1;
  padding: 6px 2px;
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--text-sub);
  background: #ede0d0;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  text-align: center;
}

.hall-tab.active {
  color: #b33939;
  background: #ffffff;
  border-color: #f39c12;
  box-shadow: 0 2px 6px rgba(243, 156, 18, 0.2);
}

/* 大殿各面板 */
.hall-panel {
  display: none !important;
  flex: 1;
  flex-direction: column;
  padding: 10px 14px 20px;
}

.hall-panel.active {
  display: flex !important;
  animation: fadeIn 0.18s ease-out;
}

/* 玩法 1：摇签求卜 */
.gacha-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px;
}

.gacha-cylinder {
  width: 90px;
  height: 130px;
  background: linear-gradient(135deg, #d35400, #b33939);
  border-radius: 12px 12px 18px 18px;
  border: 3px solid #f1c40f;
  box-shadow: 0 8px 20px rgba(180, 60, 30, 0.28);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 12px 0;
  transition: transform 0.15s;
}

.gacha-cylinder.shaking {
  animation: cylinderShake 0.4s infinite ease-in-out;
}

@keyframes cylinderShake {
  0% { transform: rotate(0deg) translate(0, 0); }
  25% { transform: rotate(-12deg) translate(-4px, -6px); }
  50% { transform: rotate(12deg) translate(4px, 2px); }
  75% { transform: rotate(-8deg) translate(-2px, -4px); }
  100% { transform: rotate(0deg) translate(0, 0); }
}

.cylinder-text {
  color: #fff;
  font-weight: 900;
  writing-mode: vertical-lr;
  letter-spacing: 4px;
  font-size: 0.95rem;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.stick-bundle {
  position: absolute;
  top: -24px;
  display: flex;
  gap: 5px;
}

.stick-b {
  width: 6px;
  height: 36px;
  background: #f5b041;
  border-radius: 3px 3px 0 0;
  border: 1px solid #d35400;
}

.stick-b.s1 { height: 32px; transform: rotate(-10deg); }
.stick-b.s2 { height: 40px; }
.stick-b.s3 { height: 34px; transform: rotate(12deg); }

.gacha-hint {
  font-size: 0.76rem;
  color: var(--text-sub);
  text-align: center;
  margin: 4px 0 8px;
}

.gacha-result-card {
  width: 100%;
  max-width: 320px;
  background: #ffffff;
  border: 2px solid #f39c12;
  border-radius: var(--border-radius-md);
  padding: 12px;
  text-align: center;
  margin-top: 12px;
  box-shadow: 0 8px 20px rgba(243, 156, 18, 0.25);
  animation: scaleUp 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* 玩法 2：功德木鱼 */
.muyu-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 10px;
}

.muyu-counter {
  font-size: 0.9rem;
  color: var(--text-main);
  background: #f5ebd9;
  padding: 6px 16px;
  border-radius: 99px;
  border: 1.5px solid #dfcfbc;
  margin-bottom: 24px;
}

.muyu-counter b {
  font-size: 1.25rem;
  color: #d35400;
  margin-left: 4px;
}

.muyu-interactive-area {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fffdf8 0%, #faecd7 60%, #e8d5be 100%);
  border: 3.5px solid #f5b041;
  box-shadow: 0 10px 24px rgba(180, 120, 60, 0.25), inset 0 2px 6px rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: transform 0.1s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.muyu-interactive-area:hover {
  transform: scale(1.05);
}

.muyu-interactive-area:active {
  transform: scale(0.92);
}

.muyu-icon {
  font-size: 4rem;
  pointer-events: none;
  filter: drop-shadow(0 4px 8px rgba(140, 90, 40, 0.2));
}

.muyu-tip {
  font-size: 0.75rem;
  color: var(--text-sub);
  margin-top: 24px;
}

.muyu-popup {
  position: absolute;
  font-size: 1.1rem;
  font-weight: 900;
  color: #d35400;
  pointer-events: none;
  animation: muyuFloat 0.6s ease-out forwards;
}

@keyframes muyuFloat {
  0% { opacity: 1; transform: translateY(0) scale(0.8); }
  50% { transform: translateY(-30px) scale(1.2); }
  100% { opacity: 0; transform: translateY(-55px) scale(1); }
}

/* 玩法 3：唐学科举 */
.exam-box {
  background: #ffffff;
  border: 2px solid var(--border-warm);
  border-radius: var(--border-radius-md);
  padding: 14px;
  box-shadow: 0 6px 16px rgba(140, 90, 40, 0.08);
}

.exam-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 800;
  color: #a06734;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1.5px dashed var(--border-warm);
}

.exam-question {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.45;
  margin-bottom: 14px;
}

.exam-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.exam-opt-btn {
  padding: 10px 12px;
  text-align: left;
  background: #fbf6ee;
  border: 1.5px solid #ebdccb;
  border-radius: var(--border-radius-sm);
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.exam-opt-btn:hover {
  background: #fff;
  border-color: #f39c12;
  transform: translateX(3px);
}

.exam-opt-btn.correct {
  background: #e8f8f0 !important;
  border-color: #2ecc71 !important;
  color: #27ae60 !important;
}

.exam-opt-btn.wrong {
  background: #fdeeee !important;
  border-color: #e74c3c !important;
  color: #c0392b !important;
}

/* 轻量级成就勋章解锁提示条 (小巧精致，不挡视线，右上/顶部优雅滑入) */
.badge-toast {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(-120%);
  background: rgba(255, 253, 248, 0.96);
  border: 1.5px solid #f39c12;
  border-radius: 99px;
  box-shadow: 0 6px 18px rgba(180, 110, 30, 0.22), 0 0 10px rgba(243, 156, 18, 0.18);
  padding: 4px 14px 4px 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 10005;
  pointer-events: none;
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  max-width: 90vw;
}

.badge-toast.active {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f5b041, #e67e22);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  box-shadow: 0 2px 6px rgba(230, 126, 34, 0.35);
  flex-shrink: 0;
}

.toast-content {
  display: flex;
  flex-direction: column;
}

.toast-title {
  font-size: 0.6rem;
  font-weight: 800;
  color: #a06734;
  letter-spacing: 0.5px;
  line-height: 1.1;
}

.toast-desc {
  font-size: 0.76rem;
  font-weight: 900;
  color: #c0392b;
  line-height: 1.2;
  white-space: nowrap;
}

/* 玩法 4：名将成就勋章系统 */
.badge-overview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f7ecd9;
  border: 1.5px solid #dfcfbc;
  border-radius: var(--border-radius-sm);
  padding: 6px 12px;
  margin-bottom: 10px;
}

.badge-prog-text {
  font-size: 0.76rem;
  color: var(--text-main);
  font-weight: 700;
}

.badge-prog-text b {
  font-size: 0.95rem;
  color: #c0392b;
}

.badge-prog-track {
  width: 90px;
  height: 8px;
  background: #ebdccb;
  border-radius: 99px;
  overflow: hidden;
}

.badge-prog-fill {
  height: 100%;
  background: linear-gradient(90deg, #f39c12, #2ecc71);
  border-radius: 99px;
  transition: width 0.3s ease-out;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 4px 0 20px;
}

.gallery-item {
  background: #ffffff;
  border-radius: var(--border-radius-sm);
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 1.5px solid var(--border-warm);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 3px 8px rgba(140, 90, 40, 0.08);
  position: relative;
}

.gallery-item.unlocked {
  border-color: #f5b041;
  background: linear-gradient(180deg, #ffffff 0%, #fffdf8 100%);
  box-shadow: 0 4px 12px rgba(243, 156, 18, 0.18);
}

.gallery-item.unlocked:hover {
  transform: translateY(-4px) scale(1.03);
  box-shadow: 0 8px 20px rgba(243, 156, 18, 0.3);
  border-color: #e67e22;
}

.gallery-item.locked {
  background: #fbf7f0;
  border-color: #ebdccb;
  opacity: 0.72;
}

.gallery-item.locked:hover {
  transform: translateY(-2px);
  opacity: 0.9;
}

.gallery-thumb {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 5px;
  background: #f7ede0;
  border: 1px solid #ebdccb;
  position: relative;
}

.gallery-item.unlocked .gallery-thumb {
  border: 1.5px solid #f39c12;
}

.gallery-item.locked .gallery-thumb img {
  filter: grayscale(1) contrast(0.85) brightness(0.7);
}

.thumb-badge-icon {
  position: absolute;
  top: 2px;
  right: 2px;
  font-size: 0.75rem;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
}

.thumb-lock-mask {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.25rem;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.6));
}

.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-badge-title {
  font-size: 0.65rem;
  color: #c0392b;
  font-weight: 900;
  white-space: nowrap;
  margin-bottom: 1px;
}

.gallery-item.locked .gallery-badge-title {
  color: #95a5a6;
}

.gallery-name {
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 3px;
  white-space: nowrap;
}

.gallery-status {
  font-size: 0.58rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 99px;
}

.gallery-status.status-ok {
  background: #e8f8f0;
  color: #27ae60;
  border: 1px solid #a3e4d7;
}

.gallery-status.status-lock {
  background: #f2f3f4;
  color: #7f8c8d;
  border: 1px solid #d5d8dc;
}

/* ========================================================
   弹窗与提示蒙层 (温馨奶白卡片)
   ======================================================== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(80, 50, 30, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: modalFadeIn 0.18s ease-out;
}

.modal-overlay.active {
  display: flex;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  width: 100%;
  max-width: 360px;
  background: #ffffff;
  border: 2.5px solid #f5b041;
  border-radius: var(--border-radius-lg);
  padding: 24px 20px;
  text-align: center;
  box-shadow: 0 16px 40px rgba(120, 70, 30, 0.28), 0 0 20px rgba(245, 176, 65, 0.25);
  animation: scaleUp 0.22s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes scaleUp {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-emoji {
  font-size: 2.8rem;
  margin-bottom: 6px;
}

.modal-title {
  font-size: 1.35rem;
  font-weight: 900;
  margin-bottom: 8px;
  color: #b33939;
}

.modal-desc {
  font-size: 0.85rem;
  color: var(--text-sub);
  margin-bottom: 18px;
  line-height: 1.55;
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #f39c12, #e67e22);
  border: none;
  border-radius: var(--border-radius-md);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(230, 126, 34, 0.35);
  transition: all 0.15s;
}

.btn-primary:active {
  transform: scale(0.96);
}

.btn-secondary {
  width: 100%;
  margin-top: 8px;
  padding: 10px;
  background: #fbf5ed;
  border: 1.5px solid #ebdccb;
  border-radius: var(--border-radius-md);
  color: var(--text-sub);
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-secondary:hover {
  background: #fdfaf5;
  color: var(--text-main);
  border-color: var(--accent-honey);
}

.btn-secondary:active {
  transform: scale(0.96);
}

/* 粒子全屏 Canvas */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 10000;
}

/* ========================================================
   多屏幕比例专项适配媒体查询 (Mobile Responsiveness)
   覆盖：
   1. 超窄屏 / 紧凑小屏 (如 iPhone SE, iPhone 5/mini, 屏幕宽度 <= 360px)
   2. 细长带刘海/灵动岛屏幕 (如 iPhone 14/15/16 Pro Max, 20:9, 21:9 比例)
   3. 矮屏 / 横屏模式 / 网页内置嵌入窗口 (高度 <= 620px)
   4. 平板 / 折叠屏展开 / 宽屏居中 (宽度 >= 480px)
   ======================================================== */

/* 1. 紧凑小屏 (宽 <= 360px) */
@media (max-width: 360px) {
  .brand-title h1 {
    font-size: 1.05rem;
  }
  .nav-tab {
    min-width: 68px;
    font-size: 0.72rem;
    padding: 6px 2px;
  }
  .btn-icon {
    width: 32px;
    height: 32px;
    font-size: 0.88rem;
  }
  .slot-container {
    gap: 3px;
    padding: 4px;
    min-height: 48px;
  }
  .slot-item {
    border-radius: 6px;
  }
  .btn-tool {
    padding: 4px 1px;
    gap: 1px;
  }
  .tool-icon {
    font-size: 1rem;
  }
  .tool-name {
    font-size: 0.6rem;
  }
  .whack-grid {
    gap: 8px;
    padding: 10px;
  }
  .memory-grid {
    gap: 6px;
    padding: 8px 10px;
  }
  .gallery-grid {
    gap: 6px;
    padding: 6px 8px 20px;
  }
  .gallery-thumb {
    width: 54px;
    height: 54px;
  }
}

/* 2. 矮屏设备 / 小窗口嵌入 (高 <= 640px) */
@media (max-height: 640px) {
  header.app-header {
    padding-top: 4px;
    padding-bottom: 4px;
  }
  .brand-title h1 {
    font-size: 1rem;
  }
  nav.mode-nav {
    padding: 4px 8px;
  }
  .hud-bar {
    padding: 4px 8px;
  }
  .hud-value {
    font-size: 0.98rem;
  }
  .match3-footer {
    padding: 4px 8px calc(4px + env(safe-area-inset-bottom, 0px));
    gap: 4px;
  }
  .slot-container {
    min-height: 46px;
    padding: 4px;
  }
  .whack-grid {
    padding: 8px;
    gap: 8px;
  }
  .whack-stats {
    padding: 4px 8px;
  }
  .memory-grid {
    padding: 6px 10px;
    gap: 6px;
  }
  .muyu-interactive-area {
    width: 100px;
    height: 100px;
  }
  .muyu-icon {
    font-size: 3rem;
  }
  .muyu-counter {
    margin-bottom: 12px;
  }
  .muyu-tip {
    margin-top: 12px;
  }
  .gacha-cylinder {
    height: 105px;
    margin: 6px 0;
  }
}

/* 3. 细长带刘海/灵动岛屏幕 (如 19.5:9, 21:9 手机高比例屏) */
@media (min-height: 800px) {
  .match3-board-wrapper {
    min-height: 300px;
  }
  .whack-grid {
    max-width: 380px;
    padding: 20px 16px;
  }
  .memory-grid {
    max-width: 400px;
    padding: 16px;
  }
  .muyu-box {
    padding-top: 36px;
  }
  .muyu-interactive-area {
    width: 150px;
    height: 150px;
  }
  .muyu-icon {
    font-size: 4.6rem;
  }
}

/* 4. 平板与桌面端大屏视口 (宽度 >= 480px 居中阴影强化) */
@media (min-width: 481px) {
  #app-container {
    border-radius: var(--border-radius-lg);
    height: calc(100vh - 32px);
    height: calc(100dvh - 32px);
    margin: auto;
  }
}
