/* 同词相遇 · 样式
   配色取自参考卡片：淡紫 + 淡青，白卡片，大圆角 */

:root {
  --brand: #10b981;
  --brand-deep: #047857;
  --brand-ink: #059669;
  --brand-soft: #d1fae5;
  --lime-soft: #ecfccb;
  --lime-ink: #4d7c0f;
  --cyan: #22d3ee;
  --cyan-ink: #0e7490;
  --cyan-soft: #c9f2fa;
  --ink: #101828;
  --muted: #6b7280;
  --line: #e4f1ea;
  --card: #ffffff;
  --danger: #f43f5e;
  --radius: 28px;
  --shadow: 0 24px 70px rgba(4, 120, 87, 0.14), 0 2px 8px rgba(16, 24, 40, 0.04);
}

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

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', 'Noto Sans SC', 'Segoe UI', system-ui, sans-serif;
  color: var(--ink);
  background: #f0fdf9;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* ---------------------------------------------------------------- 背景 */

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: linear-gradient(165deg, #f3fdf9 0%, #eefdfa 38%, #ecfdfb 68%, #f0fdf4 100%);
}

.bg .blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.55;
  animation: drift 22s ease-in-out infinite alternate;
}

.bg .b1 {
  width: 46vmax;
  height: 46vmax;
  left: -14vmax;
  top: -16vmax;
  background: radial-gradient(circle at 40% 40%, #b9f1d9, transparent 70%);
}

.bg .b2 {
  width: 40vmax;
  height: 40vmax;
  right: -12vmax;
  top: 6vmax;
  background: radial-gradient(circle at 60% 40%, #b6f0f9, transparent 70%);
  animation-delay: -7s;
}

.bg .b3 {
  width: 34vmax;
  height: 34vmax;
  left: 30%;
  bottom: -18vmax;
  background: radial-gradient(circle at 50% 50%, #c9f7d5, transparent 70%);
  animation-delay: -13s;
}

@keyframes drift {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: translate3d(3vmax, 2vmax, 0) scale(1.08);
  }
}

@media (prefers-reduced-motion: reduce) {
  .bg .blob {
    animation: none;
  }
}

/* ---------------------------------------------------------------- 布局 */

.app {
  min-height: var(--vh, 100vh);
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
}

.card {
  width: min(680px, 100%);
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(22px, 5vw, 44px);
  border: 1px solid rgba(16, 185, 129, 0.10);
  animation: rise 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
}

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

@media (prefers-reduced-motion: reduce) {
  .card {
    animation: none;
  }
}

/* ---------------------------------------------------------------- 文字 */

.brand {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: var(--brand-ink);
  text-align: center;
  margin: 0 0 18px;
  text-transform: uppercase;
}

.title {
  font-size: clamp(26px, 6.4vw, 38px);
  line-height: 1.22;
  font-weight: 800;
  letter-spacing: 0.01em;
  text-align: center;
  margin: 0 0 12px;
}

.h2 {
  font-size: clamp(20px, 5vw, 26px);
  line-height: 1.3;
  font-weight: 800;
  text-align: center;
  margin: 0 0 10px;
}

.sub {
  font-size: 14px;
  line-height: 1.7;
  color: var(--muted);
  text-align: center;
  margin: 0 0 22px;
}

.hint {
  font-size: 12px;
  color: #8fa89e;
  text-align: center;
  margin: 18px 0 0;
}

.roundtag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--brand-ink);
  background: var(--brand-soft);
  border-radius: 999px;
  padding: 6px 12px;
}

/* ---------------------------------------------------------------- 表单 */

.label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #7f9c90;
  letter-spacing: 0.08em;
  margin: 0 0 8px;
}

.input {
  width: 100%;
  height: 54px;
  border-radius: 16px;
  border: 1.5px solid var(--line);
  background: #fbfffd;
  color: var(--ink);
  font-size: 17px;
  font-family: inherit;
  padding: 0 16px;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
  -webkit-appearance: none;
}

.input::placeholder {
  color: #a9c0b7;
}

.input:focus {
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.16);
}

.input-code {
  text-transform: uppercase;
  letter-spacing: 0.34em;
  font-weight: 800;
  text-align: center;
  padding-left: 0.34em;
}

.input-word {
  font-size: 20px;
  font-weight: 700;
  height: 58px;
  text-align: center;
}

.btn {
  height: 54px;
  width: 100%;
  border: 0;
  border-radius: 16px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.18s, background 0.18s, opacity 0.18s;
  user-select: none;
}

.btn:active {
  transform: scale(0.985);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, #34d399, #0ea5a4);
  box-shadow: 0 12px 26px rgba(13, 148, 136, 0.28);
}

.btn-primary:hover {
  box-shadow: 0 14px 30px rgba(13, 148, 136, 0.34);
}

.btn-ghost {
  color: var(--brand-deep);
  background: #ecfdf5;
}

.btn-ghost:hover {
  background: #d9f9ec;
}

.btn-line {
  color: var(--muted);
  background: transparent;
  border: 1.5px solid var(--line);
}

.panel {
  display: grid;
  gap: 14px;
  margin-top: 26px;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #a9c0b7;
  font-size: 12px;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.joinrow {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.joinrow .btn {
  width: auto;
  padding: 0 22px;
}

/* ---------------------------------------------------------------- 房间码 */

.codebox {
  text-align: center;
  background: linear-gradient(180deg, #f7fefa, #effcf7);
  border: 1.5px dashed #b8f0d8;
  border-radius: 22px;
  padding: 22px 16px 18px;
  margin: 18px 0;
}

.code {
  font-size: clamp(30px, 9vw, 44px);
  font-weight: 800;
  letter-spacing: 0.22em;
  padding-left: 0.22em;
  color: var(--brand-deep);
  font-variant-numeric: tabular-nums;
}

.codeacts {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
  flex-wrap: wrap;
}

.codeacts .btn {
  width: auto;
  height: 42px;
  padding: 0 18px;
  font-size: 14px;
}

.players {
  display: grid;
  gap: 10px;
  margin-top: 6px;
}

.player {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 16px;
  background: #f8fdfa;
  border: 1.5px solid var(--line);
  font-weight: 700;
  font-size: 15px;
}

.player .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d1d5db;
  flex: none;
}

.player.on .dot {
  background: #34d399;
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.15);
}

.player.empty {
  color: #9fb8ae;
  border-style: dashed;
  font-weight: 600;
}

.player .tag {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  color: #7f9c90;
  letter-spacing: 0.08em;
}

/* ---------------------------------------------------------------- 对局 */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.timertext {
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.timertext.warn {
  color: var(--danger);
}

.timer {
  height: 6px;
  border-radius: 999px;
  background: #ecfdf5;
  overflow: hidden;
  margin-bottom: 26px;
}

.timer > i {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #34d399, #22d3ee);
  transition: width 0.12s linear, background 0.3s;
}

.timer.warn > i {
  background: linear-gradient(90deg, #fb7185, #f43f5e);
}

.pair {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  margin: 6px 0 18px;
}

.chip {
  padding: 22px 14px;
  border-radius: 18px;
  font-size: clamp(18px, 5vw, 24px);
  font-weight: 800;
  text-align: center;
  word-break: break-word;
  line-height: 1.3;
  min-height: 76px;
  display: grid;
  place-items: center;
  animation: pop 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.chip-me {
  background: var(--brand-soft);
  color: var(--brand-ink);
}

.chip-opp {
  background: var(--cyan-soft);
  color: var(--cyan-ink);
}

.chip-empty {
  color: #9fb8ae;
  font-weight: 600;
  font-size: 16px;
}

.mult {
  color: #99f6e4;
  font-size: 18px;
  font-weight: 700;
}

.chip-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  opacity: 0.6;
  margin-bottom: 6px;
}

.prompt {
  text-align: center;
  font-size: 15px;
  color: var(--muted);
  margin: 0 0 18px;
  line-height: 1.6;
}

.answer {
  display: grid;
  gap: 12px;
}

.bigword {
  font-size: clamp(28px, 8vw, 42px);
  font-weight: 800;
  text-align: center;
  color: var(--brand-ink);
  padding: 18px 0 6px;
  word-break: break-word;
}

.waiting {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
  padding: 10px 0 4px;
}

.dots {
  display: inline-flex;
  gap: 4px;
}

.dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6ee7b7;
  animation: bounce 1.1s infinite ease-in-out;
}

.dots i:nth-child(2) {
  animation-delay: 0.15s;
}

.dots i:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  40% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

.verdict {
  text-align: center;
  font-size: clamp(20px, 5.5vw, 28px);
  font-weight: 800;
  margin: 2px 0 8px;
}

.verdict.miss {
  color: #9aa1b1;
}

.verdict.hit {
  background: linear-gradient(100deg, #059669, #0e7490);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.score {
  text-align: center;
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 20px;
}

.notice {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  font-size: 12px;
  color: #b45309;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 12px;
  padding: 8px 12px;
  margin-top: 16px;
}

.conn {
  text-align: center;
  font-size: 11px;
  color: #9fb8ae;
  margin-top: 18px;
  letter-spacing: 0.06em;
}

.conn.off {
  color: #d97706;
}

/* 揭晓大词 */
.big-pair .chip {
  min-height: 92px;
  font-size: clamp(20px, 6vw, 28px);
}

/* 历史 */
.history {
  margin-top: 26px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.history h3 {
  font-size: 12px;
  letter-spacing: 0.14em;
  color: #7f9c90;
  font-weight: 800;
  margin: 0 0 12px;
}

.hrow {
  display: grid;
  grid-template-columns: 46px 1fr;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
}

.hrow .words {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hrow .n {
  color: #9fb8ae;
  font-weight: 700;
  font-size: 11px;
}

.hrow .w {
  flex: 1;
  background: #f8fdfa;
  border-radius: 10px;
  padding: 8px 10px;
  text-align: center;
  font-weight: 700;
  color: #4b5563;
  word-break: break-word;
}

.hrow.hit .w {
  background: linear-gradient(135deg, #d1fae5, #c9f2fa);
  color: var(--brand-deep);
}

.hrow .x {
  color: #cdeee0;
  font-size: 12px;
}

/* ---------------------------------------------------------------- 提示 */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  background: rgba(17, 24, 39, 0.92);
  color: #fff;
  font-size: 14px;
  padding: 12px 18px;
  border-radius: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s;
  max-width: min(90vw, 420px);
  text-align: center;
  z-index: 60;
  backdrop-filter: blur(6px);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

#confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------------------------------------------------------- 窄屏 */

@media (max-width: 420px) {
  .card {
    padding: 22px 18px 26px;
    border-radius: 24px;
  }
  .pair {
    gap: 7px;
  }
  .chip {
    padding: 16px 8px;
    min-height: 64px;
    border-radius: 15px;
  }
  .mult {
    font-size: 15px;
  }
  .btn,
  .input {
    height: 50px;
  }
  .input-word {
    height: 54px;
    font-size: 18px;
  }
  .joinrow {
    grid-template-columns: 1fr;
  }
  .joinrow .btn {
    width: 100%;
  }
}

/* 桌面：给卡片一点呼吸感 */
@media (min-width: 760px) and (min-height: 820px) {
  .card {
    padding: 48px 52px;
  }
}

/* 标题在窄屏换行 */
.br-m {
  display: none;
}

@media (max-width: 560px) {
  .br-m {
    display: inline;
  }
}

/* ---------------------------------------------------------------- 密钥门禁 */

.gate-price {
  text-align: center;
  font-size: clamp(17px, 4.6vw, 21px);
  font-weight: 800;
  color: var(--brand-deep);
  background: linear-gradient(135deg, #ecfdf5, #e0fbf6);
  border-radius: 16px;
  padding: 13px;
  margin: 0 0 18px;
  letter-spacing: 0.02em;
}

.gate {
  display: grid;
  gap: 12px;
  margin-top: 6px;
}

.gate-help {
  text-align: center;
  font-size: 13px;
  line-height: 1.7;
  color: var(--muted);
  margin: 8px 0 0;
}

.gate-help .wechat {
  color: var(--brand-ink);
  letter-spacing: 0.02em;
}

.gate-note {
  text-align: center;
  font-size: 12px;
  line-height: 1.7;
  color: #8fa89e;
  margin: 2px 0 0;
}

.input-key {
  text-align: center;
  letter-spacing: 0.16em;
  font-weight: 800;
  text-transform: uppercase;
  font-size: 19px;
  padding-left: 0.16em;
}

.linklike {
  display: block;
  width: 100%;
  margin: 20px auto 0;
  padding: 8px;
  background: none;
  border: 0;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}

.linklike:hover {
  color: var(--brand-ink);
}

.keychip {
  text-align: center;
  font-size: 12px;
  color: #7f9c90;
  margin: 8px 0 0;
  letter-spacing: 0.04em;
}

.paywall {
  margin-top: 12px;
  padding: 20px 16px;
  border-radius: 20px;
  background: linear-gradient(180deg, #f8fefa, #ecfdf5);
  border: 1.5px dashed #b8f0d8;
  text-align: center;
}

.paywall b {
  display: block;
  font-size: 17px;
  color: var(--brand-deep);
  margin-bottom: 6px;
}

.paywall p {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 14px;
}

.paywall .btn + .hint {
  margin-top: 10px;
}


/* ---------------------------------------------------------------- 三人模式 */

.trio {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 6px 0 18px;
}

.trio .chip {
  font-size: clamp(15px, 4.2vw, 20px);
  padding: 14px 8px;
  min-height: 66px;
  border-radius: 16px;
}

.trio .chip .chip-label {
  font-size: 10px;
  margin-bottom: 4px;
  letter-spacing: 0.06em;
}

.trio.big-pair .chip {
  min-height: 86px;
  font-size: clamp(16px, 4.6vw, 22px);
}

.chip-third {
  background: var(--lime-soft);
  color: var(--lime-ink);
}

/* 人数选择 */
.mode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mode-opt {
  display: grid;
  gap: 3px;
  border: 1.5px solid var(--line);
  background: #fbfffd;
  border-radius: 16px;
  padding: 13px 10px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  color: #4b5563;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s, box-shadow 0.18s;
}

.mode-opt span {
  font-size: 11px;
  font-weight: 600;
  color: #9fb8ae;
}

.mode-opt.on {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-deep);
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.16);
}

.mode-opt.on span {
  color: #047857;
}

/* 提交状态 */
.statuses {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 12px;
}

.pill {
  font-size: 12px;
  padding: 5px 11px;
  border-radius: 999px;
  background: #f2faf6;
  color: #7f9c90;
}

.pill.on {
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-weight: 700;
}


/* ---------------------------------------------------------------- 战报弹层 */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.55);
  opacity: 0;
  transition: opacity 0.2s;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sheet.on {
  opacity: 1;
}

.sheet-card {
  width: min(440px, 100%);
  background: #fff;
  border-radius: 24px;
  padding: 16px;
  display: grid;
  gap: 12px;
  box-shadow: 0 30px 80px rgba(4, 120, 87, 0.3);
}

.sheet-card img {
  display: block;
  width: 100%;
  border-radius: 16px;
}

.sheet-tip {
  margin: 0;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.sheet-card .btn {
  height: 48px;
  display: grid;
  place-items: center;
  text-decoration: none;
}
