:root {
  --orange: #FF8A3D;
  --orange-deep: #F06A16;
  --orange-dark: #B94A0A;
  --cream: #FFF6E7;
  --cream-2: #F7E6CC;
  --ink: #33200F;
  --ink-soft: #8B6448;
  --night: #140E22;
}

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

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #0B0714;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}

#game {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #0B0714;
}

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

.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(10, 6, 20, 0.48) 0%, rgba(10, 6, 20, 0) 18%),
    radial-gradient(ellipse at 50% 44%, rgba(8, 4, 16, 0) 40%, rgba(8, 4, 16, 0.58) 100%);
}

/* ---------------- HUD ---------------- */

.hud {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 0;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.hud.show {
  opacity: 1;
  transform: translateY(0);
}

.hud-col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}

.hud-col.right {
  align-items: flex-end;
}

.chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 12px 7px 7px;
  border-radius: 16px;
  border: 1px solid rgba(255, 211, 163, 0.18);
  background: rgba(24, 14, 32, 0.74);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  -webkit-backdrop-filter: blur(9px);
  backdrop-filter: blur(9px);
}

.chip-icon {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4A2109;
  background: linear-gradient(160deg, #FFC684 0%, #FFA65A 45%, #FF8A3D 100%);
  box-shadow: 0 3px 0 rgba(74, 33, 9, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

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

.chip-text {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.chip-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: rgba(255, 236, 214, 0.58);
  margin-bottom: 4px;
}

.chip-value {
  font-size: 21px;
  line-height: 1;
  font-weight: 900;
  color: #FFF2DE;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.28);
}

.hp-chip {
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  padding: 7px 11px 7px 11px;
}

.hearts {
  display: flex;
  gap: 3px;
}

.hearts .mp-icon {
  width: 18px;
  height: 18px;
  color: #FF6158;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
  transition: color 0.25s ease, opacity 0.25s ease, filter 0.25s ease;
}

.hearts .mp-icon.off {
  color: rgba(255, 236, 220, 0.24);
  filter: none;
}

.wave-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #FFD6A8;
  background: rgba(24, 14, 32, 0.62);
  border: 1px solid rgba(255, 174, 100, 0.22);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.24);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.wave-chip .mp-icon {
  width: 13px;
  height: 13px;
  color: #FFB15E;
}

/* ---------------- floating hint / banner ---------------- */

.hint {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  z-index: 6;
  transform: translate(-50%, 8px);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(20, 12, 26, 0.64);
  border: 1px solid rgba(255, 213, 170, 0.16);
  color: rgba(255, 238, 219, 0.88);
  font-size: 12px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

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

.hint .mp-icon {
  width: 15px;
  height: 15px;
  color: #FFB15E;
}

.wave-banner {
  position: absolute;
  top: 20%;
  left: 50%;
  z-index: 7;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 0);
}

.wave-banner strong {
  display: block;
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 0.07em;
  color: #FFE2B4;
  text-shadow: 0 2px 0 #7A2C08, 0 6px 20px rgba(0, 0, 0, 0.6);
}

.wave-banner span {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.24em;
  color: #FFB97A;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

.wave-banner.show {
  animation: wavePop 1.9s cubic-bezier(0.2, 0.9, 0.25, 1) both;
}

@keyframes wavePop {
  0% { opacity: 0; transform: translate(-50%, 12px) scale(0.84); }
  12% { opacity: 1; transform: translate(-50%, 0) scale(1.05); }
  22% { transform: translate(-50%, 0) scale(1); }
  72% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -18px) scale(0.98); }
}

.damage-flash {
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(ellipse at 50% 56%, rgba(255, 60, 40, 0) 32%, rgba(255, 46, 32, 0.68) 100%);
}

.damage-flash.hit {
  animation: hitFlash 0.5s ease-out;
}

@keyframes hitFlash {
  0% { opacity: 0.9; }
  100% { opacity: 0; }
}

/* ---------------- overlays ---------------- */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: flex;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top, 0px) + 26px) 20px calc(env(safe-area-inset-bottom, 0px) + 20px);
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

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

.start {
  justify-content: flex-start;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(255, 138, 61, 0.1) 0%, rgba(255, 138, 61, 0) 55%),
    linear-gradient(180deg, rgba(12, 7, 22, 0.72) 0%, rgba(12, 7, 22, 0.2) 34%, rgba(12, 7, 22, 0.6) 70%, rgba(12, 7, 22, 0.93) 100%);
}

.start-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-top: clamp(18px, 6vh, 64px);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 198, 134, 0.38);
  background: rgba(40, 21, 31, 0.6);
  color: #FFD2A0;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.22em;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.eyebrow .mp-icon {
  width: 13px;
  height: 13px;
  color: #FFA75A;
}

.logo {
  margin: 14px 0 0;
  font-size: clamp(43px, 13vw, 58px);
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0.035em;
  background: linear-gradient(180deg, #FFF8DC 6%, #FFD9A0 40%, #FF9A4E 74%, #E85F10 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 0 #6E2708) drop-shadow(0 6px 0 rgba(60, 20, 5, 0.5)) drop-shadow(0 16px 28px rgba(0, 0, 0, 0.5));
  animation: logoFloat 4.2s ease-in-out infinite;
}

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

.tagline {
  margin: 11px 0 0;
  font-size: 12px;
  letter-spacing: 0.16em;
  color: rgba(255, 232, 208, 0.74);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7);
}

.start-panel {
  position: relative;
  width: 100%;
  max-width: 380px;
  margin: auto auto 0;
  padding: 15px 16px 14px;
  border-radius: 26px;
  background:
    radial-gradient(rgba(120, 70, 30, 0.055) 1px, transparent 1.4px),
    linear-gradient(180deg, #FFFAF0 0%, #F9EBD6 100%);
  background-size: 11px 11px, 100% 100%;
  border: 2px solid rgba(91, 47, 18, 0.28);
  box-shadow:
    0 10px 0 rgba(70, 32, 12, 0.3),
    0 24px 46px rgba(0, 0, 0, 0.46),
    inset 0 1px 0 #ffffff;
  color: var(--ink);
  overflow: hidden;
  animation: panelRise 0.5s cubic-bezier(0.2, 1, 0.3, 1) both;
}

@keyframes panelRise {
  0% { opacity: 0; transform: translateY(18px); }
  100% { opacity: 1; transform: translateY(0); }
}

.start-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 18px;
  right: 18px;
  height: 3px;
  border-radius: 0 0 4px 4px;
  background: linear-gradient(90deg, rgba(255, 138, 61, 0), rgba(255, 138, 61, 0.9), rgba(255, 138, 61, 0));
}

.best-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 4px 12px;
}

.best-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
}

.best-label .mp-icon {
  width: 15px;
  height: 15px;
  color: #E08A2B;
}

.best-score {
  font-size: 23px;
  line-height: 1;
  font-weight: 900;
  color: #3A2112;
  font-variant-numeric: tabular-nums;
}

.btn {
  position: relative;
  width: 100%;
  min-height: 58px;
  border: 0;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.08em;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.07s ease, box-shadow 0.07s ease;
  -webkit-appearance: none;
  appearance: none;
}

.btn .mp-icon {
  width: 22px;
  height: 22px;
}

.btn-primary {
  color: #3D1B05;
  background: linear-gradient(180deg, #FFC87F 0%, #FFA052 34%, #FF7C22 100%);
  border: 1px solid rgba(122, 50, 8, 0.35);
  box-shadow:
    0 5px 0 #B94A0A,
    0 13px 22px rgba(255, 120, 32, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.68);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

.btn-primary:active {
  transform: translateY(4px);
  box-shadow:
    0 1px 0 #B94A0A,
    0 6px 12px rgba(255, 120, 32, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.how {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin: 11px 0 0;
  font-size: 11px;
  letter-spacing: 0.02em;
  color: #94705A;
}

.how .mp-icon {
  width: 14px;
  height: 14px;
  color: #C77A3A;
}

.start-foot {
  margin: 14px 0 0;
  text-align: center;
  font-size: 10px;
  letter-spacing: 0.26em;
  color: rgba(255, 227, 199, 0.44);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6);
}

/* game over */

.over {
  justify-content: center;
  align-items: center;
  background: radial-gradient(ellipse at 50% 42%, rgba(12, 7, 22, 0.55) 0%, rgba(8, 4, 14, 0.9) 100%);
}

.over-panel {
  position: relative;
  width: 100%;
  max-width: 356px;
  margin-top: 32px;
  padding: 26px 18px 17px;
  border-radius: 28px;
  text-align: center;
  color: var(--ink);
  background:
    radial-gradient(rgba(120, 70, 30, 0.055) 1px, transparent 1.4px),
    linear-gradient(180deg, #FFFAF0 0%, #F8E8D0 100%);
  background-size: 11px 11px, 100% 100%;
  border: 2px solid rgba(91, 47, 18, 0.3);
  box-shadow:
    0 12px 0 rgba(70, 32, 12, 0.32),
    0 30px 60px rgba(0, 0, 0, 0.56),
    inset 0 1px 0 #ffffff;
}

.overlay.over:not(.is-hidden) .over-panel {
  animation: panelIn 0.44s cubic-bezier(0.2, 1.2, 0.35, 1) both;
}

@keyframes panelIn {
  0% { opacity: 0; transform: translateY(26px) scale(0.94); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.over-badge {
  position: relative;
  width: 58px;
  height: 58px;
  margin: -56px auto 8px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4A2109;
  background: linear-gradient(160deg, #FFC882 0%, #FF9B4C 55%, #FF7A20 100%);
  border: 3px solid #FFF3DC;
  box-shadow: 0 7px 18px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  transform: rotate(-4deg);
}

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

.over-kicker {
  margin: 2px 0 0;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.32em;
  color: #B4642A;
}

.over-title {
  margin: 6px 0 0;
  font-size: 27px;
  line-height: 1.15;
  font-weight: 900;
  letter-spacing: 0.03em;
  color: #3A2112;
}

.over-wave {
  margin: 8px 0 0;
  font-size: 12px;
  color: #8B6448;
  letter-spacing: 0.06em;
}

.over-wave strong {
  color: #D9621A;
  font-size: 14px;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 16px 0 0;
}

.stat {
  padding: 10px 6px 9px;
  border-radius: 16px;
  background: linear-gradient(180deg, #F4E2C7 0%, #EFD9BA 100%);
  border: 1px solid rgba(146, 92, 50, 0.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.stat span {
  display: block;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: #94705A;
}

.stat strong {
  display: block;
  margin-top: 3px;
  font-size: 26px;
  line-height: 1;
  font-weight: 900;
  color: #3A2112;
  font-variant-numeric: tabular-nums;
}

.new-record {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 12px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #5A2607;
  background: linear-gradient(180deg, #FFD08A, #FFA453);
  border: 1px solid rgba(146, 68, 12, 0.24);
  box-shadow: 0 3px 0 rgba(160, 74, 14, 0.25);
  animation: recordPop 0.5s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

.new-record .mp-icon {
  width: 13px;
  height: 13px;
}

@keyframes recordPop {
  0% { transform: scale(0.7); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.new-record.is-hidden {
  display: none;
}

.over-panel .btn {
  margin-top: 16px;
  min-height: 54px;
}

.over-panel .how {
  margin-top: 10px;
}

@media (max-height: 720px) {
  .start-head { padding-top: 10px; }
  .logo { font-size: clamp(38px, 11vw, 48px); }
  .tagline { margin-top: 8px; font-size: 11px; }
  .start-panel { padding: 12px 14px 11px; }
  .btn { min-height: 52px; font-size: 17px; }
  .best-row { padding-bottom: 9px; }
  .start-foot { margin-top: 10px; }
  .over-panel { padding: 22px 16px 15px; }
  .over-title { font-size: 24px; }
  .stat-grid { margin-top: 12px; }
  .stat strong { font-size: 23px; }
}

@media (max-width: 350px) {
  .hint { font-size: 10px; padding: 7px 11px; }
  .hearts .mp-icon { width: 16px; height: 16px; }
  .chip-value { font-size: 19px; }
}
