/* ============================================================
   《词根猎手》样式 1/2 —— 基础 / 布局 / 导航 / 主页 / 地图
   美学方向：深夜猎场 · 火把橙 × 星光金 × 源灵青
   ============================================================ */

:root {
  --bg0: #0b1410;
  --bg1: #101c14;
  --bg2: #16222e;
  --card: #15211a;
  --card-hi: #1d2f24;
  --line: #2c4433;
  --ink: #e8f1e6;
  --ink-dim: #93a89a;
  --torch: #ff9f43;
  --gold: #ffd166;
  --aqua: #4ecdc4;
  --danger: #ff6b6b;
  --ok: #7bed9f;
  --font-game: "ZCOOL KuaiLe", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  font-family: var(--font-game);
  background: var(--bg0);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
}

/* 夜空背景：星点 + 雾气 */
#app {
  min-height: 100vh;
  background:
    radial-gradient(1px 1px at 20% 30%, rgba(255,255,255,.5) 50%, transparent 51%),
    radial-gradient(1px 1px at 70% 12%, rgba(255,255,255,.4) 50%, transparent 51%),
    radial-gradient(2px 2px at 40% 65%, rgba(255,255,255,.25) 50%, transparent 51%),
    radial-gradient(1px 1px at 85% 45%, rgba(255,255,255,.35) 50%, transparent 51%),
    radial-gradient(1px 1px at 10% 80%, rgba(255,255,255,.3) 50%, transparent 51%),
    radial-gradient(ellipse at 50% 0%, #1a2b20 0%, var(--bg0) 55%, #0a1210 100%);
  opacity: 0;
  transition: opacity .6s;
}
#app.ready { opacity: 1; }

.screen { display: none; min-height: 100vh; padding: 0 0 84px; }
.screen.on { display: block; animation: screenIn .35s ease; }
@keyframes screenIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.page { max-width: 640px; margin: 0 auto; padding: 14px 14px 20px; }

/* ---------- 状态栏 ---------- */
#rankbar {
  position: sticky; top: 0; z-index: 40;
  max-width: 640px; margin: 0 auto;
  padding: 10px 16px 12px;
  background: linear-gradient(180deg, rgba(11,20,16,.96), rgba(11,20,16,.82));
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.stat-rank { font-size: 1.05rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stat-stars { color: var(--gold); }
.stat-next { font-size: .8rem; color: var(--ink-dim); }
.stat-row { display: flex; justify-content: space-between; margin-top: 6px; font-size: .9rem; }
.stat-gem { color: var(--aqua); }
.bar { height: 8px; background: #0a100c; border-radius: 99px; overflow: hidden; margin-top: 6px; border: 1px solid var(--line); }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--torch), var(--gold)); border-radius: 99px; transition: width .5s; box-shadow: 0 0 8px var(--torch); }

/* ---------- 底部导航 ---------- */
#main-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: flex; justify-content: space-around;
  background: linear-gradient(180deg, rgba(16,28,20,.92), rgba(10,18,14,.98));
  backdrop-filter: blur(10px);
  border-top: 2px solid var(--line);
  padding: 6px 4px calc(8px + env(safe-area-inset-bottom));
}
.navbtn {
  background: none; border: none; color: var(--ink-dim);
  font-family: var(--font-game); font-size: .72rem;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px 8px; cursor: pointer; border-radius: 10px; transition: .2s;
}
.navbtn span { font-size: 1.35rem; }
.navbtn.active { color: var(--gold); transform: translateY(-2px); }
.navbtn.active span { filter: drop-shadow(0 0 6px var(--gold)); }

/* ---------- 通用按钮 ---------- */
.btn {
  font-family: var(--font-game);
  background: var(--card-hi); color: var(--ink);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 10px 18px; font-size: .95rem;
  cursor: pointer; transition: .15s;
  box-shadow: 0 3px 0 #0a120d;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #0a120d; }
.btn.primary {
  background: linear-gradient(180deg, #ffb25e, #ff9430);
  border-color: #d97a1e; color: #2b1600;
  text-shadow: 0 1px 0 rgba(255,255,255,.35);
  box-shadow: 0 4px 0 #a35c12, 0 6px 14px rgba(255,159,67,.35);
}
.btn.primary:active { box-shadow: 0 1px 0 #a35c12; }
.btn.ghost { background: transparent; }
.btn.big { font-size: 1.15rem; padding: 14px 26px; }
.btn.mini { font-size: .78rem; padding: 6px 12px; border-radius: 9px; }

/* ---------- 标题屏 ---------- */
#screen-title { display: none; }
#screen-title.on { display: flex; align-items: center; justify-content: center; }
.title-wrap { text-align: center; padding: 30px 20px; max-width: 420px; width: 100%; }
.title-stars { color: rgba(255,209,102,.5); letter-spacing: 6px; font-size: .8rem; animation: twinkle 3s infinite alternate; }
@keyframes twinkle { from { opacity: .4; } to { opacity: 1; } }
.game-title {
  font-size: clamp(3rem, 14vw, 4.6rem);
  line-height: 1.1; margin: 10px 0 4px;
  color: var(--ink);
  text-shadow: 0 0 24px rgba(255,159,67,.4), 0 4px 0 #3a2410;
  letter-spacing: .06em;
}
.game-title span { color: var(--torch); }
.game-sub { color: var(--ink-dim); font-size: .85rem; letter-spacing: .2em; margin-bottom: 18px; }
.title-campfire { font-size: 3rem; animation: flicker 1.6s infinite alternate, float 3s ease-in-out infinite; }
@keyframes flicker { from { filter: brightness(1); } to { filter: brightness(1.35) drop-shadow(0 0 18px #ff9f43); } }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

.tut-form {
  background: var(--card); border: 2px solid var(--line); border-radius: 16px;
  padding: 18px; margin: 20px 0 12px; text-align: left;
  box-shadow: 0 8px 30px rgba(0,0,0,.4);
}
.tut-label { display: block; font-size: .85rem; color: var(--ink-dim); margin: 10px 0 6px; }
.tut-label:first-child { margin-top: 0; }
#tut-name {
  width: 100%; padding: 10px 12px; font-size: 1rem;
  background: #0d1712; color: var(--ink);
  border: 2px solid var(--line); border-radius: 10px;
  font-family: var(--font-game);
}
#tut-name:focus { outline: none; border-color: var(--torch); }
.track-opts { display: flex; gap: 8px; flex-wrap: wrap; }
.track-opts label {
  flex: 1; min-width: 90px; text-align: center; font-size: .85rem;
  background: #0d1712; border: 2px solid var(--line); border-radius: 10px;
  padding: 8px 6px; cursor: pointer; transition: .2s;
}
.track-opts label:has(input:checked) { border-color: var(--gold); color: var(--gold); background: rgba(255,209,102,.08); }
.track-opts input { display: none; }
.tut-form .btn { width: 100%; margin-top: 16px; }
.title-tip { color: var(--ink-dim); font-size: .78rem; }

/* ---------- 主页 ---------- */
.hero-card {
  background: linear-gradient(145deg, var(--card-hi), var(--card));
  border: 2px solid var(--line); border-radius: 16px;
  padding: 16px; margin-bottom: 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,.35);
}
.hero-hi { font-size: 1.1rem; margin-bottom: 8px; }
.hero-lore { font-size: .85rem; color: var(--ink-dim); line-height: 1.6; background: rgba(0,0,0,.25); border-radius: 10px; padding: 10px; border-left: 3px solid var(--gold); }
.hero-lore b { color: var(--gold); }

.home-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.big-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: linear-gradient(160deg, #1e3325, #142219);
  border: 2px solid #3a5a42; border-radius: 16px;
  color: var(--ink); font-family: var(--font-game);
  padding: 18px 10px; cursor: pointer; transition: .2s;
  box-shadow: 0 5px 0 #0c1710, inset 0 1px 0 rgba(255,255,255,.06);
}
.big-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #0c1710; }
.big-btn .big-icon { font-size: 2rem; }
.big-btn .big-title { font-size: 1.05rem; }
.big-btn .big-sub { font-size: .72rem; color: var(--ink-dim); line-height: 1.4; }
.big-btn.warn { background: linear-gradient(160deg, #2b2030, #191420); border-color: #553d68; }
.big-btn.warn .big-icon { filter: drop-shadow(0 0 8px #a78bfa); }
.big-btn.dim { opacity: .75; }

.home-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.hs {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  text-align: center; padding: 10px 4px;
}
.hs b { display: block; font-size: 1.3rem; color: var(--gold); }
.hs span { font-size: .7rem; color: var(--ink-dim); }

.relic-strip { display: flex; flex-wrap: wrap; gap: 6px; }
.relic-chip {
  font-size: .75rem; background: rgba(255,209,102,.1);
  border: 1px solid rgba(255,209,102,.4); color: var(--gold);
  border-radius: 99px; padding: 4px 10px;
}
.relic-chip.dim { color: var(--ink-dim); border-color: var(--line); background: transparent; }

/* ---------- 存档迁移 ---------- */
.save-zone { display: flex; gap: 8px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.btn.danger { border-color: rgba(255,107,107,.5); color: var(--danger); }
.save-tip { text-align: center; font-size: .72rem; color: var(--ink-dim); margin-top: 8px; }
.code-box {
  width: 100%; height: 110px; margin: 10px 0;
  background: #0d1712; color: var(--aqua);
  border: 2px solid var(--line); border-radius: 10px;
  padding: 10px; font-size: .72rem; font-family: monospace;
  resize: none; word-break: break-all;
}
.code-box:focus { outline: none; border-color: var(--aqua); }

/* ---------- 地图 ---------- */
.chapter { margin-bottom: 18px; border-radius: 18px; overflow: hidden; border: 2px solid var(--line); }
.chapter.locked { opacity: .45; filter: grayscale(.7); }
.ch-head { display: flex; gap: 12px; align-items: center; padding: 14px 16px; }
.theme-forest .ch-head { background: linear-gradient(135deg, #1b3524, #12271a); }
.theme-mountain .ch-head { background: linear-gradient(135deg, #1c2b42, #122033); }
.theme-desert .ch-head { background: linear-gradient(135deg, #3d2f1a, #2a2012); }
.theme-castle .ch-head { background: linear-gradient(135deg, #3a2c1a, #241a0e); }
.ch-icon { font-size: 2rem; filter: drop-shadow(0 2px 6px rgba(0,0,0,.5)); }
.ch-name { font-size: 1.1rem; }
.ch-sub { font-size: .75rem; color: var(--ink-dim); }
.ch-levels { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; padding: 12px; background: rgba(0,0,0,.22); }
.lv {
  display: flex; flex-direction: column; gap: 3px; align-items: flex-start;
  background: var(--card); border: 2px solid var(--line); border-radius: 12px;
  color: var(--ink); font-family: var(--font-game);
  padding: 10px; cursor: pointer; transition: .15s; text-align: left;
}
.lv:not(:disabled):hover { border-color: var(--torch); transform: translateY(-2px); }
.lv.done { border-color: #4a7a56; background: linear-gradient(160deg, #17281c, #101b13); }
.lv.boss { border-color: #a35c12; background: linear-gradient(160deg, #33230f, #1f150a); }
.lv.boss:not(:disabled) { box-shadow: 0 0 14px rgba(255,159,67,.25); }
.lv.locked { opacity: .5; cursor: not-allowed; }
.lv-name { font-size: .85rem; line-height: 1.3; }
.lv-stars { font-size: .7rem; color: var(--ink-dim); }
.lv.done .lv-stars { color: var(--gold); }
