:root {
  --bg: #070b14;
  --panel: rgba(10, 16, 28, 0.88);
  --line: rgba(255, 214, 140, 0.22);
  --gold: #f4c56a;
  --gold-2: #ffe7a8;
  --red: #ff4d5a;
  --safe: #5ee0b0;
  --warn: #ffc857;
  --ink: #f4f1ea;
  --muted: #9aa6b8;
  --phone-w: 390px;
  --phone-h: 844px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #03050a;
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
}

#app {
  position: relative;
  width: min(100vw, var(--phone-w));
  height: min(100vh, var(--phone-h));
  max-width: var(--phone-w);
  max-height: var(--phone-h);
  background: var(--bg);
  overflow: hidden;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 6px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 10px 0;
  pointer-events: none;
}

.hud-card,
.hud-alert {
  min-height: 46px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  backdrop-filter: blur(8px);
}

.hud-k {
  display: block;
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.hud-card strong {
  font-size: 18px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.hud-card-gold strong {
  color: var(--gold-2);
}

.hud-alert {
  min-width: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
}

.hud-alert.safe { color: var(--safe); }
.hud-alert.warn { color: var(--warn); }
.hud-alert.hot {
  color: #fff;
  background: rgba(180, 20, 40, 0.82);
  border-color: var(--red);
  animation: pulse 0.55s ease-in-out infinite alternate;
}

@keyframes pulse {
  from { transform: scale(1); }
  to { transform: scale(1.04); }
}

.stamina-wrap {
  position: absolute;
  top: calc(64px + env(safe-area-inset-top, 0px));
  left: 10px;
  right: 10px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
  pointer-events: none;
}

.stamina-bar {
  flex: 1;
  height: 7px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.stamina-bar i {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #3ec8ff, #7dffc6);
  transform-origin: left center;
}

.banner {
  position: absolute;
  top: 38%;
  left: 24px;
  right: 24px;
  z-index: 4;
  text-align: center;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(8, 10, 18, 0.78);
  border: 1px solid rgba(255, 80, 90, 0.45);
  color: #ffdce0;
  font-weight: 700;
  letter-spacing: 0.02em;
  pointer-events: none;
}

.controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 16px calc(16px + env(safe-area-inset-bottom, 0px));
  pointer-events: none;
}

.stick {
  width: 118px;
  height: 118px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(8, 12, 22, 0.42);
  position: relative;
  pointer-events: auto;
}

.stick-knob {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(244, 197, 106, 0.92);
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.btns {
  display: flex;
  gap: 12px;
  pointer-events: auto;
}

.act-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 0;
  color: #fff;
  font-size: 22px;
  font-weight: 800;
  pointer-events: auto;
}

.hide-btn { background: #2d6bff; }
.sprint-btn { background: #e24b2c; }
.act-btn:active,
.act-btn.on {
  transform: scale(0.96);
  filter: brightness(1.12);
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 28px 22px calc(28px + env(safe-area-inset-bottom, 0px));
  background:
    linear-gradient(180deg, rgba(7, 11, 20, 0.28) 0%, rgba(7, 11, 20, 0.55) 38%, rgba(7, 11, 20, 0.94) 100%);
}

.screen.hidden { display: none; }

.eyebrow {
  color: var(--red);
  font-size: 12px;
  letter-spacing: 0.22em;
  font-weight: 700;
}

h1, h2 {
  margin: 8px 0 10px;
  font-size: 40px;
  letter-spacing: 0.06em;
}

.lead {
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

.best-box {
  margin: 18px 0;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(20, 16, 10, 0.55);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: center;
}

.best-box dt {
  color: var(--muted);
  font-size: 13px;
}

.best-box dd {
  color: var(--gold-2);
  font-size: 22px;
  font-weight: 800;
  text-align: right;
}

.primary {
  height: 52px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(180deg, #ff6a4a, #d61f2a);
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.tips {
  margin-top: 16px;
  padding-left: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

@media (min-width: 430px) {
  #app {
    border-radius: 28px;
    border: 1px solid rgba(255, 255, 255, 0.06);
  }
}
