:root {
  --bg: #0b0a26;
  --panel: #15133a;
  --line: #2f2b6e;
  --cyan: #22e3ff;
  --pink: #ff2d95;
  --violet: #8b5cf6;
  --gold: #ffc53d;
  --text: #eef2ff;
  --muted: #9aa3c7;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--text);
  background: radial-gradient(120% 70% at 50% 0%, #34207a 0%, rgba(11, 10, 38, 0) 70%), var(--bg);
  overscroll-behavior: none;
}
button { font: inherit; cursor: pointer; }

.app {
  max-width: 460px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(20px + env(safe-area-inset-top)) 22px calc(28px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
}
section { text-align: center; animation: fadeIn .3s ease; }

.avatar {
  --size: 60px;
  width: var(--size);
  height: var(--size);
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: calc(var(--size) * .58);
  line-height: 1;
  background: radial-gradient(circle at 30% 28%, rgba(255, 255, 255, .55), transparent 55%), var(--av, #888);
  user-select: none;
}
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }

/* ---------------------------------------------------------------- 加入 */
.logo {
  margin: 0;
  font-size: 60px;
  font-weight: 900;
  letter-spacing: 6px;
  color: #fff;
  text-shadow: 0 0 6px #fff, 0 0 18px var(--pink), 0 0 40px var(--pink);
}
.sub { margin: 6px 0 26px; color: var(--muted); }
.field { display: block; margin-bottom: 18px; text-align: left; }
.field span, .field-label { display: block; margin-bottom: 8px; font-size: 14px; color: var(--muted); text-align: left; }
.field input {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  border: 2px solid var(--line);
  border-radius: 14px;
  outline: none;
  font-size: 18px;
  color: #fff;
  background: #100e2e;
  -webkit-appearance: none;
}
.field input:focus { border-color: var(--cyan); box-shadow: 0 0 0 4px rgba(34, 227, 255, .18); }
.field input.bad { border-color: var(--pink); animation: shakeX .4s; }
.avatar-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 26px; }
.avatar-opt { justify-self: center; padding: 3px; border: 3px solid transparent; border-radius: 50%; background: none; transition: transform .15s; }
.avatar-opt.on { border-color: var(--cyan); box-shadow: 0 0 16px rgba(34, 227, 255, .6); transform: scale(1.06); }

.btn {
  width: 100%;
  height: 56px;
  border: 0;
  border-radius: 999px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #fff;
  background: linear-gradient(90deg, var(--violet), var(--pink));
  box-shadow: 0 8px 26px rgba(255, 45, 149, .35);
}
.btn:active { transform: scale(.97); }
.btn.ghost { height: 46px; margin-top: 24px; font-size: 15px; font-weight: 600; color: var(--muted); background: transparent; border: 2px dashed var(--line); box-shadow: none; }
.btn.motion { background: linear-gradient(90deg, #f59e0b, #ef4444); animation: breathe 1.6s ease-in-out infinite; }
.link { margin-top: 8px; border: 0; background: none; font-size: 14px; color: var(--muted); text-decoration: underline; }

/* ---------------------------------------------------------------- 等待 */
.me { display: flex; flex-direction: column; align-items: center; }
.me-avatar .avatar { --size: 110px; box-shadow: 0 0 0 4px rgba(255, 255, 255, .7), 0 0 30px rgba(34, 227, 255, .5); }
.me-name { margin-top: 14px; font-size: 26px; font-weight: 800; word-break: break-all; }
.status {
  max-width: 320px;
  margin: 34px auto 0;
  padding: 14px 20px;
  border: 2px solid var(--cyan);
  border-radius: 16px;
  font-size: 18px;
  background: rgba(34, 227, 255, .08);
  box-shadow: 0 0 18px rgba(34, 227, 255, .25);
}
.hint { margin: 16px 0 0; font-size: 14px; color: var(--muted); }

/* ---------------------------------------------------------------- 倒计时 / 比赛 */
.big-num {
  font-size: 180px;
  font-weight: 900;
  line-height: 1;
  color: #fff;
  text-shadow: 0 0 10px #fff, 0 0 40px var(--cyan), 0 0 80px var(--cyan);
  font-variant-numeric: tabular-nums;
}
.race-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 12px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  font-size: 16px;
  color: var(--muted);
  background: var(--panel);
}
.race-top b { margin: 0 2px; font-size: 26px; color: #fff; font-variant-numeric: tabular-nums; }
.phone-wrap { display: inline-block; margin-top: 40px; animation: wobble .8s ease-in-out infinite; }
.phone-icon { font-size: 130px; line-height: 1; }
.phone-icon.bump { animation: bump .25s ease-out; }
.shake-count {
  margin-top: 20px;
  font-size: 96px;
  font-weight: 900;
  line-height: 1;
  color: var(--cyan);
  text-shadow: 0 0 24px rgba(34, 227, 255, .7);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- 结果 */
.medal { font-size: 120px; line-height: 1; animation: pop .6s cubic-bezier(.2, 1.6, .4, 1); }
.r-rank { margin-top: 12px; font-size: 32px; font-weight: 800; }
.r-rank b { margin: 0 6px; font-size: 72px; color: var(--gold); text-shadow: 0 0 24px rgba(255, 197, 61, .6); }
.r-praise { margin: 6px 0 0; font-size: 20px; }
.r-detail { margin: 16px 0 0; color: var(--muted); }
.r-detail b { color: #fff; }

/* ---------------------------------------------------------------- 提示 */
.warn {
  padding: 12px 14px;
  border: 1px solid rgba(239, 68, 68, .6);
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  text-align: left;
  color: #fecaca;
  background: rgba(239, 68, 68, .15);
}
.conn {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 14px;
  white-space: nowrap;
  color: var(--muted);
  background: rgba(0, 0, 0, .75);
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } }
@keyframes wobble { 0%, 100% { transform: rotate(-10deg); } 50% { transform: rotate(10deg); } }
@keyframes bump { from { transform: scale(1.25) rotate(-20deg); } }
@keyframes pop { from { transform: scale(.3); opacity: 0; } }
@keyframes breathe { 50% { transform: scale(1.03); } }
@keyframes shakeX { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* ---------------------------------------------------------------- 防误触 */
/* 倒计时和比赛中：禁止滚动、下拉回弹、长按选字、双指缩放 */
body.locked,
body.locked * {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
body.locked { position: fixed; inset: 0; overflow: hidden; }
.grip-tip {
  display: inline-block;
  margin: 22px auto 0;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 17px;
  font-weight: 700;
  color: var(--gold);
  background: rgba(255, 197, 61, .12);
}
.toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  top: 38%;
  max-width: 86vw;
  padding: 16px 22px;
  border-radius: 16px;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  color: #fff;
  background: rgba(239, 68, 68, .95);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
  transform: translate(-50%, -50%);
  animation: toastIn .3s ease-out;
}
@keyframes toastIn { from { transform: translate(-50%, -50%) scale(.6); opacity: 0; } }
