:root {
  color-scheme: light;
  --ink: #172326;
  --muted: #647477;
  --line: rgba(255, 255, 255, 0.52);
  --glass: rgba(255, 255, 255, 0.56);
  --glass-strong: rgba(255, 255, 255, 0.72);
  --accent: #237a74;
  --accent-strong: #165f5a;
  --danger: #c5564a;
  --gold: #bf8a36;
  --sky: #5378a8;
  --violet: #7e6caf;
  --shadow: 0 24px 70px rgba(35, 55, 48, 0.2);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  background:
    linear-gradient(135deg, rgba(47, 122, 116, 0.16), transparent 34%),
    linear-gradient(32deg, transparent 48%, rgba(191, 138, 54, 0.13) 49%, transparent 67%),
    linear-gradient(180deg, #edf5ed 0%, #e5eee8 52%, #f3f6f0 100%);
  color: var(--ink);
  font-family:
    "Microsoft YaHei",
    "Noto Sans SC",
    "PingFang SC",
    system-ui,
    sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(115deg, transparent 0 20%, rgba(255, 255, 255, 0.42) 34%, transparent 46%),
    linear-gradient(250deg, transparent 0 55%, rgba(83, 120, 168, 0.12) 68%, transparent 78%);
  mix-blend-mode: screen;
}

button,
input {
  font: inherit;
}

button {
  min-height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0)),
    linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.42),
    0 10px 22px rgba(28, 99, 93, 0.18);
  color: #fff;
  cursor: pointer;
  padding: 0 14px;
  transition:
    transform 120ms ease,
    filter 120ms ease,
    opacity 120ms ease;
  white-space: nowrap;
}

button:hover:not(:disabled) {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.app-shell {
  position: relative;
  display: grid;
  grid-template-columns: minmax(380px, 430px) minmax(860px, 1fr);
  gap: 12px;
  width: min(1620px, calc(100vw - 20px));
  margin: 10px auto;
  align-items: start;
}

.game-stage,
.speech-panel {
  border: 1px solid var(--line);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.36)),
    rgba(255, 255, 255, 0.42);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(1.35);
}

.game-stage {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 980 / 620;
}

.speech-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: none;
  overflow: visible;
  border-radius: 16px;
  padding: 14px 14px 16px;
  height: auto;
  min-height: 620px;
}

.speech-panel::before {
  content: "";
  position: absolute;
  inset: 1px 1px auto;
  height: 92px;
  border-radius: 17px 17px 34px 34px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.speech-panel > * {
  position: relative;
}

.brand-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  align-items: center;
}

.brand-row h1 {
  margin: 0;
  font-size: clamp(22px, 2.15vw, 30px);
  line-height: 0.98;
}

.brand-row h1 {
  margin: 0;
  font-size: clamp(20px, 2vw, 26px);
  line-height: 0.98;
}

.brand-actions {
  display: none;
}

.map-controls {
  position: absolute;
  top: 8px;
  right: 12px;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
  align-items: center;
}

.map-controls .lang-switch,
.map-controls .script-switch,
.map-controls .difficulty-switch,
.map-controls .map-switch {
  padding: 1px;
  border-color: rgba(255, 255, 255, 0.46);
  background: rgba(255, 255, 255, 0.34);
  backdrop-filter: blur(14px) saturate(1.2);
}

.map-controls .lang-btn,
.map-controls .script-btn,
.map-controls .difficulty-btn,
.map-controls .map-stage-btn {
  min-height: 24px;
  padding: 0 6px;
  font-size: 9px;
}

.map-controls #startBtn,
.map-controls #pauseBtn {
  min-height: 28px;
  padding: 0 10px;
  font-size: 10px;
}

#pauseBtn {
  min-height: 26px;
  padding: 0 10px;
  font-size: 10px;
  font-weight: 900;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0)),
    linear-gradient(135deg, #5378a8, #7665a8);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.42),
    0 8px 18px rgba(76, 111, 159, 0.18);
}

.lang-switch,
.script-switch,
.difficulty-switch {
  display: grid;
  grid-template-columns: repeat(2, auto);
  gap: 3px;
  padding: 2px;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.46);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.58);
}

.difficulty-switch {
  grid-template-columns: repeat(5, auto);
}

.lang-btn,
.script-btn,
.difficulty-btn {
  min-height: 26px;
  padding: 0 7px;
  background: transparent;
  box-shadow: none;
  color: #435356;
  font-size: 10px;
}

.lang-btn.active,
.script-btn.active,
.difficulty-btn.active {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent),
    linear-gradient(135deg, #5378a8, #237a74);
  color: #fff;
  box-shadow: 0 6px 14px rgba(35, 122, 116, 0.18);
}

h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1;
  letter-spacing: 0;
}

.brand-row p,
.status-line {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.meter-grid div,
.prompt-box,
.ready-box {
  border: 1px solid rgba(255, 255, 255, 0.64);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.42)),
    rgba(255, 255, 255, 0.42);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    0 10px 24px rgba(45, 62, 57, 0.1);
}

.meter-grid div {
  min-width: 0;
  border-radius: 12px;
  padding: 6px 8px;
}

.meter-grid span {
  display: block;
  color: var(--muted);
  font-size: 10px;
}

.meter-grid strong {
  display: block;
  margin-top: 2px;
  font-size: 18px;
  line-height: 1;
}

.legacy-meta {
  display: none !important;
}

.hsk-picker {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto auto;
  gap: 5px;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 12px;
  padding: 5px;
  background: rgba(255, 255, 255, 0.42);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.54);
}

.hsk-picker label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
}

.hsk-picker select {
  width: 100%;
  min-height: 28px;
  border: 0;
  border-radius: 999px;
  padding: 0 28px 0 10px;
  color: #263437;
  font-size: 12px;
  font-weight: 900;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0.48)),
    rgba(255, 255, 255, 0.58);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.66),
    0 7px 16px rgba(45, 62, 57, 0.1);
}

.csv-import-btn {
  display: grid;
  place-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  color: #fff !important;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.2), transparent),
    linear-gradient(135deg, #b98127, #237a74);
  box-shadow: 0 8px 18px rgba(53, 100, 92, 0.18);
  cursor: pointer;
}

.monster-level-label,
.monster-level-select {
  font-size: 11px;
}

.monster-level-label {
  color: var(--muted);
  font-weight: 900;
}

.monster-level-select {
  min-height: 28px;
  border: 0;
  border-radius: 999px;
  padding: 0 24px 0 10px;
  color: #263437;
  font-weight: 900;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0.48)),
    rgba(255, 255, 255, 0.58);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.66),
    0 7px 16px rgba(45, 62, 57, 0.1);
}

.hidden {
  display: none !important;
}

#csvImportInput {
  display: none;
}

.hsk-btn {
  display: none;
  min-height: 28px;
  padding: 0 6px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.52);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
  color: #263437;
}

.hsk-btn.active {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent),
    linear-gradient(135deg, #5378a8, #237a74);
  color: #fff;
}

/* prompt-box 是正文阅读区域：正常占位，不再用超大 padding 撑空间 */
.prompt-box {
  display: flex;
  flex-direction: column;
  align-content: stretch;
  justify-content: flex-start;
  border-radius: 12px;
  min-height: 360px;
  height: auto;
  padding: 12px 13px 14px;
  overflow: visible;
  scrollbar-width: thin;
  flex: 0 0 auto;
}

.prompt-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
  flex: 0 0 auto;
}

.prompt-topline button {
  min-height: 28px;
  padding: 0 9px;
  background: rgba(255, 255, 255, 0.58);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.64);
  color: var(--accent-strong);
}

.hanzi {
  display: grid;
  align-items: start;
  margin: 10px 0 0;
  font-size: clamp(23px, 1.6vw, 31px);
  font-weight: 800;
  font-family:
    "Noto Serif SC",
    "Source Han Serif SC",
    "SimSun",
    "Songti SC",
    "Microsoft YaHei",
    serif;
  line-height: 1.18;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  min-height: 0;
  flex: 1 1 auto;
}

.hanzi.imported-layout {
  grid-template-rows: auto auto auto;
  gap: 14px;
  align-content: start;
}

/* 当前要读的段落 */
.prompt-current {
  display: block;
  color: var(--ink);
  align-self: start;
  overflow: visible;
  text-overflow: clip;
  font-size: 1.18em;
  line-height: 1.22;
  margin: 0;
  font-weight: 700;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.hanzi.imported-layout .prompt-current {
  align-self: start;
  font-size: 1.20em;
  line-height: 1.16;
  margin: 0;
}

.prompt-context {
  display: block;
  color: rgba(91, 102, 105, 0.82);
  font-size: 12px;
  line-height: 1.18;
  font-weight: 700;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  overflow: visible;
}

.prompt-context-prev {
  align-self: start;
  margin: 0;
  max-height: none;
  font-size: 0.50em;
  line-height: 1.35;
  opacity: 0.74;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.prompt-context-next {
  align-self: start;
  margin: 0;
  max-height: none;
  font-size: 0.55em;
  line-height: 1.35;
  opacity: 0.78;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.pinyin {
  margin: 0;
  color: var(--accent-strong);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.english {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.hidden-line {
  color: #8d9c9d;
}

/* 底部朗读/输入/匹配区域：回到正常文档流，不再悬浮遮挡正文 */
.speech-controls {
  position: static;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
  padding-top: 8px;
  min-height: auto;
  margin-top: auto;
  background: transparent;
  box-shadow: none;
  z-index: auto;
}
.voice-state {
  display: none;
  grid-column: 1 / -1;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.56);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.58),
    0 10px 22px rgba(45, 62, 57, 0.1);
  padding: 6px 9px;
}

.voice-dot {
  width: 15px;
  height: 15px;
  border-radius: 999px;
  background: #8aa09b;
  box-shadow: 0 0 0 6px rgba(138, 160, 155, 0.16);
}

.voice-state strong,
.voice-state small {
  display: block;
  min-width: 0;
}

.voice-state strong {
  font-size: 13px;
  line-height: 1.1;
}

.voice-state small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.voice-state.listening {
  background:
    linear-gradient(135deg, rgba(255,255,255,0.82), rgba(218, 244, 236, 0.66)),
    rgba(255,255,255,0.5);
  border-color: rgba(35, 122, 116, 0.5);
}

.voice-state.listening .voice-dot {
  background: #18a58d;
  box-shadow:
    0 0 0 6px rgba(24, 165, 141, 0.16),
    0 0 24px rgba(24, 165, 141, 0.62);
  animation: listenPulse 920ms ease-in-out infinite;
}

.voice-state.success .voice-dot {
  background: #d6a63f;
  box-shadow: 0 0 0 6px rgba(214, 166, 63, 0.18);
}

.voice-state.error .voice-dot {
  background: var(--danger);
  box-shadow: 0 0 0 6px rgba(197, 86, 74, 0.16);
}

@keyframes listenPulse {
  0%,
  100% {
    transform: scale(0.9);
  }

  50% {
    transform: scale(1.22);
  }
}

.listen-button {
  min-height: 37px;
  padding: 0 14px;
  font-size: 15px;
  font-weight: 800;
}

.speech-panel[data-voice="listening"] .listen-button,
.speech-panel[data-voice="processing"] .listen-button {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.2), transparent),
    linear-gradient(135deg, #d65f45, #b93434);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.42),
    0 0 0 5px rgba(214, 95, 69, 0.16),
    0 14px 28px rgba(185, 52, 52, 0.24);
}

#speechInput,
#submitSpeechBtn,
.confirm-hint,
.match-feedback {
  grid-column: auto;
}

#submitSpeechBtn {
  min-height: 52px;
  margin-top: 4px;
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 0.03em;
}

.fire-button {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.02)),
    linear-gradient(135deg, #b85f22, #d9892f 48%, #f2ba49);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.48),
    0 14px 30px rgba(170, 96, 27, 0.26),
    0 0 0 4px rgba(242, 186, 73, 0.14);
}

.fire-button::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 0 38%, rgba(255, 250, 226, 0.4) 48%, transparent 58%);
  transform: translateX(-42%);
}

.speech-panel[data-fire-mode="combo"] .fire-button {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0.02)),
    linear-gradient(135deg, #7a2f30, #b4443f 50%, #eb8d53);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.46),
    0 16px 34px rgba(138, 39, 40, 0.28),
    0 0 0 5px rgba(216, 95, 69, 0.18);
}

#submitSpeechBtn:disabled {
  color: rgba(255, 255, 255, 0.9);
}

#submitSpeechBtn[hidden] {
  display: none !important;
}

.confirm-hint {
  margin-top: 4px;
  padding: 0 4px;
  color: #5f6d6f;
  font-size: 12px;
  line-height: 1.4;
  text-align: center;
}

.speech-panel[data-fire-mode="combo"] .confirm-hint {
  color: #7b5c58;
}

.match-feedback {
  position: static;
  display: grid;
  gap: 5px;
  padding: 8px 9px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.68), rgba(255, 255, 255, 0.42)),
    rgba(255, 255, 255, 0.44);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    0 8px 18px rgba(45, 62, 57, 0.08);
  min-height: auto;
  max-height: none;
  overflow: visible;
  z-index: 2;
}

.match-feedback[hidden] {
  display: none;
}

.match-feedback.success {
  border-color: rgba(38, 115, 106, 0.42);
}

.match-feedback.error {
  border-color: rgba(197, 86, 74, 0.42);
}

.match-feedback-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  font-weight: 900;
}

.match-feedback.success .match-feedback-head {
  color: var(--accent);
}

.match-feedback.error .match-feedback-head {
  color: var(--danger);
}

.match-feedback-score,
.match-feedback-transcript {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.25;
}

.match-feedback-row {
  display: flex;
  gap: 8px;
  align-items: baseline;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.25;
}

.match-feedback-row strong {
  color: var(--ink);
  font-size: 10px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
}

.match-feedback-segments {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 3px;
  align-items: center;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.3;
}

.match-char {
  min-width: 1em;
  text-align: center;
  border-radius: 6px;
  padding: 1px 3px;
  background: rgba(138, 160, 155, 0.12);
  color: var(--muted);
}

.match-feedback .match-char {
  white-space: nowrap;
}

.match-char.ok {
  background: rgba(38, 115, 106, 0.14);
  color: var(--accent);
}

.match-char.miss {
  background: rgba(197, 86, 74, 0.12);
  color: var(--danger);
}

.match-char.neutral {
  background: transparent;
  color: var(--muted);
}

input {
  min-width: 0;
  min-height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.66);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  box-shadow: inset 0 1px 6px rgba(45, 62, 57, 0.08);
  color: var(--ink);
  padding: 0 10px;
  font-size: 12px;
  outline: none;
}

input:focus {
  border-color: rgba(35, 122, 116, 0.56);
  box-shadow:
    inset 0 1px 6px rgba(45, 62, 57, 0.08),
    0 0 0 3px rgba(35, 122, 116, 0.16);
}

.ready-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  border-radius: 12px;
  padding: 7px 9px;
}

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

.stage-ui > * {
  pointer-events: auto;
}

.map-hud {
  position: absolute;
  top: 8px;
  left: 14px;
  z-index: 2;
  display: grid;
  gap: 4px;
  max-width: calc(100% - 210px);
  color: rgba(23, 35, 38, 0.96);
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.82),
    0 0 8px rgba(255, 255, 255, 0.58);
}

.map-hud-line {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  font-size: 12px;
  font-weight: 800;
}

.map-hud-line.secondary {
  font-size: 11px;
  color: rgba(56, 71, 74, 0.92);
}

.map-hud-line strong {
  color: #153236;
  font-size: 14px;
  font-weight: 900;
}

.shop-dock {
  position: absolute;
  left: 175px;
  right: 18px;
  bottom: 6px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.shop-heading {
  display: none;
}

.shop-heading strong {
  color: #263437;
  font-size: 11px;
  line-height: 1;
}

.shop-heading span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
}

#autoBuildBtn {
  display: none;
}

.call-wave-btn {
  position: absolute;
  top: 56px;
  right: 12px;
  min-height: 34px;
  padding: 0 13px;
  font-size: 12px;
  font-weight: 900;
  color: #fff;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.2), transparent),
    linear-gradient(135deg, #b98127, #237a74);
  box-shadow: 0 10px 24px rgba(53, 100, 92, 0.24);
}

.call-wave-btn[hidden] {
  display: none;
}

.unit-kind-picker {
  display: flex;
  gap: 4px;
  margin-top: 0;
}

.item-kind-picker {
  display: flex;
  gap: 4px;
}

.target-mode-panel {
  display: none !important;
  margin-top: 7px;
}

.ready-box.selected .target-mode-panel {
  display: none;
}

.target-mode-label {
  display: block;
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
}

.target-mode-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.unit-kind-btn,
.item-kind-btn,
.target-mode-btn {
  min-height: 24px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  background: transparent;
  opacity: 0.7;
  box-shadow: none;
}

.unit-kind-btn {
  display: grid;
  grid-template-rows: 30px auto auto;
  gap: 2px;
  align-content: center;
  justify-items: center;
  min-height: 58px;
  min-width: 80px;
  padding: 1px 4px;
  line-height: 1.05;
  border: 0;
  border-radius: 0;
}

.item-kind-btn {
  display: grid;
  grid-template-rows: 30px auto auto;
  gap: 2px;
  align-content: center;
  justify-items: center;
  min-height: 58px;
  min-width: 80px;
  padding: 1px 4px;
  line-height: 1.05;
  border: 0;
  border-radius: 0;
}

.unit-kind-btn img {
  width: 26px;
  height: 26px;
  object-fit: contain;
  filter: drop-shadow(0 5px 5px rgba(34, 47, 43, 0.16));
}

.unit-kind-btn span,
.item-kind-btn span {
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hsk-picker .hsk-btn {
  display: none !important;
}

.unit-kind-btn small,
.item-kind-btn small {
  color: #bf8a36;
  font-size: 10px;
  font-weight: 900;
}

.unit-kind-btn.active small,
.item-kind-btn.active small {
  color: #fff4c6;
}

.unit-kind-btn.active,
.item-kind-btn.active,
.target-mode-btn.active {
  color: #1c413f;
  opacity: 1;
  background: transparent;
}

.shop-item-glyph {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: rgba(32, 69, 66, 0.9);
  background: transparent;
  box-shadow: none;
}

.shop-item-glyph.bomb {
  color: #b44b3e;
}

.shop-item-glyph.thunder {
  color: #3d5fb8;
}

.shop-action-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 0;
}

.shop-action-row button {
  min-height: 40px;
  padding: 0 14px;
  font-size: 12px;
  font-weight: 900;
}

.shop-action-row button:disabled {
  opacity: 0.48;
  filter: grayscale(0.35);
  cursor: not-allowed;
}

#buyUnitBtn {
  color: #fff;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent),
    linear-gradient(135deg, #bf8a36, #237a74);
}

#upgradeUnitBtn {
  color: #fff;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent),
    linear-gradient(135deg, #7665a8, #4c6f9f);
}

.ready-box.armed {
  border-color: rgba(35, 122, 116, 0.52);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.78), rgba(210, 235, 228, 0.62)),
    rgba(255, 255, 255, 0.48);
}

.shop-dock.ready-box.armed,
.shop-dock.ready-box.selected {
  border: 0;
  background: transparent;
  box-shadow: none;
}

.game-stage.paused::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(241, 246, 239, 0.2);
  pointer-events: none;
}

.map-controls .lang-switch,
.map-controls .script-switch,
.map-controls #startBtn,
.map-controls #pauseBtn {
  box-shadow: none;
}

.map-controls #startBtn {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0)),
    linear-gradient(135deg, #2f857f, #237a74);
}

.map-controls #pauseBtn {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0)),
    linear-gradient(135deg, #6677b2, #7e6caf);
}

#readyText {
  display: none;
}

.speech-panel.imported-mode .pinyin,
.speech-panel.imported-mode .english {
  display: none !important;
}

/* HSK / 默认模式：汉字、拼音、英文解释分开排版，但不把拼音推到底部 */
.speech-panel:not(.imported-mode) .prompt-box {
  min-height: 380px;
}

.speech-panel:not(.imported-mode) .hanzi {
  display: block;
  flex: 0 0 auto;
  margin: 22px 0 0;
  font-size: clamp(30px, 2.6vw, 42px);
  line-height: 1.18;
}

.speech-panel:not(.imported-mode) .pinyin {
  flex: 0 0 auto;
  margin: 10px 0 0;
  font-size: 14px;
  line-height: 1.35;
  color: var(--accent-strong);
}

.speech-panel:not(.imported-mode) .english {
  flex: 0 0 auto;
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--muted);
}

/* 导入书籍模式：正文框自己撑开，底部控制区在正文后面自然排列 */
.speech-panel.imported-mode .prompt-box {
  min-height: 520px;
  padding-bottom: 18px;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
    width: min(100vw - 20px, 1080px);
  }

  .speech-panel {
    height: auto;
    max-height: none;
  }

  .shop-dock {
    left: 148px;
    right: 12px;
    bottom: 12px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100vw - 14px, 980px);
    margin: 7px auto;
    gap: 10px;
  }

  .speech-panel {
    padding: 11px;
  }

  .brand-row {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .brand-actions {
    justify-content: flex-start;
  }

  .hsk-picker {
    grid-template-columns: repeat(2, 1fr);
  }

  .shop-dock {
    left: 10px;
    right: 10px;
    bottom: 10px;
    flex-wrap: wrap;
  }

  .map-hud {
    max-width: calc(100% - 110px);
  }
}
