/*!
 * 花灯守卫 · Lantern Guard —— 样式
 * 明快暖色调，移动端优先，自适应手机 / 平板 / 桌面，横竖屏均可玩
 */

:root {
  --red: #e8412f;
  --red-deep: #c9241a;
  --gold: #f0a417;
  --gold-soft: #ffe9c2;
  --ink: #3a2a24;
  --ink-2: #7a655c;
  --ink-3: #a89489;
  --bg: #fff6ea;
  --bg-2: #ffe9d3;
  --card: #ffffff;
  --line: #f3e2d0;
  --shadow: 0 8px 24px rgba(200, 120, 70, 0.14);
  --shadow-lg: 0 14px 40px rgba(200, 120, 70, 0.2);
  --radius: 18px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;
  overflow: hidden;
}

body {
  font-family: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(170deg, var(--bg) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

#app {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.view {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  opacity: 0;
  transition: opacity 0.22s ease;
}
.view.active { display: flex; opacity: 1; }

.scroll-area {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(20px + var(--safe-t)) calc(18px + var(--safe-r)) calc(28px + var(--safe-b)) calc(18px + var(--safe-l));
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(200, 120, 70, 0.35) transparent;
}
.scroll-area::-webkit-scrollbar { width: 6px; }
.scroll-area::-webkit-scrollbar-track { background: transparent; }
.scroll-area::-webkit-scrollbar-thumb {
  background: rgba(200, 120, 70, 0.35);
  border-radius: 3px;
}

/* ---------------- 通用组件 ---------------- */
.btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 999px;
  font-size: 17px;
  font-weight: 700;
  font-family: inherit;
  padding: 14px 20px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.16s ease, background 0.16s ease;
  letter-spacing: 1px;
}
.btn:active { transform: scale(0.97); }
.btn-lg { padding: 16px 20px; font-size: 18px; }
.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, #ff6a4d, var(--red) 55%, var(--red-deep));
  box-shadow: 0 10px 22px rgba(232, 65, 47, 0.32);
}
.btn-ghost {
  color: var(--red);
  background: #fff;
  border: 2px solid #ffd9cf;
  box-shadow: var(--shadow);
}
.btn + .btn { margin-top: 12px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.card-title {
  margin: 0 0 14px;
  font-size: 17px;
  font-weight: 800;
  color: var(--ink);
  position: relative;
  padding-left: 12px;
}
.card-title::before {
  content: "";
  position: absolute;
  left: 0; top: 3px;
  width: 4px; height: 17px;
  border-radius: 2px;
  background: linear-gradient(var(--red), var(--gold));
}

/* ---------------- 首页 ---------------- */
.hero { text-align: center; padding: 4px 0 12px; }

.hero-lantern {
  width: 92px; height: 92px;
  margin: 0 auto 12px;
  display: flex; align-items: center; justify-content: center;
  animation: sway 3.4s ease-in-out infinite;
}
.lantern-shape {
  width: 84px; height: 72px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #ff8a6b, #f2402c 55%, #c9241a);
  box-shadow: 0 0 0 6px rgba(255, 196, 90, 0.28), 0 10px 26px rgba(232, 65, 47, 0.35);
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.lantern-shape b { color: #ffeecb; font-size: 30px; font-weight: 700; }
.lantern-shape::before, .lantern-shape::after {
  content: ""; position: absolute; left: 50%; transform: translateX(-50%);
  width: 40px; height: 11px; border-radius: 4px; background: var(--gold);
}
.lantern-shape::before { top: -8px; }
.lantern-shape::after { bottom: -8px; }
@keyframes sway {
  0%, 100% { transform: rotate(-5deg); }
  50% { transform: rotate(5deg); }
}

.title {
  margin: 0;
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 6px;
  background: linear-gradient(100deg, var(--red-deep), var(--red) 40%, var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.subtitle { margin: 8px 0 0; color: var(--ink-2); font-size: 14px; letter-spacing: 1px; }

.tag-row { margin-top: 14px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.tag {
  font-size: 12px; color: var(--red);
  background: #fff2ee; border: 1px solid #ffd9cf;
  padding: 5px 11px; border-radius: 999px; font-weight: 600;
}

.best-card {
  display: flex; align-items: center;
  background: linear-gradient(120deg, #fff, #fffaf1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 8px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.best-item { flex: 1; text-align: center; }
.best-label { display: block; font-size: 12px; color: var(--ink-3); margin-bottom: 4px; }
.best-value { font-size: 22px; font-weight: 900; color: var(--red); font-variant-numeric: tabular-nums; }
.best-divider { width: 1px; height: 30px; background: var(--line); }

#btn-start { margin-bottom: 18px; }

.steps { list-style: none; margin: 0; padding: 0; }
.steps li { display: flex; gap: 12px; margin-bottom: 10px; align-items: flex-start; }
.step-no {
  flex: none;
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, #ff7a5c, var(--red));
  color: #fff; font-size: 14px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  margin-top: 2px;
}
.steps b { font-size: 15px; }
.steps p { margin: 3px 0 0; font-size: 13.5px; color: var(--ink-2); line-height: 1.6; }
.steps em, .control-block em { font-style: normal; color: var(--red); font-weight: 700; }

.color-legend {
  display: flex; gap: 10px; flex-wrap: wrap;
  padding: 10px; margin: 4px 0 12px;
  background: #fffaf2; border-radius: 12px; border: 1px dashed var(--line);
}
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); font-weight: 600; }
.legend-item i { width: 15px; height: 15px; border-radius: 50%; display: inline-block; }

.special-row { display: grid; gap: 10px; margin-bottom: 12px; }
.special {
  display: flex; gap: 10px; align-items: center;
  background: #fffaf2; border-radius: 12px; padding: 10px 12px; border: 1px solid var(--line);
}
.special b { font-size: 14px; }
.special p { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-2); line-height: 1.5; }
.orb-demo {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 800;
}
.orb-demo.blessing {
  background: radial-gradient(circle at 34% 30%, #ffd980, #ffb800);
  color: #8a4b00;
  box-shadow: 0 0 0 4px rgba(255, 184, 0, 0.2);
}
.orb-demo.shifting {
  background: linear-gradient(135deg, #12b8ae 50%, #8b5cf6 50%);
  border: 2px dashed rgba(60, 60, 60, 0.5);
}

.control-row { display: grid; gap: 10px; margin-bottom: 10px; }
.control-block { background: #fffaf2; border-radius: 12px; padding: 10px 12px; border: 1px solid var(--line); }
.control-block b { font-size: 14px; color: var(--red-deep); }
.control-block p { margin: 4px 0 0; font-size: 12.5px; color: var(--ink-2); line-height: 1.6; }
kbd {
  display: inline-block; min-width: 22px; text-align: center;
  padding: 1px 6px; margin: 0 2px;
  border: 1px solid #e5d3c2; border-bottom-width: 2px; border-radius: 5px;
  background: #fff; font-size: 12px; font-family: inherit; color: var(--ink);
}
.rule-note { margin: 0; font-size: 12.5px; color: var(--ink-3); text-align: center; }

.site-foot {
  margin-top: 14px; text-align: center;
  font-size: 12px; color: var(--ink-3);
  display: flex; gap: 8px; justify-content: center; align-items: center; flex-wrap: wrap;
}
.link-btn {
  background: none; border: none; padding: 0;
  color: var(--ink-2); font-size: 12px; text-decoration: underline;
  cursor: pointer; font-family: inherit;
}

/* ---------------- 游戏界面 ---------------- */
.game-shell {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  padding: calc(10px + var(--safe-t)) calc(12px + var(--safe-r)) calc(10px + var(--safe-b)) calc(12px + var(--safe-l));
  width: 100%; max-width: 640px; margin: 0 auto;
}

.hud { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hud-left, .hud-right { display: flex; align-items: center; gap: 8px; flex: 1; }
.hud-right { justify-content: flex-end; }
.hud-center { text-align: center; flex: none; }
.hud-label { display: block; font-size: 11px; color: var(--ink-3); line-height: 1.2; }
.hud-value { font-size: 17px; font-weight: 800; color: var(--ink); }
.hud-score { font-size: 28px; font-weight: 900; color: var(--red); font-variant-numeric: tabular-nums; line-height: 1.1; }
.hud-score.bump { animation: bump 0.24s ease; }
@keyframes bump { 50% { transform: scale(1.18); } }
.hud-combo {
  display: block; height: 15px; font-size: 12px; font-weight: 800; color: var(--gold);
  letter-spacing: 0.5px;
}

.icon-btn {
  width: 34px; height: 34px; flex: none;
  border-radius: 50%; border: 1px solid var(--line);
  background: #fff; color: var(--ink-2);
  font-size: 14px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(200, 120, 70, 0.1);
  font-family: inherit;
}
.icon-btn:active { transform: scale(0.92); }
.icon-btn.off { color: var(--ink-3); background: #f7efe6; text-decoration: line-through; }

.lives { display: flex; gap: 3px; }
.lives span {
  width: 15px; height: 15px; border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #ff8a6b, var(--red));
  box-shadow: 0 2px 6px rgba(232, 65, 47, 0.35);
  transition: transform 0.2s ease, opacity 0.2s ease, background 0.2s ease;
}
.lives span.empty { background: #eadfd4; box-shadow: none; opacity: 0.7; transform: scale(0.78); }

.level-bar {
  height: 5px; border-radius: 3px; background: #f3e3d3;
  margin: 8px 2px 6px; overflow: hidden;
}
.level-bar i {
  display: block; height: 100%; width: 0%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--gold), var(--red));
  transition: width 0.28s ease;
}

.stage {
  position: relative;
  flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  touch-action: manipulation;
  user-select: none; -webkit-user-select: none;
}
#canvas {
  display: block;
  border-radius: 50%;
  box-shadow: 0 10px 36px rgba(200, 120, 70, 0.22);
  touch-action: none;
}

.overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: rgba(255, 248, 238, 0.82);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  border-radius: 20px;
  z-index: 5;
}
.overlay[hidden] { display: none; }
.count-num {
  font-size: 88px; font-weight: 900; color: var(--red);
  line-height: 1; animation: pop 0.5s ease;
}
@keyframes pop { from { transform: scale(0.5); opacity: 0; } }
.count-tip { margin-top: 10px; color: var(--ink-2); font-size: 14px; letter-spacing: 1px; }

.overlay-panel .panel {
  background: #fff; border-radius: var(--radius);
  padding: 22px 20px; width: min(300px, 82%);
  box-shadow: var(--shadow-lg); text-align: center;
  border: 1px solid var(--line);
}
.panel h3 { margin: 0 0 4px; font-size: 20px; }
.panel-tip { margin: 0 0 16px; font-size: 12.5px; color: var(--ink-3); }

.controls {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding-top: 10px;
}
.rot-btn {
  flex: none;
  width: 84px; padding: 10px 0;
  border-radius: 16px; border: 1px solid var(--line);
  background: #fff; box-shadow: var(--shadow);
  cursor: pointer; font-family: inherit; color: var(--ink);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.rot-btn:active { transform: scale(0.94); background: #fff2ee; }
.rot-icon { font-size: 24px; line-height: 1; color: var(--red); }
.rot-text { font-size: 11px; color: var(--ink-3); }
.control-hint { flex: 1; text-align: center; font-size: 12px; color: var(--ink-3); margin: 0; }

/* ---------------- 结算页 ---------------- */
.result-card {
  background: var(--card);
  border-radius: 22px;
  padding: 26px 20px 22px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--line);
  text-align: center;
  margin-top: 6px;
  position: relative;
}
.record-badge {
  position: absolute; top: -13px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(135deg, #ffd166, var(--gold));
  color: #7a4600; font-size: 13px; font-weight: 800;
  padding: 5px 16px; border-radius: 999px; white-space: nowrap;
  box-shadow: 0 6px 16px rgba(240, 164, 23, 0.4);
  animation: pop 0.45s ease;
}
.record-badge[hidden] { display: none; }
.result-label { margin: 0; font-size: 13px; color: var(--ink-3); letter-spacing: 2px; }
.result-score {
  font-size: 64px; font-weight: 900; line-height: 1.1; margin: 2px 0 4px;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(100deg, var(--red-deep), var(--red) 45%, var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.result-comment { margin: 0 0 18px; font-size: 14px; color: var(--ink-2); }

.result-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
  margin-bottom: 14px;
}
.result-item {
  background: #fffaf2; border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 6px;
}
.result-item span { display: block; font-size: 12px; color: var(--ink-3); margin-bottom: 2px; }
.result-item strong { font-size: 19px; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }

.best-line {
  font-size: 13px; color: var(--ink-2); margin-bottom: 18px;
}
.best-line strong { color: var(--red); font-size: 16px; }
#result-gap { display: block; font-size: 12px; color: var(--ink-3); margin-top: 4px; }

/* ---------------- 自适应 ---------------- */
@media (min-width: 560px) {
  .special-row, .control-row { grid-template-columns: 1fr 1fr; }
  .result-grid { grid-template-columns: repeat(4, 1fr); }
  .title { font-size: 40px; }
}

/* 横屏 / 矮屏：压缩 HUD 与按钮，保证画布完整可见 */
@media (orientation: landscape) and (max-height: 560px) {
  .game-shell { max-width: 100%; padding-top: calc(6px + var(--safe-t)); padding-bottom: calc(6px + var(--safe-b)); }
  .hud-score { font-size: 22px; }
  .hud-combo { height: 13px; font-size: 11px; }
  .level-bar { margin: 5px 2px 4px; }
  .controls { padding-top: 6px; }
  .rot-btn { width: 72px; padding: 6px 0; }
  .rot-icon { font-size: 19px; }
  .rot-text { display: none; }
  .control-hint { font-size: 11px; }
  .count-num { font-size: 60px; }
  .scroll-area { max-width: 720px; }
}

@media (min-width: 900px) {
  .game-shell { max-width: 720px; }
  .control-hint { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ================================================================
   v2.0 新增样式
   ================================================================ */

/* ---- 广告插槽 ---- */
.ad-slot { width: 100%; }
.ad-slot[hidden] { display: none; }

.ad-card {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.ad-card .ad-tag {
  position: absolute; top: 6px; right: 8px;
  font-size: 10px; color: var(--ink-3);
  background: #f7efe6; border-radius: 4px;
  padding: 1px 5px; font-weight: 600;
}
.ad-card .ad-icon {
  flex: none; width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 18px; font-weight: 800;
}
.ad-card .ad-body { flex: 1; min-width: 0; }
.ad-card .ad-body b { font-size: 14px; display: block; }
.ad-card .ad-body p { margin: 2px 0 0; font-size: 12px; color: var(--ink-2); line-height: 1.4; }
.ad-card .ad-cta {
  flex: none; min-height: 36px; min-width: 44px;
  padding: 8px 16px;
  border: none; border-radius: 999px;
  background: linear-gradient(135deg, #ff6a4d, var(--red));
  color: #fff; font-size: 13px; font-weight: 700;
  cursor: pointer; font-family: inherit;
}
.ad-card .ad-cta:active { transform: scale(0.94); }
.ad-slot-pause .ad-card { margin-bottom: 0; padding: 10px 12px; }
.ad-slot-pause .ad-card .ad-icon { width: 36px; height: 36px; font-size: 15px; }

/* ---- 本地榜单 ---- */
.rank-card { margin-bottom: 16px; }
.rank-card[hidden] { display: none; }
.rank-list { display: flex; flex-direction: column; gap: 6px; }
.rank-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  background: #fffaf2; border-radius: 10px;
  border: 1px solid var(--line);
}
.rank-no {
  flex: none; width: 26px; height: 26px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800;
  background: #f0e6dc; color: var(--ink-2);
}
.rank-no.gold { background: linear-gradient(135deg, #ffd166, #f0a417); color: #7a4600; }
.rank-no.silver { background: linear-gradient(135deg, #e8e8e8, #c0c0c0); color: #555; }
.rank-no.bronze { background: linear-gradient(135deg, #e0a070, #c87850); color: #fff; }
.rank-score { font-size: 15px; font-weight: 800; color: var(--red); font-variant-numeric: tabular-nums; }
.rank-info { flex: 1; font-size: 12px; color: var(--ink-2); }
.rank-date { font-size: 11px; color: var(--ink-3); }
.rank-more { display: block; margin: 10px auto 0; text-align: center; }

/* ---- HUD 章节标签 ---- */
.hud-label { display: block; font-size: 11px; color: var(--ink-3); line-height: 1.2; }

/* ---- Boss 血条 ---- */
.boss-bar {
  display: flex; align-items: center; gap: 8px;
  margin: 4px 2px 6px;
  padding: 6px 10px;
  background: rgba(40, 20, 15, 0.06);
  border-radius: 10px;
}
.boss-bar[hidden] { display: none; }
.boss-name { font-size: 12px; font-weight: 700; color: var(--red-deep); white-space: nowrap; }
.boss-hp-track {
  flex: 1; height: 8px; border-radius: 4px;
  background: #f0e0d0; overflow: hidden;
}
.boss-hp-track i {
  display: block; height: 100%; width: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--red-deep), var(--red), var(--gold));
  transition: width 0.2s ease;
}

/* ---- 结算页排名 ---- */
.result-rank {
  margin: 0 0 14px; font-size: 14px; font-weight: 700;
  color: var(--red); text-align: center;
}
.result-rank:empty { display: none; }
.result-card.top3 {
  border-color: var(--gold);
  box-shadow: 0 14px 40px rgba(240, 164, 23, 0.25), 0 0 0 2px var(--gold-soft);
}

/* ---- 分享弹层 ---- */
.share-modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.share-modal[hidden] { display: none; }
.share-modal-inner {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  width: 100%; max-width: 96%;
  max-height: 96vh;
  padding: 12px;
}
.share-modal-inner img {
  max-width: 100%; max-height: 76vh;
  width: auto;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  object-fit: contain;
}
.share-actions { display: flex; gap: 10px; width: 100%; max-width: 320px; }
.share-actions .btn { flex: 1; padding: 12px 16px; font-size: 15px; }
.share-tip { margin: 0; font-size: 11px; color: rgba(255, 255, 255, 0.7); text-align: center; }

/* ---- 分享按钮 ---- */
#btn-share { margin-top: 0; }

/* ---- 横屏适配补充 ---- */
@media (orientation: landscape) and (max-height: 560px) {
  .boss-bar { margin: 3px 2px 4px; padding: 4px 8px; }
  .boss-name { font-size: 11px; }
}
