:root {
  --ink: #26324b;
  --ink-strong: #1e2940;
  --ink-soft: #5b6884;
  --muted: #8590a8;
  --line: rgba(125, 145, 195, 0.16);
  --glass: rgba(255, 255, 255, 0.72);
  --glass-strong: rgba(255, 255, 255, 0.9);
  --lav: #6b58d6;
  --lav-deep: #5342bc;
  --pink: #f7739a;
  --blue: #68a7eb;
  --yellow: #f5bd5f;
  --mint: #69cba4;
  --shadow-soft: 0 14px 36px rgba(90, 104, 155, 0.14);
  --shadow-card: 0 18px 44px rgba(92, 104, 156, 0.18);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

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

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

html {
  background: #eef4ff;
}

body {
  min-height: 100%;
  color: var(--ink);
  font-family: ui-rounded, "Nunito", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(circle at 8% 6%, #ffe9f3 0, rgba(255, 233, 243, 0) 36%),
    radial-gradient(circle at 94% 14%, #e5ecff 0, rgba(229, 236, 255, 0) 40%),
    radial-gradient(circle at 50% 100%, #e8faf5 0, rgba(232, 250, 245, 0) 46%),
    linear-gradient(160deg, #f8f6ff 0%, #eef5ff 52%, #f5fbff 100%);
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before,
body::after {
  content: "";
  position: fixed;
  z-index: 0;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(10px);
}

body::before {
  width: 42vmin;
  height: 42vmin;
  left: -14vmin;
  top: 16vh;
  background: radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.95), rgba(255, 195, 218, 0.3) 56%, rgba(255, 195, 218, 0) 72%);
}

body::after {
  width: 54vmin;
  height: 54vmin;
  right: -20vmin;
  bottom: 6vh;
  background: radial-gradient(circle at 40% 40%, rgba(255, 255, 255, 0.8), rgba(150, 196, 255, 0.26) 55%, rgba(150, 196, 255, 0) 72%);
}

button {
  font: inherit;
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled {
  cursor: default;
}

button:focus-visible {
  outline: 3px solid #9d8df4;
  outline-offset: 2px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 560px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  padding:
    calc(8px + var(--safe-top))
    calc(10px + var(--safe-right))
    calc(8px + var(--safe-bottom))
    calc(10px + var(--safe-left));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  /* 单列必须带 minmax(0, 1fr)：棋盘舞台的像素宽度由 JS 按可用空间回写，
     若列为 auto，内容会把整列撑出视口（底部操作栏被裁掉），body overflow:hidden 会掩盖这一问题。 */
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(6px, 1.2vh, 11px);
}

.topbar {
  padding: 10px 13px 9px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.86);
  background: linear-gradient(158deg, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.62));
  box-shadow:
    0 14px 34px rgba(96, 110, 160, 0.13),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(18px) saturate(1.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.level-line {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.level-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.eyebrow-row {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.eyebrow {
  color: #8b7bd2;
  font-size: 10.5px;
  line-height: 1.2;
  font-weight: 900;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  white-space: nowrap;
}

.mode-badge {
  padding: 2px 7px;
  border-radius: 999px;
  background: #fff2d8;
  color: #9a6a18;
  font-size: 9.5px;
  line-height: 1.2;
  font-weight: 900;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

.mode-badge[hidden] {
  display: none;
}

.sound-toggle {
  flex: none;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(126, 145, 195, 0.18);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(241, 244, 255, 0.9));
  box-shadow:
    inset 0 1px 0 #fff,
    0 2px 6px rgba(86, 100, 151, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.14s ease, opacity 0.14s ease;
}

.sound-toggle:active {
  transform: scale(0.92);
}

.sound-toggle[aria-pressed="false"] {
  opacity: 0.55;
}

/* 顶栏右侧的声音按钮组：音乐开关在前、音效开关在后，整体靠右。 */
#musicToggle {
  margin-left: auto;
}

.sound-settings {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sound-setting {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.sound-setting-name {
  color: #5a6683;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.sound-setting input[type="range"] {
  width: 100%;
  height: 22px;
  margin: 0;
  accent-color: #8c7bea;
  cursor: pointer;
}

.sound-hint {
  color: #929cb2;
  font-size: 10.5px;
  line-height: 1.6;
}

.level-tag {
  max-width: 56%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 2px 7px;
  border-radius: 999px;
  background: #f2efff;
  color: #6d5ac6;
  font-size: 10px;
  font-weight: 850;
}

.level-title {
  color: var(--ink-strong);
  font-size: clamp(20px, 5.6vw, 26px);
  line-height: 1.16;
  font-weight: 950;
  letter-spacing: -0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.goal-total {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  min-width: 58px;
  padding-top: 1px;
}

.goal-total span {
  color: #5145a2;
  font-size: 16px;
  line-height: 1;
  font-weight: 950;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.goal-total small {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1px;
}

.goal-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  min-height: 26px;
  flex-wrap: wrap;
}

.goal-chips {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  min-width: 0;
}

.goal-chip {
  --paint: #7e7dcd;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 26px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(126, 145, 195, 0.16);
  color: #5d6780;
  font-size: 10.5px;
  line-height: 1;
  font-weight: 800;
  box-shadow: inset 0 1px 0 #fff;
}

.goal-chip strong {
  color: #3c4661;
  font-size: 12px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.goal-chip.done {
  border-color: color-mix(in srgb, var(--paint) 42%, white);
  background: color-mix(in srgb, var(--paint) 10%, white);
}

.goal-chip.done strong {
  color: color-mix(in srgb, var(--paint) 74%, #24304a);
}

.dot {
  width: 11px;
  height: 11px;
  flex: none;
  border-radius: 50%;
  background: var(--paint);
  box-shadow:
    inset -2px -2px 3px rgba(0, 0, 0, 0.09),
    inset 2px 2px 2px rgba(255, 255, 255, 0.8),
    0 1px 3px color-mix(in srgb, var(--paint) 38%, transparent);
}

.extra-goal {
  display: none;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #fff4df;
  border: 1px solid #f1dcb3;
  color: #9a661f;
  font-size: 10px;
  line-height: 1;
  font-weight: 850;
  white-space: nowrap;
}

.extra-goal.show {
  display: inline-flex;
}

.level-progress {
  height: 4px;
  margin-top: 1px;
  border-radius: 999px;
  background: rgba(126, 141, 182, 0.14);
  overflow: hidden;
}

.level-progress i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #8c7bea, #f08cac 55%, #f3bd67);
  transition: width 0.25s ease;
}

.level-progress.progress-mode {
  height: 9px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(219, 229, 249, 0.58));
  box-shadow:
    inset 0 1px 2px rgba(91, 108, 154, 0.16),
    0 1px 0 rgba(255, 255, 255, 0.72);
}

.level-progress.progress-mode i {
  position: relative;
  background: linear-gradient(90deg, #83c9f4, #8c7bea 48%, #f6a8c0);
  box-shadow:
    0 0 8px rgba(140, 123, 234, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.72);
  transition: width 0.34s cubic-bezier(0.22, 0.8, 0.3, 1);
}

.level-progress.progress-mode i::after {
  content: '';
  position: absolute;
  inset: 1px 4px auto;
  height: 2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
}

.level-progress.progress-mode.clearing {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.8), rgba(255, 233, 210, 0.7));
}

.level-progress.progress-mode.complete {
  box-shadow:
    0 0 0 3px rgba(255, 214, 126, 0.22),
    0 0 16px rgba(243, 189, 103, 0.46),
    inset 0 1px 2px rgba(91, 108, 154, 0.12);
}

.level-progress.gain i {
  animation: progress-gain 0.48s ease;
}

.level-progress.complete-flash {
  animation: progress-complete 0.9s ease;
}

@keyframes progress-gain {
  0% {
    filter: brightness(1);
  }
  34% {
    filter: brightness(1.32);
  }
  100% {
    filter: brightness(1);
  }
}

@keyframes progress-complete {
  0%,
  100% {
    transform: scaleY(1);
  }
  35% {
    transform: scaleY(1.65);
  }
}

.goal-total.progress-mode span {
  color: #5b57b8;
  font-size: 13px;
  letter-spacing: 0.4px;
}

.goal-total.progress-mode small {
  color: #8b84bd;
}

.supply-badge[hidden] {
  display: none;
}

.board-area {
  min-height: 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.canvas-stage {
  position: relative;
  flex: none;
  border-radius: 28px;
  background: #fffdfd;
  box-shadow:
    0 24px 54px rgba(83, 97, 153, 0.2),
    0 4px 12px rgba(83, 97, 153, 0.08),
    inset 0 0 0 1px rgba(255, 255, 255, 0.95);
  touch-action: none;
}

.canvas-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(120, 138, 188, 0.09);
  pointer-events: none;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 28px;
  background: #fbfbff;
  touch-action: none;
  cursor: crosshair;
}

.tutorial-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  border-radius: 28px;
  pointer-events: none;
}

.play-status {
  min-height: 51px;
  padding: 0 5px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.gesture-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #626e89;
  font-size: 11px;
  font-weight: 800;
}

.supply-badge,
.moves-badge {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 7px;
  border-radius: 999px;
  border: 1px solid rgba(126, 145, 195, 0.14);
  background: rgba(255, 255, 255, 0.66);
  color: #76819a;
  font-size: 10px;
  line-height: 1;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.supply-badge b,
.moves-badge b {
  color: #4d5880;
  font-size: 11.5px;
  font-weight: 900;
}

.supply-badge.empty {
  opacity: 0.55;
}

.feedback {
  height: 34px;
  overflow: hidden;
  color: #5d5796;
  font-size: 11.5px;
  line-height: 1.45;
  font-weight: 700;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.actionbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.35fr);
  gap: 6px;
  padding: 6px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.82);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.58));
  box-shadow:
    0 12px 30px rgba(91, 105, 158, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.action-btn {
  min-width: 0;
  min-height: 52px;
  padding: 5px 3px;
  border-radius: 16px;
  border: 1px solid rgba(126, 145, 195, 0.13);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(241, 244, 255, 0.92));
  color: #5a6683;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  font-size: 10.5px;
  line-height: 1.25;
  font-weight: 850;
  box-shadow:
    inset 0 1px 0 #fff,
    0 2px 6px rgba(86, 100, 151, 0.07);
  transition: transform 0.14s ease, box-shadow 0.14s ease, opacity 0.14s ease;
}

.action-icon {
  font-size: 17px;
  line-height: 1;
  color: #7568c8;
}

.action-btn.primary {
  border-color: transparent;
  background: linear-gradient(135deg, #7d6be0 0%, #a17ae8 48%, #ef88aa 100%);
  color: #fff;
  box-shadow:
    0 8px 18px rgba(107, 82, 200, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.34);
}

.action-btn.primary .action-icon {
  color: #fff;
}

.action-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.action-btn:disabled {
  opacity: 0.42;
  box-shadow: none;
}

.sheet {
  width: min(560px, 100%);
  max-width: 560px;
  max-height: 88dvh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  overflow: visible;
}

.sheet::backdrop {
  background: rgba(36, 32, 72, 0.36);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.sheet-card {
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  border-radius: 26px 26px 0 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.99), rgba(250, 251, 255, 0.98));
  box-shadow: 0 -18px 56px rgba(45, 42, 94, 0.26);
  overflow: hidden;
}

.sheet-handle {
  width: 42px;
  height: 5px;
  flex: none;
  margin: 8px auto 1px;
  border-radius: 999px;
  background: #d9def0;
}

.sheet-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 18px 11px;
  border-bottom: 1px solid var(--line);
}

.sheet-head h2 {
  margin-top: 2px;
  font-size: 19px;
  line-height: 1.2;
  font-weight: 950;
  letter-spacing: -0.2px;
}

.sheet-close {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  background: #f0f2fa;
  color: #697492;
  font-size: 15px;
  font-weight: 900;
}

.sheet-scroll {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0 18px calc(24px + var(--safe-bottom));
}

.sheet-section {
  padding: 14px 0 15px;
  border-bottom: 1px solid var(--line);
}

.sheet-section:last-child {
  border-bottom: 0;
}

.sheet-section h3 {
  margin-bottom: 8px;
  color: #7e72c4;
  font-size: 10.5px;
  line-height: 1.2;
  font-weight: 950;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.desc {
  color: var(--ink-soft);
  font-size: 12.5px;
  line-height: 1.7;
}

.level-nav {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.nav-group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  color: #5d6780;
  font-size: 11.5px;
  font-weight: 850;
}

.nav-group-head small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.level-card {
  position: relative;
  min-width: 0;
  min-height: 62px;
  padding: 8px 9px;
  border-radius: 14px;
  border: 1px solid rgba(126, 145, 195, 0.15);
  background: linear-gradient(180deg, #fff, #f7f8fd);
  color: #5a6683;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-content: center;
  gap: 0 8px;
  text-align: left;
  box-shadow: 0 2px 7px rgba(85, 99, 150, 0.06);
}

.level-number {
  grid-row: 1 / 3;
  align-self: center;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: #f0eeff;
  color: #7565cb;
  font-size: 11.5px;
  font-weight: 950;
  font-variant-numeric: tabular-nums;
}

.level-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #39445f;
  font-size: 12px;
  font-weight: 850;
}

.level-state {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #929cb2;
  font-size: 9.5px;
  font-weight: 700;
}

.level-card.active {
  border-color: #8d7ce0;
  background: linear-gradient(180deg, #f7f4ff, #efebff);
  box-shadow: inset 0 0 0 1px #8d7ce022;
}

.level-card.won .level-number {
  background: #e5f8ef;
  color: #2f9d78;
}

.level-card.locked {
  opacity: 0.48;
}

.level-badge {
  position: absolute;
  right: 9px;
  top: 7px;
  color: #2f9d78;
  font-size: 10px;
  font-style: normal;
  font-weight: 950;
}

.rules {
  color: #5f6b84;
  font-size: 12px;
  line-height: 1.72;
}

.rules p + p {
  margin-top: 6px;
}

.rules b {
  color: #35415e;
}

.coach {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.coach-ring {
  position: absolute;
  width: 58px;
  height: 58px;
  transform: translate(-50%, -50%);
  border: 3px solid #e9a92b;
  border-radius: 50%;
  background: radial-gradient(circle, #fff7dd66 0, #fff7dd00 68%);
  box-shadow:
    0 0 0 9px rgba(233, 169, 43, 0.14),
    0 0 22px rgba(233, 169, 43, 0.3);
  animation: coachPulse 1.5s ease-in-out infinite;
}

.coach-drag {
  position: absolute;
  left: 9%;
  top: 54.5%;
  width: 92px;
  height: 5px;
  border-radius: 4px;
  background: linear-gradient(90deg, rgba(233, 169, 43, 0), #e9a92b 45%, #e9a92b);
  transform: translateY(-50%);
  filter: drop-shadow(0 2px 4px rgba(233, 169, 43, 0.26));
  animation: coachDrag 1.5s ease-in-out infinite;
}

.coach-drag::after {
  content: "";
  position: absolute;
  right: -10px;
  top: 50%;
  border-left: 12px solid #e9a92b;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  transform: translateY(-50%);
}

.coach:not(.coach-squeeze) .coach-drag {
  display: none;
}

.coach-card {
  position: absolute;
  left: 50%;
  top: 2.5%;
  transform: translateX(-50%);
  width: min(88%, 330px);
  padding: 10px 12px 9px;
  border-radius: 17px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: linear-gradient(150deg, rgba(55, 49, 100, 0.96), rgba(74, 61, 132, 0.93));
  color: #fff;
  box-shadow: 0 14px 30px rgba(35, 30, 73, 0.3);
  display: flex;
  flex-direction: column;
  gap: 2px;
  pointer-events: none;
}

.coach-card strong {
  font-size: 13.5px;
  line-height: 1.2;
  font-weight: 900;
}

.coach-card span {
  color: #ece8ff;
  font-size: 11.5px;
  line-height: 1.5;
}

.coach-skip {
  min-height: 42px;
  margin-top: 3px;
  align-self: flex-end;
  padding: 8px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 11px;
  font-weight: 850;
  pointer-events: auto;
}

.supply-badge.coach-target {
  outline: 2px solid #e9a92b;
  outline-offset: 2px;
  animation: coachPulse 1.5s ease-in-out infinite;
}

@keyframes coachPulse {
  0%,
  100% {
    opacity: 0.72;
  }
  50% {
    opacity: 1;
  }
}

@keyframes coachDrag {
  0%,
  100% {
    transform: translateY(-50%) translateX(0);
    opacity: 0.5;
  }
  50% {
    transform: translateY(-50%) translateX(16px);
    opacity: 1;
  }
}

@media (min-width: 700px) {
  .app {
    max-width: 560px;
    padding-top: calc(20px + var(--safe-top));
    padding-bottom: calc(20px + var(--safe-bottom));
  }

  .sheet {
    margin: auto;
    max-height: 86dvh;
  }

  .sheet-card {
    max-height: 86dvh;
    border-radius: 28px;
  }

  .sheet-handle {
    display: none;
  }

  .sheet-head {
    padding-top: 16px;
  }
}

@media (max-height: 640px) {
  .app {
    gap: 5px;
    padding-top: calc(5px + var(--safe-top));
    padding-bottom: calc(5px + var(--safe-bottom));
  }

  .topbar {
    padding: 7px 11px 6px;
    gap: 5px;
  }

  .level-title {
    font-size: 19px;
  }

  .level-tag {
    display: none;
  }

  .goal-row {
    min-height: 23px;
  }

  .goal-chip {
    min-height: 23px;
    padding: 2px 7px;
  }

  .extra-goal {
    min-height: 21px;
  }

  .action-btn {
    min-height: 46px;
  }

  .play-status {
    min-height: 43px;
  }

  .feedback {
    height: 29px;
    font-size: 11px;
  }
}

@media (max-width: 400px) {
  /* 窄屏顶栏：难度标签是装饰性信息，让位给关卡序号与音乐/音效开关；
     与竖屏低高度时隐藏标签的策略一致，避免整行溢出把音量按钮推出视口。 */
  .eyebrow-row {
    gap: 5px;
  }

  .level-tag {
    display: none;
  }

  .sound-toggle {
    width: 28px;
    height: 28px;
    font-size: 13px;
  }
}

@media (max-width: 360px) {
  .app {
    padding-left: calc(7px + var(--safe-left));
    padding-right: calc(7px + var(--safe-right));
  }

  .topbar {
    padding-left: 10px;
    padding-right: 10px;
  }

  .coach-card {
    top: 1.5%;
    width: min(94%, 330px);
    padding: 7px 10px 6px;
    gap: 1px;
  }

  .coach-card strong {
    font-size: 12.5px;
  }

  .coach-card span {
    font-size: 10.5px;
    line-height: 1.4;
  }

  .coach-skip {
    min-height: 38px;
    margin-top: 2px;
    padding: 6px 12px;
    font-size: 10.5px;
  }

  .goal-chip {
    font-size: 10px;
  }

  .goal-chip strong {
    font-size: 11px;
  }

  .action-btn {
    font-size: 9.5px;
  }

  .level-grid {
    grid-template-columns: 1fr;
  }
}

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