/* ============ 基础与主题 ============ */
* { box-sizing: border-box; }

:root {
  --gold: #f6c453;
  --gold-deep: #d99a22;
  --gold-soft: #ffe6a3;
  --ink: #1b140d;
  --panel: #241a12;
  --panel-2: #2e2116;
  --line: rgba(246, 196, 83, 0.22);
  --text: #f7ecd8;
  --muted: #b8a68c;
  --green: #63c17c;
  --red: #e8664f;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 50% -20%, #4a3320 0%, #241810 45%, #140e09 100%);
  color: var(--text);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px 20px 26px;
}

/* 背景里的细碎矿粒 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 12% 28%, rgba(246, 196, 83, .10) 0 2px, transparent 3px),
    radial-gradient(circle at 82% 18%, rgba(246, 196, 83, .08) 0 1px, transparent 2px),
    radial-gradient(circle at 68% 78%, rgba(246, 196, 83, .09) 0 2px, transparent 3px),
    radial-gradient(circle at 28% 84%, rgba(246, 196, 83, .07) 0 1px, transparent 2px);
  background-size: 420px 420px, 300px 300px, 520px 520px, 360px 360px;
  opacity: .8;
}

.page {
  width: 100%;
  max-width: 1200px;
  position: relative;
  z-index: 1;
}

/* ============ 外壳 ============ */
.game-shell {
  position: relative;
  background: linear-gradient(180deg, #2c2016 0%, #1c1410 100%);
  border: 1px solid rgba(246, 196, 83, 0.28);
  border-radius: 22px;
  box-shadow:
    0 40px 90px rgba(0, 0, 0, .65),
    0 0 0 6px rgba(0, 0, 0, .22),
    inset 0 1px 0 rgba(255, 230, 163, .12);
  overflow: hidden;
}

/* ============ HUD ============ */
.hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  padding: 14px 22px;
  background:
    linear-gradient(180deg, rgba(255, 214, 122, .08), transparent 70%),
    #241a12;
  border-bottom: 1px solid var(--line);
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 22px;
  min-width: 0;
}

.hud-block { min-width: 88px; }
.hud-block.grow { flex: 1; min-width: 0; }

.hud-label {
  font-size: 11px;
  letter-spacing: .12em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 4px;
  white-space: nowrap;
}

.hud-value {
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: .01em;
  line-height: 1.1;
}

.hud-value.gold {
  color: var(--gold);
  text-shadow: 0 0 18px rgba(246, 196, 83, .35);
}

.hud-value.small {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.goal-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.goal-bar {
  flex: 1;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .06);
  overflow: hidden;
  position: relative;
}

.goal-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #e0a52e, #ffd976 55%, #fff0bb);
  box-shadow: 0 0 14px rgba(246, 196, 83, .5);
  transition: width .25s ease;
}

.hud-center { display: flex; justify-content: center; }

.timer {
  display: flex;
  align-items: baseline;
  gap: 2px;
  min-width: 104px;
  justify-content: center;
  padding: 7px 18px;
  border-radius: 14px;
  background: rgba(0, 0, 0, .32);
  border: 1px solid rgba(246, 196, 83, .18);
  font-size: 30px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--gold-soft);
  transition: color .2s, border-color .2s, background .2s;
}

.timer .timer-unit {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-left: 3px;
}

.timer.warn {
  color: #ff8f73;
  border-color: rgba(232, 102, 79, .55);
  background: rgba(94, 26, 15, .45);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.045); }
}

.hud-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, .1);
  background: rgba(255, 255, 255, .05);
  color: var(--text);
  font-size: 17px;
  cursor: pointer;
  transition: transform .15s, background .15s;
}
.icon-btn:hover { background: rgba(255, 255, 255, .11); transform: translateY(-1px); }

.dynamite-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 40px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid rgba(232, 102, 79, .38);
  background: linear-gradient(180deg, rgba(190, 63, 42, .35), rgba(110, 34, 22, .35));
  color: #ffd6c6;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: transform .15s, filter .15s, opacity .2s;
}
.dynamite-btn:hover:not(:disabled) { filter: brightness(1.15); transform: translateY(-1px); }
.dynamite-btn:disabled { opacity: .38; cursor: not-allowed; }
.dyn-icon { font-size: 18px; }
.dyn-count { font-size: 14px; }

.buff-row {
  display: flex;
  gap: 6px;
  min-width: 0;
}

.buff-chip {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 30px;
  padding: 0 8px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 700;
  color: var(--gold-soft);
  background: rgba(246, 196, 83, .09);
  border: 1px solid rgba(246, 196, 83, .22);
  white-space: nowrap;
}

/* ============ Canvas ============ */
.canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0e0b08;
  overflow: hidden;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: manipulation;
}

.hint-bar {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  padding: 7px 16px;
  border-radius: 999px;
  background: rgba(15, 11, 7, .62);
  border: 1px solid rgba(255, 255, 255, .09);
  backdrop-filter: blur(6px);
  color: rgba(247, 236, 216, .82);
  font-size: 12px;
  letter-spacing: .02em;
  pointer-events: none;
  transition: opacity .35s;
  white-space: nowrap;
}

.hint-bar.hidden { opacity: 0; }

/* ============ 按钮 ============ */
.btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 12px;
  padding: 12px 26px;
  font: inherit;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: .02em;
  color: var(--text);
  background: rgba(255, 255, 255, .07);
  cursor: pointer;
  transition: transform .15s ease, filter .15s ease, box-shadow .15s ease, opacity .2s;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.08); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: .42; cursor: not-allowed; }

.btn.primary {
  color: #2a1a06;
  border: 1px solid #ffdf96;
  background: linear-gradient(180deg, #ffe08a, #f6c453 42%, #d99a22);
  box-shadow: 0 10px 26px rgba(217, 154, 34, .34), inset 0 1px 0 rgba(255, 255, 255, .6);
}
.btn.primary:hover:not(:disabled) { box-shadow: 0 14px 32px rgba(246, 196, 83, .42), inset 0 1px 0 rgba(255, 255, 255, .7); }
.btn.big { padding: 15px 46px; font-size: 17px; border-radius: 14px; }
.btn.wide { width: 100%; margin-top: 18px; }

.btn.buy-btn {
  width: 100%;
  padding: 9px 12px;
  font-size: 13px;
  background: rgba(246, 196, 83, .12);
  border-color: rgba(246, 196, 83, .32);
  color: var(--gold-soft);
}
.btn.buy-btn:hover:not(:disabled) { background: rgba(246, 196, 83, .2); }

/* ============ 底部提示条 ============ */
.footer-bar {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 11px 22px;
  background: #1b130d;
  border-top: 1px solid rgba(255, 255, 255, .05);
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .02em;
  flex-wrap: wrap;
}

.footer-bar .footer-goal { margin-left: auto; color: rgba(246, 196, 83, .55); }

kbd {
  display: inline-block;
  min-width: 20px;
  padding: 2px 6px;
  margin: 0 2px;
  border-radius: 5px;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .12);
  border-bottom-width: 2px;
  font-family: inherit;
  font-size: 11px;
  color: var(--text);
  text-align: center;
}

/* ============ 遮罩与面板 ============ */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 26px;
  background:
    radial-gradient(circle at 50% 40%, rgba(70, 46, 20, .55), rgba(8, 6, 4, .9) 78%);
  backdrop-filter: blur(3px);
  z-index: 5;
  opacity: 1;
  transition: opacity .28s ease, visibility .28s;
}

.overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.panel {
  width: min(760px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 30px 34px;
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255, 214, 122, .07), transparent 38%),
    linear-gradient(180deg, #2c2016, #1d150e);
  border: 1px solid rgba(246, 196, 83, .3);
  box-shadow:
    0 30px 70px rgba(0, 0, 0, .7),
    inset 0 1px 0 rgba(255, 230, 163, .14);
  text-align: center;
  animation: panelIn .32s cubic-bezier(.2, .9, .3, 1.2) both;
}

@keyframes panelIn {
  from { opacity: 0; transform: translateY(16px) scale(.975); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.panel::-webkit-scrollbar { width: 6px; }
.panel::-webkit-scrollbar-thumb { background: rgba(246, 196, 83, .25); border-radius: 99px; }

.start-panel { padding: 34px 40px 28px; }

.logo-badge {
  width: 62px;
  height: 62px;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  font-size: 30px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(246, 196, 83, .24), rgba(246, 196, 83, .06));
  border: 1px solid rgba(246, 196, 83, .38);
  box-shadow: 0 8px 24px rgba(217, 154, 34, .2);
}

.game-title {
  margin: 0;
  font-size: 42px;
  letter-spacing: .14em;
  text-indent: .14em;
  font-weight: 900;
  color: var(--gold-soft);
  text-shadow: 0 2px 0 #9b6a12, 0 10px 34px rgba(246, 196, 83, .35);
}

.tagline {
  margin: 10px 0 22px;
  color: var(--muted);
  font-size: 14px;
  letter-spacing: .04em;
}

.howto-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 24px;
  text-align: left;
}

.howto-card {
  padding: 14px 14px 12px;
  border-radius: 13px;
  background: rgba(255, 255, 255, .035);
  border: 1px solid rgba(255, 255, 255, .07);
}

.howto-emoji { font-size: 21px; margin-bottom: 7px; height: 24px; display: flex; align-items: center; }
.howto-emoji svg { color: var(--gold-soft); }
.howto-title { font-size: 13px; font-weight: 800; color: var(--gold-soft); margin-bottom: 4px; }
.howto-card p { margin: 0; font-size: 11.5px; line-height: 1.55; color: var(--muted); }

.fineprint {
  margin: 16px 0 0;
  font-size: 11.5px;
  color: rgba(184, 166, 140, .7);
}

/* 通用面板标题 */
.panel-kicker {
  font-size: 10.5px;
  letter-spacing: .3em;
  text-indent: .3em;
  font-weight: 800;
  color: rgba(246, 196, 83, .7);
  margin-bottom: 8px;
}
.panel-kicker.danger { color: rgba(232, 102, 79, .85); }

.panel-title {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: .03em;
  color: var(--gold-soft);
}

.level-panel .panel-title { text-shadow: 0 6px 24px rgba(246, 196, 83, .2); }

.panel-sub {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 13px;
}

/* 数据统计 */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 0 0 24px;
}

.stat {
  padding: 13px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, .28);
  border: 1px solid rgba(255, 255, 255, .06);
}

.stat-label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .06em;
  margin-bottom: 6px;
}

.stat-value {
  font-size: 21px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.stat-value.gold { color: var(--gold); }

/* ============ 商店 ============ */
.shop-panel { width: min(920px, 100%); padding: 26px 30px 24px; text-align: left; }

.shop-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.shop-wallet {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 9px 16px;
  border-radius: 12px;
  background: rgba(0, 0, 0, .32);
  border: 1px solid rgba(246, 196, 83, .24);
}

.wallet-label { font-size: 10.5px; color: var(--muted); letter-spacing: .08em; }
.wallet-value {
  font-size: 24px;
  font-weight: 900;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 18px rgba(246, 196, 83, .3);
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.shop-card {
  display: flex;
  flex-direction: column;
  padding: 14px 13px 12px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .05), rgba(255, 255, 255, .02));
  border: 1px solid rgba(255, 255, 255, .08);
  transition: border-color .2s, transform .2s, background .2s;
}

.shop-card:hover {
  border-color: rgba(246, 196, 83, .3);
  transform: translateY(-3px);
  background: linear-gradient(180deg, rgba(246, 196, 83, .08), rgba(255, 255, 255, .02));
}

.shop-icon { font-size: 27px; line-height: 1; margin-bottom: 8px; }

.shop-card h3 {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 800;
  color: var(--gold-soft);
  display: flex;
  align-items: center;
  gap: 6px;
}

.shop-tag {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(232, 102, 79, .2);
  border: 1px solid rgba(232, 102, 79, .4);
  color: #ffb9a8;
}

.shop-card p {
  margin: 0 0 10px;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--muted);
  min-height: 36px;
}

.shop-owned {
  font-size: 10.5px;
  color: rgba(246, 196, 83, .7);
  margin-bottom: 9px;
  margin-top: auto;
}

.shop-card.sold-out { opacity: .78; }

/* ============ 通关 ============ */
.victory-crown {
  font-size: 48px;
  line-height: 1;
  margin-bottom: 6px;
  filter: drop-shadow(0 8px 22px rgba(246, 196, 83, .5));
  animation: floaty 2.6s ease-in-out infinite;
}

@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}

.victory-panel .stat-grid { grid-template-columns: repeat(2, 1fr); }

/* ============ 提示浮层 ============ */
.toast {
  position: absolute;
  left: 50%;
  top: 22px;
  transform: translate(-50%, -14px);
  padding: 9px 18px;
  border-radius: 999px;
  background: rgba(20, 14, 9, .88);
  border: 1px solid rgba(246, 196, 83, .35);
  color: var(--gold-soft);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .02em;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 6;
  white-space: nowrap;
  box-shadow: 0 10px 26px rgba(0, 0, 0, .45);
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 连击 / 收集弹字在 canvas 内绘制，无需 DOM */

/* ============ 响应式 ============ */
@media (max-width: 1024px) {
  .hud { padding: 12px 16px; gap: 12px; }
  .hud-value { font-size: 19px; }
  .hud-left { gap: 14px; }
  .timer { font-size: 26px; padding: 6px 12px; min-width: 88px; }
  .buff-row { display: none; }
  .shop-grid { grid-template-columns: repeat(2, 1fr); }
  .shop-panel { padding: 24px; }
  .panel { padding: 24px; }
  .game-title { font-size: 34px; }
}

@media (max-width: 720px) {
  body { padding: 10px; }
  .hud { grid-template-columns: 1fr auto; row-gap: 10px; }
  .hud-center { grid-column: 1 / -1; grid-row: 2; }
  .hud-right { grid-column: 2; grid-row: 1; }
  .hud-block:first-child { display: none; }
  .howto-row { grid-template-columns: 1fr; }
  .howto-card p { min-height: 0; }
  .stat-grid { grid-template-columns: 1fr; gap: 8px; }
  .shop-grid { grid-template-columns: 1fr; }
  .footer-bar { font-size: 11px; gap: 10px; }
  .footer-bar .footer-goal { display: none; }
  .panel { padding: 20px 18px; }
  .game-title { font-size: 28px; }
  .tagline { font-size: 12px; }
  .panel-title { font-size: 21px; }
  .overlay { padding: 12px; }
  .start-panel { padding: 24px 18px; }
  .logo-badge { width: 48px; height: 48px; font-size: 24px; }
}

@media (max-height: 760px) and (min-width: 900px) {
  .panel { padding: 22px 30px; }
  .game-title { font-size: 34px; }
  .tagline { margin-bottom: 16px; }
  .howto-card { padding: 11px 12px; }
  .start-panel { padding: 24px 34px 20px; }
}
