:root {
  --orange: #FF8A3D;
  --orange-hot: #FF6B28;
  --orange-deep: #D9531A;
  --cream: #FFF4E2;
  --cream-soft: #FFE6C7;
  --ink: #2B1722;
  --ink-deep: #170D1D;
  --muted: #C7A9A0;
  --line: rgba(255, 208, 164, 0.22);
  --panel: rgba(44, 24, 42, 0.86);
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
}

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

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  background: #140c1d;
  color: var(--cream);
  font-family: var(--font);
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  display: flex;
  align-items: stretch;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 10%, rgba(255, 138, 61, 0.14), transparent 55%),
    radial-gradient(ellipse at 50% 100%, rgba(120, 47, 93, 0.22), transparent 60%),
    #140c1d;
}

button { font: inherit; }

.app {
  position: relative;
  width: 100%;
  max-width: 560px;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #1b1026;
  isolation: isolate;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

@media (min-width: 620px) {
  .app {
    max-width: 480px;
    box-shadow: 0 0 90px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 182, 122, 0.08);
  }
}

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

.scene-shade {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(15, 8, 22, 0.22) 0%, transparent 18%, transparent 72%, rgba(15, 8, 22, 0.5) 100%),
    radial-gradient(ellipse at 50% 42%, transparent 46%, rgba(12, 6, 18, 0.46) 100%);
}

/* ---------- HUD ---------- */
.hud {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px calc(env(safe-area-inset-bottom, 0px) + 18px);
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.hud.veiled {
  opacity: 0;
  visibility: hidden;
}

.app.playing { touch-action: none; }

.hud-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 7px 14px 7px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 213, 171, 0.2);
  background: linear-gradient(180deg, rgba(55, 31, 51, 0.82), rgba(31, 18, 34, 0.82));
  box-shadow: 0 8px 22px rgba(10, 4, 16, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.score-pill { padding-right: 17px; }

.pill-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: #3c1b06;
  background: linear-gradient(150deg, #ffc078, var(--orange) 58%, #f06c26);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 4px 10px rgba(255, 107, 40, 0.28);
}

.pill-icon .mp-icon { width: 20px; height: 20px; }

.pill-copy {
  display: flex;
  flex-direction: column;
  line-height: 1;
  gap: 4px;
}

.pill-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: rgba(255, 213, 171, 0.68);
}

.pill-value {
  display: flex;
  align-items: baseline;
  gap: 2px;
  color: var(--cream);
}

.pill-value b {
  font-size: 23px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.pill-value small, .best-pill small {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255, 220, 186, 0.62);
  margin-left: 1px;
}

.best-pill {
  min-height: 38px;
  padding: 7px 13px;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: rgba(255, 224, 191, 0.74);
}

.best-pill .mp-icon {
  width: 15px;
  height: 15px;
  color: #ffc46a;
}

.best-pill b {
  color: var(--cream);
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.chase {
  width: 196px;
  margin-top: 10px;
  padding: 8px 11px 9px;
  border-radius: 15px;
  background: rgba(35, 19, 36, 0.72);
  border: 1px solid rgba(255, 210, 168, 0.13);
  box-shadow: 0 6px 18px rgba(10, 4, 16, 0.22);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition: border-color 0.25s ease, background 0.25s ease;
}

.chase-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.chase-cat {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #ffb27c;
}

.chase-cat .mp-icon { width: 14px; height: 14px; }

.chase-text {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255, 224, 196, 0.82);
  font-variant-numeric: tabular-nums;
}

.chase-track {
  position: relative;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 234, 209, 0.13);
  overflow: hidden;
}

.chase-fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  transform-origin: left center;
  background: linear-gradient(90deg, #ffcf7a, var(--orange));
  box-shadow: 0 0 10px rgba(255, 145, 71, 0.55);
  transition: transform 0.14s linear, background 0.25s ease;
}

.chase-runner {
  position: absolute;
  right: 0;
  top: 50%;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  color: #4b2508;
  background: #ffe0b4;
  transform: translateY(-50%);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.chase-runner .mp-icon { width: 11px; height: 11px; }

.chase.warn .chase-fill { background: linear-gradient(90deg, #ffb04e, #ff7a2f); }
.chase.danger {
  border-color: rgba(255, 92, 62, 0.55);
  background: rgba(64, 21, 30, 0.8);
  animation: dangerPulse 0.7s ease-in-out infinite;
}
.chase.danger .chase-fill {
  background: linear-gradient(90deg, #ff9a44, #ff4f3d);
  box-shadow: 0 0 12px rgba(255, 74, 52, 0.75);
}
.chase.danger .chase-text { color: #ffb0a0; }

@keyframes dangerPulse {
  0%, 100% { box-shadow: 0 0 0 rgba(255, 82, 52, 0); }
  50% { box-shadow: 0 0 20px rgba(255, 82, 52, 0.38); }
}

.boost-chip {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding: 8px 14px;
  border-radius: 999px;
  color: #3d1b04;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
  background: linear-gradient(150deg, #ffe08e, #ffb13f 55%, #ff8a3d);
  border: 1px solid rgba(255, 245, 208, 0.7);
  box-shadow: 0 6px 18px rgba(255, 138, 61, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  opacity: 0;
  transform: translateY(-6px) scale(0.9);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.boost-chip.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.boost-chip .mp-icon { width: 16px; height: 16px; }

.hint {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px 9px 10px;
  border-radius: 999px;
  color: rgba(255, 238, 219, 0.94);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: rgba(30, 16, 32, 0.7);
  border: 1px solid rgba(255, 211, 168, 0.18);
  box-shadow: 0 8px 22px rgba(8, 3, 14, 0.28);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transform: translateX(-50%);
  white-space: nowrap;
  transition: opacity 0.4s ease, transform 0.4s ease;
  animation: hintFloat 2.6s ease-in-out infinite;
}

.hint.hidden {
  opacity: 0;
  transform: translate(-50%, 8px);
}

.hint-tap {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  color: #ffcf95;
  background: rgba(255, 138, 61, 0.18);
}

.hint-tap .mp-icon { width: 18px; height: 18px; }

@keyframes hintFloat {
  0%, 100% { margin-bottom: 0; }
  50% { margin-bottom: 3px; }
}

/* ---------- Screens ---------- */
.screen {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.32s ease, visibility 0.32s ease;
}

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

.start-screen {
  align-items: flex-end;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) 14px calc(env(safe-area-inset-bottom, 0px) + 14px);
  background:
    linear-gradient(180deg, rgba(18, 9, 26, 0) 0%, rgba(18, 9, 26, 0.08) 32%, rgba(18, 9, 26, 0.42) 54%, rgba(18, 9, 26, 0.88) 76%, rgba(18, 9, 26, 0.96) 100%);
}

.start-panel {
  position: relative;
  width: 100%;
  max-height: calc(100% - 8px);
  overflow-y: auto;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  padding: 20px 19px 18px;
  border-radius: 30px;
  border: 1px solid rgba(255, 206, 158, 0.24);
  background:
    radial-gradient(ellipse at 18% 0%, rgba(255, 138, 61, 0.2), transparent 44%),
    linear-gradient(165deg, rgba(66, 35, 50, 0.95), rgba(35, 19, 38, 0.97) 58%, rgba(27, 15, 31, 0.98));
  box-shadow: 0 26px 70px rgba(4, 1, 9, 0.6), inset 0 1px 0 rgba(255, 236, 216, 0.12);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  scrollbar-width: none;
}

.start-panel::-webkit-scrollbar { display: none; }

.panel-paw {
  position: absolute;
  top: 10px;
  right: 8px;
  width: 112px;
  height: 112px;
  color: rgba(255, 138, 61, 0.08);
  transform: rotate(-16deg);
  pointer-events: none;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px 5px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #ffcf9d;
  background: rgba(255, 138, 61, 0.14);
  border: 1px solid rgba(255, 168, 100, 0.22);
}

.eyebrow .mp-icon { width: 14px; height: 14px; }

.eyebrow.danger {
  color: #ffb2a0;
  background: rgba(255, 86, 62, 0.13);
  border-color: rgba(255, 122, 99, 0.3);
}

.game-title {
  display: flex;
  align-items: baseline;
  gap: 2px;
  margin: 12px 0 8px;
  font-size: clamp(40px, 11.5vw, 52px);
  line-height: 1.02;
  font-weight: 900;
  letter-spacing: -0.055em;
  color: #fff0dc;
  text-shadow: 0 4px 0 rgba(89, 34, 24, 0.55), 0 16px 34px rgba(10, 3, 16, 0.5);
}

.title-accent {
  color: var(--orange);
  text-shadow: 0 4px 0 #8c3510, 0 0 28px rgba(255, 138, 61, 0.5);
}

.start-desc {
  margin: 0 0 16px;
  color: rgba(255, 224, 198, 0.74);
  font-size: 13px;
  line-height: 1.65;
  letter-spacing: 0.01em;
}

.rules {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 18px;
}

.rule {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 15px;
  background: rgba(255, 238, 221, 0.055);
  border: 1px solid rgba(255, 224, 196, 0.08);
}

.rule-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 11px;
  color: #ffc182;
  background: linear-gradient(160deg, rgba(255, 138, 61, 0.25), rgba(255, 138, 61, 0.1));
  border: 1px solid rgba(255, 167, 98, 0.2);
}

.rule-icon .mp-icon { width: 18px; height: 18px; }

.rule-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.rule-copy b {
  font-size: 12.5px;
  font-weight: 800;
  color: #fff0dd;
  letter-spacing: 0.01em;
}

.rule-copy span {
  font-size: 10.5px;
  line-height: 1.35;
  color: rgba(255, 219, 190, 0.6);
}

.primary, .ghost {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 56px;
  border: 0;
  border-radius: 19px;
  cursor: pointer;
  font-weight: 900;
  letter-spacing: 0.03em;
  transition: transform 0.12s ease, filter 0.18s ease, box-shadow 0.18s ease;
}

.primary {
  color: #3a1704;
  font-size: 16.5px;
  background: linear-gradient(160deg, #ffc27c 0%, #ff9a4c 34%, #ff7b2f 70%, #f2631b 100%);
  box-shadow:
    0 5px 0 #a83c0e,
    0 14px 28px rgba(238, 91, 24, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
  overflow: hidden;
}

.primary::after {
  content: "";
  position: absolute;
  top: -60%;
  left: -30%;
  width: 34%;
  height: 220%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.42), transparent);
  transform: rotate(20deg);
  animation: buttonSweep 3.8s ease-in-out infinite;
  pointer-events: none;
}

@keyframes buttonSweep {
  0%, 64% { left: -40%; opacity: 0; }
  72% { opacity: 0.8; }
  88%, 100% { left: 120%; opacity: 0; }
}

.primary .mp-icon {
  width: 24px;
  height: 24px;
  color: #3a1704;
}

.primary:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #a83c0e, 0 6px 16px rgba(238, 91, 24, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.primary:focus-visible, .ghost:focus-visible {
  outline: 2px solid #ffe1ba;
  outline-offset: 3px;
}

.best-line {
  margin-top: 11px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: rgba(255, 217, 184, 0.56);
  letter-spacing: 0.04em;
}

.best-line b {
  color: #ffd195;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* ---------- Game over ---------- */
.over-screen {
  z-index: 12;
  align-items: center;
  justify-content: center;
  padding: 20px 16px calc(env(safe-area-inset-bottom, 0px) + 20px);
  background:
    radial-gradient(ellipse at 50% 38%, rgba(255, 106, 49, 0.13), transparent 48%),
    linear-gradient(180deg, rgba(18, 9, 26, 0.72), rgba(18, 9, 26, 0.94));
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

.over-panel {
  width: 100%;
  max-width: 370px;
  padding: 25px 20px 20px;
  text-align: center;
  border-radius: 30px;
  border: 1px solid rgba(255, 203, 154, 0.24);
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 138, 61, 0.18), transparent 44%),
    linear-gradient(165deg, rgba(68, 36, 51, 0.97), rgba(35, 19, 38, 0.98) 60%, rgba(26, 14, 30, 0.99));
  box-shadow: 0 26px 70px rgba(4, 1, 9, 0.66), inset 0 1px 0 rgba(255, 236, 216, 0.12);
  animation: panelIn 0.42s cubic-bezier(0.18, 0.9, 0.26, 1.08) both;
}

@keyframes panelIn {
  from { opacity: 0; transform: translateY(22px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.over-badge {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  margin: 0 auto 12px;
  border-radius: 50%;
  color: #421b05;
  background: linear-gradient(150deg, #ffc17a, #ff8a3d 55%, #ef5f1d);
  box-shadow: 0 10px 26px rgba(255, 107, 40, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.over-badge .mp-icon { width: 34px; height: 34px; }

.over-panel h2 {
  margin: 10px 0 7px;
  font-size: 25px;
  line-height: 1.15;
  font-weight: 900;
  letter-spacing: -0.025em;
  color: #fff0dc;
}

.over-panel > p {
  margin: 0 0 17px;
  font-size: 12px;
  line-height: 1.55;
  color: rgba(255, 218, 190, 0.62);
}

.result-card {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding: 14px 15px;
  text-align: left;
  border-radius: 21px;
  background: rgba(22, 11, 27, 0.5);
  border: 1px solid rgba(255, 217, 180, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.result-main {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-right: 13px;
  border-right: 1px solid rgba(255, 217, 180, 0.12);
}

.result-main > span {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: rgba(255, 208, 165, 0.6);
}

.result-main b {
  display: flex;
  align-items: baseline;
  gap: 2px;
  color: #ffb268;
  font-size: 34px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
}

.result-main small {
  font-size: 12px;
  font-weight: 800;
  color: rgba(255, 202, 156, 0.66);
}

.result-side {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
  font-size: 10.5px;
  font-weight: 600;
  color: rgba(255, 219, 190, 0.56);
}

.result-side b {
  color: #ffe3c2;
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.new-best {
  display: inline-block;
  margin: 0 auto 12px;
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.1em;
  color: #4a2507;
  background: linear-gradient(150deg, #ffe5a3, #ffc258);
  box-shadow: 0 6px 16px rgba(255, 194, 88, 0.28);
  animation: bestPop 1.4s ease-in-out infinite;
}

.new-best.hidden { display: none; }

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

.ghost {
  margin-top: 8px;
  min-height: 42px;
  color: rgba(255, 219, 190, 0.6);
  font-size: 12px;
  font-weight: 700;
  background: transparent;
}

.ghost:active { color: #ffd7ae; transform: translateY(1px); }

/* ---------- flash ---------- */
.flash {
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(ellipse at 50% 62%, rgba(255, 74, 42, 0.16), rgba(255, 48, 30, 0.5));
}

.flash.on {
  animation: flashHit 0.5s ease-out both;
}

@keyframes flashHit {
  0% { opacity: 0; }
  18% { opacity: 1; }
  100% { opacity: 0; }
}

/* ---------- small screens ---------- */
@media (max-height: 720px) {
  .start-panel { padding: 16px 16px 14px; border-radius: 26px; }
  .game-title { font-size: clamp(36px, 10vw, 44px); margin: 9px 0 6px; }
  .start-desc { font-size: 12px; margin-bottom: 11px; line-height: 1.5; }
  .rules { gap: 5px; margin-bottom: 13px; }
  .rule { padding: 6px 9px; }
  .rule-icon { width: 28px; height: 28px; border-radius: 9px; }
  .rule-icon .mp-icon { width: 16px; height: 16px; }
  .rule-copy b { font-size: 12px; }
  .rule-copy span { font-size: 10px; }
  .primary { min-height: 52px; font-size: 15.5px; }
  .best-line { margin-top: 8px; }
}

@media (max-height: 620px) {
  .rule-copy span { display: none; }
  .rule { padding: 5px 8px; }
  .start-desc { display: none; }
  .over-badge { width: 50px; height: 50px; margin-bottom: 8px; }
  .over-badge .mp-icon { width: 28px; height: 28px; }
  .over-panel h2 { font-size: 21px; }
  .over-panel > p { margin-bottom: 11px; }
}

@media (max-width: 350px) {
  .result-card { flex-direction: column; align-items: stretch; gap: 9px; }
  .result-main { padding-right: 0; padding-bottom: 8px; border-right: 0; border-bottom: 1px solid rgba(255, 217, 180, 0.12); }
  .result-side { flex-direction: row; flex-wrap: wrap; gap: 5px 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .primary::after, .hint, .new-best, .chase.danger, .boost-chip { animation: none; }
  .screen, .primary, .ghost, .boost-chip { transition-duration: 0.01s; }
}
