/* ============================================================
   同词相遇 · 情侣默契实时小游戏
   独立游戏样式，仅作用于本页；主题变量与主站保持一致
   ============================================================ */
:root {
  color-scheme: light;
  --pri: #d9566f;
  --pri-deep: #c94a64;
  --pri-soft: rgba(217, 86, 111, .08);
  --pl: #f3b9c5;
  --tx: #2f2a2e;
  --tl: #8a8088;
  --bg: #faf7f4;
  --card: #ffffff;
  --soft: #f4efeb;
  --line: rgba(47, 42, 46, .08);
  --line2: rgba(47, 42, 46, .05);
  --shadow: 0 4px 18px rgba(47, 42, 46, .06);
  --shadow-lg: 0 16px 40px rgba(47, 42, 46, .12);
  --ok: #4f9d7a;
  --gold: #c99a3a;
  /* 双方配色：A 紫、B 绿，呼应默契报告 */
  --a: #6f6a8c;
  --a-soft: #ecebf5;
  --b: #4f9d7a;
  --b-soft: #e6f3ec;
  --r: 20px;
  --rs: 16px;
}
[data-theme="dark"] {
  color-scheme: dark;
  --pri: #ee7f95;
  --pri-deep: #f093a5;
  --pri-soft: rgba(238, 127, 149, .14);
  --pl: #b5736c;
  --tx: #f1ecea;
  --tl: #a39a9f;
  --bg: #1d1a1c;
  --card: #272326;
  --soft: #302b2f;
  --line: rgba(255, 255, 255, .08);
  --line2: rgba(255, 255, 255, .05);
  --shadow: 0 4px 18px rgba(0, 0, 0, .35);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, .5);
  --ok: #74c0a0;
  --gold: #dcb35a;
  --a: #a99fd6;
  --a-soft: rgba(169, 159, 214, .16);
  --b: #74c0a0;
  --b-soft: rgba(116, 192, 160, .16);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  min-height: 100dvh;
  overflow-x: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--tx);
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(70% 36% at 50% -6%, rgba(255, 199, 216, .38), transparent 72%),
    radial-gradient(40% 24% at 100% 22%, rgba(210, 235, 215, .26), transparent 70%);
}
[data-theme="dark"] body::before {
  background:
    radial-gradient(70% 36% at 50% -6%, rgba(238, 127, 149, .12), transparent 72%),
    radial-gradient(40% 24% at 100% 22%, rgba(116, 192, 160, .08), transparent 70%);
}
.bg-deco { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.bg-deco span {
  position: absolute;
  color: var(--pri);
  opacity: .1;
  font-size: 16px;
  animation: bgFloat var(--dur, 8s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}
@keyframes bgFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); opacity: .06; }
  50% { transform: translateY(-18px) rotate(12deg); opacity: .16; }
}
button, a, input { font-family: inherit; }
button { color: inherit; cursor: pointer; }
svg { display: block; }
a { color: inherit; text-decoration: none; }

/* 布局 */
.app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 14px 14px calc(30px + env(safe-area-inset-bottom));
}

/* 顶栏 */
.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.icon-btn {
  width: 38px; height: 38px; flex: 0 0 38px;
  border-radius: 12px; border: 1px solid var(--line2);
  background: var(--card); color: var(--pri);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
}
.icon-btn svg { width: 19px; height: 19px; }
.brand { flex: 1; min-width: 0; }
.brand-eyebrow { font-size: .54em; font-weight: 800; letter-spacing: 2px; color: var(--tl); opacity: .7; }
.brand h1 { font-size: 1.28em; font-weight: 800; letter-spacing: .5px; color: var(--tx); line-height: 1.2; }
.couple { font-size: .72em; color: var(--tl); margin-top: 2px; }
.couple .x { margin: 0 6px; color: var(--pri); }
.couple span:first-child { color: var(--a); font-weight: 700; }
.couple span:last-child { color: var(--b); font-weight: 700; }
/* 头部双人头像 + 虚线旋转环（与首页 / 爱情树页同款） */
.couple { display: flex; align-items: center; gap: 5px; }
.couple #nameA, .couple #nameB { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.couple-av { position: relative; width: 26px; height: 26px; flex: none; }
.couple-av img {
  position: absolute; inset: 3px; width: 20px; height: 20px; z-index: 1;
  border-radius: 50%; object-fit: cover; background: var(--pri-soft);
}
.couple-av b {
  position: absolute; inset: 3px;
  display: grid; place-items: center;
  border-radius: 50%; background: var(--pri-soft); color: var(--pri);
  font-size: 11px; font-weight: 800;
}
.couple-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px dashed var(--pl); opacity: .8; pointer-events: none;
}
.couple-ring.a { animation: coupleRingSpin 16s linear infinite; }
.couple-ring.b { animation: coupleRingSpin 20s linear infinite reverse; }
@keyframes coupleRingSpin { to { transform: rotate(360deg); } }
.top-actions { display: flex; gap: 8px; }
.theme-sun { display: none; }
[data-theme="dark"] .theme-moon { display: none; }
[data-theme="dark"] .theme-sun { display: block; }

/* 通用卡片 */
.screen { animation: fadeUp .35s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.panel {
  background: var(--card);
  border: 1px solid var(--line2);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 14px;
}
.panel.center { text-align: center; }

/* 首页 */
.hero-card {
  position: relative; overflow: hidden;
  border-radius: var(--r);
  background: radial-gradient(120% 150% at 100% 0%, rgba(210, 235, 215, .5), transparent 58%), linear-gradient(135deg, #fffaf8, #fff);
  border: 1px solid var(--line2);
  box-shadow: var(--shadow);
  padding: 22px 20px;
  margin-bottom: 14px;
  text-align: center;
}
[data-theme="dark"] .hero-card { background: radial-gradient(120% 150% at 100% 0%, rgba(116, 192, 160, .14), transparent 58%), linear-gradient(135deg, #2b2629, #272326); }
.hero-emoji { font-size: 2.6em; line-height: 1; margin-bottom: 8px; filter: drop-shadow(0 6px 10px rgba(47, 42, 46, .14)); }
.hero-title { font-size: 1.16em; font-weight: 800; color: var(--tx); letter-spacing: .3px; }
.hero-sub { font-size: .8em; line-height: 1.8; color: var(--tl); margin-top: 8px; }
.hero-sub b { color: var(--pri); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: .72em; font-weight: 700; color: var(--tl); margin-bottom: 6px; }
.field input, .join-row input, .answer-box input {
  width: 100%; border: 1px solid var(--line); border-radius: 12px;
  background: var(--soft); color: var(--tx);
  padding: 12px 14px; font-size: .95em; outline: none;
  transition: border-color .2s, background .2s;
}
.field input:focus, .join-row input:focus, .answer-box input:focus { border-color: var(--pri); background: var(--card); }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; padding: 13px 16px; border: none; border-radius: 999px;
  font-size: .92em; font-weight: 700; transition: transform .12s, box-shadow .2s, opacity .2s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--pri); color: #fff; box-shadow: 0 6px 16px rgba(217, 86, 111, .25); }
.btn-primary[disabled] { opacity: .5; pointer-events: none; }
.btn-ghost { background: var(--soft); color: var(--tx); border: 1px solid var(--line); }
.btn-copy { background: var(--prisoft, var(--pri-soft)); color: var(--pri); margin-top: 12px; }
.btn-ico { font-size: 1em; }

.divider { display: flex; align-items: center; gap: 10px; margin: 16px 0; color: var(--tl); font-size: .7em; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.join-row { display: flex; gap: 10px; }
.join-row input { flex: 1; text-transform: uppercase; letter-spacing: 2px; }
.join-row .btn { width: auto; padding: 12px 22px; flex: 0 0 auto; }

.status-line { text-align: center; font-size: .76em; color: var(--tl); min-height: 1.2em; }
.status-line.err { color: var(--pri); }

/* 大厅 */
.lobby-emoji { font-size: 2.4em; margin-bottom: 6px; }
.lobby-title { font-size: 1.1em; font-weight: 800; color: var(--tx); }
.lobby-sub { font-size: .78em; line-height: 1.75; color: var(--tl); margin: 8px auto 16px; max-width: 300px; }
.room-code {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 2.4em; font-weight: 800; letter-spacing: 10px;
  color: var(--pri); background: var(--pri-soft);
  border-radius: var(--rs); padding: 14px 0 14px 10px; text-align: center;
}
.conn-hint { margin-top: 14px; font-size: .76em; color: var(--tl); display: flex; align-items: center; justify-content: center; gap: 8px; }
.conn-hint::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); animation: pulse 1.2s infinite; }
.conn-hint.on::before { background: var(--ok); animation: none; }
@keyframes pulse { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }
.link-back { display: block; width: 100%; background: none; border: none; color: var(--tl); font-size: .82em; padding: 6px; }

/* 对局 */
.round-panel { text-align: center; }
.round-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.round-badge { font-size: .74em; font-weight: 700; color: var(--pri); background: var(--pri-soft); border-radius: 999px; padding: 5px 12px; }
.round-badge b { font-size: 1.15em; }
.round-room { font-size: .68em; color: var(--tl); font-family: Consolas, monospace; letter-spacing: 1px; }
.prompt-label { font-size: .62em; letter-spacing: 1.5px; font-weight: 800; color: var(--tl); }
.prompt { font-size: 1.16em; font-weight: 800; color: var(--tx); line-height: 1.5; margin: 8px 0 6px; }
.prompt-tip { font-size: .72em; color: var(--tl); margin-bottom: 18px; }
.answer-box { display: flex; gap: 10px; }
.answer-box input { flex: 1; }
.answer-box .btn { width: auto; padding: 12px 22px; flex: 0 0 auto; }
.waiting { margin-top: 14px; font-size: .8em; color: var(--tl); display: flex; align-items: center; justify-content: center; gap: 8px; }
.waiting::before { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--pri); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 本轮揭晓 */
.reveal {
  background: var(--card); border: 1px solid var(--line2); border-radius: var(--r);
  box-shadow: var(--shadow-lg); padding: 20px 18px; margin-bottom: 14px; text-align: center;
  animation: pop .3s ease;
}
@keyframes pop { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
.reveal-round { font-size: .7em; color: var(--tl); margin-bottom: 12px; }
.reveal-row { display: flex; align-items: center; justify-content: center; gap: 12px; }
.word-pill {
  flex: 1; max-width: 150px; padding: 14px 8px; border-radius: 14px;
  font-size: 1.05em; font-weight: 800; word-break: break-all;
}
.word-pill.a { color: var(--a); background: var(--a-soft); }
.word-pill.b { color: var(--b); background: var(--b-soft); }
.reveal-mark { font-size: 1.4em; font-weight: 800; color: var(--tl); flex: 0 0 auto; }
.reveal-mark.ok { color: var(--ok); }
.reveal-note { margin-top: 14px; font-size: .78em; color: var(--tl); }
.reveal-note.ok { color: var(--ok); font-weight: 700; }

/* 轮次记录：对局中累积显示 */
.round-log {
  background: var(--card); border: 1px solid var(--line2); border-radius: var(--r);
  box-shadow: var(--shadow); padding: 16px 16px 14px; margin-bottom: 14px;
}
.round-log-title { font-size: .62em; letter-spacing: 1.5px; font-weight: 800; color: var(--tl); margin-bottom: 12px; }
.round-log-list { display: flex; flex-direction: column; gap: 10px; }
.round-log-list .word-pill { font-size: .86em; padding: 10px 8px; }
.round-log-list .report-round { flex: 0 0 38px; }
.round-log-list .report-mark { flex: 0 0 16px; font-size: .9em; }

.round-foot { text-align: center; }
.link-quiet { background: none; border: none; color: var(--tl); font-size: .78em; text-decoration: underline; }
.link-quiet.is-waiting { color: var(--pri); opacity: .78; text-decoration: none; }

/* 结束确认弹窗 */
.dialog-mask {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 24px; background: rgba(31, 26, 29, .48);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  animation: fadeUp .2s ease;
}
.dialog {
  width: 100%; max-width: 320px; text-align: center;
  background: var(--card); border: 1px solid var(--line2);
  border-radius: var(--r); box-shadow: var(--shadow-lg); padding: 24px 20px 18px;
}
.dialog-emoji { font-size: 2.2em; margin-bottom: 8px; }
.dialog-text { font-size: .96em; font-weight: 700; color: var(--tx); line-height: 1.6; }
.dialog-sub { font-size: .76em; color: var(--tl); line-height: 1.6; margin-top: 6px; }
.dialog-actions { display: flex; gap: 10px; margin-top: 20px; }
.dialog-actions .btn { padding: 12px 10px; font-size: .86em; }

/* 结果报告 */
.report {
  background: var(--card); border: 1px solid var(--line2); border-radius: var(--r);
  box-shadow: var(--shadow); padding: 22px 18px; margin-bottom: 16px;
}
.report-title { font-size: 1.32em; font-weight: 800; color: var(--pri); text-align: center; letter-spacing: .5px; }
.report-sub { font-size: .84em; color: var(--tx); text-align: center; margin-top: 8px; }
.report-sub b { color: var(--pri); }
.report-meta { font-size: .68em; color: var(--tl); text-align: center; margin: 8px 0 18px; font-family: Consolas, monospace; letter-spacing: .5px; }
.report-list { display: flex; flex-direction: column; gap: 10px; }
.report-row { display: flex; align-items: center; gap: 8px; }
.report-round { font-size: .62em; color: var(--tl); flex: 0 0 40px; }
.report-row .word-pill { flex: 1; max-width: none; padding: 11px 8px; font-size: .92em; }
.report-mark { flex: 0 0 18px; text-align: center; font-weight: 800; color: var(--tl); font-size: .95em; }
.report-mark.ok { color: var(--ok); }
.report-row.hit .word-pill { box-shadow: 0 0 0 2px var(--ok) inset; }
.report-actions { display: flex; flex-direction: column; gap: 10px; }

/* 相遇奖励 */
.report-rewards {
  margin-top: 18px; padding: 12px 10px 11px; border-radius: 14px;
  border: 1px solid var(--line);
  background: linear-gradient(155deg, rgba(253, 242, 229, .7), rgba(253, 233, 238, .5));
}
[data-theme="dark"] .report-rewards { background: linear-gradient(155deg, rgba(201, 154, 58, .1), rgba(238, 127, 149, .07)); border-color: rgba(201, 154, 58, .22); }
.report-rewards-head { text-align: center; font-size: .62em; font-weight: 800; letter-spacing: 1.2px; color: var(--gold); }
.report-reward-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 9px; }
.reward-chip {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 5px 10px 5px 8px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line);
  box-shadow: 0 2px 6px rgba(47, 42, 46, .05);
  font-size: .72em; color: var(--tl);
  animation: rewardPop .5s cubic-bezier(.2, 1.4, .4, 1) both;
}
.report-reward-list .reward-chip:nth-child(2) { animation-delay: .09s; }
.report-reward-list .reward-chip:nth-child(3) { animation-delay: .18s; }
.reward-chip i { font-style: normal; font-size: 1.25em; line-height: 1; }
.reward-chip b { font-size: 1.1em; font-weight: 800; color: var(--tx); font-variant-numeric: tabular-nums; }
.reward-chip em { font-style: normal; }
@keyframes rewardPop { 0% { opacity: 0; transform: scale(.6) translateY(6px); } 100% { opacity: 1; transform: none; } }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%) translateY(20px);
  background: rgba(47, 42, 46, .92); color: #fff; font-size: .82em;
  padding: 10px 18px; border-radius: 999px; opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s; z-index: 50; max-width: 84%; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 360px) {
  .prompt { font-size: 1.05em; }
  .room-code { font-size: 2em; letter-spacing: 7px; }
  .word-pill { font-size: .98em; }
}
