/* Sweet Match - 占位美术版本（emoji 糖果），正式美术放入 assets/ 后由 js 检测替换 */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --cell: 52px;
  --gap: 4px;
  --candy-red: #ef4444;
  --candy-orange: #f97316;
  --candy-yellow: #facc15;
  --candy-green: #22c55e;
  --candy-blue: #3b82f6;
  --candy-purple: #a855f7;
}

html, body { height: 100%; }

body {
  font-family: ui-rounded, "Segoe UI", system-ui, -apple-system, sans-serif;
  background: linear-gradient(160deg, #4c1d95 0%, #7c3aed 45%, #c026d3 100%);
  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; }

/* ---------- 地图页 ---------- */
.map-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; }
.logo { font-size: 22px; font-weight: 900; letter-spacing: 0.5px; text-shadow: 0 2px 0 rgba(0,0,0,.25); }
.map-stats { display: flex; gap: 8px; }
.pill { background: rgba(255,255,255,.15); border-radius: 999px; padding: 6px 12px; font-size: 14px; font-weight: 700; backdrop-filter: blur(4px); }

.episode-banner {
  margin: 4px 16px 12px; padding: 14px; 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-name { font-size: 18px; font-weight: 900; }
.episode-sub { font-size: 13px; 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; filter: drop-shadow(0 1px 1px rgba(0,0,0,.3)); }
.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);} }

.btn-daily {
  position: fixed; right: 16px; bottom: 18px; z-index: 5;
  border: none; border-radius: 999px; padding: 12px 18px; font-size: 15px; font-weight: 800; color: #fff;
  background: linear-gradient(160deg, #f59e0b, #d97706); cursor: pointer;
  box-shadow: 0 5px 0 rgba(0,0,0,.25);
}
.btn-daily.has-gift { animation: wiggle 1.2s ease-in-out infinite; }
@keyframes wiggle { 0%,100% { transform: rotate(-3deg);} 50% { transform: rotate(3deg);} }
.btn-sound { position: fixed; left: 16px; bottom: 18px; z-index: 5; background: rgba(255,255,255,.15); border: none; border-radius: 999px; width: 44px; height: 44px; font-size: 18px; color: #fff; cursor: pointer; }

/* ---------- 游戏页 ---------- */
.level-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); }
.level-info { flex: 1; min-width: 0; }
.level-title { font-size: 17px; font-weight: 900; }
.objective-text { font-size: 12.5px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.moves-box { text-align: center; background: rgba(255,255,255,.15); border-radius: 14px; padding: 6px 14px; min-width: 74px; }
.moves-num { font-size: 26px; font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; }
.moves-label { font-size: 10.5px; text-transform: uppercase; opacity: .75; letter-spacing: 1px; }
.moves-box.low .moves-num { color: #fda4af; animation: blink-low 1s steps(2) infinite; }
@keyframes blink-low { 50% { opacity: .4; } }

.progress-wrap { padding: 0 14px 8px; }
.progress-bar { height: 14px; 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; }
.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); }
.cell-bg.j1 { background: rgba(110, 231, 255, .22); box-shadow: inset 0 0 10px rgba(110,231,255,.35); }
.cell-bg.j2 { background: rgba(110, 231, 255, .38); box-shadow: inset 0 0 14px rgba(110,231,255,.6); }

.candy {
  position: absolute; display: flex; align-items: center; justify-content: center;
  font-size: calc(var(--cell) * .62); 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));
}
.candy img { width: 84%; height: 84%; object-fit: contain; pointer-events: none; }
.candy.selected { z-index: 5; }
.candy.selected .body { animation: selected-pulse .7s ease-in-out infinite; }
@keyframes selected-pulse { 0%,100% { transform: scale(1.08); } 50% { transform: scale(.94); } }
.candy.dragging { cursor: grabbing; }
.candy.dragging .body { transform: scale(1.16); filter: brightness(1.08); }
.candy .body { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; border-radius: 12px; position: relative; }
.candy.special .body { box-shadow: 0 0 12px 2px rgba(255,255,255,.55); border-radius: 12px; }
.candy.special-h .body { background: repeating-linear-gradient(0deg, transparent 0 5px, rgba(255,255,255,.55) 5px 8px); }
.candy.special-v .body { background: repeating-linear-gradient(90deg, transparent 0 5px, rgba(255,255,255,.55) 5px 8px); }
.candy.special-w .body { animation: wrap-glow 1s ease-in-out infinite; }
@keyframes wrap-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); } }
.candy.special-b .body { animation: bomb-spin 2.2s linear infinite; }
@keyframes bomb-spin { 0% { filter: hue-rotate(0deg); } 100% { filter: hue-rotate(360deg); } }

.candy.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; }
}
.candy.spawn { }
.candy.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); } }

/* ---------- 特效层 ---------- */
#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: 44px; font-weight: 900; letter-spacing: 1px; 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: 56px; 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) rotate(0); 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; }
}

/* ---------- 底栏 ---------- */
.booster-bar { display: flex; gap: 10px; justify-content: center; padding: 10px 0 14px; }
.booster {
  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;
  transition: transform .1s ease;
}
.booster:active { transform: scale(.92); }
.booster:disabled { opacity: .4; cursor: not-allowed; }
.booster.armed { background: #f59e0b; border-color: #fde68a; animation: armed .8s ease-in-out infinite; }
@keyframes armed { 0%,100% { box-shadow: 0 0 0 0 rgba(253,230,138,.8); } 50% { box-shadow: 0 0 0 8px rgba(253,230,138,0); } }
.booster .cnt {
  position: absolute; top: -8px; right: -8px; background: #ef4444; border-radius: 999px;
  min-width: 20px; height: 20px; font-size: 11.5px; display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
#board.hammer-mode .candy { cursor: crosshair; }
#board.hammer-mode { outline: 3px dashed #f59e0b; outline-offset: 3px; }

/* ---------- 弹窗 ---------- */
.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: 26px; 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; }
.btn.primary { background: linear-gradient(160deg, #34d399, #10b981); color: #052e1f; box-shadow: 0 4px 0 #047857; }
.btn.secondary { background: rgba(255,255,255,.18); color: #fff; }
.btn:active { transform: translateY(2px); }
.modal-hearts { font-size: 34px; letter-spacing: 4px; margin-bottom: 10px; }
.lives-timer { font-size: 15px; font-weight: 700; margin-bottom: 16px; }
.daily-gift { font-size: 60px; animation: wiggle 1s ease-in-out infinite; margin-bottom: 8px; }

/* 宽屏：棋盘侧移并展示品牌面板 */
@media (min-width: 760px) {
  .level-nodes { grid-template-columns: repeat(5, 1fr); }
}
@media (max-width: 420px) {
  :root { --cell: 42px; }
  .level-nodes { grid-template-columns: repeat(3, 1fr); }
}
