:root {
  --font-ui: "Avenir Next", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Heiti TC", sans-serif;
  --font-type: "Menlo", "Consolas", "Courier New", monospace;
  --ink: #23395b;
  --ink-soft: #4c5d78;
  --ink-faint: #71809a;
  --cream: #fff9ec;
  --cream-strong: #fffdf6;
  --sky: #bfe8ff;
  --grass: #4fbf6a;
  --grass-dark: #237a45;
  --sun: #ffd166;
  --sun-dark: #d79a24;
  --coral: #f08a5d;
  --coral-dark: #a84320;
  --purple: #8b7cf6;
  --purple-dark: #4b3aaf;
  --red: #e85d5d;
  --red-dark: #a92f3a;
  --blue: #58a6ff;
  --blue-dark: #255fa8;
  --shadow-soft: 0 18px 40px rgba(35, 57, 91, 0.14);
  --shadow-card: 0 10px 24px rgba(35, 57, 91, 0.12);
  --shadow-lift: 0 22px 48px rgba(35, 57, 91, 0.22);
  --radius-xl: 34px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --scene-bg: url("../assets/images/bg-menu.jpg");
  --scene-tint: rgba(20, 52, 84, 0.28);
  --topbar-h: 68px;
  --footer-h: 28px;
  --key-h: clamp(34px, 5vh, 46px);
  --key-w: clamp(42px, 4.1vw, 56px);
  --focus-ring: 0 0 0 4px rgba(255, 209, 102, 0.9), 0 0 0 7px rgba(35, 57, 91, 0.45);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-width: 900px;
  min-height: 100vh;
  overflow: hidden;
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--sky);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

img {
  max-width: 100%;
  display: block;
}

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

ul {
  padding: 0;
  list-style: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden,
[hidden] {
  display: none !important;
}

/* ---------- 背景 ---------- */

.sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 76% 18%, rgba(255, 241, 174, 0.9), transparent 28%),
    linear-gradient(180deg, #cdeeff 0%, #e8f7ff 52%, #fdf5df 100%);
}

.sky::before {
  content: "";
  position: absolute;
  inset: -16px;
  background-image: var(--scene-bg);
  background-size: cover;
  background-position: center;
  opacity: 0.86;
  filter: saturate(1.02);
  transition: opacity 0.8s ease, filter 0.8s ease;
}

.sky::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(15, 44, 75, 0.18) 0%, rgba(15, 44, 75, 0.04) 42%, rgba(255, 249, 236, 0.08) 100%),
    radial-gradient(circle at 50% 48%, transparent 20%, rgba(15, 44, 75, 0.16) 100%);
  pointer-events: none;
}

.sky__cloud {
  position: absolute;
  width: 280px;
  height: 90px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  filter: blur(2px);
  animation: cloud-drift 26s ease-in-out infinite alternate;
}

.sky__cloud::before,
.sky__cloud::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: inherit;
}

.sky__cloud::before {
  width: 120px;
  height: 120px;
  left: 34px;
  bottom: 20px;
}

.sky__cloud::after {
  width: 86px;
  height: 86px;
  right: 40px;
  bottom: 10px;
}

.sky__cloud--one {
  top: 12%;
  left: -60px;
  opacity: 0.62;
}

.sky__cloud--two {
  top: 30%;
  right: -80px;
  transform: scale(0.9);
  opacity: 0.5;
  animation-delay: -9s;
}

.sky__cloud--three {
  bottom: 12%;
  left: 20%;
  transform: scale(0.65);
  opacity: 0.38;
  animation-delay: -17s;
}

@keyframes cloud-drift {
  from { transform: translate3d(-16px, 0, 0); }
  to { transform: translate3d(26px, -10px, 0); }
}

/* ---------- 版面 ---------- */

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding-bottom: var(--footer-h);
  display: flex;
  flex-direction: column;
}

.topbar {
  flex: 0 0 auto;
  height: var(--topbar-h);
  padding: 0 clamp(18px, 2.4vw, 34px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: rgba(255, 253, 246, 0.78);
  border-bottom: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 8px 22px rgba(35, 57, 91, 0.08);
  backdrop-filter: blur(16px) saturate(1.15);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 0;
  background: transparent;
  padding: 4px;
  border-radius: 16px;
  cursor: pointer;
  text-align: left;
}

.brand:focus-visible,
.icon-button:focus-visible,
.button:focus-visible,
.level-node:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.brand__mark {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  color: var(--cream);
  background: linear-gradient(145deg, #65d780, var(--grass-dark));
  box-shadow: 0 6px 0 rgba(35, 122, 69, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 1px;
}

.brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand__text strong {
  font-size: 18px;
  letter-spacing: 0.05em;
}

.brand__text small {
  margin-top: 3px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-faint);
  letter-spacing: 0.16em;
}

.topbar__stats {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(35, 57, 91, 0.1);
  box-shadow: 0 3px 8px rgba(35, 57, 91, 0.06);
}

.pill--star {
  color: #8b5c00;
  background: linear-gradient(180deg, #fff3c9, #ffe49a);
  border-color: rgba(215, 154, 36, 0.35);
}

.pill--star > span:first-child {
  font-size: 17px;
  color: #e3a51e;
  text-shadow: 0 1px 0 #fff;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(35, 57, 91, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.icon-button svg {
  width: 21px;
  height: 21px;
}

.icon-button:hover {
  background: #fff;
  transform: translateY(-2px);
  box-shadow: 0 7px 16px rgba(35, 57, 91, 0.14);
}

.icon-button:active {
  transform: translateY(0) scale(0.96);
}

main {
  flex: 1 1 auto;
  min-height: 0;
}

.screen {
  display: none;
  height: calc(100vh - var(--topbar-h) - var(--footer-h));
  min-height: 0;
}

.screen.is-active {
  display: block;
}

/* ---------- 共用元件 ---------- */

.section-kicker {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.2em;
  color: var(--ink-faint);
  text-transform: uppercase;
}

.button {
  --btn-bg: #fff;
  --btn-ink: var(--ink);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 20px;
  border: 1px solid rgba(35, 57, 91, 0.1);
  border-radius: 15px;
  background: var(--btn-bg);
  color: var(--btn-ink);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
  box-shadow: 0 4px 0 rgba(35, 57, 91, 0.12);
}

.button:hover {
  transform: translateY(-2px);
  box-shadow: 0 7px 0 rgba(35, 57, 91, 0.12), 0 14px 24px rgba(35, 57, 91, 0.12);
  filter: brightness(1.015);
}

.button:active {
  transform: translateY(1px);
  box-shadow: 0 2px 0 rgba(35, 57, 91, 0.14);
}

.button--large {
  min-height: 58px;
  padding: 0 26px;
  font-size: 19px;
  border-radius: 18px;
}

.button--primary {
  --btn-bg: linear-gradient(180deg, #6cdb87, var(--grass));
  --btn-ink: #123d28;
  border-color: rgba(35, 122, 69, 0.35);
  box-shadow: 0 5px 0 var(--grass-dark), 0 14px 24px rgba(35, 122, 69, 0.2);
}

.button--primary:hover {
  box-shadow: 0 8px 0 var(--grass-dark), 0 18px 30px rgba(35, 122, 69, 0.24);
}

.button--soft {
  --btn-bg: #fff2d2;
  --btn-ink: #6d4a00;
  border-color: rgba(215, 154, 36, 0.24);
}

.button--ghost {
  --btn-bg: rgba(255, 255, 255, 0.55);
  --btn-ink: var(--ink-soft);
  border-color: rgba(35, 57, 91, 0.12);
  box-shadow: none;
}

.button--ghost:hover {
  --btn-bg: #fff;
  box-shadow: 0 7px 16px rgba(35, 57, 91, 0.1);
}

.button--danger-soft {
  --btn-bg: #ffe5e2;
  --btn-ink: var(--red-dark);
  border-color: rgba(169, 47, 58, 0.18);
}

.button--icon {
  width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.78);
}

.button--icon svg {
  width: 22px;
  height: 22px;
}

.button__arrow {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.42);
  font-size: 17px;
  transition: transform 0.18s ease;
}

.button:hover .button__arrow {
  transform: translateX(3px);
}

/* ---------- 主選單 ---------- */

.screen--menu {
  padding: clamp(14px, 2vw, 26px) clamp(18px, 2.6vw, 38px) clamp(16px, 2.2vw, 30px);
}

.menu-layout {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(340px, 0.82fr) minmax(560px, 1.45fr);
  gap: clamp(16px, 2vw, 28px);
  align-items: stretch;
}

.hero-panel {
  position: relative;
  min-height: 0;
  padding: clamp(22px, 2.5vw, 34px);
  border-radius: var(--radius-xl);
  background:
    radial-gradient(circle at 84% 8%, rgba(255, 209, 102, 0.32), transparent 24%),
    linear-gradient(160deg, rgba(255, 253, 246, 0.95), rgba(255, 248, 232, 0.86));
  border: 1px solid rgba(255, 255, 255, 0.85);
  box-shadow: var(--shadow-lift);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.hero-panel::after {
  content: "";
  position: absolute;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  right: -120px;
  top: -110px;
  background: radial-gradient(circle, rgba(88, 166, 255, 0.18), transparent 70%);
  pointer-events: none;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  padding: 6px 11px;
  border-radius: 999px;
  background: rgba(79, 191, 106, 0.12);
  color: var(--grass-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.game-title {
  position: relative;
  z-index: 1;
  margin-top: 14px;
  font-size: clamp(56px, 6.4vw, 84px);
  line-height: 0.92;
  letter-spacing: 0.06em;
  font-weight: 950;
  color: var(--ink);
  text-shadow: 0 3px 0 rgba(255, 255, 255, 0.65);
}

.game-title span {
  display: block;
}

.game-title__top {
  color: var(--ink);
}

.game-title__bottom {
  color: var(--grass-dark);
  text-shadow: 0 4px 0 rgba(79, 191, 106, 0.16), 0 2px 0 #fff;
}

.hero-lead {
  position: relative;
  z-index: 1;
  margin-top: 18px;
  max-width: 30ch;
  font-size: clamp(14px, 1.35vw, 16px);
  line-height: 1.75;
  color: var(--ink-soft);
  font-weight: 600;
}

.hero-actions {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.hero-progress {
  position: relative;
  z-index: 1;
  margin-top: 22px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(35, 57, 91, 0.08);
}

.hero-progress__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--ink-faint);
  font-weight: 800;
}

.hero-progress__row strong {
  font-size: 15px;
  color: var(--ink);
}

.hero-progress__bar {
  height: 10px;
  margin-top: 9px;
  border-radius: 999px;
  background: rgba(35, 57, 91, 0.1);
  overflow: hidden;
}

.hero-progress__bar span {
  display: block;
  height: 100%;
  width: 6.25%;
  border-radius: inherit;
  background: linear-gradient(90deg, #6cdb87, #ffd166);
  transition: width 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.hero-progress__hint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--ink-faint);
  font-weight: 600;
}

.hero-mascot {
  position: absolute;
  right: -26px;
  bottom: -42px;
  width: clamp(210px, 20vw, 290px);
  pointer-events: none;
  filter: drop-shadow(0 20px 18px rgba(35, 57, 91, 0.18));
  animation: mascot-float 4.6s ease-in-out infinite;
}

.hero-mascot img {
  width: 100%;
  height: auto;
}

.hero-mascot__bubble {
  position: absolute;
  right: 52%;
  top: 2%;
  width: max-content;
  max-width: 150px;
  padding: 9px 13px;
  border-radius: 15px 15px 4px 15px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(35, 57, 91, 0.14);
  transform: rotate(-2deg);
}

@keyframes mascot-float {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-10px) rotate(1deg); }
}

/* ---------- 冒險地圖 ---------- */

.map-panel {
  min-height: 0;
  padding: clamp(18px, 2vw, 26px);
  border-radius: var(--radius-xl);
  background: linear-gradient(165deg, rgba(255, 253, 246, 0.96), rgba(255, 248, 232, 0.9));
  border: 1px solid rgba(255, 255, 255, 0.85);
  box-shadow: var(--shadow-lift);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.map-panel__head {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 14px;
}

.map-panel__head h2 {
  margin-top: 4px;
  font-size: clamp(24px, 2.4vw, 31px);
  letter-spacing: 0.03em;
}

.map-legend {
  display: flex;
  gap: 12px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-faint);
  white-space: nowrap;
}

.map-legend > span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.star {
  font-size: 14px;
  line-height: 1;
}

.star--on {
  color: #e3a51e;
  text-shadow: 0 1px 0 #fff7d6;
}

.star--off {
  color: rgba(35, 57, 91, 0.18);
}

.world-map {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding: 2px 4px 4px 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(35, 57, 91, 0.22) transparent;
}

.world-map::-webkit-scrollbar {
  width: 8px;
}

.world-map::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(35, 57, 91, 0.18);
}

.world-card {
  --world-color: var(--grass);
  --world-dark: var(--grass-dark);
  position: relative;
  flex: 1 1 0;
  min-height: 104px;
  display: grid;
  grid-template-columns: minmax(116px, 0.72fr) minmax(0, 3.3fr);
  gap: 10px;
  padding: 10px 12px;
  border-radius: 20px;
  border: 1px solid rgba(35, 57, 91, 0.08);
  background:
    linear-gradient(110deg, rgba(255, 255, 255, 0.86), rgba(255, 255, 255, 0.46)),
    radial-gradient(circle at 0% 50%, color-mix(in srgb, var(--world-color) 18%, transparent), transparent 55%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  overflow: hidden;
}

.world-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: linear-gradient(180deg, var(--world-color), var(--world-dark));
}

.world-card__head {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding-left: 7px;
  min-width: 0;
}

.world-card__index {
  width: fit-content;
  padding: 2px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--world-color) 16%, white);
  color: var(--world-dark);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.world-card__head h3 {
  font-size: clamp(15px, 1.35vw, 18px);
  font-weight: 950;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.world-card__head p {
  font-size: 10.5px;
  color: var(--ink-faint);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.world-card__stars {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  color: var(--ink-faint);
  font-weight: 800;
}

.world-card__stars .star {
  font-size: 12px;
}

.world-levels {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  align-items: stretch;
}

.level-node {
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 9px 7px;
  border-radius: 14px;
  border: 1px solid rgba(35, 57, 91, 0.1);
  background: rgba(255, 255, 255, 0.82);
  text-align: left;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  box-shadow: 0 3px 0 rgba(35, 57, 91, 0.06);
  overflow: hidden;
}

.level-node::after {
  content: "";
  position: absolute;
  inset: auto -20px -34px auto;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--world-color) 14%, transparent);
  pointer-events: none;
}

.level-node:hover:not(.is-locked) {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--world-color) 45%, white);
  box-shadow: 0 8px 18px rgba(35, 57, 91, 0.12);
}

.level-node:active:not(.is-locked) {
  transform: translateY(0) scale(0.985);
}

.level-node.is-locked {
  cursor: not-allowed;
  background: rgba(242, 239, 229, 0.72);
  border-color: rgba(35, 57, 91, 0.06);
  box-shadow: none;
  color: var(--ink-faint);
}

.level-node.is-current {
  border-color: var(--world-color);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--world-color) 22%, transparent), 0 6px 16px rgba(35, 57, 91, 0.1);
}

.level-node__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.level-node__number {
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  flex: 0 0 auto;
  border-radius: 8px;
  background: color-mix(in srgb, var(--world-color) 16%, white);
  color: var(--world-dark);
  font-size: 12px;
  font-weight: 950;
}

.level-node.is-locked .level-node__number {
  background: rgba(35, 57, 91, 0.08);
  color: var(--ink-faint);
}

.level-node__lock {
  font-size: 11px;
  color: var(--ink-faint);
}

.level-node__title {
  font-size: clamp(11.5px, 1.02vw, 13.5px);
  font-weight: 900;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.level-node__meta {
  font-size: 9.5px;
  line-height: 1.35;
  color: var(--ink-faint);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.level-node__stars {
  display: flex;
  gap: 2px;
  font-size: 11px;
  margin-top: auto;
}

.level-node__stars .star {
  font-size: 11px;
}

.level-node__best {
  font-size: 9px;
  color: var(--world-dark);
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.level-node__lock-label {
  font-size: 9px;
  color: var(--ink-faint);
  font-weight: 700;
}

.map-footnote {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 10px;
  font-size: 11px;
  color: var(--ink-faint);
  font-weight: 600;
}

/* ---------- 遊戲畫面 ---------- */

.screen--game {
  position: relative;
  overflow: hidden;
  background: linear-gradient(160deg, rgba(255, 249, 236, 0.2), rgba(255, 249, 236, 0.04));
}

.game-shell {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.2vh, 14px);
  padding: clamp(10px, 1.4vw, 18px) clamp(18px, 2.4vw, 34px) clamp(8px, 1vh, 14px);
  position: relative;
  z-index: 2;
}

.game-hud {
  flex: 0 0 auto;
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: clamp(10px, 1.5vw, 20px);
  padding: 9px 14px;
  border-radius: 20px;
  background: rgba(255, 253, 246, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(14px);
}

.hud-level {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 190px;
}

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

.hud-label {
  font-size: 10px;
  font-weight: 800;
  color: var(--ink-faint);
  letter-spacing: 0.08em;
}

.hud-level__text strong {
  font-size: 16px;
  font-weight: 950;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-metrics {
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: clamp(8px, 1.2vw, 18px);
}

.metric {
  min-width: 74px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  padding: 4px 10px;
  border-left: 1px solid rgba(35, 57, 91, 0.08);
}

.metric:first-child {
  border-left: 0;
}

.metric__label {
  font-size: 10px;
  font-weight: 800;
  color: var(--ink-faint);
  letter-spacing: 0.06em;
}

.metric__value {
  font-size: clamp(17px, 1.55vw, 21px);
  font-weight: 950;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.metric__value small {
  font-size: 9px;
  font-weight: 800;
  color: var(--ink-faint);
}

.metric--combo .metric__value {
  color: var(--purple-dark);
}

.combo-meter {
  display: block;
  width: 54px;
  height: 5px;
  margin-top: 2px;
  border-radius: 999px;
  background: rgba(35, 57, 91, 0.1);
  overflow: hidden;
}

.combo-meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #b8a8ff, var(--purple));
  transition: width 0.18s ease;
}

.hud-timer {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 126px;
  padding: 4px 10px 4px 4px;
  border-radius: 16px;
  background: rgba(88, 166, 255, 0.1);
  border: 1px solid rgba(88, 166, 255, 0.16);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.timer-ring {
  width: 46px;
  height: 46px;
  transform: rotate(-90deg);
}

.timer-ring__track,
.timer-ring__value {
  fill: none;
  stroke-width: 5;
}

.timer-ring__track {
  stroke: rgba(35, 57, 91, 0.1);
}

.timer-ring__value {
  stroke: var(--blue);
  stroke-linecap: round;
  stroke-dasharray: 138.23;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.25s linear, stroke 0.2s ease;
}

.hud-timer__text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.hud-timer__text strong {
  font-size: 18px;
  font-weight: 950;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}

.hud-timer.is-warning {
  background: rgba(255, 209, 102, 0.24);
  border-color: rgba(215, 154, 36, 0.3);
}

.hud-timer.is-warning .timer-ring__value {
  stroke: #d79a24;
}

.hud-timer.is-danger {
  background: rgba(232, 93, 93, 0.16);
  border-color: rgba(169, 47, 58, 0.24);
  animation: timer-pulse 1s ease-in-out infinite;
}

.hud-timer.is-danger .timer-ring__value {
  stroke: var(--red);
}

@keyframes timer-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.025); }
}

.game-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(210px, 280px);
  gap: clamp(10px, 1.5vw, 20px);
  align-items: stretch;
}

.typing-card {
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(16px, 2vw, 28px) clamp(22px, 3vw, 42px);
  border-radius: var(--radius-xl);
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 209, 102, 0.16), transparent 40%),
    linear-gradient(165deg, rgba(255, 253, 246, 0.97), rgba(255, 248, 232, 0.92));
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-lift);
  overflow: hidden;
}

.typing-card::before {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: calc(var(--radius-xl) - 8px);
  border: 1px dashed rgba(35, 57, 91, 0.1);
  pointer-events: none;
}

.typing-card.is-wrong {
  animation: card-shake 0.24s ease;
  border-color: rgba(232, 93, 93, 0.55);
}

.typing-card.is-good {
  border-color: rgba(79, 191, 106, 0.6);
}

@keyframes card-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

.typing-card__head {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.level-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(79, 191, 106, 0.14);
  color: var(--grass-dark);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.typing-target {
  font-size: 11px;
  font-weight: 800;
  color: var(--ink-faint);
}

.typing-target strong {
  color: var(--coral-dark);
  font-size: 14px;
}

.typing-text {
  position: relative;
  z-index: 1;
  margin: clamp(8px, 1.4vh, 18px) 0;
  min-height: 1.3em;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  column-gap: 0.01em;
  font-family: var(--font-type);
  font-size: clamp(38px, 5vw, 72px);
  font-weight: 700;
  line-height: 1.45;
  letter-spacing: 0.02em;
  text-align: center;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.typing-text--word {
  font-size: clamp(54px, 6.6vw, 92px);
}

.typing-text--single {
  font-size: clamp(86px, 12vw, 156px);
  line-height: 1.06;
}

.typing-text--sentence {
  font-size: clamp(26px, 3.15vw, 43px);
  line-height: 1.55;
  letter-spacing: 0;
}

.word {
  display: inline-flex;
  white-space: nowrap;
  vertical-align: baseline;
}

.char {
  position: relative;
  display: inline-block;
  white-space: pre;
  border-radius: 4px;
  transition: color 0.12s ease, background 0.12s ease, transform 0.12s ease;
}

.char--space {
  min-width: 0.34em;
}

.char--done {
  color: var(--grass-dark);
}

.char--current {
  color: var(--ink);
  background: rgba(255, 209, 102, 0.34);
  box-shadow: inset 0 -4px 0 var(--sun-dark);
  animation: caret-blink 1.1s step-end infinite;
}

.char--current.char--space {
  box-shadow: inset 0 -4px 0 var(--sun-dark), inset 0 0 0 1px rgba(215, 154, 36, 0.2);
  background: rgba(255, 209, 102, 0.42);
}

.char--upcoming {
  color: rgba(35, 57, 91, 0.32);
}

.char--wrong {
  color: var(--red-dark);
  background: rgba(232, 93, 93, 0.24);
  animation: char-wrong 0.28s ease;
}

@keyframes caret-blink {
  0%, 55% { box-shadow: inset 0 -4px 0 var(--sun-dark); }
  56%, 100% { box-shadow: inset 0 -4px 0 rgba(215, 154, 36, 0.18); }
}

@keyframes char-wrong {
  0%, 100% { transform: translateX(0); }
  30% { transform: translateX(-4px); }
  60% { transform: translateX(4px); }
}

.typing-preview {
  position: relative;
  z-index: 1;
  min-height: 24px;
  text-align: center;
  font-family: var(--font-type);
  font-size: clamp(12px, 1.25vw, 15px);
  color: var(--ink-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.03em;
}

.typing-preview strong {
  color: var(--ink-soft);
}

.typing-preview span {
  opacity: 0.65;
}

.typing-card__foot {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
}

.level-progress {
  flex: 1 1 auto;
  height: 9px;
  border-radius: 999px;
  background: rgba(35, 57, 91, 0.1);
  overflow: hidden;
}

.level-progress span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #6cdb87, #ffd166);
  transition: width 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.level-progress__label {
  flex: 0 0 auto;
  font-size: 10.5px;
  font-weight: 800;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

/* ---------- 鍵寶 ---------- */

.coach-panel {
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 12px 10px 4px;
  border-radius: var(--radius-xl);
  background: linear-gradient(165deg, rgba(255, 253, 246, 0.8), rgba(255, 248, 232, 0.62));
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.coach-panel::before {
  content: "";
  position: absolute;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  top: -70px;
  right: -80px;
  background: radial-gradient(circle, rgba(255, 209, 102, 0.4), transparent 68%);
  pointer-events: none;
}

.coach-bubble {
  position: relative;
  z-index: 2;
  width: 100%;
  min-height: 54px;
  padding: 10px 13px;
  border-radius: 16px 16px 16px 5px;
  background: #fff;
  border: 1px solid rgba(35, 57, 91, 0.08);
  box-shadow: 0 8px 18px rgba(35, 57, 91, 0.1);
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.5;
  color: var(--ink-soft);
  text-align: center;
}

.coach-bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-right: 1px solid rgba(35, 57, 91, 0.08);
  border-bottom: 1px solid rgba(35, 57, 91, 0.08);
  transform: translateX(-50%) rotate(45deg);
}

.coach-mascot {
  position: relative;
  z-index: 1;
  height: clamp(140px, 26vh, 260px);
  width: auto;
  max-width: 92%;
  object-fit: contain;
  margin: 4px auto -8px;
  filter: drop-shadow(0 18px 13px rgba(35, 57, 91, 0.17));
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.coach-mascot.is-cheer {
  animation: mascot-cheer 0.55s ease;
}

.coach-mascot.is-oops {
  animation: mascot-oops 0.5s ease;
}

@keyframes mascot-cheer {
  0%, 100% { transform: translateY(0) scale(1); }
  38% { transform: translateY(-14px) scale(1.04) rotate(-2deg); }
  68% { transform: translateY(-3px) scale(0.99) rotate(1deg); }
}

@keyframes mascot-oops {
  0%, 100% { transform: translateY(0) rotate(0); }
  30% { transform: translateY(3px) rotate(-4deg); }
  65% { transform: translateY(1px) rotate(3deg); }
}

.coach-tip {
  flex: 0 0 auto;
  width: 100%;
  padding: 7px 8px;
  border-radius: 11px;
  background: rgba(88, 166, 255, 0.1);
  color: var(--blue-dark);
  font-size: 10px;
  font-weight: 800;
  text-align: center;
  line-height: 1.4;
}

/* ---------- 虛擬鍵盤 ---------- */

.keyboard-panel {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 12px 8px;
  border-radius: 22px;
  background: rgba(255, 253, 246, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.74);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(12px);
}

.keyboard {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: fit-content;
  max-width: 100%;
}

.keyboard__row {
  display: flex;
  gap: 4px;
  justify-content: center;
}

.keyboard__row--numbers {
  transform: scale(0.92);
  transform-origin: center bottom;
  opacity: 0.74;
}

.keyboard__row--home {
  margin-left: -6px;
}

.keyboard__row--bottom {
  margin-left: -12px;
}

.key {
  --finger-color: #cfd8e3;
  position: relative;
  width: var(--key-w);
  height: var(--key-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border-radius: 8px;
  border: 1px solid rgba(35, 57, 91, 0.15);
  border-bottom-width: 3px;
  background: linear-gradient(180deg, #ffffff, #f1f4f7);
  box-shadow: 0 2px 0 rgba(35, 57, 91, 0.06);
  color: var(--ink-soft);
  font-family: var(--font-type);
  font-size: clamp(10px, 1vw, 13px);
  font-weight: 800;
  line-height: 1;
  transition: transform 0.1s ease, background 0.12s ease, box-shadow 0.12s ease, color 0.12s ease;
  user-select: none;
}

.key::before {
  content: "";
  position: absolute;
  inset: auto 6px 3px;
  height: 2px;
  border-radius: 999px;
  background: var(--finger-color);
  opacity: 0.9;
}

.key__label {
  position: relative;
  z-index: 1;
}

.key__finger {
  display: none;
}

.key--wide {
  width: calc(var(--key-w) * 1.42);
}

.key--shift {
  width: calc(var(--key-w) * 1.75);
}

.key--space {
  width: calc(var(--key-w) * 6.1);
}

.key--space::before {
  inset: auto 30% 3px;
  background: var(--finger-color);
}

.key--pressed {
  transform: translateY(2px) scale(0.97);
  border-bottom-width: 1px;
  background: #e9eef4;
  box-shadow: none;
}

.key--target {
  color: #102f45;
  border-color: rgba(215, 154, 36, 0.75);
  background: linear-gradient(180deg, #fff7d9, #ffe49a);
  box-shadow: 0 0 0 3px rgba(255, 209, 102, 0.46), 0 0 22px rgba(255, 209, 102, 0.55);
  transform: translateY(-2px);
  animation: key-target-pulse 1.15s ease-in-out infinite;
}

.key--target::before {
  background: var(--sun-dark);
}

.key--shift-target {
  color: #3b2a00;
  border-color: rgba(240, 138, 93, 0.7);
  background: linear-gradient(180deg, #fff0e6, #ffd4bd);
  box-shadow: 0 0 0 3px rgba(240, 138, 93, 0.24);
}

.key--shift-target::before {
  background: var(--coral);
}

.key--hint {
  animation: key-hint-flash 0.55s ease;
}

@keyframes key-target-pulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.07); }
}

@keyframes key-hint-flash {
  0%, 100% { box-shadow: 0 2px 0 rgba(35, 57, 91, 0.06); }
  40% { box-shadow: 0 0 0 5px rgba(232, 93, 93, 0.3); }
}

.key[data-finger="left-pinky"] { --finger-color: #f28fa8; }
.key[data-finger="left-ring"] { --finger-color: #f5b56b; }
.key[data-finger="left-middle"] { --finger-color: #e8d45c; }
.key[data-finger="left-index"] { --finger-color: #7bd38a; }
.key[data-finger="right-index"] { --finger-color: #66c6d8; }
.key[data-finger="right-middle"] { --finger-color: #8fa7f0; }
.key[data-finger="right-ring"] { --finger-color: #b596e8; }
.key[data-finger="right-pinky"] { --finger-color: #e08ecb; }
.key[data-finger="thumb"] { --finger-color: #9fb4c7; }

.finger-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 12px;
  color: var(--ink-faint);
  font-size: 9.5px;
  font-weight: 700;
}

.finger-legend > span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.finger-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--finger-color, #ccc);
}

.finger-dot--left-pinky { --finger-color: #f28fa8; }
.finger-dot--left-ring { --finger-color: #f5b56b; }
.finger-dot--left-middle { --finger-color: #e8d45c; }
.finger-dot--left-index { --finger-color: #7bd38a; }
.finger-dot--right-index { --finger-color: #66c6d8; }
.finger-dot--right-middle { --finger-color: #8fa7f0; }
.finger-dot--right-ring { --finger-color: #b596e8; }
.finger-dot--right-pinky { --finger-color: #e08ecb; }
.finger-dot--thumb { --finger-color: #9fb4c7; }

.game-footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 8px;
  color: rgba(255, 253, 246, 0.9);
  text-shadow: 0 1px 4px rgba(15, 44, 75, 0.4);
  font-size: 10.5px;
  font-weight: 700;
}

.game-footer__keys {
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.game-footer kbd {
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(255, 253, 246, 0.86);
  color: var(--ink-soft);
  font-family: var(--font-ui);
  font-size: 9px;
  font-weight: 800;
  box-shadow: 0 1px 0 rgba(35, 57, 91, 0.2);
}

/* ---------- 特效 ---------- */

.fx-layer,
.score-float-layer {
  position: fixed;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  overflow: hidden;
}

.fx-flash {
  position: absolute;
  inset: 0;
  animation: flash-fade 0.36s ease-out forwards;
}

.fx-flash--good {
  background: radial-gradient(circle at 50% 48%, rgba(123, 211, 138, 0.3), transparent 62%);
}

.fx-flash--bad {
  background: radial-gradient(circle at 50% 48%, rgba(232, 93, 93, 0.24), transparent 62%);
}

@keyframes flash-fade {
  from { opacity: 1; }
  to { opacity: 0; }
}

.spark {
  position: absolute;
  width: var(--size, 10px);
  height: var(--size, 10px);
  border-radius: 50%;
  background: var(--color, var(--sun));
  box-shadow: 0 0 10px var(--color, var(--sun));
  animation: spark-fly 0.72s cubic-bezier(0.12, 0.7, 0.2, 1) forwards;
}

.spark--star {
  border-radius: 2px;
  clip-path: polygon(50% 0%, 61% 36%, 100% 50%, 61% 64%, 50% 100%, 39% 64%, 0% 50%, 39% 36%);
  box-shadow: none;
}

@keyframes spark-fly {
  0% { transform: translate(-50%, -50%) scale(0.4) rotate(0deg); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.1) rotate(160deg); opacity: 0; }
}

.score-float {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 22px;
  font-weight: 950;
  color: var(--grass-dark);
  text-shadow: 0 2px 0 #fff, 0 0 16px rgba(255, 255, 255, 0.9);
  animation: score-rise 0.85s ease-out forwards;
  white-space: nowrap;
}

.score-float--combo {
  color: var(--purple-dark);
  font-size: 18px;
}

@keyframes score-rise {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.7); }
  18% { opacity: 1; transform: translate(-50%, -56%) scale(1.08); }
  100% { opacity: 0; transform: translate(-50%, -150%) scale(0.92); }
}

/* ---------- 覆蓋層與對話框 ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 44, 75, 0.22);
  backdrop-filter: blur(7px);
}

.overlay--dim {
  background: rgba(15, 44, 75, 0.42);
}

.overlay--finale {
  background:
    radial-gradient(circle at 50% 20%, rgba(255, 209, 102, 0.3), transparent 42%),
    rgba(15, 44, 75, 0.55);
}

.dialog {
  position: relative;
  width: min(560px, 100%);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: clamp(24px, 3vw, 38px);
  border-radius: var(--radius-xl);
  background:
    radial-gradient(circle at 84% 0%, rgba(255, 209, 102, 0.22), transparent 30%),
    linear-gradient(165deg, var(--cream-strong), #fff4da);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 34px 80px rgba(15, 44, 75, 0.35);
  animation: dialog-in 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  scrollbar-width: thin;
}

.dialog--narrow {
  width: min(430px, 100%);
  text-align: center;
}

.dialog--result {
  width: min(620px, 100%);
  text-align: center;
}

.dialog--tutorial {
  width: min(780px, 100%);
}

.dialog--settings {
  width: min(560px, 100%);
}

.dialog__mascot {
  width: 124px;
  height: auto;
  margin: -18px auto 4px;
  filter: drop-shadow(0 14px 12px rgba(35, 57, 91, 0.16));
}

.dialog h2 {
  margin: 5px 0 8px;
  font-size: clamp(26px, 3vw, 34px);
  line-height: 1.2;
  letter-spacing: 0.02em;
}

.dialog > p {
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.7;
  font-weight: 600;
}

.dialog__actions {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: 22px;
}

.dialog__actions--row {
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
}

.dialog__actions--row .button {
  flex: 1 1 150px;
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* 關卡準備 */

.dialog--level {
  width: min(590px, 100%);
  text-align: center;
  background:
    radial-gradient(circle at 82% 4%, rgba(255, 209, 102, 0.28), transparent 30%),
    linear-gradient(165deg, var(--cream-strong), #fff3d6);
}

.dialog--level h2 {
  margin-top: 6px;
}

.level-focus {
  font-size: 14px;
  color: var(--grass-dark);
  font-weight: 900;
  letter-spacing: 0.06em;
}

.level-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.level-facts > div {
  padding: 10px 8px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(35, 57, 91, 0.08);
}

.level-facts span {
  display: block;
  font-size: 10px;
  color: var(--ink-faint);
  font-weight: 800;
}

.level-facts strong {
  display: block;
  margin-top: 2px;
  font-size: 16px;
  font-weight: 950;
  color: var(--ink);
}

.level-tip {
  margin-top: 12px;
  padding: 11px 14px;
  border-radius: 14px;
  background: rgba(255, 209, 102, 0.2);
  border: 1px solid rgba(215, 154, 36, 0.16);
  text-align: left;
}

.level-tip__label {
  font-size: 10px;
  font-weight: 900;
  color: #8b5c00;
  letter-spacing: 0.08em;
}

.level-tip p {
  margin-top: 3px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--ink-soft);
  font-weight: 700;
}

.level-mascot {
  width: clamp(120px, 14vw, 170px);
  height: auto;
  margin: 8px auto -2px;
  filter: drop-shadow(0 14px 12px rgba(35, 57, 91, 0.15));
}

.dialog--level .dialog__actions {
  margin-top: 8px;
}

/* 倒數 */

.countdown {
  text-align: center;
  color: var(--cream);
  text-shadow: 0 8px 30px rgba(15, 44, 75, 0.55);
}

.countdown__label {
  font-size: clamp(17px, 2vw, 22px);
  font-weight: 800;
  letter-spacing: 0.14em;
}

.countdown__number {
  display: block;
  margin: 8px 0;
  font-size: clamp(140px, 22vw, 260px);
  line-height: 0.9;
  font-weight: 950;
  color: #fff;
  text-shadow: 0 14px 0 rgba(35, 122, 69, 0.55), 0 26px 50px rgba(15, 44, 75, 0.45);
  animation: countdown-pop 1s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.countdown__hint {
  font-size: 14px;
  font-weight: 700;
  opacity: 0.9;
}

@keyframes countdown-pop {
  0% { transform: scale(0.5); opacity: 0; }
  25% { transform: scale(1.08); opacity: 1; }
  55% { transform: scale(1); }
  100% { transform: scale(0.94); opacity: 0.4; }
}

/* 結算 */

.result-stars {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  min-height: 88px;
  margin-bottom: 2px;
}

.result-star {
  position: relative;
  font-size: clamp(58px, 8vw, 82px);
  line-height: 1;
  color: rgba(35, 57, 91, 0.12);
  filter: drop-shadow(0 4px 0 rgba(255, 255, 255, 0.7));
  transform: scale(0.85);
}

.result-star.is-earned {
  color: var(--sun);
  text-shadow: 0 5px 0 #c98c13, 0 10px 22px rgba(215, 154, 36, 0.35);
  animation: star-pop 0.5s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}

.result-star:nth-child(2).is-earned { animation-delay: 0.2s; }
.result-star:nth-child(3).is-earned { animation-delay: 0.4s; }

@keyframes star-pop {
  0% { transform: scale(0.2) rotate(-18deg); opacity: 0; }
  70% { transform: scale(1.15) rotate(4deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

.result-message {
  margin-top: 2px;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 20px;
}

.result-stat {
  padding: 12px 8px 10px;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(35, 57, 91, 0.08);
}

.result-stat span {
  display: block;
  font-size: 10px;
  font-weight: 800;
  color: var(--ink-faint);
  letter-spacing: 0.06em;
}

.result-stat strong {
  display: block;
  margin-top: 3px;
  font-size: clamp(17px, 2vw, 22px);
  font-weight: 950;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.result-stat strong small {
  font-size: 9px;
  color: var(--ink-faint);
}

.result-best {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(79, 191, 106, 0.14);
  color: var(--grass-dark);
  font-size: 12px;
  font-weight: 900;
}

.result-next {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-top: 12px;
  padding: 9px 12px;
  border-radius: 12px;
  background: rgba(88, 166, 255, 0.1);
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 700;
}

.result-next strong {
  font-size: 14px;
  font-weight: 950;
}

.result-hint {
  margin-top: 12px;
  font-size: 11px;
  color: var(--ink-faint);
}

/* 教學 */

.tutorial-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.icon-button--close {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 11px;
}

.tutorial-body {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: clamp(16px, 2.4vw, 28px);
  align-items: center;
  margin-top: 18px;
}

.tutorial-visual {
  position: relative;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  border-radius: 20px;
  background:
    radial-gradient(circle at 50% 35%, rgba(255, 209, 102, 0.26), transparent 58%),
    rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(35, 57, 91, 0.08);
  overflow: hidden;
}

.tutorial-visual__hands {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.tutorial-hand {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid rgba(35, 57, 91, 0.08);
}

.tutorial-hand__label {
  font-size: 9px;
  font-weight: 800;
  color: var(--ink-faint);
  text-align: center;
}

.tutorial-keys {
  display: flex;
  gap: 3px;
}

.tutorial-key {
  width: 28px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  border: 1px solid rgba(35, 57, 91, 0.14);
  border-bottom-width: 2px;
  background: #fff;
  font-family: var(--font-type);
  font-size: 12px;
  font-weight: 800;
  color: var(--ink-soft);
}

.tutorial-key--target {
  background: linear-gradient(180deg, #fff7d9, #ffe49a);
  border-color: rgba(215, 154, 36, 0.5);
  box-shadow: 0 0 0 3px rgba(255, 209, 102, 0.3);
}

.tutorial-visual__caption {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.84);
  color: var(--ink-faint);
  font-size: 9.5px;
  font-weight: 800;
  white-space: nowrap;
}

.tutorial-focus {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-bottom: 18px;
}

.tutorial-eyes {
  color: var(--ink);
  font-size: 28px;
  letter-spacing: 10px;
  line-height: 1;
  animation: tutorial-blink 3.2s ease-in-out infinite;
}

.tutorial-keys--row {
  flex-wrap: nowrap;
}

.tutorial-oops {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 16px;
}

.tutorial-oops img {
  width: 96px;
  max-height: 186px;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 8px 10px rgba(35, 57, 91, 0.12));
}

.tutorial-oops__bubble {
  position: relative;
  max-width: 118px;
  padding: 9px 11px;
  border-radius: 13px;
  background: #fffdf6;
  border: 1px solid rgba(35, 57, 91, 0.1);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.5;
}

.tutorial-oops__bubble::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 50%;
  width: 10px;
  height: 10px;
  transform: translateY(-50%) rotate(45deg);
  background: #fffdf6;
  border-left: 1px solid rgba(35, 57, 91, 0.1);
  border-bottom: 1px solid rgba(35, 57, 91, 0.1);
}

@keyframes tutorial-blink {
  0%, 44%, 56%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(0.08); }
}

.tutorial-copy h3 {
  margin-top: 5px;
  font-size: clamp(20px, 2.2vw, 25px);
  line-height: 1.25;
}

.tutorial-copy p {
  margin-top: 8px;
  color: var(--ink-soft);
  font-size: 13.5px;
  line-height: 1.75;
  font-weight: 600;
}

.tutorial-step-label {
  font-size: 11px;
  font-weight: 900;
  color: var(--grass-dark);
  letter-spacing: 0.08em;
}

.tutorial-points {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 13px;
}

.tutorial-points li {
  position: relative;
  padding-left: 20px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink-soft);
  font-weight: 600;
}

.tutorial-points li::before {
  content: "✦";
  position: absolute;
  left: 0;
  top: 1px;
  color: var(--sun-dark);
  font-size: 11px;
}

.tutorial-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 22px;
}

.tutorial-dots {
  display: flex;
  gap: 5px;
}

.tutorial-dots span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(35, 57, 91, 0.16);
  transition: width 0.2s ease, background 0.2s ease;
}

.tutorial-dots span.is-active {
  width: 22px;
  background: var(--grass);
}

.tutorial-foot .dialog__actions {
  margin-top: 0;
}

/* 設定 */

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 18px;
}

.setting-row {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 14px;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.64);
  border: 1px solid rgba(35, 57, 91, 0.08);
  cursor: pointer;
}

.setting-row__icon {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: rgba(79, 191, 106, 0.12);
  color: var(--grass-dark);
  font-size: 16px;
  font-weight: 900;
}

.setting-row__text {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.setting-row__text strong {
  font-size: 14px;
  font-weight: 900;
}

.setting-row__text small {
  font-size: 11px;
  color: var(--ink-faint);
  font-weight: 600;
}

.switch {
  appearance: none;
  flex: 0 0 auto;
  width: 48px;
  height: 28px;
  border-radius: 999px;
  background: rgba(35, 57, 91, 0.18);
  border: 1px solid rgba(35, 57, 91, 0.1);
  cursor: pointer;
  position: relative;
  transition: background 0.2s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(35, 57, 91, 0.22);
  transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.switch:checked {
  background: var(--grass);
}

.switch:checked::after {
  transform: translateX(20px);
}

.switch:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 18px;
}

.settings-actions .button {
  flex: 1 1 180px;
}

.settings-note {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(88, 166, 255, 0.08);
  color: var(--ink-faint);
  font-size: 10.5px;
  line-height: 1.6;
  font-weight: 600;
}

.settings-version {
  margin-top: 8px;
  text-align: right;
  font-size: 9.5px;
  color: rgba(35, 57, 91, 0.42);
  font-weight: 700;
}

/* 全破 */

.finale {
  position: relative;
  width: min(760px, 100%);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: clamp(26px, 3.4vw, 44px);
  border-radius: 38px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 209, 102, 0.45), transparent 40%),
    radial-gradient(circle at 10% 80%, rgba(139, 124, 246, 0.18), transparent 36%),
    linear-gradient(165deg, #fffdf6, #fff0cd);
  border: 1px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 40px 100px rgba(15, 44, 75, 0.45);
  animation: dialog-in 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.finale-stars {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 3px;
  margin-bottom: 12px;
}

.finale-stars .star {
  font-size: clamp(20px, 2.4vw, 28px);
  color: var(--sun);
  text-shadow: 0 2px 0 #c98c13;
  animation: star-pop 0.45s ease both;
}

.finale h2 {
  font-size: clamp(38px, 5.2vw, 58px);
  color: var(--grass-dark);
  letter-spacing: 0.04em;
  text-shadow: 0 3px 0 rgba(255, 255, 255, 0.8);
}

.finale-lead {
  max-width: 48ch;
  margin: 10px auto 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.75;
  font-weight: 600;
}

.finale-mascot {
  width: clamp(200px, 24vw, 300px);
  height: auto;
  margin: -4px auto -8px;
  filter: drop-shadow(0 22px 20px rgba(35, 57, 91, 0.2));
  animation: mascot-float 3.8s ease-in-out infinite;
}

.finale-certificate {
  display: inline-flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 2px;
  padding: 12px 30px;
  border-radius: 16px;
  border: 2px dashed rgba(215, 154, 36, 0.45);
  background: rgba(255, 255, 255, 0.55);
}

.finale-certificate span {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.24em;
  color: var(--ink-faint);
}

.finale-certificate strong {
  font-size: clamp(17px, 2vw, 21px);
  color: var(--coral-dark);
}

.finale-certificate small {
  font-size: 10px;
  color: var(--ink-faint);
  font-weight: 700;
}

.finale .dialog__actions {
  margin-top: 20px;
}

/* ---------- 頁尾 ---------- */

.site-footer {
  position: fixed;
  inset: auto 0 0;
  z-index: 30;
  height: var(--footer-h);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  background: rgba(19, 45, 70, 0.78);
  border-top: 1px solid rgba(255, 255, 255, 0.22);
  color: rgba(255, 253, 246, 0.92);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  backdrop-filter: blur(12px);
}

.site-footer p {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.site-footer a {
  color: #fff;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.site-footer a:hover {
  color: var(--sun);
}

.site-footer a:focus-visible {
  outline: none;
  border-radius: 4px;
  box-shadow: var(--focus-ring);
}

/* ---------- 其他 ---------- */

.desktop-only {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  place-items: center;
  padding: 24px;
  background: linear-gradient(180deg, #cdeeff, #fdf5df);
}

.desktop-only__card {
  max-width: 420px;
  padding: 32px;
  border-radius: 28px;
  background: var(--cream);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: var(--shadow-lift);
  text-align: center;
}

.desktop-only__icon {
  font-size: 54px;
  line-height: 1;
  color: var(--grass-dark);
}

.desktop-only h2 {
  margin-top: 12px;
  font-size: 26px;
}

.desktop-only p {
  margin-top: 10px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.8;
  font-weight: 600;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--footer-h) + 18px);
  z-index: 120;
  transform: translateX(-50%) translateY(10px);
  max-width: min(520px, calc(100vw - 48px));
  padding: 11px 18px;
  border-radius: 13px;
  background: rgba(35, 57, 91, 0.94);
  color: var(--cream);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 12px 28px rgba(15, 44, 75, 0.3);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- 響應式 ---------- */

@media (max-width: 1180px) {
  .menu-layout {
    grid-template-columns: minmax(300px, 0.72fr) minmax(520px, 1.5fr);
  }

  .world-card {
    grid-template-columns: 104px minmax(0, 1fr);
  }

  .hero-mascot {
    width: 205px;
    right: -34px;
    bottom: -34px;
  }

  .game-stage {
    grid-template-columns: minmax(0, 1fr) 220px;
  }

  .coach-mascot {
    width: min(84%, 190px);
  }
}

@media (max-height: 900px) {
  .world-card {
    min-height: 90px;
    padding: 4px 10px;
  }

  .level-node {
    gap: 2px;
    padding: 4px 8px 3px;
    border-radius: 12px;
  }

  .level-node__number {
    width: 20px;
    height: 20px;
    border-radius: 7px;
    font-size: 11px;
  }

  .level-node__lock {
    font-size: 10px;
  }

  .level-node__title {
    font-size: clamp(11px, 0.95vw, 12.5px);
    line-height: 1.2;
  }

  .level-node__meta {
    font-size: 9px;
    line-height: 1.25;
  }

  .level-node__stars {
    font-size: 10px;
    line-height: 1.1;
  }

  .level-node__stars .star {
    font-size: 10px;
  }

  .level-node__best,
  .level-node__lock-label {
    font-size: 8.5px;
    line-height: 1.2;
  }
}

@media (max-height: 760px) {
  :root {
    --topbar-h: 60px;
  }

  .hero-panel {
    padding: 22px;
  }

  .game-title {
    font-size: clamp(50px, 5.8vw, 68px);
  }

  .hero-lead {
    margin-top: 12px;
    font-size: 13px;
  }

  .hero-actions {
    margin-top: 14px;
  }

  .hero-progress {
    margin-top: 14px;
    padding: 10px 13px;
  }

  .hero-mascot {
    width: 180px;
    bottom: -28px;
  }

  .map-panel {
    padding: 18px;
  }

  .map-panel__head {
    padding-bottom: 9px;
  }

  .world-card {
    min-height: 92px;
    padding: 8px 10px;
  }

  .level-node {
    padding: 6px 8px;
  }

  .game-hud {
    min-height: 58px;
    padding: 7px 12px;
  }

  .game-stage {
    grid-template-columns: minmax(0, 1fr) 200px;
  }

  .typing-card {
    padding: 14px 26px;
  }

  .typing-text {
    margin: 6px 0;
  }

  .coach-bubble {
    font-size: 11.5px;
    min-height: 48px;
  }

  .keyboard-panel {
    padding: 8px 10px 6px;
  }
}

@media (max-width: 899px) {
  body {
    min-width: 0;
    overflow: auto;
  }

  .app-shell {
    display: none;
  }

  .desktop-only {
    display: grid;
  }
}

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

.is-reduced-motion .hero-mascot,
.is-reduced-motion .coach-mascot,
.is-reduced-motion .finale-mascot,
.is-reduced-motion .sky__cloud {
  animation: none !important;
}

.is-reduced-motion .spark,
.is-reduced-motion .score-float {
  display: none !important;
}

.is-reduced-motion .typing-card.is-wrong,
.is-reduced-motion .char--wrong {
  animation: none !important;
}
