/* ============================================================
   心有灵犀 · 网页版
   风格：漫画描边 / 明亮马卡龙（还原原版小程序设计）
   ============================================================ */

:root {
  /* 原版配色 */
  --ink:      #2b3445;   /* 描边深色 */
  --blue:     #4aa8ff;
  --blue-lt:  #65b8ff;
  --pink:     #ff7ab6;
  --green:    #49cf6f;
  --green-lt: #8be3a4;
  --yellow:   #ffc837;
  --yellow-lt:#ffdd67;
  --orange:   #ff8c38;
  --orange-lt:#ffc384;
  --red:      #ff5c62;
  --red-lt:   #ff9ea1;

  --paper:    #fff;
  --cream:    #fff8c7;
  --sky:      #f7fbff;
  --text:     #2b3445;
  --text-2:   #555;
  --text-3:   #888;

  --r:    28px;
  --r-s:  20px;
  --r-xs: 16px;

  --font: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100vh;
  background: linear-gradient(135deg, #c7f0ff, #ffe7f6, #fff8c7);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  padding: 20px 16px 48px;
}

/* ============================================================
   顶栏
   ============================================================ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  max-width: 720px;
  margin: 0 auto 22px;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

/* Logo 图片 */
.brand-logo {
  width: 62px; height: 62px;
  flex: none;
  object-fit: cover;
  border-radius: var(--r-xs);
  border: 3px solid var(--ink);
  background: #fff;
  box-shadow: 0 4px 0 var(--ink);
}

.brand-txt { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-txt strong {
  font-size: 19px;
  font-weight: 900;
  color: var(--ink);
  letter-spacing: .02em;
}
.brand-txt small {
  font-size: 11.5px;
  color: var(--text-2);
  margin-top: 2px;
}

.room-badge {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 15px;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 30px;
  box-shadow: 0 4px 0 var(--ink);
  white-space: nowrap;
}
.room-badge[hidden] { display: none; }
.rb-label { font-size: 11px; color: var(--text-2); }
.rb-num {
  font-size: 16px;
  font-weight: 900;
  color: var(--blue);
  letter-spacing: .08em;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   主容器
   ============================================================ */
.app {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.screen { display: flex; flex-direction: column; gap: 20px; }
.screen[hidden] { display: none; }

/* ============================================================
   首页
   ============================================================ */
.hero { text-align: center; padding: 4px 0 2px; }

.hero h1 {
  display: inline-block;
  padding: 16px 32px;
  font-size: clamp(26px, 7vw, 36px);
  font-weight: 900;
  color: #fff;
  letter-spacing: .06em;
  background: linear-gradient(90deg, var(--blue), var(--pink));
  border: 6px solid var(--ink);
  border-radius: var(--r-xs);
  box-shadow: 0 10px 0 var(--ink);
  margin-bottom: 14px;
}
.hero h1 span { color: #fff; }

.hero p {
  font-size: 14px;
  color: var(--text-2);
  font-weight: 500;
}

/* ============================================================
   卡片（漫画描边）
   ============================================================ */
.card {
  background: #fff;
  border: 4px solid var(--ink);
  border-radius: var(--r);
  padding: 24px;
  box-shadow: 0 10px 0 var(--ink);
}

.card-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 17px;
  font-weight: 900;
  color: var(--ink);
  margin-bottom: 16px;
}
.card-title svg { width: 18px; height: 18px; color: var(--orange); }

/* ============================================================
   表单
   ============================================================ */
.field { display: block; margin-bottom: 16px; }

.field-label {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 7px;
}
.field-label em { font-style: normal; font-weight: 400; color: var(--text-3); font-size: 12px; }

input, textarea {
  width: 100%;
  padding: 15px 18px;
  font-family: var(--font);
  font-size: 16px;
  color: var(--ink);
  background: var(--sky);
  border: 3px solid var(--ink);
  border-radius: var(--r-s);
  outline: none;
  transition: border-color .18s, box-shadow .18s, background .18s;
  -webkit-appearance: none;
}
textarea { resize: vertical; line-height: 1.7; font-size: 15px; }
input::placeholder, textarea::placeholder { color: #9ab; }
input:focus, textarea:focus {
  border-color: var(--blue);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(74,168,255,.22);
}
input:disabled { opacity: .5; background: #eef3f7; }

/* ============================================================
   Tab
   ============================================================ */
.tab-row {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}
.tab {
  flex: 1;
  padding: 13px 10px;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-2);
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: var(--r-s);
  cursor: pointer;
  transition: all .18s;
  box-shadow: 0 5px 0 var(--ink);
}
.tab.active {
  color: #fff;
  background: linear-gradient(180deg, var(--blue-lt), var(--blue));
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--ink);
}
.tab:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--ink); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ============================================================
   分段按钮
   ============================================================ */
.seg-row { display: flex; gap: 10px; }
.seg {
  flex: 1;
  padding: 12px 8px;
  font-family: var(--font);
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-2);
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: var(--r-xs);
  cursor: pointer;
  transition: all .18s;
  box-shadow: 0 4px 0 var(--ink);
}
.seg.active {
  color: var(--ink);
  background: linear-gradient(180deg, var(--yellow-lt), var(--yellow));
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--ink);
}

/* ============================================================
   按钮（漫画描边）
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 9px;
  width: 100%;
  padding: 16px 22px;
  font-family: var(--font);
  font-size: 16.5px;
  font-weight: 900;
  color: #fff;
  border: 3px solid var(--ink);
  border-radius: var(--r-s);
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 6px 0 var(--ink);
}
.btn svg { width: 18px; height: 18px; }
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(180deg, var(--blue-lt), var(--blue));
}
.btn-success {
  background: linear-gradient(180deg, var(--green-lt), var(--green));
}
.btn-danger {
  background: linear-gradient(180deg, var(--red-lt), var(--red));
}
.btn-ghost {
  background: linear-gradient(180deg, #fff, #eef3f7);
  color: var(--ink);
}
.btn-sm { width: auto; padding: 15px 26px; font-size: 15.5px; }
.btn-block { width: 100%; }

.btn-row { display: flex; gap: 12px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; min-width: 0; }

/* ============================================================
   提示
   ============================================================ */
.hint {
  display: flex; align-items: flex-start; gap: 8px;
  margin-top: 14px;
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.65;
}
.hint svg { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--blue); }

/* 规则 */
.rules {
  background: #fff;
  border: 4px solid var(--ink);
  border-radius: var(--r);
  padding: 22px;
  box-shadow: 0 10px 0 var(--ink);
}
.rules h3 {
  font-size: 16px;
  font-weight: 900;
  color: var(--ink);
  margin-bottom: 12px;
}
.rules ol { padding-left: 22px; }
.rules li {
  font-size: 14px;
  color: var(--text-2);
  line-height: 2;
}
.rules li b { color: var(--pink); font-weight: 900; }

/* ============================================================
   游戏页
   ============================================================ */
.room-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px;
  padding-bottom: 16px;
  border-bottom: 3px dashed #dde;
  margin-bottom: 16px;
}
.room-label {
  font-size: 12px; font-weight: 700;
  color: var(--text-3);
}
.room-value {
  font-size: 28px;
  font-weight: 900;
  color: var(--blue);
  letter-spacing: .1em;
  font-variant-numeric: tabular-nums;
}

.share-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 11px 18px;
  font-family: var(--font);
  font-size: 14px; font-weight: 900;
  color: var(--ink);
  background: linear-gradient(180deg, var(--yellow-lt), var(--yellow));
  border: 3px solid var(--ink);
  border-radius: 30px;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--ink);
  transition: transform .12s, box-shadow .12s;
  white-space: nowrap;
}
.share-btn svg { width: 16px; height: 16px; }
.share-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }

.player-row { margin-bottom: 14px; }
.player-label {
  display: block;
  font-size: 12px; font-weight: 700;
  color: var(--text-3);
  margin-bottom: 9px;
}
.player-chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 14px 5px 5px;
  font-size: 14px; font-weight: 700;
  color: var(--ink);
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 30px;
}
.chip.me {
  background: linear-gradient(180deg, #ffe9f4, #ffd6ec);
}
.chip-avatar {
  width: 26px; height: 26px;
  flex: none;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 900;
  color: #fff;
  border: 2px solid var(--ink);
  border-radius: 50%;
}
.chip .crown { font-size: 12px; }

.room-meta {
  display: flex; gap: 22px;
  font-size: 14px;
  color: var(--text-2);
}
.room-meta b { color: var(--ink); font-weight: 900; }

/* ============================================================
   倒计时
   ============================================================ */
.countdown {
  padding: 24px;
  background: linear-gradient(180deg, #ffd6d6, var(--red-lt));
  border: 4px solid var(--ink);
  border-radius: var(--r);
  box-shadow: 0 10px 0 var(--ink);
  text-align: center;
}
.cd-waiting {
  font-size: 16px; font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0,0,0,.25);
}
.cd-waiting[hidden] { display: none; }
.cd-running[hidden] { display: none; }

.cd-ring {
  position: relative;
  width: 160px; height: 160px;
  margin: 0 auto 12px;
}
.cd-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.cd-bg { fill: none; stroke: rgba(255,255,255,.5); stroke-width: 9; }
.cd-fg {
  fill: none;
  stroke: #fff;
  stroke-width: 9;
  stroke-linecap: round;
  stroke-dasharray: 327;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset .9s linear;
}
.cd-num {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  line-height: 1;
}
.cd-num b {
  font-size: 52px; font-weight: 900;
  color: #fff;
  text-shadow: 0 3px 0 rgba(0,0,0,.18);
  font-variant-numeric: tabular-nums;
}
.cd-num span { font-size: 13px; color: rgba(255,255,255,.9); margin-top: 4px; font-weight: 700; }
.cd-hint {
  font-size: 14px; font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.2);
}

/* ============================================================
   提交
   ============================================================ */
.submit-row { display: flex; gap: 12px; }
.submit-row input { flex: 1; }

.submit-tip {
  margin-top: 14px;
  padding: 13px 16px;
  font-size: 14px; font-weight: 700;
  color: #1f8f46;
  background: #eaffea;
  border-left: 6px solid var(--green);
  border-radius: 12px;
}
.submit-tip[hidden] { display: none; }
.submit-tip.warn {
  color: #a15c00;
  background: #fff6e0;
  border-left-color: var(--orange);
}

/* ============================================================
   上一轮 / 揭晓
   ============================================================ */
.last-words, .reveal-list { display: flex; flex-direction: column; gap: 9px; }

.word-line {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  font-size: 15px;
  background: var(--sky);
  border: 3px solid var(--ink);
  border-radius: var(--r-xs);
}
.word-line .w-name {
  flex: none;
  font-size: 13px; font-weight: 700;
  color: var(--text-2);
}
.word-line .w-word {
  color: var(--ink); font-weight: 900;
}
.word-line.same {
  background: #eaffea;
  border-color: var(--green);
}
.word-line.same .w-word { color: #1f8f46; }

.empty-tip {
  padding: 18px;
  text-align: center;
  font-size: 14px;
  color: var(--text-3);
}

/* 揭晓 */
.reveal-card {
  background: linear-gradient(180deg, #fffdf0, #fff8e0);
}
.reveal-verdict {
  text-align: center;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: .04em;
  margin-bottom: 18px;
  line-height: 1.4;
}
.reveal-verdict.win { color: #1f8f46; }
.reveal-verdict.lose { color: #d97706; }
.reveal-verdict small {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  margin-top: 7px;
  letter-spacing: 0;
}

/* ============================================================
   排行榜
   ============================================================ */
.score-list { display: flex; flex-direction: column; }

.score-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 4px;
  border-bottom: 2px dashed #dde;
  font-size: 15px;
}
.score-item:last-child { border-bottom: 0; }

.score-rank {
  flex: none;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 900;
  color: var(--text-3);
  background: #eef3f7;
  border: 2px solid var(--ink);
  border-radius: 8px;
}
.score-item.top .score-rank {
  color: #fff;
  background: linear-gradient(180deg, var(--yellow-lt), var(--yellow));
}
.score-name { flex: 1; font-weight: 700; color: var(--ink); }
.score-val {
  font-size: 19px;
  font-weight: 900;
  color: #ff6622;
  font-variant-numeric: tabular-nums;
}
.score-item.top .score-val { color: #e07800; }

/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 44px;
  transform: translateX(-50%) translateY(20px);
  z-index: 999;
  max-width: calc(100vw - 48px);
  padding: 14px 26px;
  font-size: 15px;
  font-weight: 800;
  text-align: center;
  color: var(--ink);
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 30px;
  box-shadow: 0 6px 0 var(--ink);
  opacity: 0;
  pointer-events: none;
  transition: opacity .24s, transform .24s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: #ffe9e9; }
.toast.ok { background: #eaffea; }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 420px) {
  body { padding: 16px 12px 40px; }
  .card { padding: 20px; border-radius: 24px; box-shadow: 0 8px 0 var(--ink); }
  .brand-logo { width: 54px; height: 54px; }
  .brand-txt strong { font-size: 17px; }
  .brand-txt small { font-size: 10.5px; }
  .cd-ring { width: 140px; height: 140px; }
  .cd-num b { font-size: 44px; }
  .room-value { font-size: 24px; }
  .btn-row { flex-direction: column; }
  .submit-row { flex-direction: column; }
  .btn-sm { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ============================================================
   邀请弹窗（漫画风）
   ============================================================ */
.invite-modal {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.invite-modal[hidden] { display: none; }

.invite-mask {
  position: absolute;
  inset: 0;
  background: rgba(43, 52, 69, 0.55);
  backdrop-filter: blur(3px);
  animation: fadeIn .25s ease;
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }

.invite-panel {
  position: relative;
  width: min(400px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 26px 24px 22px;
  background: #fff;
  border: 4px solid var(--ink);
  border-radius: 28px;
  box-shadow: 0 12px 0 var(--ink);
  animation: popIn .32s cubic-bezier(.34, 1.4, .5, 1);
  text-align: center;
}
@keyframes popIn {
  from { opacity: 0; transform: translateY(24px) scale(.94); }
  to   { opacity: 1; transform: none; }
}

.invite-close {
  position: absolute;
  top: 14px; right: 14px;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  color: var(--text-2);
  background: #f0f4f8;
  border: 2px solid var(--ink);
  border-radius: 50%;
  cursor: pointer;
  transition: transform .12s, background .18s;
}
.invite-close:hover { background: #e2e9f0; }
.invite-close:active { transform: scale(.92); }
.invite-close svg { width: 15px; height: 15px; }

.invite-title {
  font-size: 21px;
  font-weight: 900;
  color: var(--ink);
  margin-bottom: 20px;
  letter-spacing: .03em;
}

/* 二维码容器 */
.invite-qr {
  width: 216px;
  height: 216px;
  margin: 0 auto 14px;
  padding: 12px;
  background: #fff;
  border: 4px solid var(--ink);
  border-radius: 20px;
  box-shadow: 0 6px 0 var(--ink);
  display: grid;
  place-items: center;
}
.invite-qr img,
.invite-qr canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  image-rendering: pixelated;
}
.qr-loading {
  font-size: 13px;
  color: var(--text-3);
  font-weight: 700;
}
.qr-error {
  font-size: 13px;
  color: var(--red);
  font-weight: 700;
  line-height: 1.6;
}

.invite-tip {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-2);
  margin-bottom: 18px;
}

/* 房间信息 */
.invite-info {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}
.ii-row {
  flex: 1;
  padding: 11px 8px;
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 14px;
}
.ii-key {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  margin-bottom: 3px;
}
.ii-val {
  display: block;
  font-size: 18px;
  font-weight: 900;
  color: var(--ink);
  letter-spacing: .06em;
  font-variant-numeric: tabular-nums;
}

/* 链接输入框 */
.invite-link-wrap { margin-bottom: 16px; }
#inviteLink {
  width: 100%;
  padding: 12px 14px;
  font-family: var(--font);
  font-size: 12.5px;
  color: var(--text-2);
  background: var(--sky);
  border: 3px solid var(--ink);
  border-radius: 14px;
  text-align: center;
  outline: none;
}

/* 按钮组 */
.invite-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

@media (max-width: 420px) {
  .invite-panel { padding: 22px 18px 18px; border-radius: 24px; box-shadow: 0 8px 0 var(--ink); }
  .invite-title { font-size: 19px; }
  .invite-qr { width: 190px; height: 190px; }
  .ii-val { font-size: 16px; }
}

/* ============================================================
   扫码入房提示条
   ============================================================ */
.join-notice {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 15px 18px;
  background: linear-gradient(180deg, #e4f7ff, #d0ecff);
  border: 4px solid var(--ink);
  border-radius: var(--r-s);
  box-shadow: 0 7px 0 var(--ink);
  animation: noticeIn .5s cubic-bezier(.34, 1.4, .5, 1);
}
.join-notice[hidden] { display: none; }

@keyframes noticeIn {
  from { opacity: 0; transform: translateY(-14px); }
  to   { opacity: 1; transform: none; }
}

.jn-ic {
  width: 36px; height: 36px;
  flex: none;
  display: grid; place-items: center;
  color: #fff;
  background: linear-gradient(180deg, var(--green-lt), var(--green));
  border: 3px solid var(--ink);
  border-radius: 50%;
}
.jn-ic svg { width: 18px; height: 18px; }

.jn-body { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.jn-body strong {
  font-size: 15px;
  font-weight: 900;
  color: var(--ink);
}
.jn-body .jn-room {
  color: var(--blue);
  letter-spacing: .06em;
  font-variant-numeric: tabular-nums;
}
.jn-body span:last-child {
  font-size: 12.5px;
  color: var(--text-2);
  margin-top: 2px;
}


/* ============================================================
   同步状态提示（网络不稳）
   ============================================================ */
.sync-state {
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 800;
  color: #a15c00;
  text-align: center;
  background: #fff6e0;
  border: 3px solid var(--orange);
  border-radius: var(--r-xs);
  animation: syncPulse 1.6s ease-in-out infinite;
}
.sync-state[hidden] { display: none; }

@keyframes syncPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .55; }
}


/* 换设备提示（高亮版） */
.hint-key {
  padding: 12px 15px;
  background: #fff6e0;
  border: 3px solid var(--orange);
  border-radius: 14px;
  border-left-width: 3px;
}
.hint-key svg { color: var(--orange); }
.hint-key b { color: var(--ink); font-weight: 900; }

