/* ===== PLUSH POP · peach pink theme ===== */
:root {
  --panel: #f59cb0;
  --panel-deep: #e0788f;
  --panel-edge: #c95f7b;
  --board: #a14860;
  --board-edge: #7e3247;
  --cell: #8a3c52;
  --cream: #fdf3e2;
  --cream-deep: #f3e2c5;
  --rose: #d6537a;
  --rose-deep: #b3476a;
  --gold: #ffc83d;
  --gold-deep: #f0a818;
  --white: #fff;
  --cell-size: 64px;
  --gap: 6px;
  --font: "Baloo 2", "ZCOOL KuaiLe", "Microsoft YaHei", "Segoe UI Rounded", system-ui, sans-serif;
}

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

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: linear-gradient(180deg, #ffe3c9 0%, #ffc9d6 45%, #ff9fbe 100%);
  background-size: cover;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  user-select: none;
}

body.has-bg {
  background: url(../assets/bg.png) center / cover no-repeat;
}

#stage {
  display: flex;
  align-items: center;
  gap: 30px;
  padding: 16px;
}

/* ===== left panel ===== */
#panel {
  width: 232px;
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-deep) 100%);
  border-radius: 26px;
  padding: 18px 14px 14px;
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,.45),
    inset 0 -4px 0 rgba(0,0,0,.12),
    0 10px 24px rgba(160,60,90,.35);
  display: flex;
  flex-direction: column;
  align-items: center;
}

#logo { width: 170px; min-height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
#logo.logo-css .logo-line1, #logo.logo-css .logo-line2 {
  display: block;
  font-weight: 900;
  letter-spacing: 5px;
  line-height: 1.08;
}
#logo.logo-css .logo-line1 {
  font-size: 27px; color: #fff;
  text-shadow:
    0 2px 0 #eaa7ba, 0 3px 0 #d98ca3,
    0 6px 10px rgba(150,50,80,.45);
}
#logo.logo-css .logo-line2 {
  font-size: 40px; color: var(--gold);
  text-shadow:
    0 2px 0 var(--gold-deep), 0 4px 0 #c98a10,
    0 7px 12px rgba(150,50,80,.45);
}

#banner {
  margin: 10px 0 12px;
  background: var(--rose-deep);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 4px 12px;
  border-radius: 8px;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.18), 0 2px 3px rgba(150,50,80,.25);
}

#card {
  width: 100%;
  background: var(--cream);
  border-radius: 18px;
  padding: 14px 14px 12px;
  box-shadow: inset 0 -4px 0 var(--cream-deep), 0 4px 8px rgba(150,50,80,.2);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stat { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }

.pill {
  background: linear-gradient(180deg, var(--rose) 0%, var(--rose-deep) 100%);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.5px;
  padding: 3px 14px;
  border-radius: 999px;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.15);
}

.goal-row { display: flex; align-items: center; gap: 8px; align-self: center; }
#goal-icon {
  width: 34px; height: 34px;
  background: url(../assets/piece_star.png) center / contain no-repeat;
  filter: drop-shadow(0 2px 2px rgba(150,50,80,.25));
}
#goal-icon.css-star::before { content: "⭐"; font-size: 24px; line-height: 34px; display: block; text-align: center; }
#goal { font-size: 30px; color: var(--rose-deep); }

.big-num { font-size: 34px; color: var(--rose-deep); align-self: center; line-height: 1; }
.mid-num { font-size: 24px; color: var(--rose-deep); align-self: center; line-height: 1.1; }

.time-row { display: flex; align-items: baseline; gap: 3px; align-self: center; position: relative; }
.time-unit { font-size: 13px; font-weight: 700; color: #b08c70; }
.time-row .big-num.low { color: #e8334f; animation: time-pulse 1s infinite; }
@keyframes time-pulse { 50% { opacity: .45; } }
#time-bonus {
  position: absolute;
  left: 100%; top: -4px;
  margin-left: 6px;
  font-size: 16px;
  font-weight: 800;
  color: #4caf50;
  opacity: 0;
  white-space: nowrap;
  pointer-events: none;
}
#time-bonus.show { animation: bonus-float 1.1s ease forwards; }
@keyframes bonus-float { 0% { opacity: 0; translate: 0 6px; } 25% { opacity: 1; } 100% { opacity: 0; translate: 0 -14px; } }

.stat b.bump { animation: bump .3s ease; }
@keyframes bump { 40% { transform: scale(1.25); } }

#progress {
  position: relative;
  height: 14px;
  background: #e9d8bd;
  border-radius: 999px;
  margin-top: 4px;
  box-shadow: inset 0 2px 3px rgba(0,0,0,.12);
}
#progress-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 0%;
  background: linear-gradient(180deg, #ffd76a, var(--gold-deep));
  border-radius: 999px;
  transition: width .5s ease;
}
.prog-star {
  position: absolute; top: 50%;
  width: 22px; height: 22px;
  transform: translate(-50%, -50%);
  background: #c9b797;
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  transition: background .3s, filter .3s;
}
.prog-star.lit {
  background: var(--gold);
  filter: drop-shadow(0 0 4px rgba(255,200,61,.8));
}

/* ===== tools ===== */
#tools { display: flex; gap: 12px; margin-top: 14px; }
.tool {
  position: relative;
  width: 50px; height: 50px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--rose) 0%, var(--rose-deep) 100%);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.35), inset 0 -3px 0 rgba(0,0,0,.2), 0 4px 8px rgba(150,50,80,.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .12s;
}
.tool:active { transform: scale(.92); }
.tool svg { width: 24px; height: 24px; fill: #fff; }
.tool .count {
  position: absolute;
  right: -3px; bottom: -3px;
  min-width: 19px; height: 19px;
  background: #ff4d6d;
  border: 2px solid #fff;
  border-radius: 999px;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  font-style: normal;
  line-height: 15px;
  text-align: center;
}
.tool.disabled { filter: grayscale(.9) brightness(.85); cursor: default; }
.tool.armed {
  outline: 3px solid #fff;
  outline-offset: 2px;
  animation: pulse 1s infinite;
}
@keyframes pulse { 50% { box-shadow: inset 0 2px 0 rgba(255,255,255,.35), inset 0 -3px 0 rgba(0,0,0,.2), 0 0 16px rgba(255,255,255,.9); } }

#mute {
  margin-top: 12px;
  width: 38px; height: 38px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,.25);
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.12);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
#mute svg { width: 20px; height: 20px; fill: #fff; }

/* ===== board ===== */
#board-wrap { position: relative; }

#board {
  position: relative;
  padding: 14px;
  background: linear-gradient(180deg, var(--board) 0%, #92405a 100%);
  border-radius: 24px;
  box-shadow:
    inset 0 3px 0 rgba(255,255,255,.18),
    0 8px 0 var(--board-edge),
    0 16px 28px rgba(140,50,80,.45);
}

#cells {
  display: grid;
  grid-template-columns: repeat(6, var(--cell-size));
  grid-template-rows: repeat(7, var(--cell-size));
  gap: var(--gap);
}
.cell {
  background: var(--cell);
  border-radius: 14px;
  box-shadow: inset 0 3px 5px rgba(0,0,0,.25), inset 0 -1px 0 rgba(255,255,255,.07);
}

#pieces, #fx { position: absolute; left: 14px; top: 14px; pointer-events: none; }
#pieces { pointer-events: auto; }

.piece {
  position: absolute;
  width: var(--cell-size);
  height: var(--cell-size);
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  cursor: pointer;
  transition: transform .18s ease;
  will-change: transform;
}
.piece.falling { transition: transform .3s cubic-bezier(.34, 1.3, .64, 1); }
.piece.selected {
  filter: brightness(1.15) drop-shadow(0 0 8px rgba(255,255,255,.95));
  animation: wiggle .5s ease infinite;
  z-index: 5;
}
@keyframes wiggle { 25% { rotate: -5deg; } 75% { rotate: 5deg; } }
.piece.popping {
  transition: transform .28s ease, opacity .28s ease;
  transform: scale(0) !important;
  opacity: 0;
  z-index: 6;
}
.piece.spawn { animation: spawn .25s ease; }
@keyframes spawn { from { scale: .3; opacity: .3; } }

/* fallback colored tiles (before images are ready) */
.piece.fb { border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 30px; box-shadow: inset 0 3px 0 rgba(255,255,255,.4), inset 0 -4px 0 rgba(0,0,0,.15); }
.piece.fb-heart { background-color: #ff8fab; }
.piece.fb-moon { background-color: #b89ce8; }
.piece.fb-cloud { background-color: #7ec8f0; }
.piece.fb-star { background-color: #ffd166; }
.piece.fb-flower { background-color: #ffa06b; }

/* pop ring + score float */
.pop-ring {
  position: absolute;
  width: var(--cell-size); height: var(--cell-size);
  border-radius: 50%;
  border: 4px solid rgba(255,255,255,.9);
  animation: ring .35s ease forwards;
}
@keyframes ring { from { scale: .4; opacity: 1; } to { scale: 1.5; opacity: 0; } }

.score-float {
  position: absolute;
  font-weight: 800;
  font-size: 22px;
  color: var(--gold);
  text-shadow: 0 2px 0 rgba(140,60,0,.45), 0 0 6px rgba(0,0,0,.2);
  animation: floatUp 1s ease forwards;
  white-space: nowrap;
  z-index: 8;
}
@keyframes floatUp { to { translate: 0 -52px; opacity: 0; } }

#board-toast {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255,255,255,.92);
  color: var(--rose-deep);
  font-weight: 800;
  font-size: 18px;
  padding: 10px 22px;
  border-radius: 999px;
  box-shadow: 0 6px 16px rgba(150,50,80,.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
  z-index: 9;
}
#board-toast.show { opacity: 1; }

/* ===== overlay dialog ===== */
#overlay {
  position: fixed;
  inset: 0;
  background: rgba(120,40,70,.45);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  transition: opacity .3s;
}
#overlay.hidden { opacity: 0; pointer-events: none; }

#dialog {
  background: linear-gradient(180deg, #fff6ea, var(--cream));
  border-radius: 28px;
  padding: 34px 44px 30px;
  text-align: center;
  box-shadow: inset 0 -6px 0 var(--cream-deep), 0 20px 50px rgba(100,30,55,.5);
  animation: drop-in .45s cubic-bezier(.34, 1.4, .64, 1);
}
@keyframes drop-in { from { translate: 0 -60px; scale: .8; opacity: 0; } }

#dialog-stars { display: flex; justify-content: center; gap: 10px; margin-bottom: 10px; }
.dstar {
  width: 44px; height: 44px;
  background: #d9c8a8;
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}
.dstar.lit { background: var(--gold); animation: star-pop .4s ease backwards; }
.dstar.lit:nth-child(2) { animation-delay: .15s; }
.dstar.lit:nth-child(3) { animation-delay: .3s; }
@keyframes star-pop { from { scale: 0; rotate: -90deg; } 70% { scale: 1.3; } }

#dialog h2 { color: var(--rose-deep); font-size: 30px; letter-spacing: 1px; }
#dialog p { color: #a8806b; font-size: 16px; font-weight: 700; margin: 6px 0 18px; }

#dialog-btn {
  border: none;
  font-family: var(--font);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #fff;
  background: linear-gradient(180deg, var(--rose), var(--rose-deep));
  padding: 12px 34px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.35), inset 0 -4px 0 rgba(0,0,0,.18), 0 6px 14px rgba(150,50,80,.4);
  transition: transform .12s;
}
#dialog-btn:active { transform: scale(.94); }
#dialog-btn.green {
  background: linear-gradient(180deg, #8cd45f, #5fae3a);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.35), inset 0 -4px 0 rgba(0,0,0,.18), 0 6px 14px rgba(95,174,58,.4);
}

/* ===== responsive (phone portrait like the video) ===== */
@media (max-width: 860px) {
  :root { --cell-size: min(13.5vw, 56px); --gap: 5px; }
  body { overflow-y: auto; }
  #stage { flex-direction: column; gap: 14px; padding: 12px 8px 24px; }
  #panel { width: min(94vw, 460px); flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 8px 14px; padding: 12px; border-radius: 20px; }
  #logo { width: 90px; min-height: 40px; }
  #logo.logo-css .logo-line1 { font-size: 20px; }
  #logo.logo-css .logo-line2 { font-size: 24px; }
  #banner { margin: 0; align-self: center; }
  #card { width: 100%; flex-direction: row; align-items: center; justify-content: space-around; padding: 8px 10px; gap: 4px; }
  #card .stat { align-items: center; }
  .big-num { font-size: 24px; }
  .mid-num { font-size: 20px; }
  #goal { font-size: 22px; }
  #goal-icon { width: 26px; height: 26px; }
  #progress { position: absolute; left: -9999px; }
  #tools { margin-top: 0; }
  #mute { margin-top: 0; }
}
