:root {
  --bg: #FFF8E7;
  --card: #FFFFFF;
  --primary: #FF8A3D;
  --primary-dark: #E65100;
  --primary-soft: #FFE9D6;
  --green: #5CB85C;
  --green-soft: #E4F5E4;
  --blue: #64B5F6;
  --pink: #F48FB1;
  --text: #4A3F35;
  --muted: #A6988A;
  --line: #F0E4D2;
  --shadow: 0 4px 16px rgba(176, 141, 87, .12);
  --radius: 20px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: #F3E7D3;
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font-family: inherit; font-size: 16px; }

.phone {
  max-width: 480px;
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 0 40px rgba(0,0,0,.08);
}

/* ---------- header ---------- */
.header {
  padding: 18px 18px 14px;
  background: linear-gradient(160deg, #FFE3B8 0%, #FFF8E7 100%);
  border-bottom: 2px solid var(--line);
}

.hero { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 58px; height: 58px; border-radius: 50%;
  background: #fff; border: 3px solid var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; flex-shrink: 0; overflow: hidden;
}
.avatar-img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.hero-info { flex: 1; min-width: 0; }
.hero-name { font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.hero-lv { font-size: 12px; color: var(--primary-dark); background: var(--primary-soft); padding: 2px 8px; border-radius: 10px; font-weight: 600; }
.hero-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.streak {
  background: #fff; border-radius: 14px; padding: 6px 12px;
  text-align: center; border: 2px solid #FFD8A8; flex-shrink: 0;
}
.streak-num { font-size: 20px; font-weight: 800; color: var(--primary-dark); line-height: 1; }
.streak-lbl { font-size: 11px; color: var(--muted); }

.lvbar { margin-top: 12px; }
.lvbar-top { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.bar { height: 12px; background: #F1E3CC; border-radius: 8px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 8px; transition: width .5s cubic-bezier(.3,1.4,.5,1); }
.bar-orange > i { background: linear-gradient(90deg, #FFB067, var(--primary)); }
.bar-green > i { background: linear-gradient(90deg, #9BD77E, var(--green)); }

/* ---------- main ---------- */
.main { flex: 1; padding: 14px 16px 100px; }

.card {
  background: var(--card); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); margin-bottom: 12px;
}

.section-title {
  font-size: 14px; font-weight: 700; color: var(--muted);
  margin: 18px 4px 10px; display: flex; align-items: center; gap: 6px;
}

/* 当前岛 */
.island-now {
  background: linear-gradient(140deg, #FFF3DC, #FFE6CC);
  border: 2px solid #FFCF9B;
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
}
.island-now-top { display: flex; align-items: center; gap: 10px; }
.island-emoji { font-size: 38px; }
.island-now-name { font-size: 20px; font-weight: 800; }
.island-now-theme { font-size: 13px; color: var(--primary-dark); font-weight: 600; }
.island-story { font-size: 13px; color: #8A7660; margin: 10px 0 12px; line-height: 1.6; }
.island-goal { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; margin-bottom: 6px; }

/* 食材栏 */
.pantry { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 8px; margin-bottom: 4px; }
.pantry::-webkit-scrollbar { display: none; }
.ing-chip {
  background: #fff; border: 2px solid var(--line); border-radius: 14px;
  padding: 6px 10px; display: flex; align-items: center; gap: 5px;
  flex-shrink: 0; font-size: 13px; font-weight: 600;
}
.ing-chip b { font-size: 15px; }
.ing-chip.zero { opacity: .4; }

/* 任务卡 */
.task {
  background: #fff; border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow); margin-bottom: 10px;
  display: flex; align-items: center; gap: 12px;
  transition: transform .15s, opacity .3s;
}
.task:active { transform: scale(.985); }
.task.done { background: var(--green-soft); }
.task-icon {
  width: 46px; height: 46px; border-radius: 14px; background: #FFF3E4;
  display: flex; align-items: center; justify-content: center; font-size: 24px; flex-shrink: 0;
}
.task.done .task-icon { background: #D6F0D6; }
.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 16px; font-weight: 700; }
.task-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.task-progress { display: flex; align-items: center; gap: 8px; margin-top: 7px; }
.task-progress .bar { flex: 1; height: 10px; }
.task-count { font-size: 13px; font-weight: 800; color: var(--primary-dark); flex-shrink: 0; }
.task.done .task-count { color: var(--green); }

.btn-done {
  background: var(--primary); color: #fff; font-weight: 700; font-size: 15px;
  border-radius: 14px; padding: 10px 16px; flex-shrink: 0;
  box-shadow: 0 3px 0 #D96A20; transition: transform .1s, box-shadow .1s;
}
.btn-done:active { transform: translateY(3px); box-shadow: 0 0 0 #D96A20; }
.btn-done.finished { background: var(--green); box-shadow: 0 3px 0 #449944; }
.btn-undo {
  width: 30px; height: 30px; border-radius: 50%; background: #F5EEE3;
  color: var(--muted); font-size: 15px; flex-shrink: 0;
}

/* 食谱 */
.recipe {
  background: #fff; border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow); margin-bottom: 10px;
  display: flex; align-items: center; gap: 12px;
}
.recipe.locked { opacity: .55; }
.recipe-icon { font-size: 30px; flex-shrink: 0; }
.recipe-body { flex: 1; min-width: 0; }
.recipe-name { font-size: 16px; font-weight: 700; }
.recipe-cost { font-size: 12px; color: var(--muted); margin-top: 3px; }
.btn-cook {
  background: var(--primary); color: #fff; font-weight: 700; font-size: 14px;
  border-radius: 14px; padding: 9px 14px; flex-shrink: 0; box-shadow: 0 3px 0 #D96A20;
}
.btn-cook:disabled { background: #DCD2C4; box-shadow: 0 3px 0 #C6BBA9; color: #fff; }

/* 地图 */
.map-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.map-cell {
  border-radius: 18px; padding: 14px 12px; text-align: center;
  border: 2px solid var(--line); background: #fff; position: relative;
}
.map-cell.active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.map-cell.locked { background: #F6F1E8; color: var(--muted); }
.map-cell.cleared { background: var(--green-soft); border-color: #B7E0B7; }
.map-emoji { font-size: 34px; }
.map-name { font-size: 15px; font-weight: 700; margin-top: 4px; }
.map-theme { font-size: 12px; color: var(--muted); }
.map-state { font-size: 11px; font-weight: 700; margin-top: 6px; }
.map-cell.cleared .map-state { color: var(--green); }
.map-cell.active .map-state { color: var(--primary-dark); }
.map-lock { position: absolute; top: 8px; right: 10px; font-size: 15px; }

/* 日历热力 */
.cal { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.cal-cell { aspect-ratio: 1; border-radius: 5px; background: #EFE6D6; }
.cal-cell.l1 { background: #FFE0B2; }
.cal-cell.l2 { background: #FFC078; }
.cal-cell.l3 { background: #FF9642; }

/* ---------- tabbar ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; display: flex;
  background: #fff; border-top: 2px solid var(--line);
  padding: 6px 0 max(6px, env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgba(176,141,87,.10);
  z-index: 50;
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px 0; color: var(--muted); font-size: 11px; font-weight: 600;
}
.tab.on { color: var(--primary-dark); }
.tab-emoji { font-size: 21px; }

/* ---------- toast / modal ---------- */
.toast-wrap {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: 92%; max-width: 440px;
}
.toast {
  background: rgba(74, 63, 53, .94); color: #fff; padding: 10px 18px;
  border-radius: 14px; font-size: 14px; font-weight: 600;
  animation: toastIn .3s ease; max-width: 100%;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: none; } }

.modal-wrap {
  position: fixed; inset: 0; background: rgba(60, 45, 30, .5);
  z-index: 300; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-wrap.hidden { display: none; }
.modal {
  background: #fff; border-radius: 24px; padding: 24px 20px; width: 100%; max-width: 360px;
  text-align: center; animation: pop .35s cubic-bezier(.3,1.4,.5,1);
}
@keyframes pop { from { opacity: 0; transform: scale(.8); } to { opacity: 1; transform: none; } }
.modal-emoji { font-size: 60px; }
.modal-title { font-size: 20px; font-weight: 800; margin: 8px 0 6px; }
.modal-text { font-size: 14px; color: var(--muted); line-height: 1.7; }
.modal-btns { display: flex; gap: 10px; margin-top: 18px; }
.modal-btns button { flex: 1; padding: 12px; border-radius: 14px; font-weight: 700; font-size: 15px; }
.btn-main { background: var(--primary); color: #fff; box-shadow: 0 3px 0 #D96A20; }
.btn-ghost { background: #F5EEE3; color: var(--text); }

.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; text-align: left; }
.form-row label { font-size: 13px; font-weight: 600; color: var(--muted); }
.form-row input, .form-row select {
  padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px;
  background: #FFFDF8; outline: none; width: 100%;
}
.form-row input:focus { border-color: var(--primary); }

.confetti-wrap { position: fixed; inset: 0; pointer-events: none; z-index: 400; overflow: hidden; }
.confetti-piece { position: absolute; font-size: 22px; animation: fall linear forwards; }
@keyframes fall {
  from { transform: translateY(-40px) rotate(0deg); opacity: 1; }
  to { transform: translateY(105vh) rotate(720deg); opacity: .2; }
}

.float-ing {
  position: fixed; z-index: 350; font-size: 30px; pointer-events: none;
  animation: floatUp 1s ease-out forwards;
}
@keyframes floatUp {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(-90px) scale(1.5); }
}

.gear {
  position: fixed; top: 14px; right: calc(50% - 240px + 14px); z-index: 100;
  width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,.85);
  display: flex; align-items: center; justify-content: center; font-size: 18px;
  box-shadow: var(--shadow);
}
@media (max-width: 480px) { .gear { right: 14px; } }

.empty { text-align: center; color: var(--muted); font-size: 14px; padding: 30px 0; }
.win-badge { display: inline-block; background: var(--green-soft); color: var(--green); font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 10px; }

/* ============== 单词学习 ============== */
/* 学单词入口卡片：简洁白底轻框，与橙色岛屿卡区分 */
.word-entry {
  display: flex; align-items: center; gap: 12px;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px;
  margin-bottom: 14px; cursor: pointer;
  transition: background .15s;
}
.word-entry:active { background: #FBF7EE; }
.word-entry-emoji {
  font-size: 26px; flex-shrink: 0;
  width: 42px; height: 42px; border-radius: 12px;
  background: var(--primary-soft);
  display: flex; align-items: center; justify-content: center;
}
.word-entry-body { flex: 1; min-width: 0; }
.word-entry-title { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.word-entry-sub { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.word-entry-arrow { font-size: 22px; color: var(--muted); font-weight: 700; }

.word-view-top {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 4px 16px; position: sticky; top: 0;
  background: var(--bg); z-index: 5;
}
.back-btn {
  width: 36px; height: 36px; border: none; border-radius: 50%;
  background: var(--card); color: var(--text); font-size: 20px;
  box-shadow: var(--shadow); cursor: pointer; flex-shrink: 0;
}
.word-view-top h2 { flex: 1; font-size: 17px; font-weight: 800; margin: 0; text-align: center; }
.word-count {
  background: var(--primary-soft); color: var(--primary-dark);
  font-size: 13px; font-weight: 700; padding: 6px 12px; border-radius: 14px;
  flex-shrink: 0;
}

.word-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px; padding-bottom: 20px;
}
.word-card {
  position: relative;
  background: var(--card); border-radius: 16px; padding: 14px 10px;
  text-align: center; box-shadow: var(--shadow); cursor: pointer;
  border: 2px solid transparent; transition: transform .12s;
}
.word-card:active { transform: scale(.96); }
.word-card.learned { background: var(--green-soft); border-color: var(--green); }
.word-card-emoji { font-size: 32px; margin-bottom: 4px; }
.word-card-word { font-size: 18px; font-weight: 800; color: var(--text); margin-bottom: 2px; }
.word-card-meaning { font-size: 12px; color: var(--muted); }
.word-card-check {
  position: absolute; top: 6px; right: 8px;
  color: var(--green); font-size: 16px; font-weight: 900;
}

.word-modal-mask {
  position: fixed; inset: 0; background: rgba(74, 63, 53, .55);
  z-index: 100; animation: fadeIn .15s;
}
@keyframes fadeIn { from { opacity: 0; } }
.word-modal {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: calc(100% - 28px); max-width: 380px;
  background: var(--card); border-radius: 24px;
  padding: 24px 20px 18px; z-index: 101;
  box-shadow: 0 20px 60px rgba(74, 63, 53, .3);
  animation: popIn .2s cubic-bezier(.34,1.56,.64,1);
}
@keyframes popIn { from { transform: translate(-50%, -50%) scale(.85); opacity: 0; } }
.word-modal-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 8px;
}
.word-modal-emoji { font-size: 48px; line-height: 1; }
.word-modal-close {
  width: 30px; height: 30px; border: none; border-radius: 50%;
  background: var(--bg); color: var(--muted); font-size: 22px;
  cursor: pointer; line-height: 1;
}
/* 单词大字（按音节上色，点击触发 TTS） */
.word-modal-word {
  font-size: 42px; font-weight: 900; line-height: 1.1;
  margin-bottom: 8px; letter-spacing: -.5px;
  cursor: pointer;
}
.word-modal-word:hover { opacity: .85; }
.word-modal-speak-hint {
  display: inline-block; font-size: 11px; color: var(--muted);
  background: var(--bg); padding: 2px 8px; border-radius: 8px;
  margin-bottom: 8px; font-weight: 600;
}
.word-modal-ipa {
  font-size: 16px; color: var(--muted); margin-bottom: 10px;
  font-family: 'Times New Roman', serif; font-style: italic;
}
.word-modal-pos {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 16px;
}
.pos-tag {
  background: var(--primary-soft); color: var(--primary-dark);
  font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 8px;
}
.word-modal-pos b { font-size: 16px; color: var(--text); font-weight: 700; }
.syll-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; color: var(--primary-dark);
  margin-bottom: 8px;
}
.syll-tag {
  background: var(--primary-soft); color: var(--primary-dark);
  font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 8px;
}
.syll-row { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.syll-row.single { justify-content: center; }
.syll-row.single .syll { flex: 0 1 auto; min-width: 130px; max-width: 70%; }
/* 音节块：浅色背景 + 深棕字，音节清晰可读 */
.syll {
  flex: 1 1 0;
  min-width: 92px;
  border-radius: 14px;
  padding: 12px 10px;
  text-align: center;
  color: #3D2817;
  font-weight: 800; font-size: 18px;
}
.syll i {
  display: block; font-style: italic; font-weight: 600;
  font-size: 13px; margin-top: 4px;
  color: #5D4037; opacity: 1;
}
.word-modal-ex {
  background: var(--bg); border-radius: 16px; padding: 14px;
  margin-bottom: 16px;
}
.ex-en {
  font-size: 16px; line-height: 1.6; color: var(--text);
  margin-bottom: 6px; font-weight: 600;
}
.ex-en .kw { color: var(--primary-dark); }
.ex-zh { font-size: 14px; color: var(--muted); line-height: 1.5; }

.word-modal-foot {
  display: flex; gap: 8px; align-items: center;
}
.btn-nav {
  background: var(--bg); border: none; border-radius: 14px;
  padding: 12px 8px; font-size: 13px; font-weight: 700;
  color: var(--text); cursor: pointer; flex: 0 0 auto;
}
.btn-nav:disabled { opacity: .35; cursor: not-allowed; }
.btn-learn {
  flex: 1; background: var(--primary); color: #fff;
  border: none; border-radius: 14px; padding: 12px;
  font-size: 15px; font-weight: 800; cursor: pointer;
  box-shadow: 0 3px 0 var(--primary-dark);
}
.btn-learn.done { background: var(--green); box-shadow: 0 3px 0 #3F9B3F; }
.btn-learn:active:not(:disabled) { transform: translateY(1px); box-shadow: 0 2px 0 var(--primary-dark); }
