:root {
  --gold: #ffd23a;
  --gold-deep: #b9700f;
  --ink: #021c30;
  --panel: rgba(8, 30, 48, 0.92);
}

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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #021420;
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  color: #fff;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
}

#game-root {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh;
  height: 100dvh;
}

#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* 竖屏兜底: 把整个舞台旋转 90° 呈现横屏 */
body.force-landscape #game-root {
  width: 100vh; height: 100vw;
  transform-origin: top left;
  transform: rotate(90deg) translateY(-100%);
}

/* ---------- 顶部 HUD ---------- */
#hud-top {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px;
  pointer-events: none; z-index: 5;
}
#hud-top > * { pointer-events: auto; }

.hud-pill {
  display: flex; align-items: center; gap: 8px;
  background: linear-gradient(90deg, rgba(185,112,15,0.9), rgba(120,60,8,0.7));
  border: 1px solid rgba(255,210,58,0.6);
  border-radius: 999px; padding: 4px 12px 4px 4px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.4);
}
.hud-logo { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; border: 1px solid var(--gold); }
.hud-title { font-weight: 700; font-size: 15px; letter-spacing: 1px; text-shadow: 0 1px 2px rgba(0,0,0,0.6); }

.hud-stats { display: flex; align-items: center; gap: 8px; }
.stat {
  display: flex; align-items: center; gap: 4px;
  background: rgba(0,0,0,0.4); border: 1px solid rgba(255,210,58,0.4);
  border-radius: 999px; padding: 4px 10px; font-weight: 700; font-size: 14px;
  min-width: 64px; justify-content: center;
}
.stat-ic { font-size: 14px; }
#hud-coins { color: var(--gold); }
#hud-score { color: #7fe0ff; }

.icon-btn {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(0,0,0,0.4); border: 1px solid rgba(255,210,58,0.4);
  color: #fff; font-size: 16px; cursor: pointer;
}
.icon-btn:active { transform: scale(0.92); }

/* ---------- 底部控制 ---------- */
#hud-bottom {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 10px;
  padding: 8px 12px calc(env(safe-area-inset-bottom) + 10px);
  pointer-events: none; z-index: 5;
}
#hud-bottom > * { pointer-events: auto; }

.bet-box {
  display: flex; align-items: center; gap: 6px;
  background: rgba(0,0,0,0.45); border: 1px solid rgba(255,210,58,0.45);
  border-radius: 14px; padding: 6px;
}
.bet-btn {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(180deg, #ffd86b, #c4830f);
  border: none; color: #5a2f08; font-size: 24px; font-weight: 700; cursor: pointer;
}
.bet-btn:active { transform: scale(0.92); }
.bet-label { display: flex; flex-direction: column; align-items: center; min-width: 56px; }
.bet-cap { font-size: 11px; opacity: 0.8; }
#hud-bet { font-size: 18px; font-weight: 700; color: var(--gold); }

.energy-wrap { flex: 1; max-width: 200px; margin-bottom: 6px; }
.energy-cap { font-size: 11px; opacity: 0.85; margin-bottom: 3px; text-align: center; }
.energy-bar {
  height: 12px; border-radius: 999px; overflow: hidden;
  background: rgba(0,0,0,0.5); border: 1px solid rgba(255,210,58,0.4);
}
#energy-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #ff7a2a, #ffd23a, #fff2b0);
  transition: width 0.15s linear;
}

.action-box { display: flex; flex-direction: column; gap: 8px; }
.ctl-btn {
  width: 64px; height: 40px; border-radius: 12px;
  background: rgba(0,0,0,0.45); border: 1px solid rgba(255,210,58,0.45);
  color: #fff; font-size: 15px; font-weight: 700; cursor: pointer;
}
.ctl-btn:active { transform: scale(0.94); }
.ctl-btn.on { background: linear-gradient(180deg, #36c, #149); border-color: #7fe0ff; }
.ctl-btn.ult { background: rgba(120,40,10,0.6); opacity: 0.55; }
.ctl-btn.ult.ready {
  opacity: 1;
  background: linear-gradient(180deg, #ff7a2a, #c4320f);
  border-color: var(--gold);
  animation: pulse 0.9s infinite;
}
@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(255,210,58,0.7); }
  50% { box-shadow: 0 0 14px 4px rgba(255,210,58,0.6); }
}

/* ---------- 覆盖层 ---------- */
.overlay {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 40%, rgba(6,40,60,0.7), rgba(2,18,30,0.94));
  backdrop-filter: blur(2px);
}
.overlay.hidden { display: none; }
.panel {
  width: min(86vw, 420px);
  text-align: center;
  padding: 28px 22px;
  background: var(--panel);
  border: 1px solid rgba(255,210,58,0.5);
  border-radius: 22px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6), inset 0 0 30px rgba(255,160,40,0.08);
}
.logo-big {
  width: 120px; height: 120px; border-radius: 50%;
  object-fit: cover; border: 3px solid var(--gold);
  box-shadow: 0 0 24px rgba(255,160,40,0.6);
  margin-bottom: 12px;
}
.game-name {
  font-size: 34px; font-weight: 800; letter-spacing: 3px;
  background: linear-gradient(180deg, #fff2b0, #ffae33, #ff5a2a);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  text-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.subtitle { font-size: 13px; opacity: 0.8; margin: 6px 0 14px; }
.tips { list-style: none; text-align: left; margin: 0 auto 18px; max-width: 300px; }
.tips li { font-size: 13px; line-height: 1.9; opacity: 0.92; }
.big-btn {
  width: 100%; padding: 14px; border: none; border-radius: 14px;
  font-size: 20px; font-weight: 800; letter-spacing: 4px; color: #5a2f08; cursor: pointer;
  background: linear-gradient(180deg, #ffe27a, #ffb733, #e0850f);
  box-shadow: 0 6px 16px rgba(224,133,15,0.5);
}
.big-btn:active { transform: scale(0.97); }
.final-score {
  font-size: 48px; font-weight: 800; color: var(--gold);
  margin: 6px 0 18px; text-shadow: 0 2px 10px rgba(255,160,40,0.6);
}

@media (min-width: 768px) {
  .hud-title { font-size: 18px; }
  .stat { font-size: 16px; min-width: 80px; }
}
