:root {
  --orange: #FF8A3D;
  --orange-hot: #FF6F2C;
  --orange-pale: #FFD3A6;
  --ink: #171016;
  --cream: #FFF1DE;
  --muted: rgba(255, 235, 213, .62);
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #0d0912;
  color: var(--cream);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

#stage {
  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #140f18;
  touch-action: none;
}

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

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

.hud {
  position: absolute;
  inset: 0;
  z-index: 15;
  pointer-events: none;
  opacity: 1;
  transition: opacity .3s ease;
}

.hud.is-hidden { opacity: 0; }

.hud-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 0;
}

.hud-spacer { width: 46px; height: 46px; flex: 0 0 46px; }

.hud-chip {
  background: linear-gradient(180deg, rgba(27, 19, 24, .88), rgba(17, 12, 16, .8));
  border: 1px solid rgba(255, 158, 92, .3);
  border-radius: 13px;
  box-shadow: 0 5px 16px rgba(0, 0, 0, .3), inset 0 1px 0 rgba(255, 216, 180, .1);
  -webkit-backdrop-filter: blur(9px);
  backdrop-filter: blur(9px);
}

.wave-chip {
  min-width: 82px;
  padding: 7px 13px 8px;
  border-left: 3px solid var(--orange);
}

.chip-k, .score-k {
  display: block;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .22em;
  color: rgba(255, 170, 112, .85);
  line-height: 1.2;
}

.chip-v {
  display: block;
  margin-top: 1px;
  font-size: 23px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  color: #fff4e6;
}

.score-box {
  position: relative;
  min-width: 106px;
  padding: 7px 14px 8px;
  text-align: center;
  border-radius: 13px;
  background: linear-gradient(180deg, rgba(27, 19, 24, .72), rgba(17, 12, 16, .6));
  border: 1px solid rgba(255, 255, 255, .08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
}

.score-v {
  display: block;
  margin-top: 1px;
  font-size: 21px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: .01em;
  color: #fff4e6;
  font-variant-numeric: tabular-nums;
}

.combo {
  position: absolute;
  top: calc(100% + 7px);
  right: 0;
  white-space: nowrap;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .06em;
  color: var(--orange-pale);
  text-shadow: 0 2px 8px rgba(0, 0, 0, .65);
  transition: opacity .18s ease;
}

.combo.is-hot { color: #ffd36b; }

.round-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 170, 112, .32);
  background: linear-gradient(180deg, rgba(41, 27, 30, .9), rgba(20, 13, 18, .88));
  color: #ffe3c8;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 235, 215, .12);
  cursor: pointer;
  pointer-events: auto;
  transition: transform .12s ease, background .2s ease;
}

.round-btn .mp-icon { width: 21px; height: 21px; }
.round-btn:active { transform: scale(.91); }

.sound-btn {
  position: absolute;
  z-index: 40;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  right: 16px;
}

.ico-sound-off { display: none; }
.sound-btn.muted .ico-sound-on { display: none; }
.sound-btn.muted .ico-sound-off { display: inline-block; }

.wave-banner {
  position: absolute;
  top: 19%;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  opacity: 0;
  transform: translateY(10px) scale(.97);
  pointer-events: none;
}

.wave-banner.show { animation: bannerPop 2.4s cubic-bezier(.16, .84, .28, 1) both; }

.banner-kicker {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .32em;
  color: var(--orange);
  text-shadow: 0 2px 8px rgba(0, 0, 0, .8);
}

.banner-title {
  font-size: clamp(24px, 7vw, 34px);
  font-weight: 900;
  letter-spacing: .04em;
  color: #fff1dd;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .4), 0 8px 26px rgba(0, 0, 0, .7);
}

.wave-banner.danger .banner-kicker { color: #ff6a4d; }
.wave-banner.danger .banner-title { color: #ffe0c8; }

@keyframes bannerPop {
  0% { opacity: 0; transform: translateY(14px) scale(.94); }
  12% { opacity: 1; transform: translateY(0) scale(1.02); }
  20% { transform: translateY(0) scale(1); }
  78% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-8px) scale(.99); }
}

.hud-bottom {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
}

.integrity {
  padding: 9px 12px 11px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(25, 17, 22, .84), rgba(15, 10, 14, .76));
  border: 1px solid rgba(255, 158, 92, .2);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .28), inset 0 1px 0 rgba(255, 224, 198, .08);
  -webkit-backdrop-filter: blur(9px);
  backdrop-filter: blur(9px);
}

.integrity-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  color: rgba(255, 230, 208, .8);
}

.integrity-label { display: flex; align-items: center; gap: 5px; }
.integrity-label .mp-icon { width: 14px; height: 14px; color: var(--orange); }
.integrity-head b { font-size: 12px; font-variant-numeric: tabular-nums; color: #fff1dd; }

.bar-track {
  position: relative;
  height: 11px;
  border-radius: 7px;
  overflow: hidden;
  background: rgba(0, 0, 0, .5);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, .55);
}

.bar-fill {
  position: absolute;
  inset: 0;
  width: 100%;
  border-radius: 7px;
  background: linear-gradient(90deg, #ffb765, #ff8a3d 60%, #ff7038);
  box-shadow: 0 0 12px rgba(255, 138, 61, .5);
  transition: width .18s ease-out, background .3s ease;
}

.integrity.low .bar-fill {
  background: linear-gradient(90deg, #ff7d5d, #ff4c3a 70%, #e6352c);
  box-shadow: 0 0 12px rgba(255, 68, 48, .55);
}

.integrity.critical .bar-fill { animation: barPulse .8s ease-in-out infinite; }

@keyframes barPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.45); }
}

.bar-ticks {
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(90deg, transparent 0 18%, rgba(15, 9, 12, .45) 18% 18.8%);
  opacity: .5;
}

.bar-gloss {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 45%;
  background: linear-gradient(180deg, rgba(255, 255, 255, .24), transparent);
}

.play-hint {
  margin-top: 7px;
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  color: rgba(255, 233, 211, .55);
  text-shadow: 0 1px 6px rgba(0, 0, 0, .8);
  transition: opacity .5s ease;
}

.play-hint.is-faded { opacity: 0; }

/* ---------- Screens ---------- */

.screen {
  position: absolute;
  inset: 0;
  z-index: 20;
  transition: opacity .35s ease, visibility .35s;
}

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

.start-screen {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 9vh) 22px calc(env(safe-area-inset-bottom, 0px) + 22px);
  background:
    radial-gradient(120% 55% at 50% 32%, rgba(255, 138, 61, .1), transparent 62%),
    linear-gradient(180deg, rgba(10, 7, 13, .18) 0%, rgba(10, 7, 13, .05) 30%, rgba(11, 7, 13, .58) 62%, rgba(10, 6, 11, .94) 100%);
}

.start-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(130% 80% at 50% 48%, transparent 42%, rgba(6, 4, 8, .55) 100%);
}

.brand {
  position: relative;
  z-index: 1;
  max-width: 420px;
  align-self: center;
  width: 100%;
}

.brand-kicker {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 15px;
  padding: 6px 11px 6px 9px;
  border: 1px solid rgba(255, 158, 92, .32);
  border-radius: 999px;
  background: rgba(18, 11, 16, .5);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .18em;
  color: rgba(255, 211, 170, .9);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 0 0 rgba(255, 138, 61, .55);
  animation: livePulse 2s ease-out infinite;
}

@keyframes livePulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 138, 61, .5); }
  70% { box-shadow: 0 0 0 7px rgba(255, 138, 61, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 138, 61, 0); }
}

.title {
  margin: 0;
  font-weight: 900;
  letter-spacing: -.06em;
  line-height: .9;
}

.title-line {
  display: block;
  font-size: clamp(58px, 17.2vw, 86px);
  color: #fff2e0;
  text-shadow:
    0 2px 0 rgba(49, 24, 18, .4),
    0 7px 0 rgba(23, 11, 14, .38),
    0 16px 34px rgba(0, 0, 0, .55);
}

.title-accent {
  display: flex;
  align-items: flex-start;
  background: linear-gradient(178deg, #fff6e7 8%, #ffd0a0 42%, #ff9a4f 72%, #f1742a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 7px 0 rgba(23, 11, 14, .32)) drop-shadow(0 14px 26px rgba(0, 0, 0, .45));
}

.title-four {
  margin-left: .06em;
  margin-top: -.14em;
  font-size: .5em;
  line-height: 1;
  color: var(--orange);
  -webkit-text-fill-color: var(--orange);
  text-shadow: 0 2px 0 rgba(60, 24, 10, .35);
  transform: rotate(6deg);
}

.title-en {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  max-width: 330px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .34em;
  color: rgba(255, 170, 112, .82);
  white-space: nowrap;
}

.title-en span {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(255, 138, 61, .65), rgba(255, 138, 61, .05));
}

.title-en span:last-child {
  background: linear-gradient(90deg, rgba(255, 138, 61, .05), rgba(255, 138, 61, .65));
}

.tagline {
  margin: 15px 0 0;
  font-size: 13px;
  line-height: 1.75;
  letter-spacing: .04em;
  color: rgba(255, 232, 210, .64);
  text-shadow: 0 2px 12px rgba(0, 0, 0, .7);
}

.start-actions {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
  align-self: center;
}

.best-line {
  margin-bottom: 11px;
  text-align: center;
  font-size: 11px;
  letter-spacing: .12em;
  color: rgba(255, 226, 199, .5);
}

.best-line b {
  margin-left: 3px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 235, 215, .92);
}

.best-line span { margin-left: 7px; color: rgba(255, 174, 117, .62); }

.cta {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  height: 58px;
  border: 0;
  border-radius: 17px;
  background: linear-gradient(180deg, #ffbe7c 0%, #ff984f 34%, #ff822f 70%, #f17124 100%);
  color: #2a1307;
  font-family: inherit;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: .14em;
  cursor: pointer;
  box-shadow:
    0 6px 0 #a64a16,
    0 13px 30px rgba(255, 116, 40, .3),
    inset 0 1px 0 rgba(255, 255, 255, .6),
    inset 0 -2px 0 rgba(125, 45, 5, .25);
  transition: transform .1s ease, box-shadow .1s ease, filter .2s ease;
}

.cta::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, .22);
  pointer-events: none;
}

.cta .mp-icon { width: 25px; height: 25px; }

.cta:hover { filter: brightness(1.04); }
.cta:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #a64a16, 0 6px 16px rgba(255, 116, 40, .24), inset 0 1px 0 rgba(255, 255, 255, .5);
}

.control-tip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 13px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .05em;
  color: rgba(255, 231, 209, .48);
}

.dot-sep { color: rgba(255, 170, 112, .32); }

.drag-ico {
  position: relative;
  width: 19px;
  height: 12px;
  border-radius: 6px;
  border: 1px solid rgba(255, 170, 112, .5);
}

.drag-ico::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 50%;
  width: 5px;
  height: 5px;
  margin-left: -2.5px;
  border-radius: 50%;
  background: var(--orange);
}

/* ---------- Game over ---------- */

.over-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background:
    radial-gradient(80% 60% at 50% 44%, rgba(120, 30, 18, .18), transparent 70%),
    rgba(8, 5, 9, .58);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

.over-card {
  position: relative;
  width: min(100%, 360px);
  padding: 30px 22px 22px;
  overflow: hidden;
  border-radius: 23px;
  background: linear-gradient(165deg, #261b1d 0%, #180f14 62%, #130c11 100%);
  border: 1px solid rgba(255, 148, 82, .28);
  box-shadow: 0 26px 70px rgba(0, 0, 0, .65), inset 0 1px 0 rgba(255, 220, 190, .1);
  text-align: center;
  animation: cardIn .34s cubic-bezier(.2, .9, .3, 1.2) both;
}

@keyframes cardIn {
  0% { opacity: 0; transform: translateY(18px) scale(.96); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.over-hazard {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: repeating-linear-gradient(115deg, var(--orange) 0 12px, #2a1512 12px 24px);
  opacity: .9;
}

.over-kicker {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .34em;
  color: var(--orange);
}

.over-card h2 {
  margin: 7px 0 4px;
  font-size: 32px;
  font-weight: 900;
  letter-spacing: .02em;
  color: #fff1de;
  text-shadow: 0 4px 18px rgba(0, 0, 0, .5);
}

.over-sub {
  margin: 0;
  font-size: 12px;
  letter-spacing: .08em;
  color: rgba(255, 231, 209, .56);
}

.over-sub b {
  font-size: 15px;
  color: var(--orange-pale);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 20px 0;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(0, 0, 0, .24);
  border: 1px solid rgba(255, 255, 255, .07);
}

.stat-grid > div {
  padding: 11px 4px 10px;
  border-right: 1px solid rgba(255, 255, 255, .07);
}

.stat-grid > div:last-child { border-right: 0; }

.stat-grid span {
  display: block;
  margin-bottom: 3px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .18em;
  color: rgba(255, 226, 199, .46);
}

.stat-grid b {
  font-size: 20px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: #fff0db;
}

.cta-again { height: 54px; font-size: 16px; }

/* Short phones */
@media (max-height: 680px) {
  .start-screen { padding-top: calc(env(safe-area-inset-top, 0px) + 5vh); }
  .title-line { font-size: clamp(48px, 14vw, 66px); }
  .tagline { margin-top: 10px; font-size: 12px; }
  .title-en { margin-top: 11px; }
  .brand-kicker { margin-bottom: 10px; }
  .cta { height: 52px; }
  .best-line { margin-bottom: 8px; }
  .control-tip { margin-top: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  .live-dot, .integrity.critical .bar-fill { animation: none; }
  .wave-banner.show { animation: none; opacity: 1; }
  .over-card { animation: none; }
}
