:root {
  --coral: #E85D4C;
  --coral-d: #C44738;
  --gold: #F4C95D;
  --gold-d: #D4A63A;
  --lotus: #F6A6B8;
  --pond: #3FAE7C;
  --pond-d: #2D8A60;
  --sea: #2E8F9A;
  --ink: #2B2118;
  --muted: #6B5848;
  --paper: #FFF7EC;
  --cream: #FFE9C4;
  --soft: #FFF1E0;
  --card: #FFFFFF;
  --night: #1C3144;
  --line: rgba(43, 33, 24, 0.1);
  --shadow: 0 10px 28px rgba(43, 33, 24, 0.1);
  --radius: 22px;
  --tab-h: calc(64px + env(safe-area-inset-bottom));
  --font: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Source Han Sans SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #E9D7B8; color: var(--ink); font-family: var(--font); }
body { overscroll-behavior: none; }
#app {
  min-height: 100%;
  max-width: 480px;
  margin: 0 auto;
  background:
    radial-gradient(1200px 400px at 50% -80px, #FFE2B8 0%, transparent 70%),
    linear-gradient(180deg, #FBE7C6 0%, var(--paper) 28%, #F3E4C8 100%);
  position: relative;
  overflow: hidden;
}
button, .btn {
  font: inherit; color: inherit; border: 0; background: none; cursor: pointer;
}
h1, h2, h3, p { margin: 0; }
img { max-width: 100%; }

.screen { min-height: 100dvh; padding: calc(12px + env(safe-area-inset-top)) 18px 24px; display: flex; flex-direction: column; gap: 14px; }
.screen.with-tab { padding-bottom: calc(var(--tab-h) + 16px); }
.screen.pad-top { padding-top: calc(58px + env(safe-area-inset-top)); }

.topbar {
  position: sticky; top: 0; z-index: 20;
  margin: calc(-12px - env(safe-area-inset-top)) -18px 0;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  display: flex; align-items: center; gap: 8px;
  background: linear-gradient(180deg, rgba(251,231,198,.96), rgba(251,231,198,.88));
  backdrop-filter: blur(10px);
}
.topbar h1 { font-size: 18px; font-weight: 700; flex: 1; letter-spacing: .02em; }
.back, .icon-btn {
  width: 40px; height: 40px; border-radius: 14px;
  background: #fff; box-shadow: var(--shadow);
  display: grid; place-items: center; font-size: 18px; font-weight: 700;
}
.pill {
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  background: var(--cream); color: var(--muted); font-weight: 600;
}

.hero {
  background: linear-gradient(160deg, #F07A5A 0%, #E85D4C 48%, #C95A8A 100%);
  color: #fff; border-radius: 28px; padding: 22px 20px 20px;
  box-shadow: 0 16px 36px rgba(232, 93, 76, .28);
  position: relative; overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; right: -20px; top: -30px; width: 140px; height: 140px;
  border: 10px solid rgba(244,201,93,.45); border-radius: 50%;
}
.hero .kicker { opacity: .9; font-size: 13px; }
.hero h2 { font-size: 26px; margin: 6px 0 8px; letter-spacing: .04em; }
.hero p { font-size: 14px; line-height: 1.55; opacity: .95; max-width: 22em; }

.banner {
  background: #fff7; border: 1px dashed rgba(43,33,24,.18);
  border-radius: 16px; padding: 10px 12px; font-size: 12px; color: var(--muted); line-height: 1.5;
}

.card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow);
}
.card h3 { font-size: 16px; margin-bottom: 6px; }
.card p, .muted { color: var(--muted); font-size: 13px; line-height: 1.55; }
.row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }

.btn-primary, .btn-secondary, .btn-ghost, .btn-gold {
  display: block; width: 100%; text-align: center; border-radius: 16px;
  padding: 14px 16px; font-weight: 700; font-size: 16px;
}
.btn-primary { background: var(--coral); color: #fff; box-shadow: 0 8px 18px rgba(232,93,76,.28); }
.btn-primary:active { background: var(--coral-d); }
.btn-secondary { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.btn-gold { background: var(--gold); color: var(--ink); }
.btn-ghost { background: transparent; color: var(--muted); font-size: 14px; font-weight: 600; }
.btn-row { display: flex; gap: 10px; }
.btn-row > * { flex: 1; }

.list { display: flex; flex-direction: column; gap: 10px; }
.quest, .cell {
  display: flex; align-items: center; gap: 12px;
  background: #fff; border-radius: 18px; padding: 12px 14px;
  box-shadow: var(--shadow); text-align: left; width: 100%;
}
.badge {
  width: 46px; height: 46px; border-radius: 16px; display: grid; place-items: center;
  font-size: 22px; flex: none; background: var(--cream);
}
.badge.pond { background: #D8F3E6; }
.badge.sea { background: #D3EEF1; }
.badge.lotus { background: #FDE4EB; }
.badge.gold { background: #FCE8B0; }
.quest .title { font-weight: 700; font-size: 15px; }
.quest .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #F8E1A8; color: #7A5A12; font-weight: 700; }
.tag.rare { background: #E0D4FF; color: #4C2F8A; }
.tag.legend { background: #F9D7A0; color: #6A3B00; }
.tag.myth { background: #F8C3C3; color: #8A1C1C; }
.tag.lock { background: #EEE; color: #888; }
.done { outline: 2px solid var(--pond); }
.check { color: var(--pond-d); font-weight: 800; }

.grid2, .grid3 { display: grid; gap: 10px; }
.grid2 { grid-template-columns: 1fr 1fr; }
.grid3 { grid-template-columns: 1fr 1fr 1fr; }
.tile {
  background: #fff; border-radius: 18px; padding: 12px 10px; text-align: center;
  box-shadow: var(--shadow); min-height: 108px;
}
.tile .emoji { font-size: 28px; display: block; margin-bottom: 6px; }
.tile b { display: block; font-size: 13px; }
.tile span { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; }
.tile.selected { outline: 3px solid var(--coral); }
.tile.locked { opacity: .55; }

.stage-wrap {
  position: relative; height: 52dvh; min-height: 280px; max-height: 420px;
  border-radius: 24px; overflow: hidden; background: #9AD7DE;
  box-shadow: var(--shadow);
}
.stage-wrap canvas { display: block; width: 100%; height: 100%; }
.stage-hint {
  position: absolute; left: 10px; bottom: 10px;
  background: rgba(255,255,255,.86); border-radius: 12px; padding: 6px 10px;
  font-size: 11px; color: var(--muted); pointer-events: none;
}

.tabs {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 0; width: 100%; max-width: 480px; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 6px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255,247,236,.94); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabs button {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; font-weight: 700; color: var(--muted); padding: 6px 0;
}
.tabs button.on { color: var(--coral-d); }
.tabs .ico { font-size: 18px; }

.cover { min-height: 100dvh; padding: calc(28px + env(safe-area-inset-top)) 22px calc(28px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; justify-content: flex-end; gap: 14px;
  background:
    radial-gradient(circle at 80% 12%, #F4C95D 0 18px, transparent 19px),
    radial-gradient(circle at 18% 22%, rgba(246,166,184,.7), transparent 40%),
    linear-gradient(180deg, #F07A5A 0%, #EE6B4D 36%, #F6C16A 70%, #FFF7EC 100%);
  color: #fff;
}
.cover .logo { font-size: 42px; font-weight: 800; letter-spacing: .08em; text-shadow: 0 6px 0 rgba(0,0,0,.08); }
.cover .sub { font-size: 16px; opacity: .95; margin-bottom: 8px; }
.cover .btn-primary { color: #fff; }
.cover .btn-secondary { color: var(--ink); }

.timeline { display: flex; flex-direction: column; gap: 0; }
.season {
  display: grid; grid-template-columns: 28px 1fr; gap: 10px; text-align: left; width: 100%;
  background: none; padding: 0 0 16px;
}
.season .dot {
  width: 16px; height: 16px; border-radius: 50%; background: var(--gold); border: 3px solid #fff;
  box-shadow: 0 0 0 3px var(--coral); margin: 6px auto 0; position: relative;
}
.season .dot::after { content: ""; position: absolute; top: 16px; left: 50%; width: 2px; height: calc(100% + 28px); background: #F1D9A4; transform: translateX(-50%); }
.season:last-child .dot::after { display: none; }
.season .body { background: #fff; border-radius: 18px; padding: 12px 14px; box-shadow: var(--shadow); }
.season.lock .dot { box-shadow: 0 0 0 3px #ccc; background: #eee; }

.map {
  position: relative; background: #fff; border-radius: 24px; padding: 18px 10px 22px;
  min-height: 420px; box-shadow: var(--shadow); overflow: hidden;
}
.node {
  position: absolute; transform: translate(-50%, -50%); text-align: center; width: 86px;
  background: #fff; border-radius: 16px; padding: 8px 6px; box-shadow: var(--shadow);
  font-size: 11px; font-weight: 700; line-height: 1.3;
}
.node .e { font-size: 20px; display: block; }
.node.core { outline: 3px solid var(--coral); }
.line-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.lock-screen {
  min-height: 100dvh; padding: calc(40px + env(safe-area-inset-top)) 22px;
  background: linear-gradient(180deg, #1C3144, #2E8F9A 80%);
  color: #fff; display: flex; flex-direction: column; justify-content: center; gap: 16px;
}
.lock-screen h2 { font-size: 28px; }
.gate { text-align: center; padding-top: 40px; }
.hold {
  width: 160px; height: 160px; border-radius: 50%; margin: 24px auto;
  background: conic-gradient(var(--coral) 0deg, #f3d7cf 0deg);
  display: grid; place-items: center; box-shadow: var(--shadow);
}
.hold i { width: 140px; height: 140px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-style: normal; font-weight: 800; }

.card-face {
  aspect-ratio: 3/4; border-radius: 20px; padding: 16px;
  background: linear-gradient(180deg, #FFF3D2, #F7D48A);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  box-shadow: var(--shadow); text-align: center;
}
.card-face.rare { background: linear-gradient(180deg, #F3ECFF, #C9B6F2); }
.card-face.legend { background: linear-gradient(180deg, #FFE7B0, #F0B429); }
.stars { letter-spacing: 3px; color: var(--coral-d); }

.progress { height: 8px; background: #F0E2C8; border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--pond); border-radius: 99px; }

.input, select.input {
  width: 100%; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px;
  font: inherit; background: #fff;
}
.hidden-file { display: none; }
.tiny { font-size: 11px; color: var(--muted); line-height: 1.5; }
.spacer { height: 8px; }
