:root {
  --orange: #FF8A3D;
  --orange-deep: #F26E28;
  --peach: #FFC89A;
  --cream: #FFF7EC;
  --cream-deep: #FFEDDA;
  --ink: #4A2B1E;
  --ink-2: #6E4A38;
  --ink-3: #997764;
  --mint: #7FC7B4;
  --pink: #FF8B98;
  --glass: rgba(255, 251, 245, 0.82);
  --glass-line: rgba(255, 255, 255, 0.92);
  --shadow-soft: 0 10px 28px rgba(141, 76, 38, 0.13), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  --ease-pop: cubic-bezier(0.22, 1.1, 0.34, 1.18);
}

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

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: radial-gradient(circle at 50% 18%, #F7E7D4 0%, #E8CFB5 62%, #DFC1A4 100%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  position: fixed;
  inset: 0;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.stage {
  position: absolute;
  top: 0;
  left: 50%;
  width: 100%;
  max-width: 520px;
  height: 100vh;
  height: 100dvh;
  transform: translateX(-50%);
  overflow: hidden;
  background: #FFF0DE;
  box-shadow: 0 0 90px rgba(91, 48, 26, 0.18);
}

#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  touch-action: none;
}

.grain {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.045;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='150' height='150'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.72' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
  background-size: 150px 150px;
}

.glow-edge {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(125% 75% at 50% 0%, transparent 52%, rgba(103, 54, 28, 0.085) 100%);
}

.flash {
  position: absolute;
  inset: 0;
  z-index: 12;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 50% 55%, rgba(255, 120, 94, 0.15), rgba(255, 86, 72, 0.55));
  transition: opacity 0.28s ease;
}
.flash.on { opacity: 1; transition-duration: 0.06s; }

.hidden {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* ---------- Home ---------- */
.home {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px calc(env(safe-area-inset-bottom, 0px) + 13px);
  pointer-events: none;
  transition: opacity 0.38s ease, transform 0.38s ease;
}
.home.hidden { transform: translateY(-10px) scale(0.99); }

.home-top {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}

.player-chip {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 5px 15px 5px 6px;
  border-radius: 999px;
  background: rgba(255, 252, 247, 0.58);
  border: 1px solid rgba(255, 255, 255, 0.86);
  box-shadow: 0 8px 22px rgba(115, 68, 37, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px) saturate(1.12);
  -webkit-backdrop-filter: blur(16px) saturate(1.12);
  text-align: left;
  transition: transform 0.16s var(--ease-pop);
}
.player-chip:active { transform: scale(0.97); }

.avatar {
  position: relative;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 50%;
  overflow: hidden;
  background: radial-gradient(circle at 33% 25%, #FFD9AC 0%, #FFAA62 43%, #F27B31 78%, #D96020 100%);
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: inset -4px -6px 10px rgba(158, 63, 12, 0.25), 0 4px 10px rgba(180, 90, 32, 0.24);
}
.avatar::before {
  content: "";
  position: absolute;
  left: 20%;
  top: 17%;
  width: 34%;
  height: 23%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.58);
  transform: rotate(-28deg);
  filter: blur(0.5px);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-fruit { position: absolute; inset: 0; }
.avatar-fruit::before, .avatar-fruit::after {
  content: "";
  position: absolute;
  top: 20px;
  width: 3px;
  height: 3.5px;
  border-radius: 50%;
  background: #7B3A1B;
  opacity: 0.75;
}
.avatar-fruit::before { left: 12px; }
.avatar-fruit::after { right: 12px; }
.avatar-leaf {
  position: absolute;
  right: 6px;
  top: 1px;
  width: 14px;
  height: 9px;
  border-radius: 100% 0 100% 0;
  background: linear-gradient(135deg, #A7D98A, #5E9E58);
  transform: rotate(-18deg);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.5);
}

.player-meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.player-hello { font-size: 9px; letter-spacing: 0.1em; color: var(--ink-3); font-weight: 600; }
.player-meta strong {
  max-width: 136px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  line-height: 1.2;
  font-weight: 800;
  color: var(--ink);
}

.round-btn {
  pointer-events: auto;
  position: relative;
  width: 46px;
  height: 46px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #7A533F;
  background: rgba(255, 252, 247, 0.66);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 20px rgba(115, 68, 37, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: transform 0.15s var(--ease-pop), background 0.2s;
}
.round-btn:active { transform: scale(0.92); }
.round-btn .mp-icon { width: 23px; height: 23px; }

.hero {
  position: relative;
  flex: 1 1 auto;
  min-height: 176px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.logo-wrap {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding-bottom: clamp(46px, 9vh, 92px);
  animation: logoIn 0.8s var(--ease-pop) both;
}

.logo-kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 9px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: 0.21em;
  color: rgba(103, 67, 46, 0.6);
  margin-bottom: 11px;
  text-transform: uppercase;
}
.logo-kicker .k-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #FF9A55;
  box-shadow: 0 0 0 3px rgba(255, 154, 85, 0.16);
}

.logo {
  position: relative;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.01em;
  margin: 0;
  font-size: clamp(48px, 13.4vw, 64px);
  line-height: 0.96;
  font-weight: 900;
  letter-spacing: -0.055em;
  transform: rotate(-1.4deg);
  filter: drop-shadow(0 14px 20px rgba(163, 81, 34, 0.18));
}
.logo-top {
  color: #F27845;
  -webkit-text-stroke: 3px #FFF9F0;
  paint-order: stroke fill;
}
.logo-main {
  color: #4A2B1E;
  -webkit-text-stroke: 3px #FFF9F0;
  paint-order: stroke fill;
  margin-left: -0.02em;
}
.logo::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -9px;
  width: 58%;
  height: 9px;
  transform: translateX(-50%) rotate(-1deg);
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(226, 113, 51, 0.18), transparent 70%);
}

.tagline {
  margin: 19px 0 0;
  padding: 6px 14px;
  font-size: 12px;
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: 0.045em;
  color: #8A6552;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.38);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 4px 12px rgba(139, 77, 41, 0.06);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.hero-spark {
  position: absolute;
  width: 13px;
  height: 13px;
  z-index: 1;
  background: #FFFDF6;
  clip-path: polygon(50% 0, 59% 41%, 100% 50%, 59% 59%, 50% 100%, 41% 59%, 0 50%, 41% 41%);
  filter: drop-shadow(0 0 7px rgba(255, 221, 152, 0.9));
  animation: twinkle 3.4s ease-in-out infinite;
  opacity: 0.9;
}
.hero-spark.s1 { left: 12%; top: 23%; animation-delay: -0.6s; transform: scale(0.8) rotate(12deg); }
.hero-spark.s2 { right: 13%; top: 30%; animation-delay: -1.7s; transform: scale(1.05) rotate(-16deg); }
.hero-spark.s3 { left: 26%; bottom: 20%; width: 9px; height: 9px; animation-delay: -2.5s; }

.start-panel {
  pointer-events: auto;
  position: relative;
  flex: none;
  padding: 15px 15px 13px;
  border-radius: 30px;
  background: linear-gradient(158deg, rgba(255, 253, 248, 0.93) 0%, rgba(255, 246, 235, 0.9) 100%);
  border: 1px solid rgba(255, 255, 255, 0.94);
  box-shadow: 0 22px 54px rgba(141, 74, 34, 0.17), 0 3px 10px rgba(141, 74, 34, 0.06), inset 0 1px 0 #FFFFFF;
  backdrop-filter: blur(20px) saturate(1.08);
  -webkit-backdrop-filter: blur(20px) saturate(1.08);
  animation: panelIn 0.72s 0.08s var(--ease-pop) both;
}

.best-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 2px 2px;
}
.best-copy {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ink-3);
}
.best-medal {
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  border-radius: 8px;
  color: #E7932D;
  background: linear-gradient(150deg, #FFF3D4, #FFE1A7);
  box-shadow: inset 0 1px 0 #FFFCF1, 0 3px 7px rgba(210, 139, 35, 0.16);
}
.best-medal .mp-icon { width: 15px; height: 15px; }
.best-line > strong {
  font-size: 22px;
  line-height: 1;
  font-weight: 900;
  color: var(--ink);
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
}

.mode-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin: 12px 0;
}

.mode-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 58px;
  padding: 8px 4px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(205, 168, 146, 0.24);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  color: #7A5644;
  transition: transform 0.18s var(--ease-pop), background 0.2s, box-shadow 0.2s, color 0.2s;
}
.mode-btn:active { transform: scale(0.95); }
.mode-icon {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border-radius: 9px;
  flex: none;
  background: rgba(230, 197, 174, 0.25);
  color: #A1745B;
  transition: background 0.2s, color 0.2s;
}
.mode-icon .mp-icon { width: 16px; height: 16px; }
.mode-text { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; }
.mode-text b { font-size: 13.5px; font-weight: 800; line-height: 1.1; white-space: nowrap; }
.mode-text small { font-size: 9px; font-weight: 600; opacity: 0.62; white-space: nowrap; }
.mode-btn.active {
  color: #FFFFFF;
  border-color: transparent;
  background: linear-gradient(140deg, #FFA45D 0%, #FF8A3D 48%, #F87428 100%);
  box-shadow: 0 10px 22px rgba(241, 113, 39, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transform: translateY(-1px);
}
.mode-btn.active .mode-icon {
  background: rgba(255, 255, 255, 0.24);
  color: #FFFFFF;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.mode-btn.active .mode-text small { opacity: 0.86; }

.play-btn {
  position: relative;
  width: 100%;
  min-height: 60px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 15px;
  border-radius: 21px;
  overflow: hidden;
  color: #FFFFFF;
  background: linear-gradient(135deg, #FFA45A 0%, #FF8A3D 46%, #F57529 100%);
  box-shadow: 0 14px 28px rgba(241, 111, 36, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.38), inset 0 -2px 0 rgba(173, 68, 12, 0.14);
  transition: transform 0.16s var(--ease-pop), box-shadow 0.16s;
}
.play-btn:active { transform: scale(0.975); box-shadow: 0 8px 18px rgba(241, 111, 36, 0.3), inset 0 2px 6px rgba(160, 63, 10, 0.18); }
.play-left {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.play-left .mp-icon { width: 21px; height: 21px; }
.play-copy { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; flex: 1; }
.play-copy b { font-size: 17px; font-weight: 800; letter-spacing: 0.02em; line-height: 1.1; }
.play-copy small {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
  font-weight: 600;
  opacity: 0.82;
}
.play-arrow { width: 21px; height: 21px; flex: none; opacity: 0.9; }
.play-shine {
  position: absolute;
  top: -30%;
  left: -36%;
  width: 26%;
  height: 170%;
  transform: rotate(22deg);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.34), transparent);
  animation: shine 4.4s ease-in-out infinite;
  pointer-events: none;
}

.home-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin: 10px 0 0;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #A3836F;
}
.home-hint .mp-icon { width: 13px; height: 13px; color: #FF9A52; }

/* ---------- HUD ---------- */
.hud {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  transition: opacity 0.28s ease;
}
.hud-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 0;
}
.glass {
  background: var(--glass);
  border: 1px solid var(--glass-line);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(16px) saturate(1.12);
  -webkit-backdrop-filter: blur(16px) saturate(1.12);
}
.score-card {
  min-width: 130px;
  padding: 9px 15px 10px;
  border-radius: 22px;
  transition: transform 0.14s var(--ease-pop);
}
.score-card.bump { transform: scale(1.055); }
.score-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--ink-3);
}
.score-top #hudMode { color: #F1813B; }
.score-label { opacity: 0.68; }
#scoreText {
  display: block;
  margin-top: 2px;
  font-size: 31px;
  line-height: 1.05;
  font-weight: 900;
  letter-spacing: -0.045em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
}
.lives { display: flex; align-items: center; gap: 3px; height: 15px; margin-top: 1px; }
.lives .mp-icon { width: 14px; height: 14px; color: #FF7A72; filter: drop-shadow(0 2px 3px rgba(225, 80, 72, 0.24)); }
.lives .mp-icon.empty { color: #D9C4B7; filter: none; opacity: 0.62; }
.lives .mp-icon.pop { animation: heartPop 0.36s var(--ease-pop); }

.hud-right { display: flex; align-items: flex-start; gap: 8px; pointer-events: none; }
.timer-card {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 92px;
  min-height: 46px;
  padding: 7px 11px;
  border-radius: 18px;
}
.timer-card .mp-icon { width: 19px; height: 19px; color: #F1904C; }
.timer-card > div { display: flex; flex-direction: column; gap: 1px; }
.timer-card span { font-size: 8px; font-weight: 700; letter-spacing: 0.08em; color: var(--ink-3); line-height: 1; }
.timer-card strong { font-size: 16px; font-weight: 900; line-height: 1.1; color: var(--ink); font-variant-numeric: tabular-nums; }
.timer-card.hidden, .buff.hidden, .lives.hidden { display: none; }
.timer-card.urgent { border-color: rgba(255, 118, 96, 0.65); box-shadow: 0 0 0 3px rgba(255, 112, 90, 0.1), var(--shadow-soft); animation: urgentPulse 1s ease-in-out infinite; }
.timer-card.urgent .mp-icon, .timer-card.urgent strong { color: #EF6258; }
.pause-btn { pointer-events: auto; }
.pause-btn .mp-icon { color: #EC8744; }

.combo-chip {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 94px);
  left: 16px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 11px 6px 8px;
  border-radius: 999px;
  background: linear-gradient(135deg, #FFA25B, #FF7A3E);
  color: #FFF8F0;
  box-shadow: 0 7px 16px rgba(234, 106, 42, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.32);
  transform-origin: left center;
  transition: opacity 0.2s, transform 0.2s var(--ease-pop);
}
.combo-chip .mp-icon { width: 15px; height: 15px; }
.combo-chip b { font-size: 14px; font-weight: 900; letter-spacing: -0.02em; }
.combo-chip span { font-size: 9px; font-weight: 700; opacity: 0.85; }
.combo-chip.hidden { transform: scale(0.85); }
.combo-chip.pulse { animation: chipPop 0.28s var(--ease-pop); }

.buff-row {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.buff {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px 6px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  color: #6A4A39;
  background: rgba(255, 252, 246, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 7px 18px rgba(126, 70, 33, 0.14);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.buff .mp-icon { width: 14px; height: 14px; }
.buff b { font-variant-numeric: tabular-nums; }
.buff.double { color: #C45F25; background: rgba(255, 244, 225, 0.94); }
.buff.double .mp-icon { color: #F39A2F; }
.buff.freeze { color: #3E7997; background: rgba(237, 250, 255, 0.94); }
.buff.freeze .mp-icon { color: #54A9C9; }

.game-tip {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 64px);
  transform: translateX(-50%);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: #74503D;
  background: rgba(255, 252, 247, 0.9);
  box-shadow: 0 8px 20px rgba(126, 70, 33, 0.13);
  white-space: nowrap;
  transition: opacity 0.3s;
}

/* ---------- Combo / toast ---------- */
.combo-pop {
  position: absolute;
  left: 50%;
  top: 31%;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translate(-50%, -50%) scale(0.7);
  opacity: 0;
  pointer-events: none;
  text-align: center;
  filter: drop-shadow(0 8px 18px rgba(196, 81, 27, 0.26));
}
.combo-pop span {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: #FFF8EC;
  text-shadow: 0 2px 6px rgba(150, 63, 20, 0.5);
}
.combo-pop b {
  display: block;
  margin: -2px 0 -3px;
  font-size: 54px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: -0.04em;
  color: #FFF7E9;
  -webkit-text-stroke: 2px #FF8A3D;
  paint-order: stroke fill;
  text-shadow: 0 6px 0 #E86C2E, 0 12px 20px rgba(173, 65, 17, 0.3);
}
.combo-pop em {
  padding: 3px 9px;
  border-radius: 999px;
  font-style: normal;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: #FFF8ED;
  background: rgba(233, 107, 43, 0.78);
}
.combo-pop.show { animation: comboPop 0.78s cubic-bezier(0.22, 0.9, 0.3, 1) both; }

.toast {
  position: absolute;
  left: 50%;
  top: 17%;
  z-index: 9;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 84%;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: #6F4B37;
  white-space: nowrap;
  background: rgba(255, 252, 247, 0.93);
  border: 1px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 10px 24px rgba(126, 70, 33, 0.16);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  transform: translate(-50%, -7px) scale(0.96);
  transition: opacity 0.22s, transform 0.22s var(--ease-pop);
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.toast .mp-icon { width: 15px; height: 15px; color: #F28C45; flex: none; }

/* ---------- Overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 18px calc(24px + env(safe-area-inset-bottom, 0px));
  background: rgba(67, 37, 24, 0.3);
  backdrop-filter: blur(10px) saturate(0.94);
  -webkit-backdrop-filter: blur(10px) saturate(0.94);
  transition: opacity 0.28s ease, visibility 0.28s;
}

.dialog {
  width: 100%;
  max-width: 352px;
  max-height: 100%;
  overflow: auto;
  padding: 24px 21px 20px;
  border-radius: 32px;
  background: linear-gradient(164deg, #FFFDF9 0%, #FFF6EA 56%, #FFEDDD 100%);
  border: 1px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 34px 70px rgba(71, 34, 17, 0.3), inset 0 1px 0 #FFFFFF;
  text-align: center;
  animation: dialogIn 0.4s cubic-bezier(0.22, 1.08, 0.32, 1.16) both;
  scrollbar-width: none;
}
.dialog::-webkit-scrollbar { display: none; }

.dialog-badge {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin: 0 auto 12px;
  border-radius: 20px;
  color: #FFFFFF;
  background: linear-gradient(145deg, #FFA75F, #FF853A 56%, #F47328);
  box-shadow: 0 12px 24px rgba(242, 114, 39, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transform: rotate(-4deg);
}
.dialog-badge .mp-icon { width: 27px; height: 27px; }

.dialog h2 {
  margin: 0;
  font-size: 25px;
  line-height: 1.2;
  font-weight: 900;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.dialog-sub {
  margin: 6px 0 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-3);
}

.mini-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 0 16px;
}
.mini-stats > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 8px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(218, 185, 163, 0.3);
}
.mini-stats span { font-size: 9px; font-weight: 700; letter-spacing: 0.05em; color: var(--ink-3); }
.mini-stats b { font-size: 21px; font-weight: 900; line-height: 1.1; color: var(--ink); font-variant-numeric: tabular-nums; }

.btn-primary {
  width: 100%;
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border-radius: 18px;
  color: #FFFFFF;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.02em;
  background: linear-gradient(135deg, #FFA45A 0%, #FF8A3D 46%, #F57529 100%);
  box-shadow: 0 13px 26px rgba(241, 111, 36, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.36);
  transition: transform 0.15s var(--ease-pop);
}
.btn-primary .mp-icon { width: 21px; height: 21px; }
.btn-primary:active { transform: scale(0.97); }

.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 9px; }
.btn-ghost {
  min-height: 47px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 10px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 700;
  color: #7C5947;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(211, 176, 154, 0.36);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
  transition: transform 0.15s var(--ease-pop);
}
.btn-ghost .mp-icon { width: 18px; height: 18px; opacity: 0.78; }
.btn-ghost:active { transform: scale(0.97); }
.btn-ghost.wide { width: 100%; margin-top: 9px; }

.sound-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 44px;
  margin-top: 7px;
  padding: 6px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-3);
}
.sound-row .mp-icon { width: 16px; height: 16px; }
.sound-row:active { background: rgba(255, 255, 255, 0.5); }

/* ---------- Game over ---------- */
.stars { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 13px; }
.star-wrap {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.64);
  border: 1px solid rgba(220, 190, 171, 0.4);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}
.star-wrap .mp-icon { width: 29px; height: 29px; color: #DCC8B9; }
.star-wrap.on {
  background: linear-gradient(145deg, #FFFDF4, #FFEDBD 62%, #FFDD8E);
  border-color: rgba(255, 241, 195, 0.95);
  box-shadow: 0 9px 20px rgba(238, 169, 47, 0.22), inset 0 1px 0 #FFFEFA;
  animation: starPop 0.46s var(--ease-pop) both;
}
.star-wrap.on .mp-icon { color: #EFA023; filter: drop-shadow(0 2px 3px rgba(199, 121, 17, 0.26)); }
.star-wrap:nth-child(2) { margin-top: -5px; width: 52px; height: 52px; }
.star-wrap:nth-child(2) .mp-icon { width: 33px; height: 33px; }

.over-kicker {
  margin: 0 0 3px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: #B18B74;
}
.over-dialog h2 { font-size: 24px; }

.final-score {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  margin: 13px 0;
  padding: 13px 12px 11px;
  border-radius: 22px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.85), rgba(255, 240, 224, 0.78));
  border: 1px solid rgba(255, 255, 255, 0.95);
  box-shadow: inset 0 1px 0 #FFFFFF, 0 7px 18px rgba(150, 85, 45, 0.07);
}
.final-score > span { font-size: 9px; font-weight: 800; letter-spacing: 0.14em; color: var(--ink-3); }
.final-score > strong {
  font-size: 45px;
  line-height: 1.05;
  font-weight: 900;
  letter-spacing: -0.05em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.75);
}
.new-best {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 4px 8px;
  border-radius: 999px;
  font-style: normal;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.06em;
  color: #FFFFFF;
  background: linear-gradient(135deg, #FFA255, #FF7A30);
  box-shadow: 0 4px 10px rgba(241, 111, 36, 0.28);
  animation: bestPop 0.5s 0.18s var(--ease-pop) both;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 0 0 15px;
  padding: 10px 0;
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.48);
  border: 1px solid rgba(219, 186, 164, 0.24);
}
.result-stats > div { display: flex; flex-direction: column; gap: 3px; position: relative; }
.result-stats > div + div::before {
  content: "";
  position: absolute;
  left: 0;
  top: 14%;
  width: 1px;
  height: 72%;
  background: rgba(190, 155, 132, 0.24);
}
.result-stats span { font-size: 8.5px; font-weight: 700; letter-spacing: 0.03em; color: var(--ink-3); }
.result-stats b { font-size: 18px; font-weight: 900; line-height: 1.1; color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------- Animations ---------- */
@keyframes logoIn {
  from { opacity: 0; transform: translateY(14px) scale(0.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes panelIn {
  from { opacity: 0; transform: translateY(22px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes shine {
  0%, 62% { left: -36%; opacity: 0; }
  70% { opacity: 1; }
  88% { left: 118%; opacity: 0.7; }
  100% { left: 118%; opacity: 0; }
}
@keyframes twinkle {
  0%, 100% { opacity: 0.32; }
  50% { opacity: 0.98; }
}
@keyframes comboPop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.58) rotate(-4deg); }
  16% { opacity: 1; transform: translate(-50%, -50%) scale(1.12) rotate(1deg); }
  28% { transform: translate(-50%, -50%) scale(0.98) rotate(0deg); }
  68% { opacity: 1; transform: translate(-50%, -54%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -66%) scale(0.94); }
}
@keyframes chipPop {
  0% { transform: scale(0.82); }
  60% { transform: scale(1.08); }
  100% { transform: scale(1); }
}
@keyframes heartPop {
  0% { transform: scale(0.6); }
  55% { transform: scale(1.22); }
  100% { transform: scale(1); }
}
@keyframes urgentPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.035); }
}
@keyframes dialogIn {
  from { opacity: 0; transform: translateY(18px) scale(0.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes starPop {
  0% { opacity: 0; transform: scale(0.4) rotate(-18deg); }
  65% { opacity: 1; transform: scale(1.14) rotate(3deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}
@keyframes bestPop {
  0% { opacity: 0; transform: scale(0.5) rotate(8deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

/* ---------- Small screens ---------- */
@media (max-height: 720px) {
  .logo { font-size: clamp(42px, 12.3vw, 54px); }
  .logo-wrap { padding-bottom: clamp(30px, 6vh, 60px); }
  .tagline { margin-top: 14px; font-size: 11px; }
  .home { padding-top: calc(env(safe-area-inset-top, 0px) + 9px); padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 10px); }
  .start-panel { padding: 12px 13px 11px; border-radius: 27px; }
  .mode-row { margin: 9px 0; }
  .mode-btn { min-height: 52px; }
  .play-btn { min-height: 55px; }
  .home-hint { margin-top: 7px; }
  .home-hint { font-size: 9.5px; }
  .dialog { padding: 20px 18px 17px; }
  .final-score > strong { font-size: 39px; }
  .stars { margin-bottom: 10px; }
  .star-wrap { width: 43px; height: 43px; }
  .star-wrap:nth-child(2) { width: 47px; height: 47px; }
}

@media (max-height: 620px) {
  .logo-kicker { display: none; }
  .tagline { display: none; }
  .logo-wrap { padding-bottom: 28px; }
  .home-hint { display: none; }
  .best-line { padding-bottom: 0; }
  .mode-btn { min-height: 47px; }
  .play-btn { min-height: 52px; }
  .hero { min-height: 120px; }
  .dialog { max-width: 330px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@media (hover: hover) and (pointer: fine) {
  .mode-btn:hover:not(.active) { background: rgba(255, 255, 255, 0.86); box-shadow: inset 0 1px 0 #FFFFFF, 0 6px 14px rgba(141, 76, 38, 0.08); }
  .play-btn:hover { box-shadow: 0 18px 32px rgba(241, 111, 36, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.38); }
  .round-btn:hover, .btn-ghost:hover { background: rgba(255, 255, 255, 0.86); }
  .player-chip:hover { background: rgba(255, 252, 247, 0.78); }
  .btn-primary:hover { filter: brightness(1.03); }
}
