:root {
  --ink: #432915;
  --ink-soft: #7A5838;
  --cream: #FFF7E6;
  --cream-deep: #FFE9BF;
  --orange: #FF8A3D;
  --orange-deep: #EC681B;
  --gold: #FFC83D;
  --gold-deep: #E19A12;
  --teal: #3FBDB4;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html,
body {
  height: 100%;
  margin: 0;
  background: #26150b;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

@media (min-width: 560px) {
  body {
    background:
      radial-gradient(circle at 50% 0%, #4a2a17 0%, #26150b 55%, #170c06 100%);
  }
}

.game {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #2a160c;
  isolation: isolate;
}

@media (min-width: 560px) {
  .game {
    box-shadow: 0 0 0 1px rgba(255, 206, 137, 0.14), 0 30px 90px rgba(0, 0, 0, 0.62);
  }
}

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

.shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(30, 15, 6, 0.3) 0%, rgba(30, 15, 6, 0) 21%),
    linear-gradient(0deg, rgba(28, 13, 5, 0.6) 0%, rgba(28, 13, 5, 0.14) 17%, rgba(28, 13, 5, 0) 30%);
}

/* ---------- HUD ---------- */
.hud {
  position: absolute;
  top: calc(var(--safe-top) + 10px);
  left: 16px;
  right: 16px;
  z-index: 6;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  pointer-events: none;
}

.hud-card {
  flex: 1 1 auto;
  min-width: 0;
  padding: 9px 13px 10px;
  border: 2px solid var(--ink);
  border-radius: 18px;
  background: linear-gradient(180deg, #FFF9EA 0%, #FFEDC7 100%);
  box-shadow: 0 4px 0 rgba(67, 41, 21, 0.9), 0 10px 22px rgba(37, 17, 5, 0.26);
}

.hud-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.level-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--ink);
  color: #FFE7B6;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1.4;
}

.target-tag {
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.score-line {
  display: flex;
  align-items: baseline;
  gap: 7px;
  line-height: 1;
}

.coin-badge {
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 25px;
  height: 25px;
  margin-right: 1px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #FFE890 0%, #FFC83D 55%, #E59A10 100%);
  color: #7A4500;
  box-shadow: inset 0 -2px 0 rgba(146, 83, 0, 0.28);
  flex: 0 0 auto;
}

.coin-badge .mp-icon {
  width: 17px;
  height: 17px;
}

#scoreText {
  font-size: 27px;
  font-weight: 900;
  color: var(--ink);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 0 #FFFDF4;
}

.score-sep {
  font-size: 12px;
  font-weight: 800;
  color: #9A7852;
  font-variant-numeric: tabular-nums;
}

.score-sep em {
  font-style: normal;
}

.progress {
  height: 8px;
  margin-top: 7px;
  border-radius: 999px;
  background: #E6CCA0;
  box-shadow: inset 0 1px 2px rgba(67, 41, 21, 0.22);
  overflow: hidden;
}

.progress span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #FFB23F 0%, #FF8A3D 60%, #F06B1C 100%);
  box-shadow: inset 0 1px 0 rgba(255, 238, 187, 0.62);
  transition: width 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.timer-card {
  flex: 0 0 auto;
  width: 78px;
  padding: 8px 6px 9px;
  border: 2px solid var(--ink);
  border-radius: 18px;
  background: linear-gradient(180deg, #FFF9EA 0%, #FFEDC7 100%);
  box-shadow: 0 4px 0 rgba(67, 41, 21, 0.9), 0 10px 22px rgba(37, 17, 5, 0.26);
  text-align: center;
}

.timer-card .mp-icon {
  width: 17px;
  height: 17px;
  color: var(--orange-deep);
}

.timer-num {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 1px;
  line-height: 1;
  margin-top: 1px;
}

.timer-num strong {
  font-size: 26px;
  font-weight: 900;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.timer-num span {
  font-size: 10px;
  font-weight: 800;
  color: var(--ink-soft);
}

.timer-card.warn {
  border-color: #8C2E12;
  background: linear-gradient(180deg, #FFE9DD 0%, #FFCBB7 100%);
  animation: timerPulse 0.9s ease-in-out infinite;
}

.timer-card.warn .mp-icon,
.timer-card.warn .timer-num strong {
  color: #D33B12;
}

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

/* ---------- Hint ---------- */
.hint {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 105px);
  z-index: 5;
  transform: translate(-50%, 0);
  max-width: calc(100% - 48px);
  padding: 8px 16px;
  border: 1.5px solid rgba(67, 41, 21, 0.75);
  border-radius: 999px;
  background: rgba(255, 247, 230, 0.94);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  box-shadow: 0 3px 0 rgba(67, 41, 21, 0.35), 0 8px 18px rgba(30, 14, 4, 0.22);
  opacity: 1;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
  animation: hintFloat 2.6s ease-in-out infinite;
}

.hint.is-hidden {
  opacity: 0;
  transform: translate(-50%, 10px);
  animation: none;
}

@keyframes hintFloat {
  0%, 100% { transform: translate(-50%, 0); }
  50% { transform: translate(-50%, -4px); }
}

/* ---------- Shot button ---------- */
.controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--safe-bottom) + 18px);
  z-index: 8;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.grab-btn {
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 172px;
  height: 70px;
  padding: 0;
  border: 3px solid var(--ink);
  border-radius: 24px;
  background: linear-gradient(180deg, #FFB25E 0%, #FF8A3D 52%, #F2721E 100%);
  color: #FFF8E8;
  font-family: inherit;
  cursor: pointer;
  box-shadow:
    0 6px 0 var(--ink),
    0 14px 24px rgba(46, 21, 7, 0.38),
    inset 0 2px 0 rgba(255, 244, 204, 0.62);
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}

.grab-btn:active,
.grab-btn.is-down {
  transform: translateY(5px);
  box-shadow:
    0 1px 0 var(--ink),
    0 5px 10px rgba(46, 21, 7, 0.3),
    inset 0 2px 0 rgba(255, 244, 204, 0.4);
}

.grab-btn:focus-visible {
  outline: 3px solid #FFF1C0;
  outline-offset: 3px;
}

.grab-icon {
  width: 32px;
  height: 32px;
  color: #FFF8E8;
  filter: drop-shadow(0 2px 0 rgba(112, 47, 4, 0.35));
}

.grab-label {
  font-size: 25px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-shadow: 0 2px 0 rgba(134, 59, 8, 0.35);
}

.grab-btn.is-busy {
  filter: saturate(0.68) brightness(0.94);
}

.grab-btn.is-busy .grab-label {
  font-size: 20px;
  letter-spacing: 0.06em;
}

/* ---------- Result overlay ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 26px;
}

.overlay[hidden] {
  display: none;
}

.overlay-scrim {
  position: absolute;
  inset: 0;
  background: rgba(31, 15, 5, 0.58);
  -webkit-backdrop-filter: blur(6px) saturate(0.85);
  backdrop-filter: blur(6px) saturate(0.85);
  animation: scrimIn 0.24s ease-out both;
}

.result-card {
  position: relative;
  width: min(322px, 88vw);
  padding: 30px 22px 22px;
  border: 3px solid var(--ink);
  border-radius: 28px;
  background:
    radial-gradient(circle at 50% -10%, #FFFDF3 0%, #FFF5DE 46%, #FFE9BE 100%);
  text-align: center;
  box-shadow: 0 10px 0 #3B2110, 0 28px 70px rgba(0, 0, 0, 0.55);
  animation: cardIn 0.42s cubic-bezier(0.2, 1.25, 0.36, 1) both;
}

@keyframes scrimIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes cardIn {
  0% { opacity: 0; transform: translateY(22px) scale(0.88); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.medal {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 78px;
  height: 78px;
  margin: -65px auto 8px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: radial-gradient(circle at 34% 26%, #FFF4BA 0%, #FFD354 40%, #FF9E1B 72%, #E06D08 100%);
  color: #7C4100;
  box-shadow: 0 6px 0 #3B2110, inset 0 -5px 0 rgba(157, 78, 0, 0.26);
  overflow: hidden;
}

.medal .mp-icon {
  position: relative;
  z-index: 1;
  width: 42px;
  height: 42px;
}

.medal-shine {
  position: absolute;
  top: -30%;
  left: -38%;
  width: 60%;
  height: 160%;
  background: rgba(255, 255, 255, 0.42);
  transform: rotate(24deg);
  filter: blur(2px);
}

.result-kicker {
  margin: 2px 0 4px;
  color: var(--orange-deep);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.22em;
}

.result-title {
  margin: 0;
  color: var(--ink);
  font-size: 31px;
  font-weight: 900;
  letter-spacing: 0.02em;
  line-height: 1.2;
  text-shadow: 0 2px 0 #FFFDF4;
}

.result-desc {
  margin: 9px 0 20px;
  color: var(--ink-soft);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.55;
}

.result-desc b {
  color: var(--orange-deep);
  font-size: 17px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.again-btn {
  width: 100%;
  height: 54px;
  border: 2.5px solid var(--ink);
  border-radius: 18px;
  background: linear-gradient(180deg, #FFB25E 0%, #FF8A3D 55%, #F2721E 100%);
  color: #FFF8E8;
  font-family: inherit;
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 0.12em;
  cursor: pointer;
  box-shadow: 0 5px 0 var(--ink), inset 0 2px 0 rgba(255, 244, 204, 0.55);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  -webkit-tap-highlight-color: transparent;
}

.again-btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--ink), inset 0 2px 0 rgba(255, 244, 204, 0.35);
}

.again-btn:focus-visible {
  outline: 3px solid #8C5C2E;
  outline-offset: 2px;
}

@media (max-height: 640px) {
  .hud-card { padding: 7px 11px 8px; }
  #scoreText { font-size: 23px; }
  .timer-card { width: 70px; padding: 6px 5px 7px; }
  .timer-num strong { font-size: 23px; }
  .grab-btn { width: 158px; height: 62px; }
  .grab-btn .grab-icon { width: 30px; height: 30px; }
  .grab-label { font-size: 22px; }
  .hint { bottom: calc(var(--safe-bottom) + 94px); }
  .result-card { padding: 28px 20px 18px; }
  .result-title { font-size: 27px; }
  .result-desc { margin: 7px 0 14px; }
  .again-btn { height: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  .hint,
  .timer-card.warn,
  .overlay-scrim,
  .result-card {
    animation: none;
  }
  .progress span {
    transition: none;
  }
}

/* 本轮：矿洞主题信息条与结算面板，保持原有交互结构。 */
.hud-card, .timer-card {
  background: linear-gradient(180deg, #573820, #322014);
  border-color: #ad753a;
  box-shadow: 0 3px 0 #24150c, inset 0 1px 0 #d39b53;
}
#scoreText, .timer-num strong { color: #ffdb75; text-shadow: 0 2px #24150c; }
.target-tag, .score-sep, .timer-num span { color: #f1d7ad; }
.level-tag { background: #ff8a3d; color: #29170b; }
.timer-card .mp-icon { color: #ffcf69; }
.progress { background: #24170e; }
.result-card {
  border: 3px solid #9d632d;
  border-radius: 22px;
  background: linear-gradient(180deg, #fff1cb, #ecd099);
  box-shadow: 0 8px 0 #4a2b15, 0 20px 55px #0008, inset 0 0 0 5px #ffe7b7;
}
.result-title { color: #9a5b12; }
.result-desc { padding: 16px 10px; border-radius: 12px; background: #70451c12; }
.result-card.is-failed .result-title { color: #756853; }
.again-btn { background: linear-gradient(#ffd66c, #ff8a3d); color: #45270f; }
.grab-btn.feedback-launch { animation: launchFeedback .2s ease-out; }
.hud.feedback-return { animation: returnFeedback .28s ease-out; }
@keyframes launchFeedback { 50% { transform: translateY(4px) scale(.96); } }
@keyframes returnFeedback { 50% { filter: brightness(1.5); transform: translateY(-2px); } }
@media (prefers-reduced-motion: reduce) {
  .grab-btn.feedback-launch, .hud.feedback-return { animation: none; }
}
