/* ==========================================================================
   星屿谜案 · 基础视觉
   清新纸感 + 星屿夜色 + 原创造型；无外部图片/字体依赖。
   ========================================================================== */
:root {
  --paper: #f7f3ea;
  --paper-2: #fffdf8;
  --paper-3: #f1eadc;
  --ink: #273250;
  --ink-2: #4e5a78;
  --muted: #7b849c;
  --faint: #aab0c0;
  --line: rgba(39, 50, 80, 0.12);
  --line-strong: rgba(39, 50, 80, 0.2);
  --navy: #202a4d;
  --navy-2: #29365f;
  --amber: #e9a23b;
  --amber-deep: #cf7f1e;
  --amber-soft: #fbe8c2;
  --mint: #4fb7a8;
  --mint-soft: #d9f2ec;
  --violet: #7c86e8;
  --violet-soft: #e6e7fb;
  --coral: #df7e92;
  --coral-soft: #f9e1e7;
  --sky: #5b8fd6;
  --sky-soft: #e2edfa;
  --lime: #8cb95a;
  --gold: #f2b94b;
  --danger: #cf5d68;
  --shadow-sm: 0 3px 10px rgba(37, 45, 73, 0.06);
  --shadow-md: 0 12px 32px rgba(37, 45, 73, 0.1);
  --shadow-lg: 0 24px 70px rgba(26, 34, 60, 0.18);
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --font: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-round: "Arial Rounded MT Bold", "PingFang SC", "Microsoft YaHei", var(--font);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 2%, rgba(233, 162, 59, 0.11), transparent 26rem),
    radial-gradient(circle at 94% 22%, rgba(124, 134, 232, 0.09), transparent 28rem),
    radial-gradient(circle at 46% 100%, rgba(79, 183, 168, 0.08), transparent 30rem),
    var(--paper);
  font-family: var(--font);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.36;
  z-index: 0;
  background-image:
    radial-gradient(circle, rgba(39, 50, 80, 0.12) 1px, transparent 1.2px),
    radial-gradient(circle, rgba(39, 50, 80, 0.06) 1px, transparent 1.2px);
  background-size: 92px 92px, 43px 43px;
  background-position: 0 0, 18px 26px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.7), transparent 72%);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
::selection { background: rgba(233, 162, 59, 0.28); color: var(--ink); }
:focus-visible { outline: 2px solid var(--mint); outline-offset: 3px; border-radius: 6px; }

.shell {
  position: relative;
  z-index: 1;
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
}
.shell.narrow { width: min(820px, calc(100% - 32px)); }
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* -------- buttons -------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, border-color 0.16s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary {
  color: #241b0d;
  background: linear-gradient(135deg, #ffd274, #ef9d35);
  border-color: rgba(176, 105, 21, 0.16);
  box-shadow: 0 8px 20px rgba(220, 143, 43, 0.24);
}
.btn-primary:hover { box-shadow: 0 11px 24px rgba(220, 143, 43, 0.3); }
.btn-ghost {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.54);
  border-color: var(--line);
}
.btn-ghost:hover { background: #fff; border-color: var(--line-strong); }
.btn-soft {
  color: var(--ink-2);
  background: var(--paper-3);
  border-color: transparent;
}
.btn-soft:hover { background: #ebe2d1; }
.btn-danger { color: #fff; background: #c75863; }
.btn-lg { min-height: 52px; padding: 0 26px; font-size: 15px; border-radius: 14px; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 12px; border-radius: 9px; }
.btn-block { width: 100%; }
.btn .ic { flex: none; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px; height: 42px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.58);
  color: var(--ink-2);
  transition: background 0.16s, border-color 0.16s, transform 0.16s;
}
.icon-btn:hover { background: #fff; border-color: var(--line-strong); transform: translateY(-1px); }
.icon-btn.is-on { background: var(--navy); color: #fff; border-color: var(--navy); }
.icon-btn.small { width: 34px; height: 34px; border-radius: 9px; }

/* -------- topbar -------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(247, 243, 234, 0.82);
  backdrop-filter: blur(16px) saturate(1.2);
  border-bottom: 1px solid rgba(39, 50, 80, 0.08);
}
.topbar-in {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 66px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-weight: 800;
}
.brand img { width: 34px; height: 34px; filter: drop-shadow(0 4px 10px rgba(210, 133, 34, 0.25)); }
.brand-copy { display: flex; flex-direction: column; line-height: 1.08; }
.brand-copy strong { font-family: var(--font-round); font-size: 17px; letter-spacing: 0.03em; }
.brand-copy small { margin-top: 4px; color: var(--muted); font-size: 8.5px; letter-spacing: 0.2em; font-weight: 700; }
.top-nav { display: flex; align-items: center; gap: 4px; margin-left: 16px; }
.top-nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.top-nav a:hover { color: var(--ink); background: rgba(255, 255, 255, 0.6); }
.top-nav a.on { color: var(--ink); background: #fff; box-shadow: var(--shadow-sm); }
.top-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.account-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 190px;
  min-height: 38px;
  padding: 0 12px 0 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-2);
}
.account-pill .avatar {
  display: grid; place-items: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, var(--violet), #9e8df0);
  color: #fff; font-size: 11px;
}
.account-pill .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--mint); }
.account-pill.guest .dot { background: var(--faint); }
.cloud-chip { color: var(--muted); font-size: 11px; padding-right: 4px; }
.mobile-nav { display: none; }

/* -------- home -------- */
.home-hero {
  position: relative;
  overflow: hidden;
  margin-top: 22px;
  padding: clamp(28px, 5vw, 58px);
  min-height: 334px;
  color: #f9f5eb;
  background:
    radial-gradient(circle at 82% 20%, rgba(124, 134, 232, 0.32), transparent 45%),
    radial-gradient(circle at 17% 88%, rgba(79, 183, 168, 0.18), transparent 38%),
    linear-gradient(140deg, #1f294b 0%, #27345c 58%, #202a4d 100%);
  border-radius: var(--radius-xl);
  box-shadow: 0 26px 60px rgba(26, 34, 60, 0.18);
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(280px, 0.88fr);
  align-items: center;
  gap: 18px;
}
.home-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.8;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.55) 1px, transparent 1.4px),
    radial-gradient(circle, rgba(255, 255, 255, 0.28) 1px, transparent 1.4px);
  background-size: 130px 130px, 73px 73px;
  background-position: 22px 32px, 70px 80px;
  mask-image: radial-gradient(ellipse at 70% 40%, #000, transparent 70%);
}
.hero-copy { position: relative; z-index: 2; }
.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #ffdd9a;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.22em;
}
.hero-kicker::before { content: ""; width: 22px; height: 1px; background: currentColor; opacity: 0.7; }
.home-hero h1 {
  margin: 15px 0 12px;
  max-width: 560px;
  font-family: var(--font-round);
  font-size: clamp(30px, 4.2vw, 50px);
  line-height: 1.18;
  letter-spacing: -0.02em;
  font-weight: 800;
}
.home-hero h1 em { font-style: normal; color: #ffd071; }
.hero-lead {
  margin: 0;
  max-width: 480px;
  color: rgba(249, 245, 235, 0.72);
  font-size: 14px;
  line-height: 1.8;
}
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 24px; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 22px; color: rgba(249, 245, 235, 0.58); font-size: 11px; }
.hero-meta span { display: inline-flex; align-items: center; gap: 6px; }
.hero-art-wrap { position: relative; z-index: 1; display: grid; place-items: center; min-height: 240px; }
.hero-art { width: min(100%, 430px); height: auto; filter: drop-shadow(0 24px 34px rgba(0, 0, 0, 0.22)); animation: heroFloat 7s ease-in-out infinite; }
@keyframes heroFloat { 0%, 100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-8px) rotate(1deg); } }
.hero-badge {
  position: absolute;
  z-index: 2;
  right: 8%;
  bottom: 8%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 13px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  background: rgba(24, 32, 58, 0.66);
  backdrop-filter: blur(8px);
  color: #fff7e5;
  font-size: 11px;
  font-weight: 700;
}
.hero-badge b { color: #ffd071; font-size: 16px; line-height: 1; }

.progress-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  overflow: hidden;
  margin-top: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--line);
  box-shadow: var(--shadow-sm);
}
.progress-cell { background: rgba(255, 253, 248, 0.92); padding: 16px 18px; }
.progress-cell small { display: block; color: var(--muted); font-size: 10px; letter-spacing: 0.12em; font-weight: 700; }
.progress-cell b { display: flex; align-items: baseline; gap: 5px; margin-top: 3px; font-family: var(--font-round); font-size: 24px; line-height: 1.15; }
.progress-cell b span { color: var(--faint); font-size: 12px; font-family: var(--font); font-weight: 600; }
.progress-cell .mini-bar { height: 4px; margin-top: 8px; border-radius: 4px; background: var(--paper-3); overflow: hidden; }
.progress-cell .mini-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--amber), #f5c86c); }

.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 34px 0 14px; }
.section-head h2 { margin: 0; font-family: var(--font-round); font-size: 20px; letter-spacing: 0.01em; }
.section-head h2 small { margin-left: 8px; color: var(--muted); font-family: var(--font); font-size: 11px; font-weight: 600; letter-spacing: 0.06em; }
.section-head p { margin: 0; color: var(--muted); font-size: 12px; }
.section-link { display: inline-flex; align-items: center; gap: 5px; color: var(--ink-2); font-size: 12px; font-weight: 700; }
.section-link:hover { color: var(--amber-deep); }

.chapter-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.chapter-card {
  --accent: var(--amber);
  --accent-soft: var(--amber-soft);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 192px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.88);
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.chapter-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: rgba(39, 50, 80, 0.18); }
.chapter-card::after {
  content: "";
  position: absolute;
  right: -36px; top: -44px;
  width: 150px; height: 150px;
  border-radius: 50%;
  background: var(--accent-soft);
  opacity: 0.7;
  transition: transform 0.4s ease;
}
.chapter-card:hover::after { transform: scale(1.12); }
.chapter-icon {
  position: relative;
  z-index: 1;
  display: grid; place-items: center;
  width: 44px; height: 44px;
  border-radius: 13px;
  background: var(--accent-soft);
  color: var(--accent);
}
.chapter-no { position: absolute; z-index: 1; top: 19px; right: 20px; color: var(--faint); font-size: 10px; letter-spacing: 0.18em; font-weight: 800; }
.chapter-card h3 { position: relative; z-index: 1; margin: 18px 0 4px; font-family: var(--font-round); font-size: 18px; }
.chapter-card p { position: relative; z-index: 1; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.65; }
.chapter-foot { position: relative; z-index: 1; display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 16px; color: var(--muted); font-size: 11px; font-weight: 700; }
.chapter-foot .bar { flex: 1; height: 4px; border-radius: 4px; background: var(--paper-3); overflow: hidden; }
.chapter-foot .bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.chapter-card.is-admin { border-style: dashed; background: rgba(246, 246, 241, 0.76); }

/* resume / daily */
.resume-card {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  align-items: center;
  gap: 16px;
  margin-top: 18px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(120deg, #fffdf8, #fbf5e8);
  box-shadow: var(--shadow-sm);
}
.resume-num {
  display: grid; place-items: center;
  width: 58px; height: 58px;
  border-radius: 18px;
  background: var(--navy);
  color: #ffd071;
  font-family: var(--font-round);
  font-size: 20px;
  box-shadow: 0 8px 18px rgba(32, 42, 77, 0.16);
}
.resume-card h3 { margin: 0; font-family: var(--font-round); font-size: 16px; }
.resume-card p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.resume-card .btn { flex: none; }
.resume-progress { display: flex; align-items: center; gap: 10px; margin-top: 8px; color: var(--faint); font-size: 10px; }
.resume-progress .stars { color: var(--gold); letter-spacing: 0.1em; }

/* -------- map -------- */
.page-head { padding: 30px 0 12px; }
.page-head .eyebrow { color: var(--amber-deep); font-size: 10px; font-weight: 800; letter-spacing: 0.2em; }
.page-head h1 { margin: 7px 0 5px; font-family: var(--font-round); font-size: clamp(25px, 3.5vw, 34px); line-height: 1.25; }
.page-head p { margin: 0; color: var(--muted); font-size: 13px; }
.chapter-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 13px 0 5px; scrollbar-width: none; }
.chapter-tabs::-webkit-scrollbar { display: none; }
.chapter-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: none;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.72);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.chapter-tab .ic { color: var(--accent, var(--amber)); }
.chapter-tab:hover { background: #fff; color: var(--ink); }
.chapter-tab.on { background: var(--navy); border-color: var(--navy); color: #fff; box-shadow: 0 8px 18px rgba(32, 42, 77, 0.16); }
.chapter-tab.on .ic { color: #ffd071; }
.chapter-banner {
  margin-top: 18px;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.86);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 18px;
}
.chapter-banner .chapter-icon { width: 52px; height: 52px; flex: none; }
.chapter-banner h2 { margin: 0; font-family: var(--font-round); font-size: 20px; }
.chapter-banner p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.chapter-banner .chapter-score { margin-left: auto; text-align: right; flex: none; }
.chapter-banner .chapter-score b { display: block; font-family: var(--font-round); font-size: 24px; line-height: 1.1; }
.chapter-banner .chapter-score small { color: var(--muted); font-size: 10px; letter-spacing: 0.1em; }
.level-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin: 20px 0 54px; }
.level-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 152px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 253, 248, 0.9);
  box-shadow: var(--shadow-sm);
  transition: transform 0.16s, box-shadow 0.16s, border-color 0.16s;
}
.level-card:hover { transform: translateY(-3px); border-color: var(--line-strong); box-shadow: var(--shadow-md); }
.level-card .level-no { color: var(--faint); font-family: var(--font-round); font-size: 12px; letter-spacing: 0.08em; }
.level-card h3 { margin: 9px 0 3px; font-size: 14px; line-height: 1.35; font-weight: 700; }
.level-card .level-mech { color: var(--muted); font-size: 10.5px; line-height: 1.5; }
.level-card .level-foot { display: flex; align-items: center; justify-content: space-between; gap: 5px; margin-top: auto; padding-top: 12px; }
.level-card .stars { color: var(--gold); font-size: 12px; letter-spacing: 0.12em; }
.level-card .stars .off { color: #d8d3c8; }
.level-card .marker { width: 8px; height: 8px; border-radius: 50%; background: var(--chapter-accent, var(--amber)); opacity: 0.65; }
.level-card .done-flag {
  position: absolute; top: 12px; right: 12px;
  display: grid; place-items: center;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--mint-soft);
  color: #277e70;
}
.level-card.is-done { border-color: rgba(79, 183, 168, 0.24); }
.level-card.is-admin { border-style: dashed; background: rgba(249, 247, 240, 0.8); }
.level-card .admin-chip {
  position: absolute; top: 10px; right: 10px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--paper-3);
  color: var(--muted);
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
}
.level-card.is-tutorial::before {
  content: "教学";
  position: absolute;
  left: 13px; top: -8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--amber);
  color: #fff;
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

/* -------- play -------- */
.play-wrap { padding: 18px 0 40px; }
.play-top { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.play-title { min-width: 0; }
.play-title .kicker { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10.5px; font-weight: 700; letter-spacing: 0.11em; }
.play-title h1 { margin: 2px 0 0; font-family: var(--font-round); font-size: clamp(19px, 3vw, 25px); line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.play-top .play-actions { margin-left: auto; display: flex; align-items: center; gap: 7px; }
.play-progress { display: flex; gap: 5px; margin-left: 4px; }
.play-progress i { width: 18px; height: 4px; border-radius: 3px; background: var(--paper-3); }
.play-progress i.on { background: var(--mint); }
.play-progress i.done { background: var(--navy); }

.play-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 253, 248, 0.94);
  box-shadow: var(--shadow-md);
}
.play-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 15px 20px; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, 0.45); }
.goal-pill { display: inline-flex; align-items: center; gap: 8px; min-width: 0; color: var(--ink-2); font-size: 12px; font-weight: 600; }
.goal-pill .ic { flex: none; color: var(--amber-deep); }
.goal-pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 999px; background: var(--paper-3); color: var(--ink-2); font-size: 9.5px; font-weight: 800; letter-spacing: 0.05em; white-space: nowrap; }
.chip.amber { background: var(--amber-soft); color: #9a6214; }
.chip.mint { background: var(--mint-soft); color: #287b6d; }
.chip.violet { background: var(--violet-soft); color: #4d57b0; }
.chip.coral { background: var(--coral-soft); color: #a34d60; }
.chip.navy { background: var(--navy); color: #fff; }
.play-head .head-right { display: flex; align-items: center; gap: 7px; margin-left: auto; }
.play-stat { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 10.5px; font-weight: 700; }
.play-stat b { color: var(--ink); font-size: 12px; }
.stage-strip { display: flex; align-items: center; gap: 6px; padding: 10px 20px; background: #faf6ed; border-bottom: 1px solid var(--line); overflow-x: auto; }
.stage-step { display: inline-flex; align-items: center; gap: 5px; color: var(--faint); font-size: 10px; font-weight: 700; white-space: nowrap; }
.stage-step i { display: grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; background: var(--paper-3); color: var(--muted); font-style: normal; font-size: 9px; }
.stage-step.on { color: var(--ink); }
.stage-step.on i { background: var(--navy); color: #fff; }
.stage-step.done i { background: var(--mint); color: #fff; }
.stage-step .stage-line { width: 16px; height: 1px; background: var(--line); }
.stage-area { min-height: 340px; padding: clamp(16px, 3vw, 28px); }
.stage-area.is-in { animation: stageIn 0.28s ease both; }
@keyframes stageIn { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
.play-foot { display: flex; align-items: center; gap: 8px; padding: 12px 18px calc(12px + var(--safe-bottom)); border-top: 1px solid var(--line); background: rgba(255, 255, 255, 0.52); }
.play-foot .spacer { flex: 1; }
.foot-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 13px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255, 255, 255, 0.66); color: var(--ink-2); font-size: 12px; font-weight: 700; }
.foot-btn:hover { background: #fff; border-color: var(--line-strong); }
.foot-btn.hint { background: var(--navy); border-color: var(--navy); color: #ffdf9e; }
.foot-btn.hint:hover { background: #2a3763; }

/* -------- engine shared -------- */
.engine { display: flex; flex-direction: column; align-items: center; }
.engine-board-area { width: 100%; display: flex; flex-direction: column; align-items: center; }
.engine-aside { width: 100%; max-width: 580px; margin-top: 20px; }
.engine-tip { display: flex; align-items: flex-start; gap: 10px; max-width: 580px; margin: 0 auto 16px; padding: 10px 13px; border-radius: 12px; background: #faf5e9; color: var(--ink-2); font-size: 11.5px; line-height: 1.6; }
.engine-tip .ic { flex: none; margin-top: 1px; color: var(--amber-deep); }
.engine-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin-top: 18px; }
.engine-btn { min-height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 11px; background: #fff; color: var(--ink-2); font-size: 12px; font-weight: 700; }
.engine-btn:hover { border-color: var(--line-strong); }
.engine-btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.engine-btn.primary:hover { background: #2b3965; }
.engine-btn.ghost { background: transparent; }
.engine-btn[disabled] { opacity: 0.42; cursor: not-allowed; }
.board-frame { position: relative; padding: 14px; border-radius: 20px; background: #f1eadc; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 8px 24px rgba(39, 50, 80, 0.06); touch-action: none; }
.board {
  --cols: 4;
  --rows: 4;
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  grid-template-rows: repeat(var(--rows), 1fr);
  gap: 5px;
  width: min(440px, 78vw, 56vh);
  aspect-ratio: var(--cols) / var(--rows);
  user-select: none;
  -webkit-user-select: none;
}
.board.compact { width: min(380px, 74vw, 50vh); }
.cell {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  border-radius: 10px;
  background: rgba(39, 50, 80, 0.055);
  color: var(--ink-2);
  transition: background 0.12s, transform 0.12s;
}
.cell.is-mask { background: #fffdf8; box-shadow: inset 0 0 0 1px rgba(39, 50, 80, 0.06); }
.cell.is-void { background: transparent; box-shadow: none; }
.cell.is-wall { background: repeating-linear-gradient(135deg, #45506e 0 5px, #3b4561 5px 10px); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.08); }
.cell .cell-glyph { display: grid; place-items: center; width: 58%; height: 58%; color: var(--ink-2); }
.cell .cell-glyph .ic { width: 100%; height: 100%; }
.cell .cell-num { font-family: var(--font-round); font-size: 18px; color: var(--ink); }
.cell .cell-mark { position: absolute; width: 18%; height: 18%; border-radius: 50%; background: currentColor; }
.cell.pos-0 { color: var(--amber); } .cell.pos-1 { color: var(--mint); } .cell.pos-2 { color: var(--violet); } .cell.pos-3 { color: var(--coral); } .cell.pos-4 { color: var(--sky); }

/* pack */
.pack-board .cell.is-mask { background: #fffdf8; }
.pack-board .cell.is-mask:hover { background: #fdf4df; }
.pack-board .cell.is-filled { color: #fff; }
.piece-fill {
  position: absolute;
  inset: 3px;
  border-radius: 7px;
  background: var(--piece-color, var(--amber));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transition: transform 0.12s, opacity 0.12s;
}
.piece-fill::after { content: ""; position: absolute; inset: 3px; border-radius: 5px; border: 1px solid rgba(255, 255, 255, 0.32); }
.piece-fill[data-color="mint"] { background: var(--mint); }
.piece-fill[data-color="violet"] { background: var(--violet); }
.piece-fill[data-color="coral"] { background: var(--coral); }
.piece-fill[data-color="sky"] { background: var(--sky); }
.piece-fill[data-color="rose"] { background: #e884a0; }
.piece-fill[data-color="lime"] { background: var(--lime); }
.piece-fill.picked { opacity: 0.3; }
.cell.ghost-ok .piece-fill, .cell.ghost-ok { background: rgba(79, 183, 168, 0.28); }
.pack-tray { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: center; gap: 10px; max-width: 560px; margin-top: 18px; padding: 13px; border: 1px dashed var(--line-strong); border-radius: 16px; background: rgba(255, 255, 255, 0.45); }
.tray-piece { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 8px 5px; border: 1px solid transparent; border-radius: 12px; background: transparent; color: var(--ink); }
.tray-piece:hover { background: #fffdf8; border-color: var(--line); }
.tray-piece.on { background: #fff; border-color: var(--amber); box-shadow: 0 0 0 3px rgba(233, 162, 59, 0.16); }
.tray-piece.is-placed { opacity: 0.32; filter: grayscale(0.5); }
.tray-piece small { color: var(--muted); font-size: 9px; white-space: nowrap; }
.piece-mini { display: grid; gap: 2px; }
.piece-mini i { width: 12px; height: 12px; border-radius: 3px; background: transparent; }
.piece-mini i.on { background: var(--piece-color, var(--amber)); }
.piece-mini i.on[data-color="mint"] { background: var(--mint); }
.piece-mini i.on[data-color="violet"] { background: var(--violet); }
.piece-mini i.on[data-color="coral"] { background: var(--coral); }
.piece-mini i.on[data-color="sky"] { background: var(--sky); }
.piece-mini i.on[data-color="rose"] { background: #e884a0; }
.piece-mini i.on[data-color="lime"] { background: var(--lime); }
.pack-controls { display: flex; gap: 7px; margin-top: 10px; }

/* deduce */
.deduce-slots { display: flex; justify-content: center; gap: 9px; width: 100%; max-width: 560px; }
.deduce-slot { flex: 1 1 0; min-width: 0; max-width: 108px; }
.deduce-slot .slot-box {
  position: relative;
  display: grid; place-items: center;
  aspect-ratio: 1;
  border: 2px dashed rgba(39, 50, 80, 0.18);
  border-radius: 16px;
  background: #fffdf8;
  transition: background 0.14s, border-color 0.14s, transform 0.14s;
}
.deduce-slot .slot-box:hover { border-color: var(--amber); background: #fdf6e7; }
.deduce-slot .slot-box.has-item { border-style: solid; border-color: rgba(39, 50, 80, 0.1); }
.deduce-slot .slot-num { position: absolute; top: 6px; left: 8px; color: var(--faint); font-size: 9px; font-weight: 800; }
.deduce-slot .slot-box .ic { width: 46%; height: 46%; }
.deduce-slot .slot-box.pos-0 { color: var(--amber); } .deduce-slot .slot-box.pos-1 { color: var(--mint); } .deduce-slot .slot-box.pos-2 { color: var(--violet); } .deduce-slot .slot-box.pos-3 { color: var(--coral); } .deduce-slot .slot-box.pos-4 { color: var(--sky); }
.deduce-slot .slot-label { margin-top: 5px; text-align: center; color: var(--muted); font-size: 10px; }
.deduce-item-tray { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 18px; }
.item-token { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; padding: 0 13px 0 9px; border: 1px solid var(--line); border-radius: 13px; background: #fff; color: var(--ink); font-size: 12px; font-weight: 700; }
.item-token .ic { width: 24px; height: 24px; }
.item-token:hover { border-color: var(--amber); background: #fffaf0; }
.item-token.on { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(233, 162, 59, 0.17); }
.item-token.used { opacity: 0.4; }
.clue-list { display: grid; gap: 8px; width: 100%; max-width: 560px; margin: 18px auto 0; }
.clue { display: flex; align-items: flex-start; gap: 10px; padding: 9px 12px; border-radius: 12px; background: #faf5e8; color: var(--ink-2); font-size: 11.5px; line-height: 1.55; }
.clue .clue-badge { display: grid; place-items: center; flex: none; width: 22px; height: 22px; border-radius: 7px; background: #fff; color: var(--amber-deep); }
.clue.is-new { animation: clueIn 0.4s ease; }
@keyframes clueIn { from { opacity: 0; transform: translateX(-5px); } to { opacity: 1; transform: none; } }
.deduce-check { margin-top: 16px; }
.deduce-slot.shake .slot-box { animation: shake 0.32s; border-color: var(--danger); }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* path */
.path-frame { touch-action: none; }
.path-board { position: relative; }
.path-svg { position: absolute; inset: 0; pointer-events: none; width: 100%; height: 100%; overflow: visible; }
.path-svg polyline { fill: none; stroke: var(--mint); stroke-width: 0.36; stroke-linecap: round; stroke-linejoin: round; opacity: 0.92; }
.path-svg .path-dot { fill: #fff; stroke: var(--mint); stroke-width: 0.1; }
.path-cell { z-index: 1; }
.path-cell.is-path { background: var(--mint-soft); }
.path-cell.is-head { background: #bfe8df; box-shadow: inset 0 0 0 2px var(--mint); }
.path-cell .path-glyph { position: relative; z-index: 2; width: 44%; height: 44%; display: grid; place-items: center; }
.path-cell .path-glyph .ic { width: 100%; height: 100%; }
.path-cell.is-start { background: #dff3ee; }
.path-cell.is-end { background: #ffe9bc; }
.path-cell.is-star .cell-glyph { color: var(--gold); }
.path-cell.is-gate { background: repeating-linear-gradient(135deg, #e7dfd0 0 4px, #f2ebde 4px 8px); }
.path-cell.is-gate.open { background: #e4f2e8; }
.path-cell.is-gate.locked .cell-glyph { color: #9f8865; }
.path-cell.is-blocked { animation: shake 0.3s; }
.path-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 11px; color: var(--muted); font-size: 10px; }
.path-legend span { display: inline-flex; align-items: center; gap: 4px; }
.path-legend i { width: 9px; height: 9px; border-radius: 3px; background: var(--mint-soft); }
.path-legend i.star { background: var(--gold); }
.path-legend i.gate { background: #d7cbb6; }

/* rover */
.rover-board .cell { background: #faf6ec; box-shadow: inset 0 0 0 1px rgba(39, 50, 80, 0.05); }
.rover-board .cell.is-wall { background: repeating-linear-gradient(135deg, #45506e 0 5px, #3b4561 5px 10px); }
.rover-board .cell.is-goal { background: #fff2d2; }
.rover-board .cell.is-goal::after { content: ""; width: 34%; height: 34%; border-radius: 50%; border: 2px dashed var(--amber-deep); }
.rover-board .cell.is-star .cell-glyph { color: var(--gold); }
.rover { position: absolute; z-index: 3; display: grid; place-items: center; width: 70%; height: 70%; border-radius: 13px; background: var(--navy); color: #ffd071; box-shadow: 0 4px 12px rgba(32, 42, 77, 0.28); transition: left 0.3s ease, top 0.3s ease, transform 0.25s; }
.rover .ic { width: 62%; height: 62%; }
.rover.dir-E { transform: rotate(0deg); } .rover.dir-S { transform: rotate(90deg); } .rover.dir-W { transform: rotate(180deg); } .rover.dir-N { transform: rotate(-90deg); }
.rover-board { position: relative; }
.trail-dot { position: absolute; z-index: 1; width: 12%; height: 12%; border-radius: 50%; background: rgba(79, 183, 168, 0.35); transform: translate(-50%, -50%); }
.cmd-queue { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; min-height: 54px; width: 100%; max-width: 520px; margin-top: 14px; padding: 9px; border: 1px dashed var(--line-strong); border-radius: 14px; background: rgba(255, 255, 255, 0.45); }
.cmd-empty { color: var(--faint); font-size: 11px; }
.cmd-chip { display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 9px; border-radius: 9px; background: #fff; border: 1px solid var(--line); color: var(--ink-2); font-size: 10px; font-weight: 800; }
.cmd-chip .ic { width: 15px; height: 15px; }
.cmd-palette { display: flex; justify-content: center; gap: 7px; margin-top: 10px; }
.cmd-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 66px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 11px; background: #fff; color: var(--ink-2); font-size: 10px; font-weight: 700; }
.cmd-btn .ic { width: 20px; height: 20px; }
.cmd-btn b { color: var(--ink); font-size: 10px; }
.cmd-btn:hover { border-color: var(--amber); background: #fffaf0; }
.cmd-btn[disabled] { opacity: 0.35; }

/* hanoi */
.hanoi { display: flex; justify-content: center; align-items: flex-end; gap: clamp(10px, 3vw, 28px); width: 100%; max-width: 520px; min-height: 270px; padding: 18px 10px 0; }
.peg { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; width: 31%; max-width: 150px; height: 238px; padding-bottom: 13px; border: none; background: transparent; }
.peg::before { content: ""; position: absolute; bottom: 12px; width: 5px; height: 176px; border-radius: 4px; background: #d4c9b7; }
.peg::after { content: ""; position: absolute; bottom: 5px; width: 100%; height: 9px; border-radius: 5px; background: #c8bca8; }
.peg .peg-label { position: absolute; bottom: -21px; color: var(--muted); font-size: 10px; font-weight: 700; }
.peg.on::before { background: var(--amber); }
.peg.on { background: rgba(233, 162, 59, 0.07); border-radius: 12px; }
.peg .disk { position: relative; z-index: 2; height: 20px; margin-bottom: 3px; border-radius: 7px; background: var(--disk-color); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.36), 0 2px 3px rgba(39, 50, 80, 0.1); transition: transform 0.2s; }
.peg .disk.top { outline: 2px solid rgba(39, 50, 80, 0.2); outline-offset: 1px; }
.peg .disk.drop { animation: diskDrop 0.24s ease; }
@keyframes diskDrop { from { transform: translateY(-12px); } to { transform: none; } }
.hanoi-info { display: flex; justify-content: center; gap: 18px; margin-top: 8px; color: var(--muted); font-size: 10px; }

/* lights */
.lights-board .cell { background: #f7f2e6; box-shadow: inset 0 0 0 1px rgba(39, 50, 80, 0.05); }
.lights-board .cell.lit { background: radial-gradient(circle at 40% 35%, #fff8d9, #f6d070); box-shadow: inset 0 0 0 1px rgba(217, 166, 50, 0.25), 0 0 20px rgba(242, 185, 75, 0.22); }
.lights-board .cell .cell-glyph { color: #c8bca8; transition: color 0.16s, transform 0.16s; }
.lights-board .cell.lit .cell-glyph { color: #fffdf1; transform: scale(1.05); }
.lights-board .cell:hover { background: #fff9e9; }
.lights-board .cell.lit:hover { background: #ffe49a; }

/* sudoku */
.sudoku-wrap { display: flex; align-items: flex-start; justify-content: center; gap: 18px; flex-wrap: wrap; }
.sudoku-board { display: grid; grid-template-columns: repeat(4, 1fr); width: min(370px, 78vw); aspect-ratio: 1; border: 2px solid var(--ink); border-radius: 12px; overflow: hidden; background: var(--ink); gap: 1px; }
.sudoku-cell { position: relative; display: grid; place-items: center; background: #fffdf8; color: var(--ink); font-family: var(--font-round); font-size: clamp(20px, 5vw, 30px); border: none; padding: 0; }
.sudoku-cell:nth-child(4n+3) { border-left: 3px solid var(--ink); }
.sudoku-cell:nth-child(n+9):nth-child(-n+12) { border-bottom: 3px solid var(--ink); }
.sudoku-cell.given { background: #f3ecdd; color: var(--ink-2); }
.sudoku-cell.selected { background: var(--amber-soft); }
.sudoku-cell.soft-error { color: var(--danger); }
.sudoku-cell .pencil { font-size: 10px; color: var(--muted); }
.sudoku-pad { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; width: 118px; }
.sudoku-pad button { height: 50px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-family: var(--font-round); font-size: 20px; }
.sudoku-pad button:hover { border-color: var(--amber); background: #fffaf0; }

/* slide */
.slide-board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; width: min(340px, 78vw); aspect-ratio: 1; padding: 9px; border-radius: 18px; background: #2c3658; box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.25); }
.slide-tile { display: grid; place-items: center; border: none; border-radius: 12px; background: linear-gradient(145deg, #fffaf0, #f2e3c8); color: var(--navy); font-family: var(--font-round); font-size: clamp(24px, 6vw, 36px); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.18); transition: transform 0.14s; }
.slide-tile:hover { background: #fff; }
.slide-tile.blank { background: transparent; box-shadow: none; pointer-events: none; }
.slide-tile.movable { box-shadow: 0 3px 0 rgba(0, 0, 0, 0.18), 0 0 0 2px var(--amber); }

/* combo */
.combo-stage-label { display: flex; align-items: center; gap: 8px; margin: 0 auto 14px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: 0.12em; }
.combo-stage-label b { color: var(--ink); }
.combo-stage-label .line { width: 24px; height: 1px; background: var(--line-strong); }

/* -------- tutorial / hint -------- */
.tutorial-card { max-width: 440px; text-align: left; }
.tutorial-illus { display: grid; place-items: center; height: 108px; margin-bottom: 16px; border-radius: 16px; background: radial-gradient(circle at 50% 30%, #fff4d6, #f6e9cf); color: var(--amber-deep); }
.tutorial-illus .ic { width: 52px; height: 52px; }
.tutorial-card .tut-step { color: var(--amber-deep); font-size: 9px; font-weight: 800; letter-spacing: 0.18em; }
.tutorial-card h3 { margin: 5px 0 7px; font-family: var(--font-round); font-size: 20px; }
.tutorial-card p { margin: 0; color: var(--ink-2); font-size: 13px; line-height: 1.75; }
.hint-sheet { max-width: 520px; }
.hint-intro { margin: 0 0 14px; color: var(--muted); font-size: 11.5px; line-height: 1.65; }
.hint-tier {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  margin-bottom: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fffdf8;
  text-align: left;
  transition: border-color 0.16s, background 0.16s;
}
.hint-tier:hover { border-color: var(--amber); background: #fffaf0; }
.hint-tier[disabled] { opacity: 0.5; cursor: not-allowed; }
.hint-tier .num { display: grid; place-items: center; flex: none; width: 27px; height: 27px; border-radius: 8px; background: var(--paper-3); color: var(--ink-2); font-family: var(--font-round); font-size: 12px; }
.hint-tier.tier-1 .num { background: var(--mint-soft); color: #287b6d; }
.hint-tier.tier-2 .num { background: var(--amber-soft); color: #9a6214; }
.hint-tier.tier-3 .num { background: var(--coral-soft); color: #a34d60; }
.hint-tier h4 { margin: 0; font-size: 12.5px; }
.hint-tier p { margin: 2px 0 0; color: var(--muted); font-size: 10.5px; line-height: 1.55; }
.hint-tier .tier-state { margin-left: auto; color: var(--faint); font-size: 9px; font-weight: 700; white-space: nowrap; }
.hint-lock-note { display: flex; gap: 7px; margin-top: 8px; color: var(--muted); font-size: 10px; line-height: 1.55; }
.hint-lock-note .ic { flex: none; margin-top: 1px; }
.hint-voice { display: inline-flex; align-items: center; gap: 5px; margin-top: 10px; border: 0; background: transparent; color: var(--ink-2); font-size: 10.5px; font-weight: 700; }

/* -------- result -------- */
.result-card { max-width: 470px; text-align: center; }
.result-kicker { color: var(--amber-deep); font-size: 9px; font-weight: 800; letter-spacing: 0.2em; }
.result-card h2 { margin: 7px 0 2px; font-family: var(--font-round); font-size: 25px; }
.result-card .result-sub { margin: 0; color: var(--muted); font-size: 12px; }
.result-stars { display: flex; justify-content: center; gap: 8px; margin: 20px 0 14px; }
.result-stars .star { color: #ded8cb; transform: scale(0.82); transition: transform 0.3s, color 0.3s; }
.result-stars .star.on { color: var(--gold); transform: scale(1); filter: drop-shadow(0 4px 6px rgba(242, 185, 75, 0.25)); }
.result-stats { display: flex; justify-content: center; gap: 1px; overflow: hidden; margin: 0 auto 18px; max-width: 340px; border: 1px solid var(--line); border-radius: 12px; background: var(--line); }
.result-stats div { flex: 1; padding: 9px 6px; background: #fffdf8; }
.result-stats small { display: block; color: var(--muted); font-size: 9px; }
.result-stats b { font-family: var(--font-round); font-size: 16px; }
.result-note { margin: 0 0 15px; padding: 9px 11px; border-radius: 10px; background: #faf5e8; color: var(--muted); font-size: 10.5px; line-height: 1.55; }
.result-actions { display: flex; flex-direction: column; gap: 8px; }

/* -------- toast / modal -------- */
#toast { position: fixed; z-index: 90; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 7px; width: min(92vw, 440px); pointer-events: none; }
.toast-item { max-width: 100%; padding: 9px 15px; border-radius: 999px; background: rgba(32, 42, 77, 0.94); color: #fffaf0; box-shadow: 0 10px 28px rgba(32, 42, 77, 0.24); font-size: 11.5px; font-weight: 600; text-align: center; animation: toastIn 0.22s ease both; backdrop-filter: blur(8px); }
.toast-item.ok { background: rgba(42, 124, 107, 0.96); }
.toast-item.err { background: rgba(167, 71, 83, 0.96); }
.toast-item.is-out { animation: toastOut 0.24s ease both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(5px); } }
#modal-root { position: relative; z-index: 80; }
.modal-backdrop { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(28, 36, 61, 0.42); backdrop-filter: blur(5px); opacity: 0; transition: opacity 0.18s; overflow-y: auto; }
.modal-backdrop.is-in { opacity: 1; }
.modal-panel { position: relative; width: min(100%, 480px); max-height: 92vh; overflow-y: auto; padding: 25px; border-radius: 22px; background: var(--paper-2); box-shadow: var(--shadow-lg); transform: translateY(8px) scale(0.985); transition: transform 0.2s; }
.modal-backdrop.is-in .modal-panel { transform: none; }
.modal-close { position: absolute; top: 13px; right: 13px; width: 34px; height: 34px; border: 0; background: transparent; }
.modal-title { margin: 0 34px 11px 0; font-family: var(--font-round); font-size: 19px; line-height: 1.35; }
.modal-body { color: var(--ink-2); font-size: 12.5px; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.confetti-layer { position: fixed; inset: 0; z-index: 95; pointer-events: none; overflow: hidden; }
.confetti-bit { position: absolute; top: -16px; border-radius: 2px; animation: confettiFall 1.9s cubic-bezier(0.2, 0.7, 0.3, 1) forwards; }
@keyframes confettiFall { to { transform: translateY(105vh) rotate(540deg); opacity: 0.75; } }

/* -------- empty / error -------- */
.empty-state { display: grid; place-items: center; padding: 56px 20px; text-align: center; }
.empty-state .ic { color: var(--faint); }
.empty-state h3 { margin: 12px 0 4px; font-family: var(--font-round); font-size: 18px; }
.empty-state p { margin: 0; color: var(--muted); font-size: 12px; }
.loading-screen { display: grid; place-items: center; min-height: 55vh; color: var(--muted); font-size: 12px; }
.loading-ring { width: 34px; height: 34px; margin-bottom: 12px; border: 3px solid var(--paper-3); border-top-color: var(--amber); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* -------- footer -------- */
.site-foot { position: relative; z-index: 1; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 28px 0 34px; color: var(--faint); font-size: 10px; }
.site-foot .foot-links { display: flex; gap: 14px; }
.site-foot a:hover { color: var(--ink-2); }

/* -------- auth -------- */
.auth-page { min-height: 100vh; }
.auth-shell { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 430px); gap: clamp(32px, 7vw, 84px); align-items: center; min-height: calc(100vh - 118px); padding: 28px 0 48px; }
.auth-intro .auth-kicker { color: var(--amber-deep); font-size: 10px; font-weight: 800; letter-spacing: 0.22em; }
.auth-intro h1 { margin: 13px 0 14px; font-family: var(--font-round); font-size: clamp(32px, 4.4vw, 48px); line-height: 1.18; letter-spacing: -0.02em; }
.auth-intro h1 em { font-style: normal; color: var(--amber-deep); }
.auth-intro p { max-width: 440px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.8; }
.auth-points { display: grid; gap: 10px; margin: 24px 0 0; padding: 0; list-style: none; }
.auth-points li { display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-size: 12px; }
.auth-points b { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 8px; background: var(--amber-soft); color: #a46a17; font-size: 10px; }
.auth-card { padding: 26px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: rgba(255, 253, 248, 0.95); box-shadow: var(--shadow-lg); }
.auth-card h2 { margin: 0; font-family: var(--font-round); font-size: 22px; }
.auth-card .auth-desc { margin: 4px 0 17px; color: var(--muted); font-size: 11.5px; line-height: 1.6; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 3px; margin-bottom: 17px; border-radius: 11px; background: var(--paper-3); }
.auth-tab { min-height: 36px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 700; }
.auth-tab.on { background: #fff; color: var(--ink); box-shadow: 0 2px 6px rgba(39, 50, 80, 0.08); }
.auth-field { display: block; margin-bottom: 12px; }
.auth-field > span { display: flex; align-items: center; gap: 4px; margin-bottom: 5px; color: var(--ink-2); font-size: 10.5px; font-weight: 700; }
.auth-field > span b { color: var(--amber-deep); }
.auth-field input {
  width: 100%; height: 43px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink); font-size: 13px;
  transition: border-color 0.16s, box-shadow 0.16s;
}
.auth-field input:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px rgba(233, 162, 59, 0.14); }
.auth-field small { display: block; margin-top: 4px; color: var(--faint); font-size: 9.5px; line-height: 1.5; }
.auth-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.auth-check { display: flex; align-items: center; gap: 7px; margin: 4px 0 14px; color: var(--muted); font-size: 10.5px; }
.auth-check input { accent-color: var(--amber); }
.auth-help { margin: 10px 0 0; color: var(--muted); font-size: 10px; line-height: 1.6; }
.auth-help a { color: var(--amber-deep); font-weight: 700; }
.auth-status { margin-bottom: 12px; padding: 9px 11px; border-radius: 9px; font-size: 11px; line-height: 1.55; background: #fbecef; color: #9d4554; }
.auth-status.ok { background: var(--mint-soft); color: #287b6d; }
.auth-status.muted { background: var(--paper-3); color: var(--muted); }
.offline-notice { display: flex; flex-direction: column; gap: 2px; margin-bottom: 13px; padding: 9px 11px; border-radius: 9px; background: #eef1f8; color: var(--ink-2); font-size: 10.5px; line-height: 1.55; }
.offline-notice strong { font-size: 11px; }
.auth-submit { width: 100%; margin-top: 3px; }
.auth-switch { margin-top: 11px; text-align: center; color: var(--muted); font-size: 10.5px; }
.auth-switch button { border: 0; background: transparent; color: var(--amber-deep); font-size: inherit; font-weight: 700; }
.logged-card { text-align: center; }
.logged-avatar { display: grid; place-items: center; width: 66px; height: 66px; margin: 3px auto 12px; border-radius: 50%; background: linear-gradient(135deg, var(--violet), #9e8df0); color: #fff; font-family: var(--font-round); font-size: 25px; box-shadow: 0 10px 22px rgba(124, 134, 232, 0.24); }
.logged-card h2 { margin: 0; }
.logged-card p { margin: 4px 0 17px; color: var(--muted); font-size: 11px; }
.logged-links { display: flex; justify-content: center; gap: 16px; margin-top: 12px; font-size: 10.5px; color: var(--muted); }
.logged-links a:hover { color: var(--amber-deep); }

/* -------- responsive -------- */
@media (max-width: 940px) {
  .home-hero { grid-template-columns: 1fr; min-height: 0; }
  .hero-art-wrap { position: absolute; right: -55px; bottom: -35px; width: 330px; opacity: 0.55; pointer-events: none; }
  .hero-copy { position: relative; z-index: 3; padding-right: 80px; }
  .hero-badge { display: none; }
  .chapter-grid { grid-template-columns: repeat(2, 1fr); }
  .level-grid { grid-template-columns: repeat(4, 1fr); }
  .auth-shell { grid-template-columns: 1fr; max-width: 500px; gap: 24px; min-height: 0; }
  .auth-intro h1 { font-size: 34px; }
}
@media (max-width: 720px) {
  .shell { width: min(100% - 24px, 1120px); }
  .topbar-in { min-height: 58px; }
  .top-nav { display: none; }
  .mobile-nav { display: flex; position: fixed; z-index: 40; left: 50%; bottom: calc(9px + var(--safe-bottom)); transform: translateX(-50%); width: calc(100% - 24px); max-width: 440px; padding: 4px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255, 253, 248, 0.96); box-shadow: 0 12px 30px rgba(39, 50, 80, 0.14); backdrop-filter: blur(12px); }
  .mobile-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 2px; border-radius: 10px; color: var(--muted); font-size: 8px; font-weight: 700; }
  .mobile-nav a.on { color: var(--ink); background: var(--paper-3); }
  .mobile-nav .ic { width: 19px; height: 19px; }
  .cloud-chip { display: none; }
  .account-pill { max-width: 120px; padding-right: 8px; }
  .account-pill .name { max-width: 54px; }
  .home-hero { margin-top: 12px; padding: 28px 22px 30px; border-radius: 24px; }
  .hero-copy { padding-right: 0; }
  .home-hero h1 { font-size: 31px; max-width: 280px; }
  .hero-lead { max-width: 300px; font-size: 12.5px; }
  .hero-art-wrap { right: -68px; bottom: -36px; width: 245px; opacity: 0.38; }
  .hero-meta { gap: 10px; font-size: 9.5px; }
  .progress-strip { grid-template-columns: repeat(2, 1fr); }
  .progress-cell { padding: 12px 13px; }
  .progress-cell b { font-size: 20px; }
  .section-head { margin-top: 26px; }
  .chapter-grid { grid-template-columns: 1fr; gap: 10px; }
  .chapter-card { min-height: 148px; padding: 16px; }
  .chapter-card h3 { margin-top: 14px; }
  .level-grid { grid-template-columns: repeat(2, 1fr); gap: 9px; margin-bottom: 78px; }
  .level-card { min-height: 138px; padding: 12px; }
  .chapter-banner { flex-wrap: wrap; gap: 12px; padding: 15px; }
  .chapter-banner .chapter-score { margin-left: 0; text-align: left; width: 100%; display: flex; justify-content: space-between; align-items: baseline; border-top: 1px solid var(--line); padding-top: 9px; }
  .chapter-banner .chapter-score b { font-size: 19px; }
  .page-head { padding-top: 20px; }
  .play-wrap { padding-top: 10px; }
  .play-top { gap: 10px; }
  .play-title h1 { font-size: 19px; }
  .play-card { border-radius: 20px; }
  .play-head { padding: 12px 14px; }
  .goal-pill { width: 100%; order: 2; }
  .play-head .head-right { order: 1; width: 100%; justify-content: flex-end; }
  .stage-strip { padding: 8px 14px; }
  .stage-area { padding: 14px 10px 18px; min-height: 300px; }
  .play-foot { gap: 5px; padding: 9px 10px calc(9px + var(--safe-bottom)); }
  .foot-btn { padding: 0 10px; font-size: 10.5px; }
  .foot-btn .label { display: none; }
  .foot-btn.hint .label { display: inline; }
  .play-top .play-actions .icon-btn { width: 36px; height: 36px; }
  .board-frame { padding: 8px; border-radius: 16px; }
  .board { width: min(430px, calc(100vw - 58px), 54vh); gap: 4px; }
  .board.compact { width: min(360px, calc(100vw - 70px), 48vh); }
  .cell { border-radius: 7px; }
  .pack-tray { gap: 5px; padding: 8px; }
  .tray-piece { padding: 6px 5px 4px; }
  .piece-mini i { width: 10px; height: 10px; }
  .deduce-slots { gap: 5px; }
  .deduce-slot .slot-box { border-radius: 12px; }
  .deduce-item-tray { gap: 5px; }
  .item-token { min-height: 39px; padding: 0 9px 0 7px; font-size: 11px; }
  .rover .ic { width: 60%; height: 60%; }
  .hanoi { min-height: 228px; gap: 8px; padding-inline: 0; }
  .peg { height: 206px; }
  .peg::before { height: 152px; }
  .sudoku-wrap { flex-direction: column; align-items: center; }
  .sudoku-pad { grid-template-columns: repeat(4, 1fr); width: min(370px, 78vw); }
  .sudoku-pad button { height: 44px; }
  .modal-panel { padding: 20px; border-radius: 19px; }
  .site-foot { padding-bottom: 92px; }
  .mobile-nav ~ .site-foot { padding-bottom: 92px; }
  .auth-shell { padding-top: 10px; }
  .auth-intro h1 { font-size: 31px; }
  .auth-intro p { font-size: 12px; }
  .auth-card { padding: 20px; }
  .auth-grid { grid-template-columns: 1fr; gap: 0; }
}
@media (max-width: 390px) {
  .home-hero h1 { font-size: 28px; }
  .chapter-tabs { gap: 5px; }
  .chapter-tab { padding: 0 10px; font-size: 11px; }
  .level-card h3 { font-size: 13px; }
  .cmd-btn { min-width: 56px; padding: 6px 7px; }
}
@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;
  }
}

/* -------- 补充：提示、后台预览、账号与状态 -------- */
.hint-pulse { animation: hintPulse 1.15s ease-in-out infinite; }
@keyframes hintPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(233, 162, 59, 0.0); }
  45% { box-shadow: 0 0 0 5px rgba(233, 162, 59, 0.28); background-color: #fff4d6; }
}
.ghost-bad { background: rgba(207, 93, 104, 0.16) !important; box-shadow: inset 0 0 0 1px rgba(207, 93, 104, 0.35) !important; }
.preview-banner {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 12px 0 -4px; padding: 9px 13px;
  border: 1px solid #d8d2f5; border-radius: 11px;
  background: #f1eeff; color: #4d57b0; font-size: 10.5px; line-height: 1.5;
}
.preview-banner a { margin-left: auto; font-weight: 800; color: #4d57b0; text-decoration: underline; text-underline-offset: 3px; }
.map-note {
  display: flex; align-items: flex-start; gap: 8px;
  margin: -24px 0 54px; padding: 11px 14px;
  border-radius: 11px; background: #faf5e8; color: var(--muted); font-size: 10.5px; line-height: 1.6;
}
.map-note .ic { flex: none; margin-top: 1px; color: var(--amber-deep); }
.play-note {
  display: flex; align-items: flex-start; gap: 8px;
  margin: 12px auto 0; max-width: 790px; padding: 10px 14px;
  color: var(--muted); font-size: 10.5px; line-height: 1.6;
}
.play-note .ic { flex: none; margin-top: 1px; color: var(--amber-deep); }
.hint-tier { cursor: pointer; }
.hint-tier[disabled] { cursor: not-allowed; }
.foot-btn.nudge { animation: hintPulse 1.4s ease-in-out infinite; border-color: var(--amber); }
.foot-btn.used { transform: scale(0.96); }
.stage-complete { text-align: center; color: var(--ink-2); font-size: 12px; }
.stage-complete-mark {
  display: grid; place-items: center; width: 58px; height: 58px;
  margin: 2px auto 13px; border-radius: 50%;
  background: var(--mint-soft); color: #2a7f70;
}
.stage-complete p { margin: 0; line-height: 1.7; }

/* account */
.account-panel {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 18px;
  padding: 22px; border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: linear-gradient(130deg, #fffdf8, #f8f0df); box-shadow: var(--shadow-sm);
}
.account-big { display: flex; align-items: center; gap: 14px; min-width: 0; }
.account-big .avatar.big {
  display: grid; place-items: center; flex: none;
  width: 58px; height: 58px; border-radius: 50%;
  background: linear-gradient(135deg, var(--violet), #9e8df0);
  color: #fff; font-family: var(--font-round); font-size: 22px;
}
.account-big h2 { margin: 0; font-family: var(--font-round); font-size: 20px; }
.account-big p { margin: 3px 0 0; color: var(--muted); font-size: 10.5px; }
.account-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.account-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 15px; }
.account-card { padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255, 253, 248, 0.88); box-shadow: var(--shadow-sm); }
.account-card h3 { margin: 0 0 12px; font-family: var(--font-round); font-size: 15px; }
.account-stats { display: flex; gap: 1px; overflow: hidden; border-radius: 10px; background: var(--line); }
.account-stats div { flex: 1; padding: 10px 7px; background: #fffdf8; text-align: center; }
.account-stats b { display: block; font-family: var(--font-round); font-size: 21px; line-height: 1.15; }
.account-stats small { color: var(--muted); font-size: 9px; }
.account-bar { height: 5px; margin: 13px 0 8px; border-radius: 4px; background: var(--paper-3); overflow: hidden; }
.account-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--amber), #f4c46a); }
.account-card p { margin: 0; color: var(--muted); font-size: 10.5px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.setting-row:last-child { border-bottom: 0; padding-bottom: 0; }
.setting-row span { display: flex; flex-direction: column; gap: 1px; }
.setting-row b { font-size: 11.5px; }
.setting-row small { color: var(--muted); font-size: 9.5px; }
.setting-row input { width: 17px; height: 17px; accent-color: var(--amber); }
.account-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.danger-text { color: var(--danger); }
.account-legal { margin: 20px 0 10px; color: var(--faint); font-size: 9.5px; line-height: 1.6; }

@media (max-width: 720px) {
  .account-panel { padding: 16px; }
  .account-actions { width: 100%; }
  .account-actions .btn { flex: 1; }
  .account-grid { grid-template-columns: 1fr; }
  .map-note { margin-top: -28px; }
}
.reduce-motion .hero-art { animation: none; }
.reduce-motion .confetti-layer { display: none; }

/* -------- layout corrections -------- */
.site-foot {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
}
.board {
  width: min(410px, 78vw, 44vh);
}
.board.compact { width: min(360px, 74vw, 38vh); }
.hanoi { padding-bottom: 34px; }
.hanoi-info { margin-top: 38px; }
@media (max-width: 720px) {
  .site-foot { width: calc(100% - 24px); }
  .board { width: min(420px, calc(100vw - 58px), 47vh); }
  .board.compact { width: min(350px, calc(100vw - 70px), 42vh); }
  .hanoi { padding-bottom: 28px; }
  .hanoi-info { margin-top: 32px; }
}

/* -------- modal flex: keep actions visible -------- */
.modal-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: min(92vh, 900px);
}
.modal-title { flex: none; }
.modal-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-right: 2px; }
.modal-actions { flex: none; padding-top: 12px; border-top: 1px solid var(--line); margin-top: 14px; background: var(--paper-2); }
.admin-page .modal-actions { position: relative; z-index: 2; }

/* -------- true small-screen fixes -------- */
@media (max-width: 560px) {
  .topbar-in { gap: 8px; }
  .brand { gap: 8px; }
  .brand img { width: 30px; height: 30px; }
  .brand-copy strong { font-size: 15px; }
  .brand-copy small { display: none; }
  .account-pill { max-width: 86px; padding: 0 9px 0 6px; }
  .account-pill .name { display: none; }
  .account-pill .avatar { width: 24px; height: 24px; }
  .top-actions { gap: 5px; }
  .icon-btn.small { width: 34px; height: 34px; }
  .modal-backdrop { padding: 12px; align-items: center; }
  .modal-panel { width: calc(100vw - 24px) !important; max-width: calc(100vw - 24px); padding: 18px; border-radius: 18px; }
  .modal-actions { flex-direction: column-reverse; align-items: stretch; }
  .modal-actions .btn { width: 100%; }
  .modal-body { overflow-x: hidden; }
  .home-hero h1 { font-size: 28px; }
  .hero-actions .btn { flex: 1; min-width: 0; padding-inline: 12px; }
}

/* -------- touch & mobile spacing -------- */
.tray-piece, .board, .deduce-slot .slot-box, .item-token, .cmd-btn, .peg, .slide-tile, .sudoku-cell { touch-action: manipulation; }
.tray-piece, .board { touch-action: none; }
@media (max-width: 720px) {
  #view { padding-bottom: 84px; }
  .mobile-nav ~ .site-foot { padding-bottom: 24px; }
  .site-foot { padding-bottom: 24px; }
}

/* -------- immersive play on phones -------- */
body.is-play .mobile-nav { display: none; }
body.is-play #view { padding-bottom: 0; }
body.is-play .site-foot { display: none; }
