/* 午后纸飞机 · Paper Glider — 统一暖纸质视觉 */
:root {
  --paper: #f7eeda;
  --paper-dark: #eadfc6;
  --ink: #4a3a28;
  --ink-soft: #7a6a50;
  --accent: #d9793f;
  --gold: #e8b04a;
  --sage: #7fae8a;
  --danger: #c9584a;
  --panel-bg: rgba(250, 240, 220, 0.94);
  --shadow: 0 10px 36px rgba(90, 60, 20, 0.25);
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  font-family: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: #f0dcb8; color: var(--ink);
  user-select: none; -webkit-user-select: none;
  width: 100%; height: 100vh; height: 100dvh;
  touch-action: none;
}
#app { position: fixed; inset: 0; }
#gl-wrap, #gl-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 14px 16px; pointer-events: none; z-index: 5;
}
.hud-left { display: flex; flex-direction: column; gap: 6px; min-width: 240px; }
.hud-row { display: flex; align-items: center; gap: 10px; }
.chip {
  background: rgba(74, 58, 40, 0.82); color: var(--paper);
  padding: 5px 14px; border-radius: 999px; font-size: 15px; font-weight: 600; letter-spacing: 1px;
}
.lives { display: inline-flex; gap: 4px; align-items: center; }
.lives svg { filter: drop-shadow(0 1px 1px rgba(0,0,0,0.25)); }
.objective { font-size: 16px; font-weight: 600; color: var(--ink); text-shadow: 0 1px 0 rgba(255,255,255,0.6); }
.objective b { color: var(--accent); font-size: 18px; }
.progress {
  width: 230px; height: 10px; background: rgba(74, 58, 40, 0.25);
  border-radius: 999px; overflow: hidden; border: 1px solid rgba(74, 58, 40, 0.3);
}
#hud-progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--gold), var(--accent));
  border-radius: 999px; transition: width 0.25s ease;
}
.sub { font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.hud-right { display: flex; gap: 10px; pointer-events: auto; }
.icon-btn {
  width: 46px; height: 46px; border-radius: 14px; border: 1px solid rgba(74,58,40,0.35);
  background: var(--panel-bg); color: var(--ink); cursor: pointer;
  display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow);
}
.icon-btn:active { transform: scale(0.94); }

/* ---------- 下一环标记 ---------- */
#ring-marker { position: absolute; z-index: 4; pointer-events: none; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; }
#ring-marker .diamond {
  width: 20px; height: 20px; transform: rotate(45deg);
  border: 3px solid var(--gold); background: rgba(232, 176, 74, 0.25);
  box-shadow: 0 0 12px rgba(232, 176, 74, 0.8); border-radius: 3px;
}
.marker-dist { font-size: 12px; font-weight: 700; color: #7a5a10; margin-top: 5px; text-shadow: 0 1px 0 rgba(255,255,255,0.7); }

/* ---------- 提示气泡 ---------- */
#toasts {
  position: absolute; top: 96px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; align-items: center; z-index: 6; pointer-events: none;
}
.toast {
  background: var(--panel-bg); border: 1px solid rgba(201, 168, 106, 0.8); color: var(--ink);
  padding: 8px 20px; border-radius: 999px; font-size: 15px; font-weight: 600;
  box-shadow: var(--shadow); animation: toast-in 0.25s ease, toast-out 0.4s ease 1.5s forwards;
}
.toast.good { border-color: var(--sage); color: #2e6a44; }
.toast.bad { border-color: var(--danger); color: var(--danger); }
.toast.wind { border-color: #6a8aae; color: #33557a; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px) scale(0.9); } to { opacity: 1; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-10px); } }

/* ---------- 触控按钮 ---------- */
#touch-controls {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 7;
  display: flex; justify-content: space-between; align-items: flex-end;
  padding: 0 18px calc(18px + env(safe-area-inset-bottom)); pointer-events: none;
}
.tc-group { display: flex; gap: 14px; pointer-events: auto; }
.tc-col { display: flex; flex-direction: column; gap: 14px; }
.tc-right { align-items: flex-end; }
.tc-btn {
  width: 72px; height: 72px; border-radius: 22px; border: 2px solid rgba(74, 58, 40, 0.4);
  background: rgba(250, 240, 220, 0.82); color: var(--ink); cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 2px;
  box-shadow: var(--shadow); touch-action: none;
  font-size: 13px; font-weight: 700;
}
.tc-btn.held, .tc-btn:active { background: var(--accent); color: #fff; border-color: var(--accent); transform: scale(0.95); }
.tc-action { width: 72px; height: 158px; }
.tc-action.cd { opacity: 0.45; }

/* ---------- 覆盖层 ---------- */
.overlay {
  position: absolute; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(60, 42, 20, 0.35), rgba(45, 30, 12, 0.55));
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  padding: 18px;
}
.panel {
  background: var(--panel-bg); border-radius: 22px; padding: 30px 36px;
  box-shadow: var(--shadow); border: 1px solid rgba(201, 168, 106, 0.6);
  text-align: center; max-width: min(680px, 94vw); max-height: 92vh; overflow-y: auto;
}
.panel h2 { font-size: 30px; letter-spacing: 4px; margin-bottom: 6px; }
.panel-sub { color: var(--ink-soft); margin-bottom: 18px; font-size: 14px; }
.primary-btn, .secondary-btn {
  display: block; width: 100%; margin: 10px auto 0; padding: 14px 20px;
  border-radius: 14px; font-size: 18px; font-weight: 700; cursor: pointer; letter-spacing: 2px;
  border: 2px solid transparent; transition: transform 0.08s ease;
}
.primary-btn { background: var(--accent); color: #fff; box-shadow: 0 6px 18px rgba(217, 121, 63, 0.4); }
.secondary-btn { background: transparent; color: var(--ink); border-color: rgba(74, 58, 40, 0.4); }
.primary-btn:active, .secondary-btn:active { transform: scale(0.97); }

/* ---------- 菜单 ---------- */
.menu-panel { padding: 26px 30px; }
.title-glider { margin-bottom: 2px; filter: drop-shadow(0 4px 8px rgba(120, 80, 20, 0.3)); }
.title { font-family: Georgia, "Songti SC", "SimSun", serif; font-size: 40px; letter-spacing: 8px; }
.subtitle { color: var(--ink-soft); font-size: 13px; margin: 8px 0 20px; letter-spacing: 1px; }
#level-cards { display: flex; gap: 14px; justify-content: center; margin-bottom: 20px; flex-wrap: wrap; }
.level-card {
  width: 168px; border-radius: 16px; padding: 14px 12px; cursor: pointer; position: relative;
  border: 2px solid rgba(74, 58, 40, 0.25); text-align: left; overflow: hidden;
  transition: transform 0.12s ease, border-color 0.12s ease;
  color: var(--ink);
}
.level-card:hover { transform: translateY(-3px); }
.level-card.selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(217, 121, 63, 0.35); }
.level-card .lc-preview { height: 64px; border-radius: 10px; margin-bottom: 10px; position: relative; }
.level-card .lc-name { font-weight: 800; font-size: 16px; }
.level-card .lc-sub { font-size: 11.5px; color: var(--ink-soft); margin-top: 3px; min-height: 30px; }
.level-card .lc-best { font-size: 12px; margin-top: 6px; font-weight: 700; color: #8a6a10; min-height: 16px; }
.level-card.locked { filter: grayscale(0.9); opacity: 0.65; cursor: not-allowed; }
.level-card .lc-lock {
  position: absolute; top: 8px; right: 8px; background: rgba(74,58,40,0.8); color: var(--paper);
  border-radius: 8px; padding: 4px; display: flex;
}
.lc-preview svg { position: absolute; right: 6px; bottom: 4px; opacity: 0.85; }
.help { margin-top: 16px; display: flex; flex-direction: column; gap: 5px; }
.help-row { font-size: 12.5px; color: var(--ink-soft); }
.help-row b { color: var(--ink); }

/* ---------- 倒计时 ---------- */
#countdown { background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; }
#countdown-num {
  font-family: Georgia, serif; font-size: 120px; font-weight: 700; color: var(--paper);
  text-shadow: 0 6px 30px rgba(120, 70, 20, 0.8); animation: count-pop 0.5s ease;
}
.count-hint { color: var(--paper); font-size: 16px; letter-spacing: 6px; text-shadow: 0 2px 10px rgba(120, 70, 20, 0.8); }
@keyframes count-pop { from { transform: scale(1.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- 结算 ---------- */
.stars { display: flex; gap: 8px; justify-content: center; margin: 10px 0; }
.stars svg { filter: drop-shadow(0 2px 4px rgba(200, 140, 30, 0.5)); }
.end-stats { display: flex; gap: 22px; justify-content: center; margin: 12px 0 18px; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; gap: 3px; }
.stat .k { font-size: 12px; color: var(--ink-soft); letter-spacing: 2px; }
.stat .v { font-size: 22px; font-weight: 800; }
.stat .v.gold { color: #b07a10; }
#end-title.won { color: #2e6a44; }
#end-title.lost { color: var(--danger); }

/* ---------- 移动端 ---------- */
@media (max-width: 720px), (pointer: coarse) {
  #hud { padding: 10px; }
  .hud-left { min-width: 0; }
  .chip { font-size: 12px; padding: 4px 10px; }
  .objective { font-size: 14px; }
  .objective b { font-size: 15px; }
  .progress { width: 150px; height: 8px; }
  .sub { font-size: 11px; }
  .icon-btn { width: 40px; height: 40px; border-radius: 12px; }
  #toasts { top: 78px; }
  .toast { font-size: 13px; padding: 6px 14px; }
  .menu-panel { padding: 20px 16px; }
  .title { font-size: 30px; letter-spacing: 5px; }
  .level-card { width: 30vw; min-width: 104px; padding: 10px 8px; }
  .level-card .lc-preview { height: 44px; }
  .level-card .lc-sub { display: none; }
  .level-card .lc-best { font-size: 10.5px; }
  .help-row { font-size: 11px; }
  .panel { padding: 22px 18px; }
  .panel h2 { font-size: 24px; }
  #countdown-num { font-size: 90px; }
  .tc-btn { width: 64px; height: 64px; }
  .tc-action { height: 142px; }
}
@media (max-width: 420px) {
  .tc-btn { width: 58px; height: 58px; border-radius: 18px; }
  .tc-action { width: 58px; height: 130px; }
  .tc-btn svg { width: 24px; height: 24px; }
}
