:root {
  --purple: #7a5cd6;
  --purple-deep: #5b41a8;
  --purple-soft: #ece4ff;
  --purple-pill: linear-gradient(180deg, #f4efff 0%, #e9e0ff 100%);
  --teal: #2fa89b;
  --teal-deep: #1f7a70;
  --teal-soft: #d9f2ef;
  --teal-pill: linear-gradient(180deg, #e8f8f5 0%, #d7f1ed 100%);
  --ink: #3b3350;
  --ink-soft: #5f5678;
  --muted: #948da8;
  --line: rgba(122, 92, 214, 0.13);
  --card: #ffffff;
  --radius: 22px;
  --shadow: 0 10px 30px -18px rgba(91, 65, 168, 0.55);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }

body {
  min-height: 100dvh;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", system-ui, sans-serif;
  background:
    radial-gradient(120% 55% at 8% 0%, #efe6ff 0%, rgba(239, 230, 255, 0) 58%),
    radial-gradient(120% 55% at 96% 6%, #e2f9f4 0%, rgba(226, 249, 244, 0) 55%),
    linear-gradient(180deg, #faf7ff 0%, #f5f1fc 52%, #f1faf8 100%);
  background-attachment: fixed;
  display: flex;
  justify-content: center;
  -webkit-font-smoothing: antialiased;
}

.app {
  width: 100%;
  max-width: 440px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 26px 18px calc(30px + env(safe-area-inset-bottom));
}

/* ------------------------------ 通用 ------------------------------ */
.screen {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 16px;
  animation: rise .34s cubic-bezier(.22,.9,.3,1) both;
}
#play, #reveal { justify-content: center; }
.hidden { display: none !important; }
.center { text-align: center; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.brand {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--purple-deep);
  opacity: .85;
}
.brand.small { text-align: center; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 18px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, .9);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.label {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  letter-spacing: .5px;
}

.hint { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.hint.error { color: #d4586f; }

.btn {
  appearance: none;
  border: 0;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  padding: 14px 18px;
  border-radius: 16px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .18s ease, opacity .18s ease;
  width: 100%;
}
.btn:active { transform: scale(.978); }
.btn.primary {
  color: #fff;
  background: linear-gradient(135deg, #8b6ae6 0%, #6f4fd0 100%);
  box-shadow: 0 12px 24px -12px rgba(111, 79, 208, .85);
}
.btn.ghost {
  color: var(--purple-deep);
  background: #f5f1ff;
  border: 1px solid var(--line);
}
.btn.text {
  background: none;
  color: var(--muted);
  font-weight: 500;
  font-size: 14px;
  padding: 8px;
}
.btn[disabled] { opacity: .55; pointer-events: none; }

.btnrow { display: flex; gap: 10px; }
.btnrow .btn { flex: 1; font-size: 14.5px; padding: 13px 10px; }

input[type="text"], input:not([type]) {
  width: 100%;
  font: inherit;
  font-size: 17px;
  color: var(--ink);
  background: #faf8ff;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 13px 15px;
  outline: none;
  transition: border-color .18s ease, background .18s ease;
}
input::placeholder { color: #b8b2c8; }
input:focus { border-color: rgba(122, 92, 214, .55); background: #fff; }
input[disabled] { color: var(--purple-deep); background: #f3eeff; -webkit-text-fill-color: var(--purple-deep); opacity: 1; }

.field { display: flex; flex-direction: column; gap: 8px; }
.field > span { font-size: 13px; color: var(--muted); }

.seg { display: flex; gap: 8px; }
.seg button {
  flex: 1;
  font: inherit;
  font-size: 14px;
  padding: 10px 0;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: #faf8ff;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all .16s ease;
}
.seg button.on {
  background: var(--purple-soft);
  border-color: rgba(122, 92, 214, .35);
  color: var(--purple-deep);
  font-weight: 600;
}

.or { display: flex; align-items: center; gap: 12px; color: #b8b2c8; font-size: 12px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.joinrow { display: flex; gap: 10px; align-items: stretch; }
.joinrow input { flex: 1; letter-spacing: 3px; font-weight: 600; text-transform: uppercase; }
.joinrow .btn {
  width: auto;
  padding: 0 22px;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ------------------------------ 首页 ------------------------------ */
.hero { display: flex; flex-direction: column; gap: 12px; padding: 6px 4px 2px; }
.hero h1 {
  margin: 0;
  font-size: 31px;
  line-height: 1.28;
  letter-spacing: .5px;
  color: #2f2745;
  font-weight: 800;
}
.lead { margin: 0; font-size: 14px; line-height: 1.75; color: var(--ink-soft); }

.rules {
  margin: 2px 0 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 2;
}
.rules b { color: var(--purple-deep); font-weight: 600; }

/* ------------------------------ 房间 ------------------------------ */
.code {
  font-size: 38px;
  font-weight: 800;
  letter-spacing: 8px;
  color: var(--purple-deep);
  font-variant-numeric: tabular-nums;
  padding: 2px 0 6px 8px;
  text-shadow: 0 6px 18px rgba(122, 92, 214, .25);
}

.players { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.players li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #faf8ff;
  font-size: 15px;
}
.players li .avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #9d7ff0, #6f4fd0);
  flex: 0 0 auto;
}
.players li.empty { color: #b8b2c8; }
.players li.empty .avatar { background: #eae6f5; color: #b8b2c8; }
.players li .me { margin-left: auto; font-size: 11.5px; color: var(--muted); }
.players li .ok { margin-left: auto; font-size: 12px; color: var(--teal-deep); }

/* ------------------------------ 对局 ------------------------------ */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 0 4px; }
.roundtext { font-size: 14px; color: var(--ink-soft); font-weight: 600; }
.timer {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--purple-deep);
  background: var(--purple-soft);
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
}
.timer.warn { color: #c14a63; background: #ffe9ee; }

.dots { display: flex; gap: 6px; justify-content: center; padding: 2px 0 4px; flex-wrap: wrap; }
.dots i {
  width: 8px; height: 8px; border-radius: 50%;
  background: #e4dff2;
  display: block;
}
.dots i.done { background: #b9a8ec; }
.dots i.hit { background: var(--teal); }
.dots i.now { background: var(--purple); animation: pulse 1.3s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.45); opacity: .6; } }

.playcard { padding: 20px 18px 18px; gap: 14px; }
.playcard input { text-align: center; font-size: 20px; font-weight: 600; padding: 16px 14px; }
.versus.live { padding: 0 0 2px; gap: 8px; }
.pill.live {
  width: 100%;
  padding: 16px 10px;
  font-size: 17px;
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  word-break: break-word;
}
.pill.live.empty {
  background: #f6f3fb;
  color: #b0a9c4;
  font-weight: 500;
  font-size: 14px;
  box-shadow: none;
}
.status { margin: 0; font-size: 13px; color: var(--muted); min-height: 19px; text-align: center; }
.status.wait { color: var(--purple-deep); }
.status.ok { color: var(--teal-deep); font-weight: 600; }

/* ------------------------------ 开奖 ------------------------------ */
.versus { display: flex; align-items: center; gap: 10px; padding: 18px 0 6px; }
.vcol { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.vcol .who { font-size: 12px; color: var(--muted); letter-spacing: .5px; }
.vcol .pill { width: 100%; flex: 0 0 auto; }
.pill {
  flex: 1;
  min-width: 0;
  text-align: center;
  padding: 16px 10px;
  border-radius: 16px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: .5px;
  word-break: break-word;
}
.pill.big { padding: 34px 12px; font-size: 24px; animation: pop .38s cubic-bezier(.2,1.3,.4,1) both; }
.pill.purple { background: var(--purple-pill); color: var(--purple-deep); }
.pill.teal { background: var(--teal-pill); color: var(--teal-deep); }
.pill.hit { box-shadow: 0 0 0 2px rgba(47, 168, 155, .55) inset; }
@keyframes pop { from { opacity: 0; transform: scale(.86); } to { opacity: 1; transform: none; } }

.vs { color: #c9c2da; font-size: 18px; flex: 0 0 auto; }
.vs.hit { color: var(--teal); font-size: 22px; font-weight: 700; }

.revealmsg { margin: 10px 0 0; text-align: center; font-size: 21px; font-weight: 700; color: var(--ink); }
.revealmsg.hit { color: var(--teal-deep); }

/* ------------------------------ 结算 ------------------------------ */
.result-head { text-align: center; padding: 8px 4px 0; }
.result-head h1 {
  margin: 0 0 10px;
  font-size: 25px;
  font-weight: 800;
  color: #2f2745;
  letter-spacing: .5px;
}
.result-head .sub { margin: 0 0 6px; font-size: 14px; color: var(--ink-soft); line-height: 1.7; }
.result-head .sub b { color: var(--purple-deep); }
.result-head .meta { margin: 0; font-size: 12px; color: var(--muted); letter-spacing: .3px; }

.legend { display: flex; align-items: center; gap: 6px; justify-content: center; font-size: 12px; color: var(--muted); }
.legend .ldot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.legend .ldot.purple { background: #b9a8ec; }
.legend .ldot.teal { background: #8fd6cc; margin-left: 10px; }

.rounds { display: flex; flex-direction: column; gap: 12px; }
.rounds + .btnrow { margin-top: 10px; }
.round { display: flex; flex-direction: column; gap: 6px; }
.round .rlabel { font-size: 12.5px; color: var(--muted); padding-left: 4px; }
.round .rrow { display: flex; align-items: center; gap: 8px; }
.round .mark { color: #c9c2da; font-size: 15px; flex: 0 0 auto; width: 14px; text-align: center; }
.round.hit .mark { color: var(--teal); font-weight: 700; }
.round .pill { padding: 13px 10px; font-size: 16.5px; }
.round.hit .pill.purple { box-shadow: 0 0 0 1.5px rgba(122, 92, 214, .4) inset; }
.round.hit .pill.teal { box-shadow: 0 0 0 1.5px rgba(47, 168, 155, .5) inset; }

/* ------------------------------ 杂项 ------------------------------ */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(38px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  background: rgba(59, 51, 80, .94);
  color: #fff;
  font-size: 13.5px;
  padding: 11px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
  z-index: 50;
  max-width: 88vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.netbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  background: #ffd9e2;
  color: #a83c55;
  font-size: 12.5px;
  text-align: center;
  padding: calc(7px + env(safe-area-inset-top)) 10px 7px;
  z-index: 60;
}

@media (max-width: 360px) {
  .hero h1 { font-size: 27px; }
  .code { font-size: 32px; letter-spacing: 6px; }
  .pill.big { font-size: 19px; }
}
