/* ================= 单词贪吃蛇 ================= */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: linear-gradient(160deg, #0f2f1e 0%, #123524 50%, #0d2418 100%);
  color: #eaf5ee;
  overscroll-behavior: none;
}
#app { max-width: 520px; margin: 0 auto; height: 100dvh; position: relative; }

/* ---------- 屏幕切换 ---------- */
.screen {
  display: none; flex-direction: column;
  height: 100%; overflow: hidden;
  padding: max(10px, env(safe-area-inset-top)) 14px max(10px, env(safe-area-inset-bottom));
}
.screen.active { display: flex; }

/* ---------- 通用按钮 ---------- */
.btn {
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.08);
  color: #eaf5ee; border-radius: 14px;
  padding: 10px 16px; font-size: 15px; cursor: pointer;
  text-align: center; text-decoration: none; display: inline-block;
  transition: transform .06s, background .15s;
  user-select: none;
}
.btn:active { transform: scale(.96); }
.btn.primary { background: linear-gradient(135deg, #35c26e, #1f9e55); border: none; box-shadow: 0 6px 18px rgba(53,194,110,.35); font-weight: 700; }
.btn.big { width: 100%; padding: 14px; font-size: 17px; margin-top: 12px; }
.btn.small { padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.btn.danger { border-color: rgba(255,99,99,.4); color: #ffb4b4; background: rgba(255,99,99,.12); }
.btn-row { display: flex; gap: 10px; margin-top: 10px; }
.btn-row .btn { flex: 1; margin-top: 0; }

/* ---------- 顶部栏 ---------- */
.topbar, .page-head, .game-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 10px; flex: none;
}
.page-head b, .game-head .game-title { font-size: 17px; letter-spacing: 1px; }
.home-link {
  color: #ffd76a; text-decoration: none; font-size: 14px; font-weight: 600;
  border: 1px solid rgba(255,215,106,.45); background: rgba(255,215,106,.12);
  padding: 6px 12px; border-radius: 12px; white-space: nowrap;
}
.home-link:active { transform: scale(.95); }

/* ---------- 遮罩层 ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(6, 20, 13, .82); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.overlay.hidden { display: none; }
.splash-card, .poster-card {
  background: #16382a; border: 1px solid rgba(255,255,255,.12);
  border-radius: 20px; padding: 26px 22px; max-width: 380px; width: 100%;
  text-align: center; max-height: 86dvh; overflow: auto;
}
.splash-logo { font-size: 54px; margin-bottom: 6px; }
.splash-card h2, .poster-card h3 { margin: 4px 0 10px; }
.splash-card p { font-size: 13.5px; color: #bcd6c4; line-height: 1.7; margin: 6px 0; text-align: left; }
.splash-card ul { text-align: left; padding-left: 18px; margin: 8px 0 14px; }
.splash-card li { font-size: 13px; color: #a9c8b3; line-height: 1.8; }
.age-tag {
  display: inline-block; background: rgba(255,215,106,.15); color: #ffd76a;
  font-size: 12px; padding: 3px 10px; border-radius: 999px; margin-bottom: 6px;
}

/* ---------- 首页 ---------- */
.home-hero { text-align: center; padding: 18px 0 6px; }
.home-logo {
  width: 96px; height: 96px; margin: 0 auto 12px;
  font-size: 56px; line-height: 96px;
  background: radial-gradient(circle at 30% 25%, #2f6b4d, #17402c);
  border-radius: 30px; box-shadow: 0 10px 30px rgba(0,0,0,.4), inset 0 2px 6px rgba(255,255,255,.15);
}
.home-hero h1 { margin: 0; font-size: 30px; letter-spacing: 4px; }
.slogan { color: #a9c8b3; font-size: 13.5px; line-height: 1.9; margin: 8px 0 0; }
.home-menu { margin-top: 8px; }
.nick-row {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-top: 16px; font-size: 14px; color: #bcd6c4;
}
.nick-row b { color: #ffd76a; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-foot { display: flex; justify-content: center; gap: 10px; margin-top: 14px; }
.copyright { text-align: center; color: #6f8f7a; font-size: 12px; margin: 18px 0 6px; }

/* ---------- 玩法说明 ---------- */
.rules-body { overflow-y: auto; flex: 1; }
.rule-card {
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1);
  border-radius: 16px; padding: 14px 16px; margin-bottom: 12px;
}
.rule-card h3 { margin: 0 0 8px; font-size: 15.5px; color: #ffd76a; }
.rule-card p { margin: 5px 0; font-size: 14px; line-height: 1.75; color: #d5e9db; }
.c-gold { color: #ffd76a; } .c-grey { color: #aab5ad; }
.rule-actions { display: flex; gap: 10px; justify-content: center; padding: 8px 0 20px; }

/* ---------- 开局设置 ---------- */
.setup-body { overflow-y: auto; flex: 1; padding-bottom: 16px; }
.sec-title { font-size: 15px; color: #ffd76a; margin: 14px 0 8px; }
.setup-lists { display: flex; flex-direction: column; gap: 8px; }
.list-card {
  display: flex; justify-content: space-between; align-items: center;
  background: rgba(255,255,255,.07); border: 2px solid rgba(255,255,255,.12);
  border-radius: 14px; padding: 12px 16px; cursor: pointer; font-size: 15px;
}
.list-card .cnt { font-size: 13px; color: #a9c8b3; }
.list-card.sel { border-color: #35c26e; background: rgba(53,194,110,.16); }
.diff-cards { display: flex; gap: 8px; }
.diff-card {
  flex: 1; display: flex; flex-direction: column; gap: 4px; align-items: center;
  background: rgba(255,255,255,.07); border: 2px solid rgba(255,255,255,.12);
  border-radius: 14px; padding: 12px 6px; cursor: pointer; color: #eaf5ee;
  font-size: 11.5px; line-height: 1.5;
}
.diff-card b { font-size: 14.5px; }
.diff-card.sel { border-color: #ffd76a; background: rgba(255,215,106,.15); }
.setup-tip { text-align: center; color: #8fae9b; font-size: 12.5px; margin-top: 10px; }

/* ---------- 游戏屏 ---------- */
#screen-game { padding-left: 8px; padding-right: 8px; }
.game-head .game-title { font-weight: 700; color: #cfe9d8; }
.clue-bar {
  flex: none; display: flex; align-items: center; flex-wrap: wrap; justify-content: center;
  gap: 6px; background: rgba(255,215,106,.1);
  border: 1px solid rgba(255,215,106,.3); border-radius: 12px;
  padding: 7px 10px; font-size: 14.5px; margin-bottom: 6px;
}
.clue-label { color: #bcd6c4; }
.clue-bar b { color: #ffd76a; font-size: 16px; }
.next-chip {
  margin-left: auto; background: rgba(255,215,106,.9); color: #3c2d00;
  border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 700;
}
.next-chip b { color: #3c2d00; font-size: 15px; }

.word-track {
  flex: none; display: flex; justify-content: center; gap: 4px;
  flex-wrap: wrap; margin-bottom: 6px; min-height: 34px;
}
.wt-cell {
  width: 26px; height: 30px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 16px; font-family: Consolas, Menlo, monospace;
  background: rgba(255,255,255,.08); color: #5c7a68; border: 1px solid rgba(255,255,255,.1);
}
.wt-cell.done { background: rgba(53,194,110,.35); color: #b8ffd4; border-color: rgba(53,194,110,.6); }
.wt-cell.cur {
  background: #ffd76a; color: #4a3600; border-color: #ffd76a;
  animation: pulse .9s infinite;
}
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,215,106,.55);} 50% { box-shadow: 0 0 0 6px rgba(255,215,106,0);} }

.hud { flex: none; display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-bottom: 6px; }
.hud-chip {
  background: rgba(0,0,0,.3); border: 1px solid rgba(255,255,255,.12);
  border-radius: 999px; padding: 3px 10px; font-size: 12.5px; color: #d5e9db;
  display: inline-flex; align-items: center; gap: 4px;
}
.hud-chip b { color: #fff; font-size: 13.5px; }
.scale-chip i { margin: 0 1px 0 3px; }

/* 小鳞片图标 */
.sc { display: inline-block; width: 12px; height: 12px; border-radius: 4px; vertical-align: -1px; }
.sc-silver { background: linear-gradient(135deg, #e8eef0, #9fb0b8); box-shadow: 0 0 4px rgba(220,230,235,.6); }
.sc-gold { background: linear-gradient(135deg, #ffe28a, #e8a61b); box-shadow: 0 0 6px rgba(255,206,58,.7); }
.sc-diamond {
  background: linear-gradient(135deg, #b3f3ff, #58c9e8);
  box-shadow: 0 0 8px rgba(126,232,250,.8);
  transform: rotate(45deg); border-radius: 2px; width: 10px; height: 10px;
}

.board-wrap {
  flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center;
  border-radius: 16px; overflow: hidden; background: #0a1d13;
  border: 1px solid rgba(255,255,255,.1);
  touch-action: none;
}
#board { display: block; }

/* 方向键 */
.dpad {
  flex: none; display: grid; grid-template-columns: repeat(3, 64px);
  grid-template-rows: repeat(2, 48px); gap: 6px;
  justify-content: center; margin-top: 8px; touch-action: none;
}
.dp {
  border: 1px solid rgba(255,255,255,.16); background: rgba(255,255,255,.09);
  color: #d5e9db; border-radius: 12px; font-size: 19px; cursor: pointer; user-select: none;
}
.dp:active { background: rgba(53,194,110,.4); }
.dp.up { grid-column: 2; grid-row: 1; }
.dp.left { grid-column: 1; grid-row: 2; }
.dp.down { grid-column: 2; grid-row: 2; }
.dp.right { grid-column: 3; grid-row: 2; }
@media (pointer: fine) { .dpad { display: none; } }

/* ---------- 结算 ---------- */
.result-body { overflow-y: auto; flex: 1; padding-bottom: 20px; }
.result-card {
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12);
  border-radius: 20px; padding: 18px; text-align: center;
}
.result-card h2 { margin: 0 0 4px; font-size: 24px; }
.result-sub { margin: 0; color: #a9c8b3; font-size: 13.5px; }
.score-big { margin: 12px 0 4px; }
.score-big span { font-size: 26px; }
.score-big b { font-size: 46px; color: #ffd76a; margin: 0 6px; font-family: Consolas, Menlo, monospace; }
.score-big em { font-style: normal; color: #a9c8b3; font-size: 14px; }
.rank-line { color: #8fe3b0; font-size: 13.5px; min-height: 20px; margin: 4px 0; }
.result-stats { display: flex; gap: 8px; margin-top: 10px; }
.result-stats > div {
  flex: 1; background: rgba(0,0,0,.25); border-radius: 12px; padding: 10px 4px;
}
.result-stats b { display: block; font-size: 18px; color: #fff; }
.result-stats span { font-size: 12px; color: #a9c8b3; }
.scale-show { display: flex; gap: 8px; margin-top: 12px; }
.scale-item {
  flex: 1; background: rgba(0,0,0,.25); border-radius: 12px; padding: 10px 4px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.scale-item b { font-size: 18px; }
.scale-item span { font-size: 12px; color: #a9c8b3; }
.word-review { display: flex; flex-wrap: wrap; gap: 8px; }
.wr-chip {
  background: rgba(53,194,110,.14); border: 1px solid rgba(53,194,110,.4);
  border-radius: 10px; padding: 6px 10px; font-size: 13px;
}
.wr-chip b { color: #b8ffd4; font-family: Consolas, Menlo, monospace; }
.wr-chip span { color: #a9c8b3; margin-left: 6px; font-size: 12px; }
.wr-chip.miss { background: rgba(255,99,99,.1); border-color: rgba(255,99,99,.35); }
.wr-chip.miss b { color: #ffb4b4; }
.result-btns .home-big { margin-top: 12px; border-color: rgba(255,215,106,.45); color: #ffd76a; background: rgba(255,215,106,.12); }

/* ---------- 排行榜 ---------- */
.board-tabs { flex: none; display: flex; gap: 8px; margin-bottom: 10px; }
.board-tabs .tab {
  flex: 1; padding: 9px; border-radius: 12px; border: 1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.07); color: #d5e9db; font-size: 14px; cursor: pointer;
}
.board-tabs .tab.active { background: rgba(53,194,110,.3); border-color: #35c26e; color: #fff; font-weight: 700; }
.board-list { overflow-y: auto; flex: 1; }
.board-row {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,.05); border-radius: 12px;
  padding: 10px 12px; margin-bottom: 7px; font-size: 14px;
}
.board-row.me { border: 1px solid #ffd76a; background: rgba(255,215,106,.12); }
.br-rank {
  width: 34px; text-align: center; font-weight: 800; font-size: 15px; color: #8fae9b; flex: none;
}
.br-rank.r1 { color: #ffd76a; } .br-rank.r2 { color: #d9e4de; } .br-rank.r3 { color: #e8a06a; }
.br-main { flex: 1; min-width: 0; }
.br-nick { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.br-sub { font-size: 11.5px; color: #8fae9b; margin-top: 2px; }
.br-score { font-weight: 800; color: #ffd76a; font-size: 16px; font-family: Consolas, Menlo, monospace; flex: none; }
.br-medal { font-size: 15px; flex: none; }
.board-empty { text-align: center; color: #8fae9b; padding: 50px 0; font-size: 14px; }

/* ---------- 海报弹层 ---------- */
.poster-card img { width: 100%; border-radius: 14px; margin: 10px 0; }
.poster-tip { color: #a9c8b3; font-size: 13px; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 15%; transform: translateX(-50%);
  background: rgba(0,0,0,.82); color: #fff; padding: 10px 18px;
  border-radius: 12px; font-size: 14px; z-index: 200;
  opacity: 0; pointer-events: none; transition: opacity .25s;
  max-width: 86vw; text-align: center;
}
#toast.show { opacity: 1; }

/* 窄屏适配 */
@media (max-width: 380px) {
  .wt-cell { width: 22px; height: 27px; font-size: 14px; }
  .dpad { grid-template-columns: repeat(3, 56px); }
}
