:root {
  --ink: #071412;
  --ink-2: #0c221e;
  --teal: #1ec8a5;
  --teal-dim: #0e7a64;
  --amber: #f0b429;
  --coral: #ff6b4a;
  --fog: rgba(232, 244, 240, 0.86);
  --muted: rgba(180, 210, 200, 0.65);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--fog);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.demo-back-btn {
  position: fixed;
  z-index: 40;
  top: max(10px, var(--safe-top));
  left: max(10px, var(--safe-left));
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(7, 20, 18, 0.72);
  color: #fff;
  text-decoration: none;
  font-size: 0.85rem;
  backdrop-filter: blur(8px);
}

/* —— Lobby —— */
.lobby-page {
  min-height: 100%;
}

.lobby {
  position: relative;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 72px 20px 40px;
}

.lobby__bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(30, 200, 165, 0.22), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 80%, rgba(240, 180, 41, 0.12), transparent 50%),
    linear-gradient(160deg, #061512 0%, #0a1f1b 45%, #071410 100%);
}

.lobby__bg::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image: radial-gradient(rgba(30, 200, 165, 0.35) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(ellipse at center, #000 20%, transparent 75%);
}

.lobby__content {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  text-align: center;
}

.lobby__eyebrow {
  margin: 0 0 10px;
  letter-spacing: 0.22em;
  font-size: 0.72rem;
  color: var(--teal);
  font-weight: 700;
}

.lobby__brand {
  margin: 0;
  font-size: clamp(2.4rem, 10vw, 3.4rem);
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: 0.04em;
  background: linear-gradient(120deg, #e8f8f3 10%, var(--teal) 55%, var(--amber) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lobby__tagline {
  margin: 16px 0 28px;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--muted);
}

.lobby__actions {
  display: grid;
  gap: 12px;
}

.lobby__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 20px;
  border-radius: 12px;
  border: none;
  font-size: 1rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.lobby__btn:active {
  transform: scale(0.98);
}

.lobby__btn--primary {
  background: linear-gradient(135deg, var(--teal), var(--teal-dim));
  color: #04201a;
  box-shadow: 0 10px 28px rgba(30, 200, 165, 0.28);
}

.lobby__btn--ghost {
  background: rgba(255, 255, 255, 0.06);
  color: var(--fog);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.lobby__hint {
  margin: 22px 0 0;
  font-size: 0.78rem;
  color: rgba(180, 210, 200, 0.45);
}

/* —— Play —— */
.play-page {
  touch-action: none;
  user-select: none;
}

#game {
  display: block;
  width: 100vw;
  height: 100dvh;
  background: var(--ink);
}

.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  padding: calc(52px + var(--safe-top)) 12px 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.hud__left {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hud__stat {
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(7, 20, 18, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.78rem;
  color: var(--muted);
  backdrop-filter: blur(6px);
}

.hud__stat strong {
  color: #fff;
  font-size: 1rem;
  margin-left: 4px;
}

.hud__buff {
  color: #ffe8a3;
  border-color: rgba(255, 215, 106, 0.35);
}

.hud__rank {
  margin: 0;
  padding: 8px 10px;
  list-style: none;
  min-width: 132px;
  border-radius: 10px;
  background: rgba(7, 20, 18, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(6px);
  font-size: 0.72rem;
  color: var(--muted);
}

.hud__rank li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 0;
}

.hud__rank li.is-me {
  color: var(--amber);
  font-weight: 700;
}

.stick {
  position: fixed;
  z-index: 6;
  left: max(18px, var(--safe-left));
  bottom: max(24px, var(--safe-bottom));
  width: 120px;
  height: 120px;
  pointer-events: none;
  opacity: 0.85;
}

.stick__base {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid rgba(30, 200, 165, 0.35);
  background: rgba(7, 20, 18, 0.35);
  position: relative;
}

.stick__knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #7dffd6, var(--teal-dim));
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  transition: transform 0.05s linear;
}

.boost-btn {
  position: fixed;
  z-index: 8;
  right: max(18px, var(--safe-right));
  bottom: max(28px, var(--safe-bottom));
  width: 76px;
  height: 76px;
  border: 2px solid rgba(240, 180, 41, 0.45);
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 28%, rgba(255, 230, 150, 0.35), transparent 55%),
    linear-gradient(160deg, rgba(40, 28, 8, 0.85), rgba(12, 20, 18, 0.75));
  color: var(--amber);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0;
  cursor: pointer;
  user-select: none;
  touch-action: none;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.boost-btn__icon {
  display: grid;
  place-items: center;
  line-height: 0;
}

.boost-btn__mul {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

.boost-btn.is-held {
  transform: scale(0.94);
  border-color: rgba(255, 200, 80, 0.9);
  color: #ffe08a;
  box-shadow:
    0 0 0 3px rgba(240, 180, 41, 0.22),
    0 10px 28px rgba(240, 180, 41, 0.28);
}

.boost-btn.is-x2 {
  color: #ff9f43;
  border-color: rgba(255, 159, 67, 0.7);
}

.boost-btn.is-x3 {
  color: #ff6b4a;
  border-color: rgba(255, 107, 74, 0.85);
  box-shadow:
    0 0 0 4px rgba(255, 107, 74, 0.2),
    0 12px 30px rgba(255, 107, 74, 0.3);
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 12, 10, 0.72);
  backdrop-filter: blur(8px);
}

.overlay[hidden] {
  display: none !important;
}

.overlay__card {
  width: min(360px, 100%);
  text-align: center;
  padding: 28px 22px;
  border-radius: 16px;
  background: linear-gradient(165deg, #0e2622, #091816);
  border: 1px solid rgba(30, 200, 165, 0.25);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.overlay__eyebrow {
  margin: 0;
  letter-spacing: 0.2em;
  font-size: 0.7rem;
  color: var(--coral);
  font-weight: 700;
}

.overlay__title {
  margin: 8px 0 10px;
  font-size: 1.55rem;
}

.overlay__text {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.overlay__actions {
  display: grid;
  gap: 10px;
}

.overlay__card--settle {
  max-width: min(420px, 92vw);
  max-height: min(86vh, 640px);
  overflow: auto;
}

.settle-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  text-align: left;
  max-height: 280px;
  overflow: auto;
}

.settle-list li {
  display: grid;
  grid-template-columns: 2rem 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  margin-bottom: 6px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.86rem;
  color: var(--muted);
}

.settle-list li.is-me {
  background: rgba(30, 200, 165, 0.18);
  color: #e8f8f3;
}

.settle-list li.is-winner {
  box-shadow: inset 0 0 0 1px rgba(240, 180, 41, 0.55);
}

.settle-list .settle-rank {
  font-weight: 700;
  color: var(--amber);
}

.settle-list .settle-meta {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.hud__time strong {
  color: #7dffd6;
}

@media (min-width: 900px) {
  .stick {
    opacity: 0.55;
  }
}
