:root {
  --bg: #05060a;
  --panel: rgba(14, 16, 24, 0.92);
  --ink: #e8ecf4;
  --muted: #8b93a7;
  --line: rgba(255, 140, 60, 0.18);
  --primary: #ff6b2c;
  --primary-dark: #e04f12;
  --green: #34d399;
  --warning: #f59e0b;
  --cell: #1a1511;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 50% -10%, rgba(255, 90, 20, 0.16), transparent 42%),
    radial-gradient(circle at 85% 20%, rgba(120, 40, 255, 0.10), transparent 28rem),
    radial-gradient(circle at 10% 80%, rgba(255, 60, 0, 0.08), transparent 24rem),
    linear-gradient(180deg, #0a0b10 0%, #05060a 45%, #030308 100%);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

button, textarea { font: inherit; }
button { cursor: pointer; }

.app {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 12px;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.music-toggle {
  position: relative;
  display: inline-flex;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: #ffd2a8;
  border: 1px solid rgba(255, 140, 60, 0.38);
  border-radius: 50%;
  background: rgba(18, 12, 8, 0.88);
  box-shadow: 0 0 12px rgba(255, 90, 20, 0.18);
  transition: color .2s, border-color .2s, box-shadow .2s, background .2s;
}

.music-toggle:hover {
  border-color: rgba(255, 170, 90, 0.7);
  background: rgba(40, 22, 12, 0.95);
  box-shadow: 0 0 16px rgba(255, 90, 20, 0.32);
}

.music-toggle[aria-pressed="true"] {
  animation: music-pulse 2.6s ease-in-out infinite;
}

.music-toggle.is-off {
  color: #6b7280;
  border-color: rgba(107, 114, 128, 0.35);
  box-shadow: none;
  animation: none;
}

.music-toggle svg {
  display: block;
  width: 18px;
  height: 18px;
}

.music-slash {
  position: absolute;
  display: none;
  pointer-events: none;
}

.music-toggle.is-off .music-slash {
  display: block;
}

@keyframes music-pulse {
  0%, 100% { box-shadow: 0 0 10px rgba(255, 90, 20, 0.2); }
  50% { box-shadow: 0 0 18px rgba(255, 140, 40, 0.48); }
}

@media (prefers-reduced-motion: reduce) {
  .music-toggle[aria-pressed="true"] { animation: none; }
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: #fff;
  border-radius: 13px;
  background: linear-gradient(145deg, #ff8a3d, #c2410c);
  box-shadow: 0 0 22px rgba(255, 90, 20, 0.35);
  font-size: 1.25rem;
  font-weight: 800;
}

h1 {
  margin: 0;
  font-size: clamp(1.25rem, 3vw, 1.65rem);
  letter-spacing: -0.03em;
  color: #f3f4f8;
  text-shadow: 0 0 24px rgba(255, 120, 40, 0.25);
}

.subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.level-stars,
.goal-stars {
  display: inline-block;
  color: #fbbf24;
  letter-spacing: 0.12em;
  text-shadow: 0 0 10px rgba(251, 191, 36, 0.35);
  vertical-align: 0.05em;
}

.level-stars {
  margin-left: 0.45em;
  font-size: 0.92em;
}

.goal-stars {
  margin-right: 0.35em;
  font-size: 1.05em;
}

.lore {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid rgba(255, 140, 60, 0.18);
  border-radius: 14px;
  background:
    linear-gradient(120deg, rgba(255, 90, 20, 0.08), rgba(14, 16, 24, 0.4) 40%, rgba(88, 28, 135, 0.1));
  box-shadow: inset 0 1px 0 rgba(255, 180, 100, 0.08);
}

.lore p {
  margin: 0;
  color: #c9b8a4;
  font-size: 0.86rem;
  line-height: 1.7;
}

.lore strong {
  color: #fbbf24;
  font-weight: 750;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 20px;
  background:
    linear-gradient(160deg, rgba(24, 18, 14, 0.95), rgba(10, 11, 16, 0.96));
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 180, 100, 0.06);
}

.stage-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 480px;
  padding: 14px 16px 18px;
  overflow: hidden;
  flex: 1 1 auto;
}

.stage-panel::before {
  content: "";
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(circle at 50% 30%, rgba(255, 80, 0, 0.08), transparent 40%),
    radial-gradient(circle at 70% 80%, rgba(88, 28, 135, 0.12), transparent 35%);
  pointer-events: none;
}

.stage-head {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px 12px;
  margin-bottom: 10px;
  flex: 0 0 auto;
}

.stage-title {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #ffb070;
  font-size: 0.9rem;
  font-weight: 700;
}

.hud {
  display: flex;
  flex-wrap: wrap;
  flex: 1 1 200px;
  justify-content: flex-end;
  gap: 6px;
  pointer-events: none;
}

.hud .chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  color: #c9b8a4;
  border: 1px solid rgba(255, 140, 60, 0.22);
  border-radius: 999px;
  background: rgba(8, 8, 12, 0.88);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.74rem;
  white-space: nowrap;
}

.hud .chip i { font-style: normal; }
.hud .chip.on { color: #7dd3fc; border-color: rgba(125, 211, 252, 0.45); }
.hud .chip.warn { color: #fca5a5; border-color: rgba(252, 165, 165, 0.45); }
.hud .chip.done { color: #86efac; border-color: rgba(134, 239, 172, 0.4); }

.stage-status {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  margin: 10px 0 0;
  padding: 0;
  color: #ffe08a;
  background: none;
  border: 0;
  box-shadow: none;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.45;
  text-align: center;
  text-shadow: 0 0 14px rgba(255, 196, 60, 0.55);
}

.stage-status[data-tone="run"] {
  color: #7dd3fc;
  text-shadow: 0 0 14px rgba(56, 189, 248, 0.55);
}

.stage-status[data-tone="ok"] {
  color: #86efac;
  text-shadow: 0 0 14px rgba(74, 222, 128, 0.55);
}

.stage-status[data-tone="bad"] {
  color: #fda4af;
  text-shadow: 0 0 14px rgba(251, 113, 133, 0.55);
}

.grid-wrap {
  position: relative;
  --cell: 40px;
  --gap: 3px;
  width: min(100%, calc(var(--cols, 10) * var(--cell) + (var(--cols, 10) - 1) * var(--gap) + 32px));
  height: auto;
  margin: auto;
  padding: 10px;
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 120%, rgba(255, 80, 0, 0.28), transparent 55%),
    radial-gradient(circle at 50% -10%, rgba(255, 160, 0, 0.2), transparent 45%),
    #0a0604;
  box-shadow:
    0 0 0 1px rgba(255, 140, 40, 0.28),
    0 0 28px rgba(255, 90, 0, 0.28),
    inset 0 0 18px rgba(255, 60, 0, 0.12);
  overflow: visible;
}

.game-grid {
  position: relative;
  z-index: 2;
  display: grid;
  width: 100%;
  height: auto;
  grid-template-columns: repeat(var(--cols, 10), minmax(0, 1fr));
  grid-auto-rows: auto;
  gap: var(--gap, 3px);
  padding: 4px;
  border: 2px solid #5b4634;
  border-radius: 10px;
  background: #5b4634;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.cell {
  position: relative;
  aspect-ratio: 1;
  width: 100%;
  height: auto;
  border-radius: 4px;
  overflow: hidden;
}

.cell.path {
  background: #fff8ee;
  box-shadow:
    inset 0 0 0 1.5px #c4a882,
    inset 0 -2px 0 rgba(120, 80, 40, 0.08);
}

.cell.wall {
  background: radial-gradient(circle at 50% 85%, #4a1800 0%, #1a0800 70%);
  box-shadow: inset 0 0 0 1.5px #8a3a10;
}

.cell.wall .flame {
  position: absolute;
  bottom: -10%;
  left: 50%;
  width: 55%;
  height: 95%;
  border-radius: 45% 45% 20% 20%;
  transform: translateX(-50%);
  transform-origin: center bottom;
  background: radial-gradient(circle at 50% 75%, #fff8c0 0%, #ffcf4d 22%, #ff7a1a 48%, #e12a00 72%, transparent 86%);
  filter: blur(0.3px);
  animation: wall-flame var(--dur, 0.7s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
  opacity: 0.92;
  pointer-events: none;
}

.cell.wall .flame:nth-child(1) {
  width: 42%;
  left: 32%;
  height: 80%;
  --dur: 0.62s;
}

.cell.wall .flame:nth-child(2) {
  width: 58%;
  left: 50%;
  height: 100%;
  --dur: 0.78s;
  --delay: 0.12s;
}

.cell.wall .flame:nth-child(3) {
  width: 38%;
  left: 68%;
  height: 72%;
  --dur: 0.55s;
  --delay: 0.22s;
}

.cell.wall::after {
  content: "";
  position: absolute;
  inset: auto 18% 0;
  height: 28%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 180, 60, 0.55), transparent 70%);
  filter: blur(3px);
  animation: ember-glow 1.1s ease-in-out infinite alternate;
  pointer-events: none;
}

.cell.start {
  background: #d8f5e7;
  box-shadow: inset 0 0 0 2.5px #19a974;
}

.cell.goal {
  background: #fff8ee;
  box-shadow: inset 0 0 0 2.5px #e11d48;
  display: grid;
  place-items: center;
}

.cell.goal .goal-flag {
  width: 70%;
  height: 70%;
  overflow: visible;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
  animation: flag-wave 1.4s ease-in-out infinite;
  transform-origin: 18% 90%;
}

@keyframes flag-wave {
  0%, 100% { transform: rotate(-4deg); }
  50% { transform: rotate(5deg); }
}

.cell.active {
  background: #e8e4ff;
  box-shadow: inset 0 0 0 2.5px #635bff;
}

.cell.wall.active {
  background: radial-gradient(circle at 50% 85%, #5a1a00 0%, #1a0800 70%);
  box-shadow: inset 0 0 0 2.5px #ff7a1a;
}

@keyframes tongue-flicker {
  0%, 100% {
    transform: scaleY(1) scaleX(1) translateY(0);
    opacity: 0.85;
    filter: hue-rotate(0deg) brightness(1);
  }
  30% {
    transform: scaleY(1.25) scaleX(0.88) translateY(-2px);
    opacity: 1;
    filter: hue-rotate(-8deg) brightness(1.15);
  }
  55% {
    transform: scaleY(0.9) scaleX(1.08) translateY(1px);
    opacity: 0.75;
    filter: hue-rotate(10deg) brightness(0.95);
  }
  80% {
    transform: scaleY(1.18) scaleX(0.94) translateY(-1px);
    opacity: 0.95;
  }
}

@keyframes wall-flame {
  0%, 100% {
    transform: translateX(-50%) scaleY(1) scaleX(1) rotate(0deg);
    opacity: 0.88;
    filter: brightness(1);
  }
  25% {
    transform: translateX(-50%) scaleY(1.2) scaleX(0.86) rotate(-4deg);
    opacity: 1;
    filter: brightness(1.2);
  }
  50% {
    transform: translateX(-50%) scaleY(0.92) scaleX(1.1) rotate(3deg);
    opacity: 0.8;
    filter: brightness(0.95);
  }
  75% {
    transform: translateX(-50%) scaleY(1.15) scaleX(0.9) rotate(-2deg);
    opacity: 0.95;
    filter: brightness(1.1);
  }
}

@keyframes ember-glow {
  from { opacity: 0.45; transform: scale(0.9); }
  to { opacity: 0.9; transform: scale(1.15); }
}

.hero {
  position: absolute;
  z-index: 3;
  display: grid;
  place-items: center;
  grid-template-columns: 100%;
  grid-template-rows: 100%;
  width: 40px;
  height: 40px;
  background: transparent;
  border: 0;
  box-shadow: none;
  transform: translate(0, 0);
  transition: left .36s cubic-bezier(.2,.9,.3,1.2), top .36s cubic-bezier(.2,.9,.3,1.2);
  pointer-events: none;
  transform-origin: center bottom;
}

.hero svg {
  width: 138%;
  height: 138%;
  overflow: visible;
  position: relative;
  top: -22%;
  transform-origin: center bottom;
  filter:
    drop-shadow(0 0 1px #fff7ed)
    drop-shadow(0 0 6px rgba(255, 247, 237, 0.7))
    drop-shadow(0 3px 4px rgba(0, 0, 0, 0.4));
}

.hero .hero-burned { display: none; }
.hero .hero-normal { display: block; }

.hero.dead .hero-normal { display: none; }
.hero.dead .hero-burned { display: block; }

.hero.dead {
  animation: hero-burn 0.95s cubic-bezier(.4, .1, .3, 1) forwards;
}

.hero.won {
  animation: hero-celebrate 0.7s cubic-bezier(.34, 1.4, .64, 1) infinite;
  z-index: 5;
}

.hero.won svg {
  filter: drop-shadow(0 0 14px rgba(251, 191, 36, 1));
}

.hero.on-fire svg {
  filter: drop-shadow(0 0 10px rgba(255, 90, 0, 0.95)) brightness(1.15) saturate(1.2);
  animation: heat-flicker 0.35s ease-in-out infinite alternate;
}

@keyframes heat-flicker {
  from { transform: scale(1); }
  to { transform: scale(1.04); }
}

@keyframes hero-celebrate {
  0% { transform: translateY(0) rotate(0deg) scale(1); }
  15% { transform: translateY(-18px) rotate(-12deg) scale(1.15); }
  30% { transform: translateY(-6px) rotate(14deg) scale(1.08); }
  45% { transform: translateY(-22px) rotate(-8deg) scale(1.18); }
  60% { transform: translateY(-4px) rotate(10deg) scale(1.05); }
  75% { transform: translateY(-16px) rotate(-6deg) scale(1.12); }
  100% { transform: translateY(0) rotate(0deg) scale(1); }
}

.celebrate-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  overflow: hidden;
  border-radius: 18px;
}

.celebrate-layer .bit {
  position: absolute;
  top: 48%;
  left: 50%;
  font-size: var(--size, 1.15rem);
  animation: confetti-fly var(--dur, 1.4s) cubic-bezier(.15, .75, .25, 1) forwards;
  opacity: 0;
  will-change: transform, opacity;
}

.celebrate-layer .strip {
  width: 8px;
  height: 16px;
  border-radius: 2px;
  font-size: 0;
  background: var(--color, #38bdf8);
  box-shadow: 0 0 8px var(--color, #38bdf8);
}

.celebrate-layer .burst {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  font-size: 0;
  background: radial-gradient(circle, #fff 0%, var(--color, #fbbf24) 55%, transparent 70%);
  animation: burst-pop var(--dur, 0.9s) ease-out forwards;
}

.celebrate-layer .bubble {
  top: auto;
  bottom: 28%;
  font-size: 0.85rem;
  font-weight: 800;
  color: #e0f2fe;
  text-shadow: 0 2px 8px rgba(14, 165, 233, 0.8);
  animation: meow-bubble 1.6s ease-out forwards;
}

@keyframes confetti-fly {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.3) rotate(0deg);
  }
  70% { opacity: 1; }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.35) rotate(var(--spin));
  }
}

@keyframes burst-pop {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.2);
  }
  40% {
    opacity: 1;
    transform: translate(calc(-50% + var(--dx) * 0.45), calc(-50% + var(--dy) * 0.45)) scale(1.4);
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.4);
  }
}

@keyframes meow-bubble {
  0% {
    opacity: 0;
    transform: translate(-50%, 20px) scale(0.5);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1.15);
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), -90px) scale(1);
  }
}

.stage-panel.celebrating {
  animation: stage-party 0.55s ease-in-out 3;
}

.stage-panel.celebrating .grid-wrap {
  animation: board-glow 0.8s ease-in-out infinite alternate;
}

.stage-panel.celebrating .goal-flag {
  animation: flag-party 0.35s ease-in-out infinite alternate;
  transform-origin: 18% 90%;
}

.stage-panel.celebrating::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% 30%, rgba(56, 189, 248, 0.18), transparent 28%),
    radial-gradient(circle at 80% 25%, rgba(250, 204, 21, 0.16), transparent 26%),
    radial-gradient(circle at 50% 70%, rgba(244, 114, 182, 0.14), transparent 32%);
  animation: party-wash 1.2s ease-in-out infinite alternate;
}

.stage-panel.celebrating::after {
  content: "🎉 通关啦！喵~";
  position: absolute;
  top: 52px;
  left: 50%;
  z-index: 6;
  transform: translateX(-50%);
  padding: 10px 20px;
  border-radius: 999px;
  color: #fffef8;
  background: linear-gradient(110deg, #38bdf8, #a78bfa, #fb7185, #fbbf24);
  background-size: 220% 220%;
  box-shadow: 0 10px 28px rgba(56, 189, 248, 0.35);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  animation:
    badge-pop 0.55s cubic-bezier(.2, 1.6, .4, 1),
    badge-rainbow 1.4s linear infinite,
    badge-bounce 0.7s ease-in-out infinite;
}

@keyframes badge-pop {
  0% { transform: translateX(-50%) scale(0.2) rotate(-12deg); opacity: 0; }
  100% { transform: translateX(-50%) scale(1) rotate(0deg); opacity: 1; }
}

@keyframes badge-rainbow {
  0% { background-position: 0% 50%; }
  100% { background-position: 100% 50%; }
}

@keyframes badge-bounce {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -5px; }
}

@keyframes stage-party {
  0%, 100% { transform: translateX(0) rotate(0deg); }
  25% { transform: translateX(-3px) rotate(-0.4deg); }
  75% { transform: translateX(3px) rotate(0.4deg); }
}

@keyframes board-glow {
  from { filter: brightness(1); box-shadow: 0 0 0 rgba(56, 189, 248, 0); }
  to { filter: brightness(1.08); box-shadow: 0 0 28px rgba(56, 189, 248, 0.35); }
}

@keyframes flag-party {
  from { transform: rotate(-10deg) scale(1.05); }
  to { transform: rotate(14deg) scale(1.2); }
}

@keyframes party-wash {
  from { opacity: 0.55; }
  to { opacity: 1; }
}

.hero.dead .smoke {
  animation: smoke-rise 0.9s ease-out infinite;
}

.hero.dead .smoke.s2 { animation-delay: 0.12s; }
.hero.dead .smoke.s3 { animation-delay: 0.24s; }

@keyframes hero-burn {
  0% {
    transform: scale(1) rotate(0deg);
    filter: brightness(1);
  }
  15% {
    transform: scale(1.12) rotate(-6deg);
    filter: brightness(1.8) sepia(1) hue-rotate(-20deg);
  }
  35% {
    transform: scale(1.05) rotate(8deg);
    filter: brightness(1.3) sepia(0.8);
  }
  55% {
    transform: scale(0.98) rotate(-4deg);
    filter: brightness(0.7) contrast(1.2);
  }
  100% {
    transform: scale(1) rotate(0deg);
    filter: brightness(0.85) contrast(1.15);
  }
}

@keyframes smoke-rise {
  0% { opacity: 0.2; transform: translateY(4px); }
  50% { opacity: 0.9; }
  100% { opacity: 0; transform: translateY(-10px); }
}

.stage-panel.shake {
  animation: stage-shake 0.45s ease;
}

@keyframes stage-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 4fr) minmax(0, 6fr);
  gap: 16px;
  align-items: stretch;
}

.play-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  min-height: 0;
}

.toolbox-head {
  grid-area: head;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 8px 12px;
  border-top: 1px solid rgba(255, 140, 60, 0.14);
  background: rgba(8, 8, 12, 0.72);
}

.toolbox-head .section-heading {
  margin: 0;
  font-size: 0.88rem;
}

.code-prefs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pref-switch {
  display: inline-flex;
  padding: 3px;
  border: 1px solid rgba(255, 140, 60, 0.28);
  border-radius: 10px;
  background: rgba(8, 8, 12, 0.72);
}

.pref-switch button {
  min-width: 52px;
  height: 30px;
  padding: 0 11px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #9aa3b2;
  font-size: 0.78rem;
  font-weight: 750;
}

.pref-switch button:hover {
  color: #ffd2a8;
}

.pref-switch button[aria-pressed="true"] {
  color: #1a0b04;
  background: #ffc08a;
}

.section-heading {
  margin: 0 0 5px;
  font-size: 1rem;
}

.tool-slot {
  grid-area: tools;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 6px;
  padding: 6px 10px 8px;
  min-height: 0;
  max-height: 28vh;
  overflow: auto;
}

.tool-group {
  overflow: hidden;
  border: 1px solid rgba(255, 140, 60, 0.16);
  border-radius: 10px;
  background: rgba(8, 8, 12, 0.62);
}

.tool-group-toggle {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  color: #ffd2a8;
  border: 0;
  background: transparent;
  font-size: 0.82rem;
  font-weight: 750;
  text-align: left;
}

.tool-group-toggle:hover {
  background: rgba(255, 100, 30, 0.1);
}

.tool-group-label {
  flex: 1;
}

.tool-group-count {
  min-width: 1.4em;
  color: #9aa3b2;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.75rem;
  font-weight: 700;
  text-align: right;
}

.tool-group.open .chevron {
  transform: rotate(180deg);
}

.tool-group-body {
  display: none;
  padding: 0 8px 8px;
}

.tool-group.open .tool-group-body {
  display: grid;
  gap: 6px;
}

.block-chip {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 100%;
  padding: 7px 12px;
  color: #fffef8;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 0.82rem;
  font-weight: 750;
  line-height: 1.2;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.2);
}

.block-chip.is-move,
.block-chip.is-turn,
.block-chip.is-act,
.block-chip.is-loop,
.block-chip.is-logic,
.block-chip.is-var,
.block-chip.is-def {
  border-radius: 8px;
}

.block-chip.is-sensor {
  border-radius: 18px;
}

.block-chip.is-move { background: #d65c1a; }
.block-chip.is-turn { background: #d68a1a; }
.block-chip.is-act { background: #c0392b; }
.block-chip.is-sensor { background: #1aa6b8; }
.block-chip.is-logic { background: #1a6eb8; }
.block-chip.is-loop { background: #27ae60; }
.block-chip.is-var { background: #8e44ad; }
.block-chip.is-def { background: #9b1ac6; }

.block-chip .block-chip {
  box-shadow: none;
}

.block-chip.mini {
  padding: 2px 8px;
  font-size: 0.74rem;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.16);
  vertical-align: middle;
}

.block-slot {
  display: inline-flex;
  min-width: 22px;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 12px;
  background: #fff;
  color: #1a0b04;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.78rem;
  font-weight: 800;
}

.block-how {
  display: block;
  margin: 0 0 8px;
  color: #ffd2a8;
}

.block-ex {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.38);
}

.block-ex-line {
  padding-left: calc(var(--pad, 0) * 18px);
}

.tool {
  overflow: hidden;
  border: 1px solid rgba(255, 140, 60, 0.16);
  border-radius: 12px;
  background: rgba(8, 8, 12, 0.72);
  transition: border-color .2s, box-shadow .2s;
}

.tool:hover, .tool.open {
  border-color: rgba(255, 120, 40, 0.45);
  box-shadow: 0 0 18px rgba(255, 80, 0, 0.12);
}

.tool-button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  color: #ffb070;
  border: 0;
  background: transparent;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.8rem;
  font-weight: 700;
  text-align: left;
}

.tool-button > span:first-child {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  min-width: 0;
}

.tool-button code {
  overflow-wrap: anywhere;
  font-family: inherit;
}

.tool-button .tok-fn { color: #ff9a56; font-weight: 800; }
.tool-button .tok-paren { color: #67e8f9; font-weight: 650; }
.tool-button .tok-arg { color: #8b93a7; font-weight: 500; }

.tool-button em {
  margin-left: 8px;
  color: #9ca3af;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-style: normal;
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.04em;
}

.chevron {
  color: #6b7280;
  transition: transform .2s;
}

.tool.open .chevron { transform: rotate(180deg); }

.tool-description {
  display: none;
  padding: 0 14px 13px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.tool.open .tool-description { display: block; }

.cmd-ex {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 140, 60, 0.16);
}

.cmd-ex-goal {
  margin: 0 0 6px;
  color: #e7d7c3;
}

.cmd-ex-code {
  margin: 0;
  padding: 8px 10px;
  overflow-x: auto;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.38);
  color: #ffc08a;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre;
}

.cmd-ex-code .tok-fn,
.cmd-help-head .tok-fn { color: #ff9a56; font-weight: 800; }
.cmd-ex-code .tok-paren,
.cmd-help-head .tok-paren { color: #67e8f9; font-weight: 650; }
.cmd-ex-code .tok-arg,
.cmd-help-head .tok-arg { color: #9aa3b2; font-weight: 500; }

.editor-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto auto auto auto;
  grid-template-areas:
    "editor"
    "head"
    "tools"
    "toolbar"
    "footer";
  min-width: 0;
  height: 0;
  min-height: 100%;
  overflow: hidden;
}

.editor-panel.is-blocks {
  display: flex;
  flex-direction: column;
}

.editor-panel.is-blocks .toolbox-head,
.editor-panel.is-blocks .tool-slot {
  display: none !important;
}

.editor-toolbar {
  grid-area: toolbar;
  flex-shrink: 0;
  padding: 12px 18px;
  border-top: 1px solid rgba(255, 140, 60, 0.14);
}

.editor-actions-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.editor-mode {
  margin-left: auto;
}

.editor-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.editor-hint kbd {
  padding: 2px 7px;
  color: #ffd2a8;
  border: 1px solid rgba(255, 140, 60, 0.32);
  border-radius: 6px;
  background: rgba(255, 100, 30, 0.18);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.78rem;
  font-weight: 800;
}

.actions {
  display: flex;
  flex-shrink: 0;
  gap: 9px;
}

.action-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 39px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 750;
  transition: transform .15s, background .15s, box-shadow .15s;
}

.action-button:hover:not(:disabled) { transform: translateY(-1px); }
.action-button:disabled { cursor: not-allowed; opacity: .55; }

.run-button {
  color: white;
  background: linear-gradient(145deg, #ff7a3a, #c2410c);
  box-shadow: 0 0 20px rgba(255, 90, 20, 0.35);
}

.run-button:hover:not(:disabled) {
  background: linear-gradient(145deg, #ff8f55, #e04f12);
}

.reset-button {
  color: #ffd2a8;
  border-color: rgba(255, 140, 60, 0.32);
  background: rgba(18, 12, 8, 0.85);
}

.reset-button:hover:not(:disabled) {
  border-color: rgba(255, 160, 80, 0.55);
  background: rgba(40, 22, 12, 0.95);
  box-shadow: 0 0 14px rgba(255, 90, 20, 0.18);
}

.editor-body {
  --ed-pad: 18px;
  --ed-line: 24px;
  --ed-size: 14px;
  grid-area: editor;
  display: grid;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overflow-anchor: none;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: start;
  background: #07080d;
  scrollbar-width: thin;
  scrollbar-color: #ff7a3a #0a0706;
}

.line-numbers {
  padding: var(--ed-pad) 0;
  color: #5b6478;
  border-right: 1px solid #1c2230;
  background: #05060a;
  font: var(--ed-size)/var(--ed-line) "Cascadia Code", Consolas, monospace;
  text-align: center;
  user-select: none;
}

.line-number {
  display: block;
  height: var(--ed-line);
  line-height: var(--ed-line);
}

.line-number.current {
  color: #fff;
  background: rgba(255, 100, 30, .35);
}

.line-number.bad {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.28);
}

.line-number.bad.current {
  color: #fff;
  background: rgba(239, 68, 68, 0.42);
}

#codeEditor {
  display: block;
  width: 100%;
  min-height: 0;
  padding: var(--ed-pad);
  overflow-x: auto;
  overflow-y: hidden;
  resize: none;
  color: #e9edf5;
  border: 0;
  outline: 0;
  background:
    linear-gradient(rgba(255,100,30,.12), rgba(255,100,30,.12)) 0 var(--active-line, -100px) / 100% var(--ed-line) no-repeat,
    #07080d;
  caret-color: #ffb070;
  font: var(--ed-size)/var(--ed-line) "Cascadia Code", Consolas, monospace;
  white-space: pre;
  tab-size: 4;
  scrollbar-width: thin;
  scrollbar-color: #ff7a3a #0a0706;
}

.editor-body::-webkit-scrollbar,
#codeEditor::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}

.editor-body::-webkit-scrollbar-track,
#codeEditor::-webkit-scrollbar-track {
  background:
    linear-gradient(90deg, rgba(255, 90, 20, 0.08), transparent 40%),
    #0a0706;
  box-shadow: inset 1px 0 0 rgba(255, 140, 60, 0.16);
}

#codeEditor::-webkit-scrollbar-track {
  box-shadow: inset 0 1px 0 rgba(255, 140, 60, 0.16);
}

.editor-body::-webkit-scrollbar-thumb,
#codeEditor::-webkit-scrollbar-thumb {
  background:
    linear-gradient(180deg, #ffb070 0%, #ff7a3a 42%, #c2410c 100%);
  border: 2px solid #0a0706;
  border-radius: 999px;
  box-shadow: 0 0 10px rgba(255, 90, 20, 0.45);
}

#codeEditor::-webkit-scrollbar-thumb {
  background: linear-gradient(90deg, #ffb070 0%, #ff7a3a 42%, #c2410c 100%);
}

.editor-body::-webkit-scrollbar-thumb:hover,
#codeEditor::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #ffd2a8 0%, #ff8f55 50%, #e04f12 100%);
  box-shadow: 0 0 14px rgba(255, 140, 40, 0.7);
}

#codeEditor::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(90deg, #ffd2a8 0%, #ff8f55 50%, #e04f12 100%);
}

.editor-body::-webkit-scrollbar-corner,
#codeEditor::-webkit-scrollbar-corner {
  background: #0a0706;
}

.editor-panel.is-blocks .editor-body {
  display: block;
  position: relative;
  overflow: hidden;
}

.editor-panel.is-blocks .line-numbers,
.editor-panel.is-blocks #codeEditor {
  display: none;
}

.blockly-host {
  display: none;
  width: 100%;
  height: 100%;
  min-height: 280px;
  background: #07080d;
}

.editor-panel.is-blocks .blockly-host {
  display: block;
  position: absolute;
  inset: 0;
}

.blockly-host.is-locked {
  pointer-events: none;
  opacity: 0.72;
}

.blockly-host .injectionDiv {
  width: 100%;
  height: 100%;
}

.blocklyZoom {
  display: none !important;
}

.blocklyToolboxDiv {
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-weight: 750;
  border-right: 1px solid rgba(255, 140, 60, 0.18) !important;
}

.blocklyFlyout {
  max-width: 360px;
}

.blocklyFlyoutLabelText {
  fill: #ffd2a8 !important;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif !important;
  font-weight: 800 !important;
}

.blocklyWidgetDiv,
.blocklyDropDownDiv {
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

.blocklyHighlightedConnectionPath {
  stroke: #ff9a56 !important;
}

.editor-footer {
  grid-area: footer;
  display: flex;
  flex-shrink: 0;
  min-height: 42px;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 9px 16px;
  color: var(--muted);
  border-top: 1px solid rgba(255, 140, 60, 0.14);
  background: rgba(8, 8, 12, 0.9);
  font-size: .78rem;
}

.editor-footer .editor-hint {
  font-size: inherit;
}

.editor-footer .editor-hint.is-warn {
  color: #fca5a5;
}

.editor-footer .editor-hint kbd {
  padding: 1px 6px;
  font-size: 0.72rem;
}

.toast {
  position: fixed;
  z-index: 50;
  right: 24px;
  bottom: 96px;
  display: flex;
  max-width: min(390px, calc(100vw - 32px));
  align-items: flex-start;
  gap: 11px;
  padding: 14px 52px 14px 16px;
  border: 1px solid rgba(255, 140, 60, 0.35);
  border-radius: 13px;
  background: rgba(18, 12, 8, 0.96);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(18px);
  transition: .25s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.toast.has-help {
  max-width: min(460px, calc(100vw - 32px));
}

.toast.is-pinned {
  border-color: rgba(255, 180, 80, 0.7);
  box-shadow: 0 0 22px rgba(255, 140, 40, 0.28);
}

.toast-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 2px;
}

.toast-pin,
.toast-close {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  color: #c9b8a4;
  border: 0;
  border-radius: 8px;
  background: transparent;
  line-height: 1;
}

.toast-pin svg {
  width: 15px;
  height: 15px;
}

.toast-pin path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.toast-close {
  font-size: 1.25rem;
}

.toast-close:hover {
  color: #fff;
  background: rgba(255, 100, 30, 0.16);
}

.toast-pin:hover {
  color: #fff;
}

.toast-pin[aria-pressed="true"] {
  color: #ffd2a8;
  background: transparent;
}

.toast-pin[aria-pressed="true"] path {
  fill: currentColor;
  stroke: none;
}

.toast-icon { font-size: 1.15rem; }
.toast strong { display: block; margin-bottom: 2px; font-size: .88rem; color: #ffd2a8; padding-right: 4px; }
#toastMessage { color: #c9b8a4; font-size: .8rem; line-height: 1.45; }

.toast-help {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed rgba(255, 140, 60, 0.28);
  color: #c9b8a4;
  font-size: 0.75rem;
  line-height: 1.45;
}

.toast-help .cmd-help-head {
  margin-bottom: 4px;
  color: #ffd2a8;
}

.toast-help .cmd-help-head em {
  margin-left: 6px;
  color: #9ca3af;
  font-style: normal;
  font-size: 0.72rem;
}

.toast-help .cmd-ex {
  border-top-color: rgba(255, 140, 60, 0.12);
}

/* ===================== 账号 / 登录 / 魔力 ===================== */

.account {
  position: relative;
  z-index: 30;
}

.account-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 12px;
  color: #ffd2a8;
  border: 1px solid rgba(255, 140, 60, 0.38);
  border-radius: 999px;
  background: rgba(18, 12, 8, 0.88);
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
}

.account-chip.logged { padding: 4px 12px 4px 6px; }
.account-chip:hover { border-color: rgba(255, 170, 90, 0.7); background: rgba(40, 22, 12, 0.95); }

.account-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: linear-gradient(145deg, #ff8a3d, #c2410c);
}

.account-avatar.fallback {
  display: grid;
  place-items: center;
  font-size: 0.95rem;
}

.account-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  line-height: 1.15;
}
.account-meta b {
  max-width: 96px;
  overflow: hidden;
  color: #fff;
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-points {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: #ffb070;
  font-style: normal;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
}
.account-points .menu-ico {
  width: 11px;
  height: 11px;
  flex: 0 0 11px;
}

.account-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 20;
  display: grid;
  min-width: 156px;
  padding: 6px;
  border: 1px solid rgba(255, 140, 60, 0.32);
  border-radius: 12px;
  background: rgba(18, 12, 8, 0.96);
  box-shadow: var(--shadow);
}

.account-menu[hidden] { display: none; }

.account-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  color: #ffd2a8;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
}

.account-menu .menu-ico {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
}

.account-menu button:hover { background: rgba(255, 100, 30, 0.16); }
.account-menu button[data-act="clear"] { color: #fca5a5; }
.account-menu button[data-act="clear"]:hover { background: rgba(220, 38, 38, 0.18); }

.profile-form { display: grid; gap: 12px; }

.profile-field {
  display: grid;
  gap: 6px;
  color: #ffd2a8;
  font-size: 0.82rem;
  font-weight: 700;
}

.profile-field input {
  min-height: 40px;
  padding: 0 12px;
  color: #fff;
  border: 1px solid rgba(255, 140, 60, 0.32);
  border-radius: 10px;
  background: rgba(8, 8, 12, 0.65);
  font: inherit;
}

.profile-field input:focus {
  outline: 0;
  border-color: rgba(255, 170, 90, 0.7);
}

.age-stepper {
  display: grid;
  grid-template-columns: 1fr 38px;
  min-height: 44px;
  overflow: hidden;
  border: 1px solid rgba(255, 140, 60, 0.32);
  border-radius: 10px;
  background: rgba(8, 8, 12, 0.65);
}

.age-stepper:focus-within {
  border-color: rgba(255, 170, 90, 0.7);
}

.age-stepper input {
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  -moz-appearance: textfield;
  appearance: textfield;
}

.age-stepper input::-webkit-outer-spin-button,
.age-stepper input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.age-spin {
  display: grid;
  grid-template-rows: 1fr 1fr;
  border-left: 1px solid rgba(255, 140, 60, 0.28);
}

.age-spin button {
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 0;
  color: #ffd2a8;
  border: 0;
  background: rgba(18, 12, 8, 0.55);
}

.age-spin button:first-child {
  border-bottom: 1px solid rgba(255, 140, 60, 0.22);
}

.age-spin button:hover {
  color: #fff;
  background: rgba(255, 100, 30, 0.22);
}

.age-che {
  width: 16px;
  height: 16px;
}

.age-che path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.gender-picks { display: flex; gap: 8px; }

.gender-picks button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 72px;
  padding: 10px 8px;
  color: #ffd2a8;
  border: 1px solid rgba(255, 140, 60, 0.32);
  border-radius: 10px;
  background: rgba(18, 12, 8, 0.85);
  font: inherit;
  font-weight: 750;
}

.gender-ico {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
}

.gender-picks button:hover {
  border-color: rgba(255, 160, 80, 0.55);
  background: rgba(40, 22, 12, 0.95);
}

.gender-picks button[aria-pressed="true"] {
  color: #fff;
  border-color: rgba(255, 170, 90, 0.85);
  background: rgba(255, 100, 30, 0.22);
}

.modal.is-required .modal-close { display: none; }

.invite-url {
  margin: 0 0 12px;
  padding: 10px 12px;
  word-break: break-all;
  color: #ffd2a8;
  border: 1px dashed rgba(255, 140, 60, 0.38);
  border-radius: 10px;
  background: rgba(255, 120, 40, 0.08);
  font-size: 0.82rem;
}

.invite-stats {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal[hidden] { display: none !important; }

.modal.is-opening .modal-backdrop,
.modal.is-opening .modal-close {
  pointer-events: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 4, 8, 0.72);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  max-height: min(88vh, 720px);
  overflow: auto;
  padding: 22px 22px 18px;
  border: 1px solid rgba(255, 140, 60, 0.32);
  border-radius: 18px;
  background:
    linear-gradient(160deg, rgba(28, 18, 12, 0.98), rgba(10, 11, 16, 0.98));
  box-shadow: var(--shadow);
}

.modal-card:has(.login-title) {
  color: #1f2937;
  border-color: #e5e7eb;
  background: #fff;
}

.modal-card:has(.login-title) .modal-close {
  color: #9ca3af;
}

.modal-card:has(.login-title) .modal-close:hover {
  color: #111827;
  background: rgba(0, 0, 0, 0.06);
}

.modal-card:has(.login-title) .modal-status {
  color: #6b7280;
}

.modal-card:has(.login-title) .text-btn {
  color: #07c160;
}

.modal-card:has(.login-title) .qr-box {
  border: 0;
  box-shadow: none;
}

.modal-card:has(.login-title) .wx-open-hint {
  color: #4b5563;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 32px;
  height: 32px;
  color: #c9b8a4;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
}

.modal-close:hover { color: #fff; background: rgba(255, 100, 30, 0.16); }

.modal-card h3 {
  margin: 0 0 8px;
  font-size: 1.15rem;
}

.login-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0 0 14px;
}

.wechat-icon {
  width: 1.2em;
  height: 1.2em;
  color: #07c160;
  flex-shrink: 0;
}

.wx-auth-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  margin: 8px 0 4px;
  padding: 0 16px;
  color: #fff;
  border: 0;
  border-radius: 999px;
  background: #07c160;
  font: inherit;
  font-weight: 750;
  text-decoration: none;
}

.wx-auth-btn .wechat-icon { color: #fff; }

.wx-auth-btn:hover { filter: brightness(1.05); }

.wx-open-hint {
  margin: 0 0 12px;
  padding-left: 1.2em;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.7;
  text-align: left;
}

.wx-open-hint b { letter-spacing: 2px; }

.modal-lead {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.modal-lead strong { color: #86efac; }

.qr-box {
  display: grid;
  justify-items: center;
  gap: 10px;
  margin: 0 auto 12px;
  padding: 14px;
  border-radius: 14px;
  background: #fff;
}

.qr-box:empty { display: none; }

.qr-box.qr-frame {
  padding: 0;
  overflow: hidden;
  background: #fff;
}

.qr-box iframe {
  display: block;
  width: 300px;
  max-width: 100%;
  height: 340px;
  border: 0;
  background: #fff;
}

.qr-box img {
  display: block;
  width: 220px;
  height: 220px;
}

.qr-open, .text-btn {
  color: #ffb070;
  border: 0;
  background: none;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.modal-status {
  margin: 0 0 8px;
  color: #ffd2a8;
  text-align: center;
  font-size: 0.86rem;
}

.modal-status:empty { display: none; }

.modal-alt {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin: 8px 0 0;
}

.recharge-box .modal-lead { margin-bottom: 10px; }

#shopPane { display: grid; gap: 10px; }
#shopPane[hidden] { display: none !important; }

.invite-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 170, 80, 0.55);
  border-radius: 12px;
  background:
    linear-gradient(105deg, rgba(255, 110, 30, 0.28), rgba(255, 140, 40, 0.08));
  box-shadow: inset 0 0 0 1px rgba(255, 200, 120, 0.08);
}

.invite-copy { flex: 1; min-width: 0; }
.invite-copy strong {
  display: block;
  color: #ffe7c4;
  font-size: 0.92rem;
  line-height: 1.25;
}
.invite-copy span {
  display: block;
  margin-top: 2px;
  color: #d7b48c;
  font-size: 0.76rem;
}

.invite-cta {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 16px;
  color: #2a1408;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffd28a, #ff8c2a);
  box-shadow: 0 4px 14px rgba(255, 120, 30, 0.38);
  font: inherit;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.invite-cta:hover {
  background: linear-gradient(180deg, #ffe0a8, #ff9a3a);
}

.product-list {
  display: grid;
  gap: 8px;
  margin: 0;
  max-height: min(46vh, 360px);
  overflow: auto;
}

.product-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  width: 100%;
  margin: 0;
  padding: 10px 12px;
  color: inherit;
  text-align: left;
  border: 1px solid rgba(255, 140, 60, 0.22);
  border-radius: 12px;
  background: rgba(8, 8, 12, 0.55);
  font: inherit;
  cursor: pointer;
}

.product-card:hover {
  border-color: rgba(255, 160, 80, 0.55);
  background: rgba(40, 22, 12, 0.95);
}

.product-meta { display: grid; flex: 1; min-width: 0; }
.product-meta strong { margin-top: 2px; font-size: 0.9rem; font-weight: 750; }
.product-desc { margin-top: 2px; color: var(--muted); font-size: 0.75rem; }

.product-energy,
.product-price {
  display: flex;
  align-items: baseline;
  gap: 4px;
  color: #ffb070;
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
}
.product-energy b,
.product-price b {
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
}
.product-price s { color: #6b7280; font-size: 0.75rem; font-weight: 500; }

.product-pay button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 12px;
  color: #ffd2a8;
  border: 1px solid rgba(255, 140, 60, 0.32);
  border-radius: 8px;
  background: rgba(18, 12, 8, 0.85);
  font: inherit;
  font-weight: 750;
}

.product-pay { display: flex; gap: 8px; }
.product-pay button { flex: 1; }

.product-pay button:hover {
  border-color: rgba(255, 160, 80, 0.55);
  background: rgba(40, 22, 12, 0.95);
}

/* ===================== 关卡条 ===================== */

.level-bar {
  display: grid;
  grid-template-columns: repeat(16, minmax(0, 1fr));
  gap: 4px;
  margin: 0 0 12px;
}

.level-chip {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 32px;
  padding: 0 0 4px;
  color: #c9b8a4;
  border: 1px solid rgba(255, 140, 60, 0.2);
  border-radius: 8px;
  background: rgba(12, 10, 14, 0.85);
  font-weight: 700;
  line-height: 1;
  transition: color .2s, border-color .2s, background .2s;
}

.level-chip b {
  color: #ffb070;
  font-size: 0.75rem;
}

.level-chip:hover:not(:disabled) { border-color: rgba(255, 170, 90, 0.6); color: #ffd2a8; }
.level-chip:hover:not(:disabled) b { color: #ffd2a8; }

.level-chip.current {
  color: #fff7ed;
  border-color: rgba(255, 140, 60, 0.75);
  background: linear-gradient(140deg, rgba(255, 122, 58, 0.35), rgba(120, 40, 10, 0.55));
  box-shadow: 0 0 12px rgba(255, 90, 20, 0.25);
}

.level-chip.current b { color: #fff7ed; }

.level-chip.locked { opacity: .42; cursor: not-allowed; }

.level-chip[data-stars="1"]::after,
.level-chip[data-stars="2"]::after,
.level-chip[data-stars="3"]::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 4px;
  height: 3px;
  border-radius: 99px;
  background: #fbbf24;
  box-shadow: 0 0 6px rgba(251, 191, 36, 0.55);
  transform: translateX(-50%);
}

.level-chip[data-stars="1"]::after { width: 5px; }
.level-chip[data-stars="2"]::after { width: 10px; }
.level-chip[data-stars="3"]::after { width: 15px; }

.lore-hint { margin: 8px 0 0 !important; color: #9aa3b2 !important; font-size: 0.8rem !important; }
.lore code, .tool-description code, .toast-help code {
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(255, 140, 60, 0.14);
  color: #ffc08a;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.92em;
}

.cmd-ex-code code,
.toast-help .cmd-ex-code code,
.toast-help .cmd-help-head code {
  padding: 0;
  background: none;
  color: inherit;
  font-size: inherit;
}

.tool-kind {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(99, 91, 255, 0.18);
  color: #a5b4fc;
  font-size: 0.72rem;
  font-weight: 700;
}

.next-button {
  flex-shrink: 0;
  color: #052e16;
  background: linear-gradient(145deg, #86efac, #22c55e);
  box-shadow: 0 0 18px rgba(34, 197, 94, 0.32);
}

/* ===================== 地形素材 ===================== */

.cell-art {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.cell-art .art {
  width: 84%;
  height: 84%;
  overflow: visible;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35));
}

.cell.wall .flame { animation-delay: calc(var(--delay, 0s) + var(--seed, 0s)); }

.cell.void { background: #04040a; box-shadow: inset 0 0 0 1.5px #16161f; }

/* 迷雾：还没走到过的格子，只知道「有一格」，不知道是什么 */
.cell.unknown {
  background: repeating-linear-gradient(135deg, #16131c 0 4px, #1d1922 4px 8px);
  box-shadow: inset 0 0 0 1.5px rgba(255, 200, 130, 0.14);
}

.cell.unknown .cell-art {
  color: rgba(255, 200, 130, 0.32);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.82rem;
  font-weight: 800;
}

.cell.goal .art-flag {
  width: 72%;
  height: 72%;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.25));
  animation: flag-wave 1.4s ease-in-out infinite;
  transform-origin: 18% 90%;
}

.cell.rock { box-shadow: inset 0 0 0 1.5px #9aa0ac; }
.cell.rock .art { width: 92%; height: 92%; }

.cell.gem {
  background: linear-gradient(180deg, #eaf7ff, #fff8ee);
  box-shadow: inset 0 0 0 1.5px #38bdf8;
}

.cell.gem .art { animation: gem-shine 1.5s ease-in-out infinite alternate; }

@keyframes gem-shine {
  from { transform: scale(.94) rotate(-3deg); filter: brightness(1); }
  to { transform: scale(1.05) rotate(3deg); filter: brightness(1.25); }
}

.cell.fx-gem::before {
  content: "💎";
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  animation: fx-pop .6s ease-out forwards;
}

.cell.jug {
  background: linear-gradient(180deg, #fff1d6, #fff8ee);
  box-shadow: inset 0 0 0 1.5px #f59e0b;
}

.cell.mire {
  background: linear-gradient(180deg, #e8d7bb, #cbb08a);
  box-shadow: inset 0 0 0 1.5px #6b4a22;
}

.cell.patrol {
  background: radial-gradient(circle at 50% 90%, #ffe6c4, #fff8ee 70%);
  box-shadow: inset 0 0 0 1.5px #f97316;
}

.cell.patrol.cool .art { opacity: .16; filter: grayscale(1); }
.cell.patrol.hot {
  background: radial-gradient(circle at 50% 90%, #ffb066, #ffd9a8 70%);
  box-shadow: inset 0 0 0 2.5px #ea580c;
}
.cell.patrol.hot .art { animation: blaze-dance .45s ease-in-out infinite alternate; }

.cell.fx-slip::before {
  content: "💫";
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  animation: fx-pop .6s ease-out forwards;
}

.cell.marked::after {
  content: "📍";
  position: absolute;
  right: 2px;
  top: 1px;
  z-index: 2;
  font-size: 0.72rem;
  line-height: 1;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.45));
  pointer-events: none;
}

.cell.fx-mark::before {
  content: "✎";
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  animation: fx-pop .6s ease-out forwards;
}

.cell.pond {
  background: linear-gradient(180deg, #e6f6ff, #fff8ee);
  box-shadow: inset 0 0 0 1.5px #3f9fe0;
}

.cell.pond .art { width: 96%; height: 96%; }
.cell.pond .ripple { animation: ripple 2.2s ease-out infinite; transform-origin: center; }

@keyframes ripple {
  0% { transform: scale(.4); opacity: .9; }
  100% { transform: scale(1.5); opacity: 0; }
}

.cell.blaze {
  background: radial-gradient(circle at 50% 90%, #ffd9a8, #fff8ee 70%);
  box-shadow: inset 0 0 0 2px #ff7a1a;
}

.cell.blaze .art {
  animation: blaze-dance .62s ease-in-out infinite alternate;
  transform-origin: center bottom;
}

@keyframes blaze-dance {
  from { transform: scaleY(.94) scaleX(1.04) rotate(-3deg); filter: brightness(1); }
  to { transform: scaleY(1.08) scaleX(.94) rotate(3deg); filter: brightness(1.2); }
}

.cell.plant { background: linear-gradient(180deg, #eafbe7, #fff8ee); box-shadow: inset 0 0 0 1.5px #2eab55; }
.cell.plant .plant-open,
.cell.plant .plant-closed { display: none; }
.cell.plant.open .plant-open { display: block; }
.cell.plant.closed .plant-closed { display: block; }
.cell.plant.open { box-shadow: inset 0 0 0 2.5px #e5457f; }
.cell.plant.open .art { animation: plant-chomp .5s ease-in-out infinite alternate; }

@keyframes plant-chomp {
  from { transform: scale(1) rotate(-2deg); }
  to { transform: scale(1.08) rotate(2deg); }
}

.cell-badge {
  position: absolute;
  right: 2px;
  bottom: 1px;
  z-index: 2;
  min-width: 15px;
  padding: 0 3px;
  color: #fff;
  border-radius: 999px;
  background: rgba(190, 40, 0, 0.92);
  box-shadow: 0 0 6px rgba(255, 90, 20, 0.5);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.62rem;
  font-weight: 800;
  font-style: normal;
  line-height: 1.5;
  text-align: center;
}

/* ===================== 动作特效 ===================== */

.cell.fx-smash { animation: fx-smash .5s ease-out; }
.cell.fx-splash::before, .cell.fx-quench::before {
  content: "💦";
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  animation: fx-pop .6s ease-out forwards;
}
.cell.fx-quench::before { content: "💨"; }

@keyframes fx-smash {
  0% { transform: scale(1.18) rotate(-6deg); filter: brightness(2); }
  60% { transform: scale(.94) rotate(4deg); }
  100% { transform: scale(1); }
}

@keyframes fx-pop {
  0% { opacity: 0; transform: scale(.4) translateY(6px); }
  40% { opacity: 1; transform: scale(1.15) translateY(-2px); }
  100% { opacity: 0; transform: scale(1) translateY(-14px); }
}

/* ===================== 团团朝向 ===================== */

.hero-art {
  position: relative;
  grid-area: 1 / 1;
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
}

.hero-face {
  grid-area: 1 / 1;
  align-self: end;
  justify-self: center;
  width: 0;
  height: 0;
  border-right: 5px solid transparent;
  border-left: 5px solid transparent;
  border-top: 7px solid rgba(251, 191, 36, .95);
  filter: drop-shadow(0 0 4px rgba(255, 150, 40, .85));
}

.hero.face-up .hero-face { align-self: start; transform: rotate(180deg); }
.hero.face-left .hero-face { align-self: center; justify-self: start; transform: rotate(90deg); }
.hero.face-right .hero-face { align-self: center; justify-self: end; transform: rotate(-90deg); }
.hero.dead .hero-face, .hero.won .hero-face { display: none; }

.hero.jumping { animation: hero-hop .42s ease-out; }

@keyframes hero-hop {
  0%, 100% { margin-top: 0; }
  50% { margin-top: -22px; }
}

@media (min-width: 1100px) {
  .level-bar { grid-template-columns: repeat(32, minmax(0, 1fr)); }
}

@media (max-width: 960px) {
  .workspace { grid-template-columns: 1fr; min-height: 0; }
  .stage-panel { min-height: 0; }
  .editor-panel { height: auto; min-height: 560px; max-height: none; }
}

@media (max-width: 760px) {
  .app { width: min(100% - 20px, 620px); padding: 18px 0; }
  .music-toggle { width: 38px; height: 38px; }
  .lore { padding: 12px 14px; }
  .stage-panel { padding: 12px 14px 16px; }
  .hud { justify-content: flex-start; }
  .hud .chip { padding: 4px 8px; font-size: 0.68rem; }
  .level-bar { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .level-chip { height: 30px; }
  .actions { width: auto; }
  .action-button { justify-content: center; }
  .tool-slot { max-height: 36vh; }
}

/* ===================== AI 向导 ===================== */

body.coach-open .toast.show {
  opacity: 0;
  pointer-events: none;
}

.coach {
  display: none !important;
}

.coach-fab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 48px;
  padding: 0 16px 0 12px;
  color: #fff7ed;
  border: 1px solid rgba(255, 170, 90, 0.7);
  border-radius: 999px;
  background: linear-gradient(145deg, #ff8a3d, #e04f12);
  box-shadow: 0 8px 24px rgba(255, 90, 20, 0.38);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.coach-fab:hover {
  border-color: #ffd2a8;
  box-shadow: 0 10px 28px rgba(255, 110, 30, 0.5);
}

.coach-fab-ico { font-size: 1.05rem; line-height: 1; }
.coach-fab-label { font-size: 0.86rem; }

.coach-panel {
  display: flex;
  width: min(340px, calc(100vw - 32px));
  max-height: min(42vh, 280px);
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(255, 140, 60, 0.38);
  border-radius: 16px;
  background: rgba(14, 11, 12, 0.97);
  box-shadow: var(--shadow);
}

.coach-panel.is-chat {
  max-height: min(52vh, 400px);
}

.coach-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 10px 10px 14px;
  border-bottom: 1px solid rgba(255, 140, 60, 0.16);
}

.coach-title {
  color: #ffd2a8;
  font-size: 0.9rem;
  font-weight: 800;
}

.coach-head-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.coach-text-btn,
.coach-icon-btn,
.coach-send {
  color: #c9b8a4;
  border: 0;
  background: transparent;
}

.coach-text-btn {
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 0.74rem;
}

.coach-text-btn:hover,
.coach-icon-btn:hover { color: #fff; background: rgba(255, 100, 30, 0.16); }

.coach-text-btn:disabled,
.coach-send:disabled { opacity: .45; cursor: default; }

.coach-icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 1.2rem;
  line-height: 1;
}

.coach-thread {
  flex: 1;
  overflow: auto;
  padding: 12px 14px 14px;
  min-height: 72px;
}

.coach-note {
  color: #9aa3b2;
  font-size: 0.78rem;
}

.coach-msg { margin: 0 0 12px; }
.coach-msg:last-child { margin-bottom: 0; }

.coach-who {
  display: block;
  margin-bottom: 4px;
  color: #8b93a7;
  font-size: 0.7rem;
}

.coach-bubble {
  color: #e8ecf4;
  font-size: 0.82rem;
  line-height: 1.5;
}

.coach-msg.is-user .coach-bubble {
  padding: 8px 10px;
  border-radius: 10px 10px 4px 10px;
  background: rgba(255, 140, 60, 0.12);
}

.coach-bubble code {
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(255, 140, 60, 0.14);
  color: #ffc08a;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.92em;
}

.coach-code {
  margin: 8px 0 0;
  padding: 8px 10px;
  overflow: auto;
  border-radius: 8px;
  background: #09090f;
  color: #ffd2a8;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.45;
}

.coach-code code { padding: 0; background: none; color: inherit; }

.coach-compose {
  display: flex;
  gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid rgba(255, 140, 60, 0.16);
}

.coach-compose textarea {
  flex: 1;
  min-height: 44px;
  max-height: 96px;
  padding: 8px 10px;
  resize: none;
  color: var(--ink);
  border: 1px solid rgba(255, 140, 60, 0.28);
  border-radius: 10px;
  background: rgba(8, 8, 12, 0.9);
}

.coach-send {
  align-self: flex-end;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(255, 122, 58, 0.22);
  color: #ffd2a8;
  font-weight: 700;
}

.coach-send:hover { color: #fff; background: rgba(255, 122, 58, 0.38); }

.coach.is-busy .coach-note::after {
  content: "";
  display: inline-block;
  width: 0.9em;
  animation: coach-dots 1.2s steps(4, end) infinite;
}

@keyframes coach-dots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75% { content: "..."; }
}

@media (max-width: 760px) {
  .coach { right: 12px; bottom: 12px; }
  .coach-panel.is-chat {
    width: min(100vw - 24px, 420px);
    max-height: min(68vh, 480px);
  }
}
