:root {
  --ink: #33245a;
  --ink-soft: #64548a;
  --cream: #fff8e8;
  --paper: #fffdf8;
  --pink: #ff6fa5;
  --pink-deep: #e64d8d;
  --yellow: #ffd93d;
  --orange: #ff9f43;
  --mint: #4ecdc4;
  --blue: #5aa9ff;
  --purple: #8b5cf6;
  --green: #39b86a;
  --green-deep: #239b52;
  --red: #ff5d6c;
  --shadow-lg: 0 24px 60px rgba(66, 38, 112, 0.22);
  --shadow-md: 0 12px 30px rgba(66, 38, 112, 0.16);
  --shadow-sm: 0 5px 14px rgba(66, 38, 112, 0.12);
  --radius-xl: 38px;
  --radius-lg: 28px;
  --radius-md: 20px;
  --font-body: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", sans-serif;
  --font-display: "Baloo 2", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --vh: 1vh;
  --header-height: 74px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 217, 61, 0.28), transparent 32%),
    radial-gradient(circle at 88% 16%, rgba(255, 111, 165, 0.22), transparent 30%),
    radial-gradient(circle at 50% 100%, rgba(78, 205, 196, 0.2), transparent 40%),
    #fff9ee;
  overflow-x: hidden;
}

button {
  font-family: inherit;
  color: inherit;
  cursor: pointer;
}

button:focus-visible,
a:focus-visible {
  outline: 4px solid #2f7df6;
  outline-offset: 4px;
}

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

.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;
}

.noscript {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #fff9ee;
  font-size: 20px;
  z-index: 100000;
}

/* ---------- Global bar ---------- */
#global-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 clamp(16px, 4vw, 46px);
  z-index: 900;
  background: rgba(255, 253, 248, 0.86);
  border-bottom: 1px solid rgba(90, 60, 140, 0.1);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: background 0.35s ease, color 0.35s ease, box-shadow 0.35s ease;
}

body[data-screen="home"] #global-bar {
  background: linear-gradient(to bottom, rgba(43, 20, 78, 0.55), transparent);
  border-bottom: 0;
  color: #fff;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(17px, 2.2vw, 23px);
  letter-spacing: 0.02em;
}

.brand-star {
  color: var(--yellow);
  font-size: 1.1em;
  animation: twinkle 2.2s ease-in-out infinite;
}

.brand-sub {
  font-size: 0.66em;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--yellow);
  color: #6a3b00;
  letter-spacing: 0.08em;
}

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

.bar-btn {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  border: 0;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow-sm);
  font-size: 23px;
  display: grid;
  place-items: center;
  transition: transform 0.18s ease, background 0.2s ease, opacity 0.2s ease;
}

body[data-screen="home"] .bar-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: none;
}

body[data-screen="home"] #home-btn {
  visibility: hidden;
  pointer-events: none;
}

.bar-btn:hover {
  transform: translateY(-2px) scale(1.04);
}

.bar-btn.is-off {
  opacity: 0.62;
  filter: grayscale(0.6);
}

.bar-btn.is-off::after {
  content: "";
  position: absolute;
  width: 26px;
  height: 3px;
  background: currentColor;
  transform: rotate(-38deg);
  border-radius: 4px;
}

/* ---------- Screens ---------- */
#app {
  min-height: 100vh;
}

.screen {
  display: none;
  min-height: 100vh;
  padding-top: var(--header-height);
}

.screen.active {
  display: block;
  animation: screen-in 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

body[data-screen="home"] .screen.active {
  padding-top: 0;
}

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

/* ---------- Home ---------- */
.home-view {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  overflow: hidden;
  isolation: isolate;
  background: #1b0f36;
}

.home-backdrop {
  position: absolute;
  inset: -4%;
  background-size: cover;
  background-position: center;
  transform: scale(1.04);
  filter: saturate(1.15) brightness(0.92);
  animation: slow-zoom 22s ease-in-out infinite alternate;
  z-index: -3;
}

.home-view::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(100deg, rgba(27, 15, 54, 0.9) 0%, rgba(27, 15, 54, 0.62) 40%, rgba(27, 15, 54, 0.08) 72%),
    linear-gradient(to top, rgba(27, 15, 54, 0.82), transparent 55%);
  z-index: -2;
}

.home-glow {
  position: absolute;
  width: 70vw;
  height: 70vw;
  max-width: 820px;
  max-height: 820px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 217, 61, 0.32), transparent 62%);
  right: -14vw;
  top: -18vw;
  filter: blur(10px);
  z-index: -1;
  animation: glow-pulse 6s ease-in-out infinite alternate;
}

.home-content {
  position: relative;
  z-index: 3;
  width: min(760px, 60vw);
  margin-left: clamp(24px, 8vw, 120px);
  padding: calc(var(--header-height) + 26px) 24px 64px 0;
  color: #fff;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.12em;
  background: rgba(255, 217, 61, 0.2);
  border: 1px solid rgba(255, 217, 61, 0.55);
  color: #ffe98a;
  backdrop-filter: blur(6px);
}

.game-title {
  margin: 22px 0 18px;
  font-family: var(--font-display);
  line-height: 0.96;
  letter-spacing: 0.02em;
  text-shadow: 0 6px 0 rgba(80, 30, 110, 0.35), 0 18px 40px rgba(0, 0, 0, 0.35);
}

.title-top {
  display: block;
  font-size: clamp(48px, 7.4vw, 92px);
  font-weight: 800;
  color: #fff;
}

.title-bottom {
  display: inline-block;
  font-size: clamp(56px, 9vw, 116px);
  font-weight: 800;
  background: linear-gradient(180deg, #fff8b6 0%, #ffd93d 45%, #ff9f43 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-stroke: 2px rgba(255, 255, 255, 0.35);
  filter: drop-shadow(0 8px 0 rgba(151, 62, 0, 0.28));
}

.subtitle {
  margin: 0 0 30px;
  font-size: clamp(16px, 2vw, 21px);
  font-weight: 500;
  color: rgba(255, 255, 255, 0.86);
  letter-spacing: 0.04em;
}

.home-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 30px;
}

.start-adventure {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 16px;
  padding: 20px 44px;
  border: 0;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: clamp(22px, 2.6vw, 30px);
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #5b2100;
  background: linear-gradient(135deg, #ffe26b 0%, #ffd93d 30%, #ff9f43 75%, #ff7a59 100%);
  box-shadow: 0 12px 0 #c45f1e, 0 26px 48px rgba(255, 122, 89, 0.42);
  overflow: hidden;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
  animation: button-bob 2.6s ease-in-out infinite;
}

.start-adventure:hover {
  transform: translateY(-3px);
  box-shadow: 0 15px 0 #c45f1e, 0 30px 54px rgba(255, 122, 89, 0.48);
}

.start-adventure:active {
  transform: translateY(6px);
  box-shadow: 0 5px 0 #c45f1e, 0 16px 26px rgba(255, 122, 89, 0.3);
}

.start-icon {
  font-size: 1.1em;
  filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.15));
}

.start-shine {
  position: absolute;
  top: -60%;
  left: -30%;
  width: 22%;
  height: 220%;
  background: rgba(255, 255, 255, 0.55);
  transform: rotate(24deg);
  animation: shine-sweep 3.4s ease-in-out infinite;
}

.how-btn,
.continue-btn {
  border: 2px solid rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border-radius: 999px;
  padding: 14px 26px;
  font-size: 17px;
  font-weight: 700;
  backdrop-filter: blur(8px);
  transition: background 0.2s ease, transform 0.2s ease;
}

.how-btn:hover,
.continue-btn:hover {
  background: rgba(255, 255, 255, 0.26);
  transform: translateY(-2px);
}

.continue-btn {
  border-color: rgba(255, 217, 61, 0.8);
  color: #ffe98a;
}

.home-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.stat-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(8px);
  font-size: 14px;
  color: rgba(255, 255, 255, 0.9);
}

.stat-chip strong {
  font-family: var(--font-display);
  font-size: 22px;
  color: #ffe98a;
}

.stat-emoji {
  font-size: 18px;
}

.home-note {
  max-width: 560px;
  font-size: 13px;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.62);
}

.home-mascot {
  position: absolute;
  right: clamp(16px, 6vw, 100px);
  bottom: clamp(24px, 6vh, 70px);
  z-index: 4;
  width: clamp(150px, 20vw, 280px);
  animation: mascot-float 4.2s ease-in-out infinite;
}

.home-mascot img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 42% 42% 46% 46%;
  border: 8px solid rgba(255, 255, 255, 0.88);
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.35);
}

.mascot-bubble {
  position: absolute;
  top: -18px;
  left: -80px;
  width: max-content;
  max-width: 220px;
  padding: 12px 18px;
  border-radius: 20px 20px 6px 20px;
  background: #fffdf6;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  box-shadow: var(--shadow-md);
  animation: bubble-bob 3.6s ease-in-out infinite;
}

.floating-symbols {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  color: rgba(255, 255, 255, 0.5);
  font-family: var(--font-display);
  font-weight: 800;
}

.floating-symbols span {
  position: absolute;
  font-size: clamp(24px, 3vw, 46px);
  text-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
  animation: symbol-float 7s ease-in-out infinite;
}

.floating-symbols span:nth-child(1) { top: 18%; left: 45%; animation-delay: -1s; color: #ffe26b; }
.floating-symbols span:nth-child(2) { top: 30%; left: 53%; animation-delay: -2.4s; color: #7fffd4; }
.floating-symbols span:nth-child(3) { top: 62%; left: 47%; animation-delay: -3.2s; color: #ff9fb9; }
.floating-symbols span:nth-child(4) { top: 76%; left: 58%; animation-delay: -0.6s; color: #b9a6ff; }
.floating-symbols span:nth-child(5) { top: 15%; left: 64%; animation-delay: -4.4s; color: #ffd93d; }
.floating-symbols span:nth-child(6) { top: 47%; left: 61%; animation-delay: -2s; color: #8fe3ff; }
.floating-symbols span:nth-child(7) { top: 84%; left: 42%; animation-delay: -5.1s; color: #ffe26b; }
.floating-symbols span:nth-child(8) { top: 42%; left: 40%; animation-delay: -3.8s; color: #ffb3c8; }

/* ---------- Map ---------- */
.map-view {
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px clamp(16px, 4vw, 44px) 40px;
}

.map-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 20px;
  margin-bottom: 26px;
}

.map-back {
  align-self: start;
}

.map-heading {
  text-align: center;
}

.map-heading .eyebrow {
  color: #8a5a00;
  background: rgba(255, 217, 61, 0.24);
  border-color: rgba(255, 159, 67, 0.45);
}

.map-heading h1 {
  margin: 8px 0 6px;
  font-family: var(--font-display);
  font-size: clamp(32px, 4.4vw, 52px);
  line-height: 1;
  color: var(--ink);
}

.map-heading p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 15px;
}

.map-summary {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
}

.summary-star {
  color: #b47800;
}

.reset-btn {
  border: 0;
  background: transparent;
  color: #a18fbe;
  font-size: 12px;
  text-decoration: underline;
  padding: 2px;
}

.island-list {
  display: grid;
  gap: 30px;
}

.island-card {
  position: relative;
  border-radius: var(--radius-xl);
  overflow: hidden;
  min-height: 320px;
  box-shadow: var(--shadow-lg);
  isolation: isolate;
  border: 4px solid rgba(255, 255, 255, 0.8);
}

.island-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  transform: scale(1.03);
  transition: transform 0.8s ease;
  z-index: -3;
}

.island-card:hover .island-bg {
  transform: scale(1.08);
}

.island-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to bottom, rgba(27, 15, 54, 0.52) 0%, rgba(27, 15, 54, 0.12) 42%, rgba(27, 15, 54, 0.66) 100%),
    linear-gradient(100deg, rgba(27, 15, 54, 0.5), transparent 60%);
  z-index: -2;
}

.island-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 26px 30px 20px;
  color: #fff;
}

.island-title-wrap {
  display: flex;
  gap: 16px;
  align-items: center;
}

.island-emoji {
  font-size: clamp(42px, 5vw, 64px);
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.3));
  animation: mascot-float 5s ease-in-out infinite;
}

.island-kicker {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: #ffe98a;
}

.island-header h2 {
  margin: 2px 0 4px;
  font-family: var(--font-display);
  font-size: clamp(26px, 3.2vw, 38px);
  line-height: 1.1;
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.35);
}

.island-header p {
  margin: 0;
  max-width: 560px;
  font-size: 14px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.82);
}

.island-progress-pill {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  padding: 10px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(8px);
  font-size: 13px;
  font-weight: 700;
}

.island-stars {
  color: #ffe98a;
  font-size: 15px;
}

.island-done {
  color: rgba(255, 255, 255, 0.75);
  font-size: 11px;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 0 24px 26px;
}

.level-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 18px 14px 15px;
  border: 3px solid rgba(255, 255, 255, 0.75);
  border-radius: 24px;
  background: rgba(255, 253, 247, 0.92);
  color: var(--ink);
  box-shadow: 0 10px 22px rgba(30, 15, 60, 0.18);
  text-align: center;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  backdrop-filter: blur(6px);
}

.level-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 18px 34px rgba(30, 15, 60, 0.26);
  background: #fffdf7;
}

.level-card.perfect {
  border-color: #ffd93d;
  box-shadow: 0 0 0 4px rgba(255, 217, 61, 0.32), 0 14px 28px rgba(30, 15, 60, 0.22);
}

.level-card.locked {
  background: rgba(238, 233, 248, 0.78);
  color: #8d80a8;
  filter: saturate(0.4);
  border-color: rgba(255, 255, 255, 0.4);
}

.level-card.locked .level-emoji {
  opacity: 0.55;
  filter: grayscale(0.7);
}

.level-number {
  position: absolute;
  top: 10px;
  left: 12px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 800;
  color: #a58fc9;
  letter-spacing: 0.04em;
}

.level-emoji {
  font-size: 42px;
  line-height: 1.1;
  filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.12));
}

.level-title {
  font-size: 17px;
  font-weight: 900;
  line-height: 1.25;
}

.level-skill {
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--ink-soft);
  min-height: 32px;
}

.level-card.locked .level-skill {
  color: #9c90b4;
}

.level-stars {
  margin-top: 2px;
}

.stars {
  display: inline-flex;
  gap: 2px;
  font-size: 17px;
  line-height: 1;
}

.star.earned {
  color: #ffc107;
  text-shadow: 0 2px 0 #c98a00;
}

.star.empty {
  color: #ddd3e8;
}

.locked-shake {
  animation: shake 0.45s ease;
}

.map-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 34px;
  padding-top: 18px;
  border-top: 1px dashed rgba(100, 84, 138, 0.25);
  color: #a18fbe;
  font-size: 12px;
}

.map-footer .reset-btn {
  margin-left: auto;
}

/* ---------- Level ---------- */
.level-view {
  position: relative;
  min-height: calc(100vh - var(--header-height));
  padding: 20px clamp(14px, 4vw, 44px) 90px;
  background:
    radial-gradient(circle at 10% 10%, var(--theme-glow, rgba(255, 217, 61, 0.28)), transparent 34%),
    radial-gradient(circle at 90% 84%, var(--theme-glow2, rgba(78, 205, 196, 0.2)), transparent 38%),
    var(--theme-bg, #f9f3ff);
}

.theme-forest { --theme-bg: #f1fff4; --theme-accent: #39b86a; --theme-glow: rgba(94, 231, 168, 0.3); --theme-glow2: rgba(255, 217, 61, 0.22); }
.theme-ocean { --theme-bg: #edfbff; --theme-accent: #2aa7c9; --theme-glow: rgba(90, 169, 255, 0.26); --theme-glow2: rgba(78, 205, 196, 0.24); }
.theme-cloud { --theme-bg: #f3f2ff; --theme-accent: #7c8cf8; --theme-glow: rgba(124, 140, 248, 0.24); --theme-glow2: rgba(255, 111, 165, 0.16); }
.theme-space { --theme-bg: #f4efff; --theme-accent: #8b5cf6; --theme-glow: rgba(139, 92, 246, 0.24); --theme-glow2: rgba(255, 217, 61, 0.2); }

.level-topbar {
  max-width: 1000px;
  margin: 0 auto 18px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.round-back {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 0;
  background: #fff;
  box-shadow: var(--shadow-sm);
  font-size: 22px;
  font-weight: 800;
  display: grid;
  place-items: center;
  transition: transform 0.18s ease;
}

.round-back:hover {
  transform: translateX(-3px) scale(1.04);
}

.level-progress {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress-track {
  flex: 1;
  height: 16px;
  border-radius: 999px;
  background: #fff;
  box-shadow: inset 0 2px 5px rgba(80, 60, 120, 0.14);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #5ee7a8, #4ecdc4 40%, #5aa9ff);
  transition: width 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.progress-label {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 15px;
  color: var(--ink-soft);
  min-width: 48px;
  text-align: right;
}

.hint-top {
  border: 0;
  border-radius: 999px;
  padding: 11px 20px;
  background: #fff3c4;
  color: #8a5a00;
  font-size: 15px;
  font-weight: 800;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease;
}

.hint-top:hover {
  transform: translateY(-2px);
}

.question-stage {
  position: relative;
  max-width: 1000px;
  margin: 0 auto;
}

.question-card {
  position: relative;
  background: var(--paper);
  border-radius: var(--radius-xl);
  padding: clamp(20px, 3.4vw, 38px);
  box-shadow: var(--shadow-lg);
  border: 4px solid rgba(255, 255, 255, 0.9);
  overflow: hidden;
}

.question-card::before {
  content: "";
  position: absolute;
  top: -70px;
  right: -70px;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: var(--theme-glow, rgba(255, 217, 61, 0.2));
  pointer-events: none;
}

.question-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.meta-chip {
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--theme-accent, #7c8cf8);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.meta-chip.soft {
  background: rgba(100, 84, 138, 0.1);
  color: var(--ink-soft);
}

.prompt-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 18px;
}

.question-prompt {
  flex: 1;
  margin: 0;
  font-size: clamp(22px, 3.3vw, 34px);
  font-weight: 900;
  line-height: 1.35;
  letter-spacing: 0.02em;
  color: var(--ink);
}

.icon-btn {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  border: 0;
  background: linear-gradient(145deg, #5aa9ff, #3d86e8);
  color: #fff;
  font-size: 24px;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 0 #2d6bc0, 0 10px 18px rgba(61, 134, 232, 0.28);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.icon-btn:hover {
  transform: translateY(-2px);
}

.icon-btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #2d6bc0;
}

.visual-zone {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 230px;
  padding: clamp(14px, 2.8vw, 28px);
  margin-bottom: 20px;
  border-radius: 26px;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.92), transparent 70%),
    linear-gradient(145deg, #fff6dc, #eef9ff);
  border: 2px dashed rgba(120, 95, 165, 0.18);
}

.visual {
  animation: visual-in 0.5s cubic-bezier(0.22, 1, 0.36, 1);
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.visual-caption {
  margin-top: 4px;
  font-size: 12.5px;
  font-weight: 700;
  color: #9b89b8;
  text-align: center;
}

.hint-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  margin-bottom: 18px;
  border-radius: 20px;
  background: #fff6c9;
  border: 2px solid #ffe27a;
  animation: hint-in 0.35s ease;
}

.hint-box[hidden] {
  display: none;
}

.hint-icon {
  font-size: 26px;
}

.hint-box p {
  flex: 1;
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.5;
  color: #7a5200;
}

.hint-speak {
  width: 42px;
  height: 42px;
  font-size: 19px;
  border-radius: 13px;
  background: linear-gradient(145deg, #ffce4a, #f2a900);
  box-shadow: 0 5px 0 #c28200;
}

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

.answer-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 88px;
  padding: 14px 18px;
  border: 3px solid #e7def5;
  border-radius: 24px;
  background: #fff;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 800;
  box-shadow: 0 7px 0 #e5d9f4, 0 10px 20px rgba(66, 38, 112, 0.08);
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  animation: option-in 0.4s both cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
}

.answer-btn:hover:not(:disabled) {
  transform: translateY(-3px);
  border-color: #b9a4e6;
  box-shadow: 0 10px 0 #e5d9f4, 0 18px 30px rgba(66, 38, 112, 0.14);
}

.answer-btn:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: 0 3px 0 #e5d9f4;
}

.answer-index {
  position: absolute;
  top: 8px;
  left: 12px;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: #f1eafd;
  color: #a18acd;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 800;
  display: grid;
  place-items: center;
}

.answer-emoji {
  font-size: 1.15em;
}

.answer-label {
  line-height: 1.15;
}

.answer-btn.correct {
  background: linear-gradient(145deg, #d8ffe5, #b4f7c9);
  border-color: var(--green);
  color: #126b34;
  box-shadow: 0 7px 0 #63cf8b, 0 0 0 5px rgba(57, 184, 106, 0.18);
  animation: correct-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.answer-btn.correct::after {
  content: "✓";
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 26px;
  color: #1c9349;
}

.answer-btn.wrong {
  background: #fff0f1;
  border-color: var(--red);
  color: #b32134;
  animation: shake 0.45s ease;
}

.answer-btn.wrong::after {
  content: "✕";
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 24px;
  color: var(--red);
}

.answer-btn.dimmed {
  opacity: 0.45;
  filter: grayscale(0.5);
}

.answer-btn.revealed {
  animation: reveal-pulse 1s ease infinite alternate;
}

.feedback {
  min-height: 34px;
  margin-top: 18px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 18px;
  font-weight: 800;
  text-align: center;
  line-height: 1.5;
}

.next-inline {
  flex: 0 0 auto;
  border: 0;
  border-radius: 999px;
  padding: 9px 18px;
  background: linear-gradient(135deg, #5ee7a8, #39b86a);
  color: #0b4d2a;
  font-size: 14px;
  font-weight: 900;
  box-shadow: 0 4px 0 #239b52;
  transition: transform 0.15s ease;
}

.next-inline:hover {
  transform: translateY(-2px);
}

.next-inline:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #239b52;
}

.feedback.correct {
  color: var(--green-deep);
  animation: feedback-pop 0.4s ease;
}

.feedback.gentle {
  color: #b07a00;
}

.feedback.reveal {
  color: #5c4a86;
}

.buddy {
  position: absolute;
  right: -6px;
  bottom: 12px;
  width: 112px;
  pointer-events: none;
  animation: mascot-float 4.4s ease-in-out infinite;
}

.buddy img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 50%;
  border: 5px solid #fff;
  box-shadow: var(--shadow-md);
}

.buddy-bubble {
  position: absolute;
  right: 96px;
  top: 12px;
  width: max-content;
  max-width: 150px;
  padding: 8px 13px;
  border-radius: 14px 14px 4px 14px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  box-shadow: var(--shadow-sm);
}

/* ---------- Intro / result overlays ---------- */
.intro-overlay,
.result-overlay {
  position: fixed;
  inset: 0;
  z-index: 850;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(34, 18, 62, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: fade-in 0.3s ease;
}

.intro-card,
.result-card {
  position: relative;
  width: min(620px, 94vw);
  max-height: 92vh;
  overflow: auto;
  padding: clamp(28px, 5vw, 50px);
  border-radius: 42px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.95), transparent 55%),
    linear-gradient(160deg, #fffdf7, #f4ecff);
  box-shadow: 0 30px 80px rgba(20, 8, 50, 0.45);
  border: 5px solid rgba(255, 255, 255, 0.85);
  animation: card-in 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.intro-card .round-back {
  position: absolute;
  top: 18px;
  left: 18px;
}

.intro-emoji {
  font-size: clamp(70px, 12vw, 110px);
  line-height: 1;
  filter: drop-shadow(0 12px 14px rgba(80, 40, 120, 0.2));
  animation: mascot-float 3.6s ease-in-out infinite;
}

.intro-island {
  display: inline-block;
  margin-top: 14px;
  padding: 6px 16px;
  border-radius: 999px;
  background: var(--theme-glow, #fff3c4);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.intro-card h1 {
  margin: 12px 0 4px;
  font-family: var(--font-display);
  font-size: clamp(34px, 6vw, 56px);
  line-height: 1.05;
  color: var(--ink);
}

.intro-skill {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 800;
  color: var(--theme-accent, var(--purple));
}

.intro-text {
  margin: 0 auto 26px;
  max-width: 420px;
  font-size: 17px;
  line-height: 1.7;
  color: var(--ink-soft);
}

.big-btn,
.secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  border-radius: 999px;
  padding: 17px 36px;
  font-family: var(--font-display);
  font-size: clamp(19px, 2.4vw, 24px);
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #ff8a5c, #ff5d8f);
  box-shadow: 0 8px 0 #c73d68, 0 18px 34px rgba(255, 93, 143, 0.34);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.big-btn:hover {
  transform: translateY(-2px);
}

.big-btn:active {
  transform: translateY(5px);
  box-shadow: 0 3px 0 #c73d68;
}

.secondary-btn {
  background: linear-gradient(135deg, #7fb7ff, #5a7bff);
  box-shadow: 0 8px 0 #3f5ed0, 0 18px 34px rgba(90, 123, 255, 0.28);
}

.text-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-size: 15px;
  font-weight: 800;
  padding: 10px 14px;
  border-radius: 12px;
}

.text-btn:hover {
  background: rgba(100, 84, 138, 0.1);
}

.intro-start {
  margin-bottom: 14px;
}

.result-card h2 {
  margin: 8px 0 6px;
  font-family: var(--font-display);
  font-size: clamp(34px, 6vw, 52px);
  color: var(--ink);
}

.result-emoji {
  font-size: clamp(70px, 12vw, 104px);
  line-height: 1;
  animation: mascot-float 3.8s ease-in-out infinite;
}

.result-stars {
  margin: 4px 0 14px;
}

.result-stars .stars {
  gap: 8px;
  font-size: clamp(42px, 7vw, 62px);
}

.result-line {
  margin: 0 0 6px;
  font-size: 17px;
  color: var(--ink-soft);
}

.result-line strong {
  font-family: var(--font-display);
  font-size: 24px;
  color: var(--pink-deep);
}

.result-new {
  display: inline-block;
  margin: 4px 0;
  padding: 5px 14px;
  border-radius: 999px;
  background: #fff0b8;
  color: #9a6a00;
  font-size: 13px;
  font-weight: 800;
  animation: twinkle 1.6s ease-in-out infinite;
}

.result-skill {
  margin: 10px 0 22px;
  font-size: 14px;
  font-weight: 800;
  color: var(--green-deep);
}

.result-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

/* ---------- How to ---------- */
.how-overlay {
  position: fixed;
  inset: 0;
  z-index: 950;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(34, 18, 62, 0.6);
  backdrop-filter: blur(8px);
}

.how-card {
  position: relative;
  width: min(600px, 94vw);
  max-height: 90vh;
  overflow: auto;
  padding: 34px;
  border-radius: 34px;
  background: var(--paper);
  box-shadow: var(--shadow-lg);
  animation: card-in 0.4s ease;
}

.how-card .round-back {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  font-size: 16px;
}

.how-card h2 {
  margin: 0 0 18px;
  font-family: var(--font-display);
  font-size: 34px;
}

.how-list {
  list-style: none;
  padding: 0;
  margin: 0 0 22px;
  display: grid;
  gap: 12px;
}

.how-list li {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: 18px;
  background: #fff7e6;
}

.how-list li > span {
  font-size: 26px;
}

.how-list strong {
  font-size: 15px;
}

.how-list p {
  margin: 2px 0 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-soft);
}

.how-card > .big-btn {
  width: 100%;
}

/* ---------- Visual: ten frame ---------- */
.ten-frame-wrap,
.double-ten-wrap,
.compare-wrap,
.ordinal-wrap,
.bond-wrap,
.addsub-wrap,
.maketen-wrap,
.breakten-wrap,
.clock-wrap,
.baseten-wrap,
.shape-wrap,
.ruler-wrap,
.coins-wrap,
.vertical-wrap,
.calendar-wrap,
.table-wrap,
.scene-wrap,
.numberline-wrap {
  width: 100%;
}

.ten-frame {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
  width: min(360px, 78vw);
  padding: 10px;
  border-radius: 18px;
  background: #fff;
  border: 4px solid #ffcf5c;
  box-shadow: 0 8px 0 #f0b73d, 0 12px 24px rgba(180, 120, 0, 0.14);
}

.double-ten {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
}

.double-ten .ten-frame {
  width: min(300px, 44vw);
}

.ten-cell {
  aspect-ratio: 1;
  border-radius: 9px;
  background: #fff8e8;
  border: 1.5px solid #f0dfbd;
  display: grid;
  place-items: center;
  min-width: 0;
}

.ten-chip {
  font-size: clamp(18px, 3.2vw, 30px);
  line-height: 1;
  animation: chip-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.ten-frame-split {
  border-color: #74c6ff;
  box-shadow: 0 8px 0 #4aa4e8, 0 12px 24px rgba(60, 140, 220, 0.14);
}

/* compare */
.compare-board {
  display: flex;
  align-items: stretch;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.compare-column {
  min-width: 140px;
  padding: 14px;
  border-radius: 20px;
  background: #fff;
  border: 3px solid #dcd0f3;
  box-shadow: var(--shadow-sm);
}

.compare-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
  max-width: 168px;
}

.compare-chip {
  font-size: clamp(20px, 3vw, 28px);
  animation: chip-pop 0.35s both;
}

.compare-count {
  margin-top: 8px;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 20px;
  color: #b3a1cf;
}

.compare-versus {
  align-self: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
  color: #b3a1cf;
}

.compare-left { border-color: #ffc7d8; background: #fff7fa; }
.compare-right { border-color: #bde8ff; background: #f4fbff; }

/* ordinal */
.ordinal-line {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 18px;
  border-radius: 22px;
  background: #fff;
  border: 3px solid #d9ecff;
  box-shadow: var(--shadow-sm);
}

.ordinal-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 10px;
  border-radius: 14px;
  background: #f8f4ff;
  animation: option-in 0.4s both;
}

.ordinal-emoji {
  font-size: clamp(30px, 5vw, 46px);
  line-height: 1;
}

.ordinal-number {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 14px;
  color: var(--ink-soft);
}

.ordinal-arrow {
  align-self: center;
  font-size: 13px;
  font-weight: 800;
  color: #b07a00;
  background: #fff3c4;
  padding: 7px 10px;
  border-radius: 999px;
}

.ordinal-label {
  font-size: 14px;
  font-weight: 800;
  color: var(--ink-soft);
}

.ordinal-hint-line {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #a18fbe;
}

/* number bond */
.bond-board {
  width: min(320px, 80vw);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.bond-whole,
.bond-part {
  display: grid;
  place-items: center;
  min-width: 86px;
  height: 70px;
  padding: 0 16px;
  border-radius: 20px;
  background: linear-gradient(145deg, #ffe26b, #ffc93d);
  border: 3px solid #f0a800;
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 800;
  color: #6d4300;
  box-shadow: 0 6px 0 #d99400;
}

.bond-part {
  background: linear-gradient(145deg, #bde8ff, #8ed4ff);
  border-color: #4aa4e8;
  color: #0b4d7a;
  box-shadow: 0 6px 0 #3c8bc4;
}

.bond-whole.is-unknown,
.bond-part.is-unknown {
  background: #fff;
  border: 3px dashed #b3a1cf;
  color: #8d7aac;
  box-shadow: none;
}

.bond-stems {
  position: relative;
  width: 220px;
  height: 52px;
}

.bond-stem {
  position: absolute;
  top: 0;
  width: 4px;
  height: 64px;
  border-radius: 4px;
  background: #c9b6e8;
  transform-origin: top center;
}

.bond-stem-left { left: 50%; transform: rotate(38deg); }
.bond-stem-right { left: 50%; transform: rotate(-38deg); }

.bond-parts {
  display: flex;
  gap: 54px;
}

/* add/sub scene */
.addsub-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.object-group {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  justify-content: center;
  max-width: 180px;
  padding: 10px;
  border-radius: 16px;
  background: #fff;
  border: 1.5px solid #e8def8;
  min-height: 54px;
}

.object-chip {
  font-size: clamp(20px, 3vw, 30px);
  animation: chip-pop 0.35s both;
}

.crossed-out .object-chip {
  opacity: 0.42;
  text-decoration: line-through;
  text-decoration-thickness: 3px;
  text-decoration-color: #ff5d6c;
}

.addsub-sign {
  font-family: var(--font-display);
  font-size: clamp(24px, 3.4vw, 36px);
  font-weight: 800;
  color: #8b5cf6;
}

.addsub-answer {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  border: 3px dashed #b3a1cf;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 800;
  color: #8d7aac;
  background: #fff;
}

/* make ten / break ten */
.maketen-board,
.breakten-board {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}

.mini-frame {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  width: min(250px, 38vw);
  padding: 8px;
  border-radius: 16px;
  background: #fff;
  border: 3px solid #ffcf5c;
}

.mini-frame-second {
  border-color: #8ed4ff;
}

.mini-frame .ten-cell {
  border-radius: 7px;
}

.mini-frame .ten-chip {
  font-size: clamp(15px, 2.5vw, 24px);
}

.ten-chip.to-move {
  animation: move-pulse 1.2s ease-in-out infinite;
  filter: drop-shadow(0 0 6px #ff9f43);
}

.maketen-plus,
.breakten-plus {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 800;
  color: #8b5cf6;
}

.breakten-ten {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  width: min(250px, 38vw);
  padding: 8px;
  border-radius: 16px;
  background: #fff;
  border: 3px solid #ffcf5c;
}

.breakten-ones {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
  max-width: 110px;
  padding: 8px;
  border-radius: 16px;
  background: #fff;
  border: 3px dashed #8ed4ff;
  min-height: 108px;
  align-content: flex-start;
}

.crossed-chip {
  opacity: 0.38;
  text-decoration: line-through;
  text-decoration-thickness: 2px;
  text-decoration-color: #ff5d6c;
}

/* clock */
.clock-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.clock-face {
  width: min(260px, 60vw);
  height: auto;
  filter: drop-shadow(0 10px 16px rgba(80, 50, 140, 0.18));
}

.clock-rim { fill: #ffcf5c; }
.clock-dial { fill: #fffdf7; stroke: #f0b73d; stroke-width: 3; }
.clock-tick { stroke: #d8c9ee; stroke-width: 2; }
.clock-tick.major { stroke: #9c86c4; stroke-width: 4; }
.clock-number {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 800;
  fill: #55427a;
}
.clock-hand { stroke-linecap: round; }
.hour-hand { stroke: #5b3f8c; stroke-width: 10; }
.minute-hand { stroke: #ff5d8f; stroke-width: 6; }
.clock-center { fill: #ff5d8f; stroke: #fff; stroke-width: 3; }
.clock-legend {
  margin-top: 6px;
  font-size: 12.5px;
  font-weight: 700;
  color: #8d7aac;
}
.legend-short { color: #5b3f8c; font-weight: 900; }
.legend-long { color: #e64d8d; font-weight: 900; }

/* base ten */
.baseten-board {
  display: flex;
  gap: 24px;
  justify-content: center;
  flex-wrap: wrap;
}

.baseten-column {
  padding: 14px;
  border-radius: 18px;
  background: #fff;
  border: 2px solid #e8def8;
  min-width: 140px;
}

.baseten-label {
  margin-bottom: 10px;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  color: #8d7aac;
}

.baseten-rods,
.baseten-cubes {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: center;
  max-width: 240px;
}

.ten-rod {
  display: flex;
  flex-direction: column;
  gap: 1px;
  width: 26px;
  padding: 2px;
  border-radius: 5px;
  background: #ff9f43;
  border: 1.5px solid #d97706;
}

.rod-cell {
  height: 12px;
  border-radius: 2px;
  background: #ffd08a;
  border-bottom: 1px solid rgba(180, 90, 0, 0.25);
}

.one-cube {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: #5aa9ff;
  border: 1.5px solid #2d6bc0;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.4);
}

/* shapes */
.shape-canvas {
  width: min(540px, 88vw);
  height: auto;
  border-radius: 20px;
  background: #fff;
  border: 2px solid #e8def8;
}

/* ruler */
.ruler-wrap {
  --cell: 46px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.ruler-stage {
  position: relative;
  padding-top: 56px;
}

.ruler-object {
  position: absolute;
  top: 0;
  left: 0;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  background: repeating-linear-gradient(90deg, #fff2c9 0, #fff2c9 calc(var(--cell) - 1px), #ffcf5c calc(var(--cell) - 1px), #ffcf5c var(--cell));
  border: 2px solid #ffcf5c;
  border-radius: 12px;
  overflow: hidden;
}

.ruler {
  display: flex;
  height: 58px;
  border: 3px solid #b48b00;
  border-radius: 10px;
  overflow: hidden;
  background: #ffe98a;
}

.ruler-cell {
  width: var(--cell);
  border-right: 1px solid #d9a900;
  position: relative;
  flex: 0 0 auto;
}

.ruler-number {
  position: absolute;
  bottom: 4px;
  left: 4px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 800;
  color: #7a5200;
}

.ruler-end {
  position: relative;
  align-self: flex-end;
  padding-bottom: 4px;
  left: -4px;
}

/* coins */
.coin-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  align-items: center;
  padding: 18px;
  border-radius: 22px;
  background: #fff;
  border: 2px solid #e8def8;
  min-height: 100px;
}

.coin {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  line-height: 1;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.15), 0 6px 10px rgba(60, 40, 100, 0.18);
  border: 3px solid rgba(255, 255, 255, 0.7);
}

.coin small { font-size: 10px; margin-top: 2px; }
.coin span { font-size: 24px; }
.coin-1 { background: radial-gradient(circle at 35% 30%, #f4f6fb, #c8cedd); color: #5f6577; width: 58px; height: 58px; }
.coin-5 { background: radial-gradient(circle at 35% 30%, #f7d9a8, #c98b45); color: #6d3f0c; width: 63px; height: 63px; }
.coin-10 { background: radial-gradient(circle at 35% 30%, #eef2fa, #aeb9cc); color: #4c5568; }
.coin-50 { background: radial-gradient(circle at 35% 30%, #ffe9a3, #e0a72b); color: #704e00; width: 82px; height: 82px; border-color: #ffe9a3; }

/* vertical math */
.vertical-board {
  width: min(320px, 86vw);
  padding: 18px;
  border-radius: 20px;
  background: #fff;
  border: 3px solid #dcd0f3;
  box-shadow: var(--shadow-sm);
}

.vertical-head,
.vertical-row {
  display: grid;
  grid-template-columns: 40px 1fr 1fr;
  align-items: center;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 800;
}

.vertical-head {
  font-family: var(--font-body);
  font-size: 12px;
  color: #a18fbe;
  padding-bottom: 8px;
}

.vertical-row {
  font-size: 34px;
  color: #4a356f;
  line-height: 1.35;
}

.vertical-row.answer { color: #e64d8d; }
.vertical-op { font-size: 26px; color: #8b5cf6; }
.vertical-line {
  height: 3px;
  margin: 4px 0 6px 40px;
  background: #8b5cf6;
  border-radius: 3px;
}

/* calendar */
.calendar-card {
  width: min(460px, 90vw);
  padding: 16px;
  border-radius: 22px;
  background: #fff;
  border: 3px solid #dcd0f3;
  box-shadow: var(--shadow-sm);
}

.calendar-title {
  text-align: center;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  color: #5b3f8c;
  margin-bottom: 10px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar-weekday {
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  color: #a18fbe;
  padding: 4px 0;
}

.calendar-day {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: #faf7ff;
  font-family: var(--font-display);
  font-size: clamp(12px, 2.2vw, 16px);
  font-weight: 700;
  color: #5b4b7a;
}

.calendar-day.empty { background: transparent; }
.calendar-day.highlight {
  background: linear-gradient(145deg, #ff8a5c, #ff5d8f);
  color: #fff;
  box-shadow: 0 4px 0 #c73d68;
  animation: correct-pop 0.5s ease;
  font-weight: 800;
}
.calendar-day.today { outline: 2px solid #5aa9ff; }

/* table */
.table-title {
  text-align: center;
  font-size: 15px;
  font-weight: 800;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.data-table {
  border-collapse: separate;
  border-spacing: 0;
  margin: 0 auto;
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  font-size: 14px;
}

.data-table th,
.data-table td {
  padding: 10px 14px;
  text-align: center;
  border-bottom: 1px solid #efe7fa;
}

.data-table th {
  background: #f4ecff;
  font-size: 12px;
  color: #7c6a9e;
}

.data-table tr:last-child td { border-bottom: 0; }
.data-table td:first-child { text-align: left; font-weight: 800; }
.table-value { font-family: var(--font-display); font-size: 20px; font-weight: 800; color: #5b3f8c; }

/* scene */
.scene-stage {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  padding: 14px;
  border-radius: 20px;
  background: #fff;
  border: 2px solid #e8def8;
  min-height: 80px;
  align-items: center;
}

.scene-emoji {
  font-size: clamp(26px, 4vw, 38px);
  animation: chip-pop 0.4s both;
}

.scene-text {
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-soft);
}

/* number line */
.numberline {
  display: flex;
  justify-content: space-between;
  padding: 14px 8px 4px;
  border-top: 3px solid #c9b6e8;
  position: relative;
  overflow-x: auto;
}

.numberline-tick {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 24px;
}

.numberline-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c9b6e8;
  margin-top: -18px;
}

.numberline-number {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  color: #8d7aac;
  margin-top: 4px;
}

.numberline-tick.marked .numberline-dot { background: #ff5d8f; transform: scale(1.6); }
.numberline-tick.from .numberline-number,
.numberline-tick.to .numberline-number { color: #e64d8d; font-weight: 900; }

/* ---------- Toast / confetti ---------- */
#confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9990;
}

#toast {
  position: fixed;
  left: 50%;
  top: calc(var(--header-height) + 14px);
  transform: translate(-50%, -18px);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 22px;
  border-radius: 999px;
  background: rgba(43, 25, 80, 0.94);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  box-shadow: 0 16px 40px rgba(20, 8, 50, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 10000;
  max-width: 88vw;
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast-emoji { font-size: 21px; }

/* ---------- Animations ---------- */
@keyframes slow-zoom {
  from { transform: scale(1.04) translateY(0); }
  to { transform: scale(1.12) translateY(-1.5%); }
}

@keyframes glow-pulse {
  from { transform: scale(1); opacity: 0.75; }
  to { transform: scale(1.12); opacity: 1; }
}

@keyframes button-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@keyframes shine-sweep {
  0%, 55% { left: -30%; opacity: 0; }
  65% { opacity: 0.7; }
  100% { left: 120%; opacity: 0; }
}

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

@keyframes bubble-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes symbol-float {
  0%, 100% { transform: translateY(0) rotate(-6deg); opacity: 0.4; }
  50% { transform: translateY(-20px) rotate(8deg); opacity: 0.85; }
}

@keyframes twinkle {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.88); }
}

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

@keyframes card-in {
  from { opacity: 0; transform: translateY(26px) scale(0.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

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

@keyframes hint-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes chip-pop {
  0% { opacity: 0; transform: scale(0.3) rotate(-12deg); }
  70% { transform: scale(1.14) rotate(3deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

@keyframes option-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes correct-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

@keyframes reveal-pulse {
  from { box-shadow: 0 7px 0 #63cf8b, 0 0 0 3px rgba(57, 184, 106, 0.15); }
  to { box-shadow: 0 7px 0 #63cf8b, 0 0 0 9px rgba(57, 184, 106, 0.28); }
}

@keyframes feedback-pop {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px) rotate(-1deg); }
  40% { transform: translateX(7px) rotate(1deg); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

@keyframes move-pulse {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 2px #ff9f43); }
  50% { transform: scale(1.14); filter: drop-shadow(0 0 9px #ff9f43); }
}

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .home-content {
    width: min(720px, 92vw);
    margin-left: 5vw;
  }
  .home-mascot {
    width: 180px;
    right: 3vw;
    bottom: 3vh;
    opacity: 0.96;
  }
  .mascot-bubble { display: none; }
  .level-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .map-header { grid-template-columns: auto 1fr; }
  .map-summary { grid-column: 1 / -1; flex-direction: row; justify-content: space-between; align-items: center; }
  .buddy { display: none; }
}

@media (max-width: 680px) {
  :root { --header-height: 64px; }
  .brand-sub { display: none; }
  .bar-btn { width: 42px; height: 42px; border-radius: 14px; font-size: 20px; }
  .home-content { padding-top: calc(var(--header-height) + 10px); margin-left: 0; width: 100%; padding-left: 22px; padding-right: 22px; }
  .home-mascot { display: none; }
  .home-view::before {
    background:
      linear-gradient(to bottom, rgba(27, 15, 54, 0.72), rgba(27, 15, 54, 0.42) 50%, rgba(27, 15, 54, 0.86));
  }
  .home-stats { gap: 7px; }
  .stat-chip { padding: 8px 12px; font-size: 12px; }
  .start-adventure { width: 100%; justify-content: center; padding: 18px 24px; }
  .how-btn, .continue-btn { width: 100%; }
  .map-view { padding-top: 18px; }
  .map-heading h1 { font-size: 32px; }
  .map-heading p { font-size: 13px; }
  .island-header { flex-direction: column; padding: 20px 18px 14px; }
  .island-progress-pill { flex-direction: row; align-items: center; gap: 10px; }
  .level-grid { padding: 0 14px 18px; gap: 10px; }
  .level-card { padding: 14px 8px 12px; border-radius: 20px; }
  .level-emoji { font-size: 34px; }
  .level-title { font-size: 15px; }
  .level-skill { font-size: 10.5px; min-height: 28px; }
  .map-footer { flex-direction: column; text-align: center; }
  .question-card { border-radius: 28px; }
  .visual-zone { min-height: 190px; padding: 12px; }
  .answer-grid { gap: 10px; }
  .answer-btn { min-height: 74px; border-radius: 19px; padding: 10px 12px; }
  .answer-index { width: 20px; height: 20px; font-size: 10px; top: 6px; left: 8px; }
  .answer-btn.correct::after, .answer-btn.wrong::after { right: 8px; font-size: 20px; }
  .hint-top { padding: 9px 14px; font-size: 13px; }
  .progress-label { font-size: 13px; }
  .intro-card, .result-card { border-radius: 30px; padding: 26px 20px; }
  .intro-card .round-back { top: 10px; left: 10px; }
  .double-ten .ten-frame { width: min(220px, 42vw); }
  .mini-frame, .breakten-ten { width: min(200px, 42vw); }
  .compare-column { min-width: 110px; padding: 10px; }
  .compare-chips { max-width: 120px; }
  .bond-parts { gap: 28px; }
  .baseten-board { gap: 10px; }
  .baseten-column { min-width: 110px; padding: 10px; }
  .coin { width: 60px; height: 60px; }
  .coin-1 { width: 48px; height: 48px; }
  .coin-5 { width: 53px; height: 53px; }
  .coin-50 { width: 68px; height: 68px; }
  .ruler-wrap { --cell: 34px; }
  .ruler-object { font-size: 27px; height: 46px; }
  .ruler-stage { padding-top: 48px; }
  .ruler { height: 48px; }
  .toast { font-size: 13px; }
}

@media (max-width: 420px) {
  .title-bottom { font-size: 62px; }
  .title-top { font-size: 42px; }
  .subtitle { font-size: 14px; }
  .level-card .level-skill { display: none; }
  .level-card { padding: 12px 6px 10px; }
  .level-title { font-size: 13.5px; }
  .level-emoji { font-size: 30px; }
  .question-prompt { font-size: 21px; }
  .answer-btn { font-size: 22px; }
  .answer-emoji { font-size: 1em; }
  .compare-board { gap: 6px; }
  .ordinal-line { gap: 4px; padding: 10px; }
  .ordinal-item { padding: 6px; }
  .visual-caption { font-size: 11px; }
  .data-table th, .data-table td { padding: 8px 9px; }
  .calendar-card { padding: 10px; }
}

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