:root {
  --orange: #FF8A3D;
  --orange-deep: #F06A18;
  --gold: #FFC65C;
  --gold-hi: #FFE6A6;
  --ink: #22140A;
  --panel: rgba(16, 22, 17, 0.62);
  --panel-border: rgba(255, 196, 120, 0.22);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

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

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #070d0a;
  color: #fff;
  font-family: var(--font);
  overscroll-behavior: none;
}

body {
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

button { font-family: var(--font); }

.hidden { display: none !important; }

.app {
  position: relative;
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  overflow: hidden;
  background: #0b120f;
  box-shadow: 0 0 90px rgba(0, 0, 0, 0.75);
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  outline: none;
}

/* ---------------- screen fx ---------------- */
.screen-fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
.fx-vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 80% at 50% 42%, transparent 40%, rgba(4, 9, 7, 0.28) 78%, rgba(3, 6, 5, 0.66) 100%),
    linear-gradient(to bottom, rgba(5, 10, 8, 0.28) 0%, transparent 20%, transparent 72%, rgba(4, 8, 6, 0.42) 100%);
}
.fx-flash {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: radial-gradient(90% 70% at 50% 60%, rgba(255, 92, 40, 0.55), rgba(120, 8, 0, 0.15) 60%, transparent 78%);
}
.fx-flash.on { animation: flashHit 0.55s ease-out; }
@keyframes flashHit {
  0% { opacity: 0.95; }
  100% { opacity: 0; }
}
.fx-speed {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.6s ease;
  background:
    linear-gradient(90deg, rgba(255, 190, 120, 0.12), transparent 14%, transparent 86%, rgba(255, 190, 120, 0.12)),
    radial-gradient(80% 50% at 50% 52%, transparent 58%, rgba(255, 160, 80, 0.1) 100%);
}

/* ---------------- HUD ---------------- */
.hud {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.32s ease, transform 0.32s ease;
}
.hud.show { opacity: 1; transform: translateY(0); }
.hud-top {
  position: absolute;
  top: calc(var(--safe-top) + 12px);
  left: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.chip {
  height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(10, 16, 12, 0.55);
  border: 1px solid rgba(255, 214, 150, 0.22);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff7e9;
  font-size: 16px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}
.chip-coin { padding-left: 10px; }
.chip-dist {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  min-width: 88px;
  justify-content: center;
  background: rgba(10, 16, 12, 0.45);
}
.chip-dist em { font-style: normal; font-size: 12px; font-weight: 700; opacity: 0.7; margin-left: 2px; }
.coin-glyph {
  width: 21px;
  height: 21px;
  border-radius: 50%;
  display: inline-block;
  background: radial-gradient(circle at 32% 28%, #fff3bf 0%, #ffd05e 38%, #ff9a24 72%, #c96a0d 100%);
  box-shadow: 0 0 10px rgba(255, 185, 70, 0.6), inset 0 0 0 2px rgba(255, 240, 190, 0.45);
  position: relative;
  flex: none;
}
.coin-glyph::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 7px;
  height: 7px;
  transform: translate(-50%, -50%);
  border-radius: 2px;
  background: rgba(132, 69, 8, 0.55);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.coin-glyph.small { width: 17px; height: 17px; }
.coin-glyph.small::after { width: 6px; height: 6px; }
.icon-btn {
  margin-left: auto;
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 50%;
  border: 1px solid rgba(255, 214, 150, 0.27);
  background: rgba(10, 16, 12, 0.55);
  color: #ffe9c6;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
  transition: transform 0.12s ease, background 0.2s ease;
}
.icon-btn .mp-icon { width: 22px; height: 22px; }
.icon-btn:active { transform: scale(0.92); background: rgba(255, 138, 61, 0.28); }

.swipe-hint {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 30px);
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px 9px 12px;
  border-radius: 999px;
  background: rgba(10, 16, 12, 0.5);
  border: 1px solid rgba(255, 214, 150, 0.16);
  color: rgba(255, 244, 225, 0.82);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: opacity 0.6s ease;
}
.swipe-hint .mp-icon { width: 19px; height: 19px; color: var(--gold); }
.swipe-hint.fade { opacity: 0; }

/* ---------------- overlay base ---------------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
}
.menu {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
  padding: calc(var(--safe-top) + 12px) 18px calc(var(--safe-bottom) + 16px);
  background:
    radial-gradient(92% 24% at 50% 41%, rgba(3, 8, 6, 0.6) 0%, rgba(3, 8, 6, 0.32) 46%, rgba(3, 8, 6, 0) 76%),
    linear-gradient(to bottom, rgba(4, 10, 8, 0.38) 0%, rgba(4, 10, 8, 0) 24%, rgba(4, 10, 8, 0) 44%, rgba(4, 10, 8, 0.62) 68%, rgba(4, 9, 7, 0.93) 100%);
}
.menu-glow {
  position: absolute;
  left: 50%;
  top: 8%;
  width: 120%;
  height: 54%;
  transform: translateX(-50%);
  background: radial-gradient(50% 50% at 50% 44%, rgba(255, 160, 68, 0.2), rgba(255, 110, 30, 0.05) 55%, transparent 72%);
  pointer-events: none;
  mix-blend-mode: screen;
}
.menu-top {
  position: relative;
  display: flex;
  justify-content: center;
  pointer-events: none;
}
.best-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: 999px;
  background: rgba(10, 16, 12, 0.42);
  border: 1px solid rgba(255, 210, 140, 0.18);
  color: rgba(255, 244, 225, 0.92);
  font-size: 13px;
  font-weight: 700;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}
.best-pill .mp-icon { width: 18px; height: 18px; color: var(--gold); }
.best-pill b { color: var(--gold-hi); font-size: 15px; font-variant-numeric: tabular-nums; }

.brand {
  position: relative;
  margin-top: 1.2vh;
  text-align: center;
  pointer-events: none;
  filter: drop-shadow(0 18px 30px rgba(0, 0, 0, 0.45));
  z-index: 1;
}
.brand::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 48%;
  width: min(500px, 132vw);
  height: 210%;
  transform: translate(-50%, -50%);
  background: radial-gradient(50% 48% at 50% 50%, rgba(3, 8, 6, 0.62) 0%, rgba(3, 8, 6, 0.38) 42%, rgba(3, 8, 6, 0.12) 62%, rgba(3, 8, 6, 0) 76%);
  pointer-events: none;
  z-index: -1;
}
.brand-kicker {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.42em;
  color: rgba(255, 220, 170, 0.7);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
  margin-bottom: 8px;
  padding-left: 0.42em;
}
.logo {
  margin: 0;
  font-size: clamp(46px, 15.2vw, 74px);
  line-height: 0.98;
  font-weight: 900;
  letter-spacing: 0.055em;
  padding-left: 0.055em;
  transform: rotate(-2.2deg);
  position: relative;
  display: inline-block;
}
.logo span {
  display: inline-block;
  background: none;
  color: #ffd35f;
  -webkit-text-fill-color: #ffd35f;
  -webkit-text-stroke: 0;
  text-shadow:
    1.5px 0 0 #3a1603,
    -1.5px 0 0 #3a1603,
    0 1.5px 0 #3a1603,
    0 -1.5px 0 #3a1603,
    1.2px 1.2px 0 #3a1603,
    -1.2px 1.2px 0 #3a1603,
    1.2px -1.2px 0 #3a1603,
    -1.2px -1.2px 0 #3a1603,
    0 2px 0 #ffefb5,
    0 5px 0 #8a3d09,
    0 8px 0 #552405,
    0 14px 18px rgba(0, 0, 0, 0.55);
  filter: none;
}
.logo::after {
  content: "";
  position: absolute;
  left: 3%;
  right: 3%;
  bottom: -11px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(50% 50% at 50% 50%, rgba(255, 170, 70, 0.5), transparent 72%);
  filter: blur(3px);
}
.tagline {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.28em;
  color: rgba(255, 236, 205, 0.9);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.65);
}
.tagline i { width: 26px; height: 1px; background: linear-gradient(90deg, transparent, rgba(255, 197, 110, 0.7)); display: block; }
.tagline i:last-child { background: linear-gradient(270deg, transparent, rgba(255, 197, 110, 0.7)); }

.menu-bottom {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: auto;
}
.menu-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(26, 35, 27, 0.66), rgba(12, 18, 14, 0.72));
  border: 1px solid var(--panel-border);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.mstat { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.mstat:nth-child(3) { text-align: right; }
.mstat-label { font-size: 11px; font-weight: 600; color: rgba(232, 220, 200, 0.55); letter-spacing: 0.12em; }
.mstat-val { display: flex; align-items: center; gap: 7px; font-size: 22px; line-height: 1; color: #fff2d9; font-variant-numeric: tabular-nums; }
.mstat:nth-child(3) .mstat-val { justify-content: flex-end; align-items: baseline; }
.mstat-val b { font-weight: 800; }
.mstat-val em { font-style: normal; font-size: 12px; font-weight: 700; opacity: 0.55; margin-left: 1px; }
.mstat-div { width: 1px; height: 34px; background: linear-gradient(transparent, rgba(255, 214, 150, 0.22), transparent); margin: 0 16px; }

.btn-primary {
  position: relative;
  width: 100%;
  min-height: 58px;
  border-radius: 19px;
  border: 1px solid rgba(255, 230, 180, 0.65);
  background:
    linear-gradient(180deg, #ffc35c 0%, #ff9a32 42%, #ff7a1f 100%);
  color: #341703;
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 0.12em;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow:
    0 12px 26px rgba(255, 108, 24, 0.35),
    0 3px 0 rgba(122, 52, 6, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
  text-shadow: 0 1px 0 rgba(255, 235, 190, 0.6);
  transition: transform 0.11s ease, filter 0.16s ease, box-shadow 0.16s ease;
  touch-action: manipulation;
}
.btn-primary::before {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  pointer-events: none;
}
.btn-primary:active {
  transform: translateY(2px) scale(0.985);
  filter: brightness(0.96);
  box-shadow: 0 5px 14px rgba(255, 108, 24, 0.26), 0 1px 0 rgba(122, 52, 6, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.btn-label { position: relative; z-index: 2; }
.btn-play-ico { width: 25px; height: 25px; position: relative; z-index: 2; }
.btn-shine {
  position: absolute;
  top: -40%;
  left: -30%;
  width: 36%;
  height: 180%;
  transform: rotate(20deg);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  animation: shine 3.6s ease-in-out infinite;
  pointer-events: none;
}
@keyframes shine {
  0%, 62% { left: -36%; opacity: 0; }
  70% { opacity: 0.9; }
  88%, 100% { left: 118%; opacity: 0; }
}
.btn-start { min-height: 62px; font-size: 20px; }

.control-guide {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 14px;
  border-radius: 15px;
  background: rgba(9, 15, 11, 0.5);
  border: 1px solid rgba(255, 214, 150, 0.13);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  position: relative;
}
.cg-item { display: flex; align-items: center; gap: 5px; color: rgba(255, 243, 224, 0.78); font-size: 11px; font-weight: 700; white-space: nowrap; }
.cg-ico { display: inline-flex; color: var(--gold); }
.cg-ico .mp-icon { width: 17px; height: 17px; }
.cg-note { margin-left: auto; font-size: 10px; color: rgba(255, 235, 205, 0.4); white-space: nowrap; }

/* ---------------- modal ---------------- */
.modal {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--safe-top) + 22px) 22px calc(var(--safe-bottom) + 22px);
  background: rgba(4, 9, 7, 0.62);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  animation: fadeIn 0.22s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  position: relative;
  width: 100%;
  max-width: 360px;
  border-radius: 26px;
  padding: 26px 22px 20px;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(255, 152, 62, 0.14), transparent 58%),
    linear-gradient(180deg, rgba(28, 37, 29, 0.97), rgba(13, 19, 15, 0.98));
  border: 1px solid rgba(255, 199, 124, 0.28);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.09);
  animation: cardIn 0.3s cubic-bezier(0.2, 0.9, 0.25, 1.15);
  text-align: center;
}
@keyframes cardIn {
  from { transform: translateY(16px) scale(0.96); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
.modal-kicker {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.4em;
  color: rgba(255, 192, 112, 0.58);
  margin-bottom: 8px;
  padding-left: 0.4em;
}
.modal-title {
  margin: 0;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 0.06em;
  color: #fff1d8;
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.45);
}
.modal-sub {
  margin: 8px 0 22px;
  font-size: 12.5px;
  color: rgba(238, 226, 206, 0.55);
  letter-spacing: 0.03em;
}
.modal-card .btn-primary { min-height: 54px; font-size: 17px; }
.modal-links {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}
.btn-text {
  border: 0;
  background: transparent;
  color: rgba(255, 235, 205, 0.62);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: color 0.16s ease, background 0.16s ease, transform 0.1s ease;
}
.btn-text:active { color: #ffd28f; background: rgba(255, 180, 90, 0.1); transform: scale(0.97); }

.result-card { padding-top: 24px; }
.result-hero {
  margin-top: 14px;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  color: #ffd782;
  text-shadow: 0 0 26px rgba(255, 170, 60, 0.3), 0 4px 10px rgba(0, 0, 0, 0.4);
}
.result-hero span { font-size: 64px; line-height: 1; font-weight: 900; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.result-hero em { font-style: normal; font-size: 17px; font-weight: 800; opacity: 0.7; }
.result-sub { font-size: 11px; letter-spacing: 0.16em; color: rgba(238, 226, 206, 0.45); margin-top: 4px; }
.result-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 18px 0 6px;
  padding: 13px 10px;
  border-radius: 16px;
  background: rgba(8, 13, 10, 0.45);
  border: 1px solid rgba(255, 204, 133, 0.12);
}
.result-cell { flex: 1; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px; color: #ffe9c7; }
.result-cell b { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.result-cell em { font-style: normal; font-size: 11px; opacity: 0.6; font-weight: 700; }
.result-cell .coin-glyph { margin-right: 2px; }
.result-cell-label { flex-basis: 100%; font-size: 10px; color: rgba(238, 226, 206, 0.42); letter-spacing: 0.1em; }
.result-div { width: 1px; height: 34px; background: linear-gradient(transparent, rgba(255, 204, 133, 0.2), transparent); }
.result-total { font-size: 11px; color: rgba(255, 214, 150, 0.5); margin-bottom: 18px; letter-spacing: 0.06em; }
.btn-back { margin-top: 8px; }

/* ---------------- boot / fatal ---------------- */
.boot {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background:
    radial-gradient(80% 60% at 50% 40%, #1c2b1e 0%, #0a110d 68%, #060b08 100%);
  transition: opacity 0.5s ease;
}
.boot.done { opacity: 0; pointer-events: none; }
.boot-logo {
  font-size: 38px;
  font-weight: 900;
  letter-spacing: 0.1em;
  padding-left: 0.1em;
  color: #ffcf74;
  text-shadow: 0 0 26px rgba(255, 150, 50, 0.4), 0 4px 0 #6e330a, 0 7px 18px rgba(0, 0, 0, 0.6);
  transform: rotate(-2deg);
}
.boot-ring {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 2px solid rgba(255, 190, 100, 0.18);
  border-top-color: #ffac45;
  animation: spin 0.85s linear infinite;
}
.boot-ring span {
  display: block;
  width: 8px;
  height: 8px;
  margin: 4px auto 0;
  border-radius: 50%;
  background: #ffd58a;
  box-shadow: 0 0 12px #ffab3d;
}
@keyframes spin { to { transform: rotate(360deg); } }
.boot-text { font-size: 12px; letter-spacing: 0.24em; color: rgba(255, 225, 180, 0.5); padding-left: 0.24em; }

.fatal {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #0a110d;
}
.fatal-card {
  max-width: 340px;
  text-align: center;
  padding: 26px 22px;
  border-radius: 22px;
  background: #141d16;
  border: 1px solid rgba(255, 190, 110, 0.2);
}
.fatal-card h2 { margin: 0 0 10px; font-size: 20px; color: #ffd08a; }
.fatal-card p { margin: 0; font-size: 13px; line-height: 1.7; color: rgba(240, 230, 212, 0.6); }
.rotate-note { display: none; }

/* ---------------- responsive ---------------- */
@media (max-height: 720px) {
  .brand { margin-top: 0; }
  .logo { font-size: clamp(40px, 13.5vw, 60px); }
  .tagline { margin-top: 11px; font-size: 11.5px; }
  .menu-bottom { gap: 9px; }
  .menu-stats { padding: 10px 16px; }
  .mstat-val { font-size: 19px; }
  .btn-start { min-height: 54px; }
  .control-guide { padding: 9px 12px; gap: 10px; }
  .cg-note { display: none; }
}
@media (max-height: 620px) {
  .best-pill { padding: 7px 12px; font-size: 11px; }
  .brand-kicker { margin-bottom: 4px; font-size: 9px; }
  .tagline { margin-top: 8px; }
  .menu { padding-left: 14px; padding-right: 14px; }
  .menu-stats { display: none; }
  .control-guide { justify-content: center; }
}
@media (min-width: 640px) {
  .app { border-left: 1px solid rgba(255, 190, 110, 0.08); border-right: 1px solid rgba(255, 190, 110, 0.08); }
}
@media (prefers-reduced-motion: reduce) {
  .btn-shine, .boot-ring { animation: none; }
}

/* 金币拾取反馈 */
.chip-coin.pop { animation: chipPop 0.22s cubic-bezier(0.2, 1.4, 0.4, 1); }
@keyframes chipPop {
  0% { transform: scale(1); }
  45% { transform: scale(1.13); }
  100% { transform: scale(1); }
}
