/* TopFun 自研游戏共享套件样式（_kit）——被 gem-blitz / fruit-splash / forest-friends / zoo-pop / triple-stack 复用 */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  font-family: ui-rounded, "Segoe UI", system-ui, -apple-system, sans-serif;
  color: #fff;
  overflow: hidden;
  user-select: none;
}

#app { height: 100%; max-width: 900px; margin: 0 auto; display: flex; flex-direction: column; position: relative; }
.screen { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.hidden { display: none !important; }

/* ---------- 顶栏 / HUD ---------- */
.game-header { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.icon-btn { background: rgba(255,255,255,.15); color: #fff; border: none; border-radius: 12px; width: 42px; height: 42px; font-size: 20px; cursor: pointer; flex-shrink: 0; }
.icon-btn:active { transform: scale(.92); }
.game-title { flex: 1; min-width: 0; }
.game-title .t1 { font-size: 17px; font-weight: 900; }
.game-title .t2 { font-size: 12.5px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-box { text-align: center; background: rgba(255,255,255,.15); border-radius: 14px; padding: 6px 14px; min-width: 74px; }
.stat-box .n { font-size: 24px; font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-box .l { font-size: 10.5px; text-transform: uppercase; opacity: .75; letter-spacing: 1px; }
.stat-box.low .n { color: #fda4af; animation: blink-low 1s steps(2) infinite; }
@keyframes blink-low { 50% { opacity: .4; } }

.progress-wrap { padding: 0 14px 8px; }
.progress-bar { height: 13px; background: rgba(0,0,0,.28); border-radius: 999px; overflow: hidden; border: 1.5px solid rgba(255,255,255,.2); }
.progress-fill { height: 100%; width: 0%; border-radius: 999px; background: linear-gradient(90deg, #34d399, #a3e635); transition: width .4s ease; }
.objective-detail { display: flex; gap: 12px; justify-content: center; font-size: 13px; font-weight: 700; margin-top: 5px; min-height: 18px; flex-wrap: wrap; }
.objective-detail .done { opacity: .55; text-decoration: line-through; }

/* ---------- 棋盘 ---------- */
#board-wrap { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; padding: 4px; position: relative; }
.board { position: relative; background: rgba(0,0,0,.25); border: 2px solid rgba(255,255,255,.18); border-radius: 16px; box-shadow: inset 0 2px 12px rgba(0,0,0,.3); touch-action: none; }
.board.shake { animation: shake .35s ease; }
@keyframes shake { 0%,100% { transform: translate(0,0); } 20% { transform: translate(-6px,3px); } 40% { transform: translate(6px,-3px); } 60% { transform: translate(-4px,-2px); } 80% { transform: translate(4px,2px); } }

.cell-bg { position: absolute; border-radius: 10px; background: rgba(255,255,255,.05); }
.overlay-ice { position: absolute; border-radius: 10px; background: rgba(186,230,253,.4); border: 2px solid rgba(224,242,254,.7); box-shadow: inset 0 0 10px rgba(255,255,255,.5); }
.overlay-ice.x2 { background: rgba(186,230,253,.65); }
.overlay-vine { position: absolute; border-radius: 10px; background: repeating-linear-gradient(45deg, rgba(74,222,128,.35) 0 6px, rgba(34,197,94,.25) 6px 12px); border: 2px dashed rgba(134,239,172,.8); }
.overlay-cage { position: absolute; border-radius: 10px; background: repeating-linear-gradient(0deg, rgba(120,72,20,.55) 0 4px, transparent 4px 9px), repeating-linear-gradient(90deg, rgba(120,72,20,.55) 0 4px, transparent 4px 9px); border: 2.5px solid rgba(180,120,60,.9); }

.piece { position: absolute; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: transform .3s cubic-bezier(.22,1.61,.36,1); will-change: transform; filter: drop-shadow(0 3px 3px rgba(0,0,0,.35)); }
.piece img { width: 84%; height: 84%; object-fit: contain; pointer-events: none; }
.piece .body { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; border-radius: 12px; position: relative; }
.piece.selected { z-index: 5; }
.piece.selected .body { animation: selected-pulse .7s ease-in-out infinite; }
@keyframes selected-pulse { 0%,100% { transform: scale(1.08); } 50% { transform: scale(.94); } }
.piece.dragging { cursor: grabbing; }
.piece.dragging .body { transform: scale(1.16); filter: brightness(1.1); }
.piece.special .body { box-shadow: 0 0 12px 2px rgba(255,255,255,.55); }
.piece.special-line .body { background: repeating-linear-gradient(90deg, transparent 0 5px, rgba(255,255,255,.5) 5px 8px); }
.piece.special-area .body { animation: area-glow 1s ease-in-out infinite; }
@keyframes area-glow { 0%,100% { box-shadow: 0 0 8px 2px rgba(251,191,36,.5); } 50% { box-shadow: 0 0 18px 6px rgba(251,191,36,.9); } }
.piece.special-bomb .body { animation: bomb-spin 2.2s linear infinite; }
@keyframes bomb-spin { 0% { filter: hue-rotate(0deg); } 100% { filter: hue-rotate(360deg); } }
.piece.pop { animation: pop .3s cubic-bezier(.3,.7,.4,1) forwards; z-index: 6; }
@keyframes pop {
  0% { transform: var(--tf) scale(1); }
  35% { transform: var(--tf) scale(1.45); filter: brightness(1.8) drop-shadow(0 0 10px #fff); }
  100% { transform: var(--tf) scale(0); opacity: 0; }
}
.piece.flash-create .body { animation: create-flash .5s ease; }
@keyframes create-flash { 0% { transform: scale(0); } 55% { transform: scale(1.5); filter: brightness(2); } 100% { transform: scale(1); } }
.piece.hint { animation: hint-bounce .8s ease-in-out infinite; z-index: 4; }
@keyframes hint-bounce { 0%,100% { filter: brightness(1); } 50% { filter: brightness(1.8) drop-shadow(0 0 8px #fff); } }
.piece.group-hover { filter: brightness(1.35) drop-shadow(0 0 8px rgba(255,255,255,.8)); }

/* ---------- 特效 ---------- */
#fx-layer { position: absolute; inset: 0; pointer-events: none; overflow: visible; z-index: 20; }
.float-score { position: absolute; font-weight: 900; font-size: 17px; color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.4); animation: float-up .9s ease forwards; }
.float-score.hot { font-size: 22px; text-shadow: 0 0 12px rgba(253,224,71,.8), 0 2px 0 rgba(0,0,0,.4); }
@keyframes float-up { 0% { transform: translateY(0) scale(.8); opacity: 0; } 20% { opacity: 1; transform: translateY(-8px) scale(1.1); } 100% { transform: translateY(-52px) scale(1); opacity: 0; } }
.combo-text { position: absolute; left: 50%; top: 42%; transform: translate(-50%,-50%); font-size: 42px; font-weight: 900; white-space: nowrap; color: #fde047; text-shadow: 0 3px 0 #d97706, 0 6px 18px rgba(0,0,0,.5); animation: combo-in .8s cubic-bezier(.2,1.6,.4,1) forwards; }
.combo-text.big { font-size: 54px; color: #fff; background: linear-gradient(92deg, #fde047, #fb7185, #a78bfa); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; filter: drop-shadow(0 3px 0 rgba(0,0,0,.45)); }
@keyframes combo-in { 0% { transform: translate(-50%,-50%) scale(0) rotate(-8deg); opacity: 0; } 45% { transform: translate(-50%,-50%) scale(1.15) rotate(2deg); opacity: 1; } 80% { transform: translate(-50%,-50%) scale(1); opacity: 1; } 100% { transform: translate(-50%,-50%) scale(1.1); opacity: 0; } }
.particle { position: absolute; border-radius: 50%; }
.particle.bit { border-radius: 2px; }
/* 冲击波圆环：消除时向外扩散 */
.fx-ring { position: absolute; width: 14px; height: 14px; border-radius: 50%; border: 3px solid #fff; pointer-events: none; animation: fx-ring .45s cubic-bezier(.2,.7,.3,1) forwards; }
@keyframes fx-ring {
  0% { transform: translate(-50%,-50%) scale(.4); opacity: .95; border-width: 4px; }
  100% { transform: translate(-50%,-50%) scale(3.4); opacity: 0; border-width: 1px; }
}
/* 白色星光：四角星闪现 */
.fx-sparkle { position: absolute; width: 15px; height: 15px; background: #fff; pointer-events: none; clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%); animation: fx-sparkle .5s ease-out forwards; }
@keyframes fx-sparkle {
  0% { transform: translate(-50%,-50%) scale(0) rotate(0deg); opacity: 1; }
  60% { transform: translate(-50%,-50%) scale(1.2) rotate(90deg); opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(.2) rotate(180deg); opacity: 0; }
}

/* ---------- 新手引导高亮（merge-kit 教程） ---------- */
.mk-tut { animation: mk-tut-pulse 1.1s ease-in-out infinite; outline: 3px solid #fde047 !important; border-radius: 12px; }
@keyframes mk-tut-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(253, 224, 71, .85); transform: scale(1); }
  50% { box-shadow: 0 0 18px 6px rgba(253, 224, 71, .55); transform: scale(1.06); }
}
/* 生产器就绪高亮（merge-kit 冷却结束可点击时闪烁提示） */
.mk-gen-glow { animation: mk-tut-pulse 1.1s ease-in-out infinite; outline: 3px solid #fde047 !important; border-radius: 12px; }

/* ---------- 地图 ---------- */
.map-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; }
.map-header .logo { font-size: 21px; font-weight: 900; text-shadow: 0 2px 0 rgba(0,0,0,.25); }
.map-header .stats { display: flex; gap: 8px; }
.pill { background: rgba(255,255,255,.15); border-radius: 999px; padding: 6px 12px; font-size: 14px; font-weight: 700; }
.episode-banner { margin: 4px 16px 12px; padding: 12px; border-radius: 18px; text-align: center; background: linear-gradient(135deg, rgba(255,255,255,.18), rgba(255,255,255,.06)); border: 1px solid rgba(255,255,255,.25); }
.episode-banner .en { font-size: 17px; font-weight: 900; }
.episode-banner .es { font-size: 12.5px; opacity: .8; margin-top: 2px; }
.level-nodes { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; padding: 10px 20px 24px; align-content: start; }
.level-node { position: relative; aspect-ratio: 1; border-radius: 50%; background: linear-gradient(160deg, #f472b6, #db2777); border: 3px solid rgba(255,255,255,.5); display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 900; font-size: 22px; cursor: pointer; box-shadow: 0 6px 0 rgba(0,0,0,.22), 0 8px 18px rgba(0,0,0,.2); transition: transform .12s ease; }
.level-node:not(.locked):hover { transform: scale(1.06); }
.level-node:not(.locked):active { transform: scale(.96); }
.level-node .stars { font-size: 11px; letter-spacing: -2px; margin-top: -2px; }
.level-node.locked { background: linear-gradient(160deg, #6b7280, #4b5563); cursor: not-allowed; opacity: .75; }
.level-node.locked::after { content: '🔒'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 24px; }
.level-node.current { animation: pulse-node 1.6s ease-in-out infinite; }
@keyframes pulse-node { 0%,100% { box-shadow: 0 6px 0 rgba(0,0,0,.22), 0 0 0 0 rgba(255,255,255,.5); } 50% { box-shadow: 0 6px 0 rgba(0,0,0,.22), 0 0 0 12px rgba(255,255,255,0); } }

/* ---------- 弹窗 / 按钮 ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.55); backdrop-filter: blur(3px); }
.modal-card { width: min(90vw, 360px); background: linear-gradient(165deg, #8b5cf6, #6d28d9); border: 2px solid rgba(255,255,255,.3); border-radius: 22px; padding: 26px 22px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.45); animation: modal-in .35s cubic-bezier(.2,1.4,.4,1); }
@keyframes modal-in { 0% { transform: scale(.6) translateY(30px); opacity: 0; } 100% { transform: scale(1) translateY(0); opacity: 1; } }
.result-title { font-size: 25px; font-weight: 900; margin-bottom: 8px; text-shadow: 0 2px 0 rgba(0,0,0,.25); }
.result-stars { font-size: 40px; letter-spacing: 6px; margin: 8px 0; min-height: 52px; }
.result-stars .star { display: inline-block; opacity: .25; transform: scale(.6); filter: grayscale(1); }
.result-stars .star.on { opacity: 1; transform: scale(1); filter: none; animation: star-slam .5s cubic-bezier(.2,1.8,.4,1); }
@keyframes star-slam { 0% { transform: scale(2.4) rotate(20deg); opacity: 0; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
.result-score { font-size: 19px; font-weight: 800; margin-bottom: 6px; }
.result-extra { font-size: 14px; opacity: .9; margin-bottom: 14px; min-height: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: center; }
.btn { border: none; border-radius: 999px; padding: 12px 26px; font-size: 16px; font-weight: 900; cursor: pointer; color: #fff; }
.btn.primary { background: linear-gradient(160deg, #34d399, #10b981); color: #052e1f; box-shadow: 0 4px 0 #047857; }
.btn.secondary { background: rgba(255,255,255,.18); }
.btn:active { transform: translateY(2px); }

/* ---------- 底栏（道具/槽位） ---------- */
.bottom-bar { display: flex; gap: 10px; justify-content: center; align-items: center; padding: 10px 0 14px; flex-wrap: wrap; }
.tool-btn { position: relative; border: 2px solid rgba(255,255,255,.35); background: rgba(255,255,255,.14); color: #fff; border-radius: 14px; padding: 10px 14px; font-size: 16px; font-weight: 800; cursor: pointer; }
.tool-btn:active { transform: scale(.92); }
.tool-btn:disabled { opacity: .4; cursor: not-allowed; }
.tool-btn.armed { background: #f59e0b; border-color: #fde68a; }

/* ---------- Triple Stack 牌区 ---------- */
#tile-board { position: relative; width: 100%; max-width: 560px; margin: 0 auto; }
.tile { position: absolute; display: flex; align-items: center; justify-content: center; border-radius: 10px; background: #fff7ed; border: 2px solid rgba(0,0,0,.15); box-shadow: 0 3px 6px rgba(0,0,0,.35); cursor: pointer; transition: transform .15s ease, opacity .2s ease; font-size: calc(var(--ts, 40px) * .6); }
.tile.free:hover { transform: scale(1.08); }
.tile.blocked { filter: brightness(.75) saturate(.7); cursor: not-allowed; }
.tile.to-slot { animation: to-slot .25s ease forwards; }
@keyframes to-slot { 100% { opacity: 0; transform: scale(.4); } }
.tile.clearing { animation: tile-clear .3s ease forwards; }
@keyframes tile-clear { 40% { transform: scale(1.35); filter: brightness(1.8); } 100% { opacity: 0; transform: scale(0); } }
.slots-bar { display: flex; justify-content: center; gap: 6px; padding: 12px 8px; }
.slot { width: 46px; height: 46px; border-radius: 10px; background: rgba(0,0,0,.3); border: 2px dashed rgba(255,255,255,.3); display: flex; align-items: center; justify-content: center; font-size: 26px; }
.slot.danger { border-color: #f87171; animation: blink-low 1s steps(2) infinite; }

@media (max-width: 420px) { .level-nodes { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 760px) { .level-nodes { grid-template-columns: repeat(5, 1fr); } }
