/* ================= 基础与主题 ================= */
:root {
  --ink: #4a2542;
  --ink-soft: #7f5a76;
  --ink-faint: #a986a0;
  --paper: rgba(255, 255, 255, .66);
  --paper-strong: rgba(255, 255, 255, .86);
  --line: rgba(255, 255, 255, .76);
  --coral: #ff5d7d;
  --coral-deep: #e83b63;
  --orange: #ff9f43;
  --cream: #fff7ee;
  --shadow: 0 22px 50px -26px rgba(111, 43, 88, .38);
  --shadow-soft: 0 10px 26px -16px rgba(111, 43, 88, .35);
  --radius-lg: 30px;
  --radius-md: 20px;
  --font-display: "Arial Rounded MT Bold", "Trebuchet MS", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-body: "Trebuchet MS", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(1100px 700px at 8% -10%, #fff8ea 0%, transparent 55%),
    radial-gradient(1000px 640px at 100% 5%, #ffd8e8 0%, transparent 60%),
    radial-gradient(900px 900px at 50% 110%, #c9f1dd 0%, transparent 55%),
    linear-gradient(135deg, #ffe8cc 0%, #ffd9e6 42%, #f6dfef 66%, #d9f3e6 100%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .35;
  background-image: radial-gradient(rgba(255, 255, 255, .85) 1px, transparent 1px);
  background-size: 24px 24px;
  mask-image: linear-gradient(to bottom, #000, transparent 75%);
}

button {
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible {
  outline: 3px solid rgba(248, 76, 120, .8);
  outline-offset: 3px;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* ================= 背景装饰 ================= */
.ambient {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(2px);
  opacity: .7;
  animation: blobFloat 16s ease-in-out infinite alternate;
}

.blob-a {
  width: 46vw;
  height: 46vw;
  min-width: 360px;
  min-height: 360px;
  left: -18vw;
  top: -16vw;
  background: radial-gradient(circle at 45% 45%, rgba(255, 228, 160, .75), rgba(255, 228, 160, 0) 68%);
}

.blob-b {
  width: 42vw;
  height: 42vw;
  min-width: 320px;
  min-height: 320px;
  right: -15vw;
  top: 4vh;
  background: radial-gradient(circle at 50% 50%, rgba(255, 154, 190, .5), rgba(255, 154, 190, 0) 70%);
  animation-delay: -5s;
}

.blob-c {
  width: 55vw;
  height: 42vw;
  min-width: 420px;
  left: 22vw;
  bottom: -24vw;
  background: radial-gradient(circle at 50% 50%, rgba(129, 224, 182, .46), rgba(129, 224, 182, 0) 70%);
  animation-delay: -9s;
}

.ambient-fruit {
  position: absolute;
  display: block;
  filter: blur(1.2px) saturate(.9);
  opacity: .28;
  animation: ambientFloat 9s ease-in-out infinite alternate;
}

.ambient-fruit svg { width: 100%; height: 100%; display: block; }
.af-1 { width: 102px; height: 102px; left: 4%; top: 25%; transform: rotate(-16deg); }
.af-2 { width: 76px; height: 76px; right: 7%; top: 17%; animation-delay: -3s; }
.af-3 { width: 88px; height: 88px; right: 3%; bottom: 13%; animation-delay: -5s; transform: rotate(14deg); }
.af-4 { width: 64px; height: 64px; left: 8%; bottom: 8%; animation-delay: -7s; }

.bubble {
  position: absolute;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, .65);
  background: radial-gradient(circle at 32% 28%, rgba(255, 255, 255, .7), rgba(255, 255, 255, .06) 60%);
  box-shadow: inset 0 0 12px rgba(255, 255, 255, .35);
  animation: bubbleRise 14s linear infinite;
}

.b1 { width: 18px; height: 18px; left: 14%; bottom: -20px; animation-delay: -2s; }
.b2 { width: 9px; height: 9px; left: 25%; bottom: -20px; animation-delay: -9s; animation-duration: 18s; }
.b3 { width: 24px; height: 24px; left: 47%; bottom: -20px; animation-delay: -6s; animation-duration: 16s; }
.b4 { width: 12px; height: 12px; left: 68%; bottom: -20px; animation-delay: -12s; }
.b5 { width: 16px; height: 16px; left: 82%; bottom: -20px; animation-delay: -4s; animation-duration: 19s; }
.b6 { width: 7px; height: 7px; left: 91%; bottom: -20px; animation-delay: -7s; animation-duration: 12s; }

@keyframes blobFloat {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(3vw, 2vh, 0) scale(1.06); }
}

@keyframes ambientFloat {
  from { translate: 0 0; }
  to { translate: 0 -16px; }
}

@keyframes bubbleRise {
  0% { transform: translateY(0) scale(.9); opacity: 0; }
  10% { opacity: .8; }
  85% { opacity: .5; }
  100% { transform: translateY(-105vh) translateX(22px) scale(1.1); opacity: 0; }
}

/* ================= 顶部品牌栏 ================= */
.topbar {
  position: relative;
  z-index: 2;
  width: min(1040px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 4px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  user-select: none;
}

.brand-mark {
  position: relative;
  width: 54px;
  height: 54px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, rgba(255, 255, 255, .96), rgba(255, 232, 238, .8));
  box-shadow: 0 12px 24px -13px rgba(174, 48, 94, .55), inset 0 0 0 2px rgba(255, 255, 255, .8);
  transform: rotate(-4deg);
}

.brand-mark svg { width: 70%; height: 70%; filter: drop-shadow(0 4px 4px rgba(157, 37, 78, .18)); }

.brand-spark {
  position: absolute;
  right: -7px;
  top: -9px;
  font-style: normal;
  font-size: 22px;
  color: #ffb01f;
  text-shadow: 0 2px 0 #fff;
  animation: sparkle 2.8s ease-in-out infinite;
}

.brand-text h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(23px, 2.7vw, 31px);
  letter-spacing: .5px;
  line-height: 1;
  color: #54264b;
  text-shadow: 0 2px 0 rgba(255, 255, 255, .65);
}

.brand-text p {
  margin: 6px 0 0;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 4.2px;
  color: #b06f92;
}

.top-actions { display: flex; gap: 10px; }

.icon-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .75);
  border-radius: 15px;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: #8b4f77;
  background: rgba(255, 255, 255, .5);
  box-shadow: 0 8px 18px -12px rgba(98, 37, 73, .45), inset 0 1px 0 rgba(255, 255, 255, .8);
  backdrop-filter: blur(10px);
  transition: transform .2s ease, background .2s ease, color .2s ease;
}

.icon-btn svg { width: 21px; height: 21px; }
.icon-btn:hover { transform: translateY(-2px); background: rgba(255, 255, 255, .82); color: var(--coral-deep); }
.icon-btn:active { transform: translateY(0) scale(.95); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }

@keyframes sparkle {
  0%, 100% { transform: scale(.8) rotate(0deg); opacity: .65; }
  50% { transform: scale(1.18) rotate(20deg); opacity: 1; }
}

/* ================= 主布局 ================= */
.app {
  position: relative;
  z-index: 2;
  width: min(1040px, calc(100% - 40px));
  margin: 0 auto;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 680px) minmax(250px, 288px);
  gap: 22px;
  justify-content: center;
  align-items: start;
}

.board-section { min-width: 0; }

/* ================= HUD ================= */
.hud {
  display: grid;
  grid-template-columns: auto auto minmax(160px, 1fr);
  align-items: stretch;
  gap: 10px;
  margin-bottom: 12px;
}

.hud-pill {
  min-height: 58px;
  padding: 9px 17px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(255, 255, 255, .85);
  backdrop-filter: blur(14px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}

.hud-pill span {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.1px;
  color: var(--ink-faint);
  white-space: nowrap;
}

.hud-pill strong {
  font-family: var(--font-display);
  font-size: 23px;
  line-height: .95;
  color: #5a2b51;
}

.hud-level { min-width: 88px; }
.hud-level strong { color: var(--coral-deep); }
.hud-moves { min-width: 106px; }
.hud-moves.low { background: rgba(255, 224, 230, .76); }
.hud-moves.low strong { color: #ef3f63; animation: lowPulse 1.1s ease-in-out infinite; }

.hud-score {
  min-width: 0;
  min-height: 58px;
  padding: 10px 17px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(255, 255, 255, .85);
  backdrop-filter: blur(14px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
}

.hud-score-line {
  display: flex;
  align-items: baseline;
  gap: 5px;
  min-width: 0;
}

.hud-score-line > span {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--ink-faint);
  white-space: nowrap;
}

.hud-score-line strong {
  margin-left: auto;
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1;
  color: #5a2b51;
  transition: transform .18s ease;
}

.hud-score-line strong.bump { animation: scoreBump .34s ease; }
.hud-score-line em { font-style: normal; font-size: 10px; font-weight: 800; color: #b491a7; white-space: nowrap; }

.progress-track {
  position: relative;
  height: 8px;
  border-radius: 99px;
  background: rgba(113, 53, 87, .11);
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(91, 41, 72, .08);
}

.progress-track > i {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffad3d, #ff6f7c 55%, #ff4d88);
  box-shadow: 0 0 10px rgba(255, 92, 120, .5);
  transition: width .45s cubic-bezier(.2, .8, .25, 1);
}

.progress-track > i::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .7), transparent);
  transform: translateX(-100%);
  animation: barShine 2.6s ease-in-out infinite;
}

@keyframes lowPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

@keyframes scoreBump {
  0% { transform: scale(1); }
  45% { transform: scale(1.18); color: var(--coral-deep); }
  100% { transform: scale(1); }
}

@keyframes barShine {
  0%, 55% { transform: translateX(-100%); }
  100% { transform: translateX(120%); }
}

/* ================= 侧栏 ================= */
.side-panel {
  display: flex;
  flex-direction: column;
  gap: 13px;
  padding-top: 0;
}

.panel {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper);
  box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(255, 255, 255, .85);
  backdrop-filter: blur(15px);
  overflow: hidden;
}

.mission-panel { padding: 17px 18px 18px; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.panel-head > span {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.2px;
  color: var(--ink-faint);
}

.level-tag {
  padding: 4px 9px;
  border-radius: 99px;
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: .7px;
  color: #fff;
  background: linear-gradient(135deg, #ff9d4d, #ff5f78);
  box-shadow: 0 4px 10px -4px rgba(236, 80, 103, .65);
}

.target-line {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 12px;
}

.target-star {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, #ffd14f, #ff9a2e);
  box-shadow: 0 8px 16px -9px rgba(239, 146, 30, .75), inset 0 1px 0 rgba(255, 255, 255, .55);
  transform: rotate(-6deg);
}

.target-star svg { width: 19px; height: 19px; }

.target-line strong {
  font-family: var(--font-display);
  font-size: clamp(28px, 3.2vw, 36px);
  line-height: 1;
  letter-spacing: -.5px;
  color: #54264b;
}

.side-progress { height: 9px; }
.side-progress > i {
  background: linear-gradient(90deg, #63d1a1, #35b98c 40%, #ffbd46);
  box-shadow: 0 0 10px rgba(78, 195, 151, .38);
}

.mission-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 9px;
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-faint);
}

.mission-meta b { color: var(--ink-soft); }

.stats-panel {
  display: flex;
  align-items: center;
  padding: 16px 18px;
}

.stat-item { flex: 1; min-width: 0; }
.stat-item span { display: block; margin-bottom: 3px; font-size: 9px; font-weight: 800; letter-spacing: .8px; color: var(--ink-faint); }
.stat-item strong { font-family: var(--font-display); font-size: 22px; color: #54264b; }
.stat-divider { width: 1px; height: 30px; margin: 0 16px; background: rgba(103, 49, 82, .12); }

.tip-panel { padding: 17px 18px 18px; }
.tip-panel h2 {
  margin: 0 0 13px;
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 1px;
  color: #6a3559;
}

.tip-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 7px 0;
}

.tip-row + .tip-row { border-top: 1px dashed rgba(110, 55, 88, .12); }

.mini-tile {
  position: relative;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(145deg, #fff, #ffe7ef);
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .9), 0 5px 10px -7px rgba(98, 37, 73, .4);
}

.mini-tile svg { width: 78%; height: 78%; }
.mini-tile.stripe-demo::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 7px;
  background: repeating-linear-gradient(0deg, transparent 0 4px, rgba(255, 255, 255, .9) 4px 6px);
  mix-blend-mode: overlay;
}
.mini-tile.rainbow-demo {
  background: conic-gradient(from 40deg, #ffd95c, #ff7e9f, #b88cff, #6bc6ff, #7ce5a8, #ffd95c);
  color: #fff;
}
.mini-tile.rainbow-demo svg { filter: drop-shadow(0 1px 2px rgba(91, 40, 72, .25)); }

.tip-row p {
  margin: 0;
  font-size: 10px;
  line-height: 1.45;
  color: var(--ink-faint);
}
.tip-row p b { font-size: 11px; color: var(--ink-soft); }

/* ================= 底部 ================= */
.footer {
  position: relative;
  z-index: 2;
  width: min(1040px, calc(100% - 40px));
  margin: 0 auto;
  padding: 18px 0 26px;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .4px;
  color: #a9809a;
}

/* ================= 响应式 ================= */
@media (max-width: 920px) {
  .game-layout {
    grid-template-columns: minmax(0, 620px);
  }

  .side-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
  }

  .tip-panel { grid-column: 1 / -1; }
  .tip-panel { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 16px; }
  .tip-panel h2 { grid-column: 1 / -1; margin-bottom: 2px; }
  .tip-row { padding: 6px 0; }
  .tip-row + .tip-row { border-top: 0; }
}

@media (max-width: 620px) {
  .topbar { width: calc(100% - 28px); padding: 18px 0 13px; }
  .app { width: calc(100% - 24px); }
  .footer { width: calc(100% - 28px); font-size: 9px; line-height: 1.6; padding-top: 14px; }
  .brand-mark { width: 45px; height: 45px; border-radius: 15px; }
  .brand-text h1 { font-size: 23px; }
  .brand-text p { font-size: 8px; letter-spacing: 3.4px; margin-top: 4px; }
  .icon-btn { width: 39px; height: 39px; border-radius: 13px; }
  .icon-btn svg { width: 18px; height: 18px; }

  .hud { grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 9px; }
  .hud-score { grid-column: 1 / -1; grid-row: 2; min-height: 50px; }
  .hud-pill { min-height: 50px; padding: 7px 14px; border-radius: 15px; }
  .hud-pill strong { font-size: 20px; }
  .hud-moves { min-width: 0; align-items: flex-end; }
  .hud-level { min-width: 0; }

  .side-panel { grid-template-columns: 1fr 1fr; gap: 9px; }
  .tip-panel { grid-template-columns: 1fr; }
  .tip-panel h2 { margin-bottom: 8px; }
  .tip-row + .tip-row { border-top: 1px dashed rgba(110, 55, 88, .1); }
  .side-panel .tip-panel { display: none; }
  .panel { border-radius: 17px; }
  .mission-panel { padding: 14px; }
  .stats-panel { flex-direction: column; align-items: stretch; gap: 8px; padding: 12px 14px; }
  .stat-item { flex: none; }
  .stat-item strong { font-size: 19px; }
  .stat-divider { width: 100%; height: 1px; margin: 0; }
  .target-star { width: 29px; height: 29px; }
}

@media (max-width: 390px) {
  .brand-text p { display: none; }
  .hud-pill { padding: 7px 12px; }
  .hud-score { padding: 9px 13px; }
  .hud-score-line strong { font-size: 20px; }
  .mission-panel .target-line strong { font-size: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}
