/* ============================================================
 * 五子棋 · 亲子对战
 * ============================================================ */
:root {
  --bg: #0c1317;
  --bg-2: #101a1f;
  --panel: #162126;
  --panel-2: #1b292f;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --ink: #f2ece0;
  --muted: #8d9ba1;
  --amber: #e0a458;
  --amber-2: #f4cf94;
  --wood: #e7c088;
  --wood-2: #d3a05c;
  --green: #5fa88a;
  --blue: #6f9fd8;
  --red: #cf5b4e;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --serif: "Songti SC", "STSong", "Noto Serif SC", "Kaiti SC", "STKaiti", "KaiTi", serif;
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  overscroll-behavior: none;
}

body {
  min-height: 100vh;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

button, input {
  font-family: inherit;
  color: inherit;
}

button {
  border: 0;
  background: none;
  cursor: pointer;
}

.hidden { display: none !important; }

#app {
  position: relative;
  height: var(--app-h, 100vh);
  width: 100%;
  overflow: hidden;
}

/* ============ 屏幕 ============ */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  opacity: 0;
  transition: opacity 0.22s ease;
}

.screen.active {
  display: flex;
  opacity: 1;
}

/* ============ 首页 ============ */
#screen-home {
  justify-content: flex-start;
  align-items: center;
  padding: calc(env(safe-area-inset-top) + 20px) 18px calc(env(safe-area-inset-bottom) + 18px);
  background:
    radial-gradient(120% 70% at 50% -10%, rgba(52, 92, 96, 0.4), transparent 60%),
    radial-gradient(80% 50% at 85% 100%, rgba(139, 92, 50, 0.2), transparent 65%),
    linear-gradient(180deg, #0d161a 0%, #090f12 100%);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.home-glow {
  position: absolute;
  width: 560px;
  height: 560px;
  border-radius: 50%;
  top: -250px;
  left: 50%;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(224, 164, 88, 0.18), transparent 65%);
  pointer-events: none;
}

.home-grid {
  position: absolute;
  inset: 0;
  opacity: 0.16;
  background-image:
    linear-gradient(rgba(224, 164, 88, 0.22) 1px, transparent 1px),
    linear-gradient(90deg, rgba(224, 164, 88, 0.22) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(70% 60% at 50% 40%, #000 0%, transparent 78%);
  -webkit-mask-image: radial-gradient(70% 60% at 50% 40%, #000 0%, transparent 78%);
  pointer-events: none;
}

.stones-deco {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.9;
}

.stone {
  position: absolute;
  border-radius: 50%;
  display: block;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
}

.stone.black {
  background: radial-gradient(circle at 34% 30%, #4b565b, #161c1f 62%, #0a0d0f);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.stone.white {
  background: radial-gradient(circle at 34% 30%, #ffffff, #e8e0d2 58%, #bfb5a4);
  border: 1px solid rgba(255, 255, 255, 0.5);
}

.d1 { width: 22px; height: 22px; left: 8%; top: 12%; opacity: 0.45; }
.d2 { width: 15px; height: 15px; left: 16%; top: 18%; opacity: 0.3; }
.d3 { width: 26px; height: 26px; right: 9%; top: 9%; opacity: 0.38; }
.d4 { width: 13px; height: 13px; right: 18%; top: 16%; opacity: 0.28; }
.d5 { width: 18px; height: 18px; right: 12%; bottom: 14%; opacity: 0.24; }

.home-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 430px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 20px;
  margin: 0 auto;
  flex: 0 0 auto;
  animation: rise 0.5s ease both;
}

.home-inner > * {
  flex-shrink: 0;
}

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

.brand {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  margin-bottom: 2px;
}

.brand-mark {
  width: 92px;
  height: 74px;
  position: relative;
  margin-bottom: 8px;
}

.bm-stone {
  position: absolute;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: block;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
}

.bm-stone.black {
  left: 4px;
  top: 2px;
  background: radial-gradient(circle at 34% 28%, #58666c, #161d20 58%, #080b0d);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.bm-stone.white {
  right: 4px;
  bottom: 0;
  background: radial-gradient(circle at 34% 28%, #fffdf8, #ece4d5 56%, #c4b9a6);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28), inset 0 -3px 8px rgba(120, 95, 60, 0.18);
}

.brand h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 46px;
  letter-spacing: 0.24em;
  text-indent: 0.24em;
  font-weight: 700;
  background: linear-gradient(180deg, #fff7e7, #e3bd84);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand p {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--muted);
}

.mode-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mode-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 15px 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(29, 42, 47, 0.92), rgba(20, 29, 34, 0.94));
  border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  text-align: left;
  transition: transform 0.12s ease, border-color 0.2s, background 0.2s;
}

.mode-card:active {
  transform: scale(0.985);
  border-color: rgba(224, 164, 88, 0.38);
}

.mode-ico {
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 23px;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.mode-ico.amber {
  color: var(--amber-2);
  background: linear-gradient(160deg, rgba(224, 164, 88, 0.24), rgba(224, 164, 88, 0.06));
}

.mode-ico.green {
  color: #9ad8bb;
  background: linear-gradient(160deg, rgba(95, 168, 138, 0.24), rgba(95, 168, 138, 0.06));
}

.mode-ico.blue {
  color: #a9c8ee;
  background: linear-gradient(160deg, rgba(111, 159, 216, 0.24), rgba(111, 159, 216, 0.06));
}

.mode-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.mode-text b {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.mode-text small {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chev {
  color: rgba(255, 255, 255, 0.24);
  font-size: 20px;
  line-height: 1;
}

.family-tip {
  display: flex;
  gap: 11px;
  padding: 13px 14px;
  border-radius: 16px;
  border: 1px dashed rgba(224, 164, 88, 0.26);
  background: rgba(224, 164, 88, 0.06);
}

.tip-ico {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--amber-2);
  background: rgba(224, 164, 88, 0.14);
  font-size: 15px;
}

.family-tip b {
  font-size: 12.5px;
  color: var(--amber-2);
  font-weight: 600;
}

.family-tip p {
  margin: 3px 0 0;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--muted);
}

.home-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--muted);
}

.net-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8d9ba1;
  box-shadow: 0 0 0 3px rgba(141, 155, 161, 0.12);
}

.home-tip {
  text-align: center;
  font-size: 11px;
  color: rgba(141, 155, 161, 0.7);
  margin-top: -10px;
}

.install-btn {
  align-self: center;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--amber-2);
  border: 1px solid rgba(224, 164, 88, 0.3);
  background: rgba(224, 164, 88, 0.08);
}

/* ============ 通用导航 ============ */
.nav {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 14px 10px;
  gap: 10px;
}

.nav h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.nav-pad { width: 40px; }

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 26px;
  line-height: 1;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
}

.icon-btn:active { background: rgba(255, 255, 255, 0.09); }

.text-btn {
  font-size: 13px;
  color: var(--amber-2);
  padding: 8px 6px;
}

/* ============ 房间大厅 ============ */
#screen-room {
  background:
    radial-gradient(100% 60% at 50% -10%, rgba(52, 92, 96, 0.28), transparent 65%),
    linear-gradient(180deg, #0d171b 0%, #0a1013 100%);
}

.lan-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 18px calc(env(safe-area-inset-bottom) + 22px);
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
}

.tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
  margin-bottom: 20px;
}

.tabs button {
  flex: 1;
  padding: 10px 6px;
  border-radius: 10px;
  font-size: 13.5px;
  color: var(--muted);
  transition: background 0.18s, color 0.18s;
}

.tabs button.active {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.09);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fade-in 0.2s ease both; }

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.field { margin-bottom: 19px; }

.field label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 9px;
  letter-spacing: 0.02em;
}

.label-note {
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 999px;
  color: rgba(244, 207, 148, 0.85);
  background: rgba(224, 164, 88, 0.1);
}

input[type="text"], input:not([type]), .code-input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border-radius: 13px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.045);
  color: var(--ink);
  font-size: 15px;
  outline: none;
  transition: border-color 0.18s, background 0.18s;
}

input::placeholder { color: rgba(141, 155, 161, 0.6); }

input:focus {
  border-color: rgba(224, 164, 88, 0.55);
  background: rgba(255, 255, 255, 0.065);
}

.code-input {
  font-size: 24px;
  letter-spacing: 0.34em;
  text-indent: 0.1em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.seg {
  display: flex;
  gap: 6px;
  padding: 4px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
}

.seg button {
  flex: 1;
  padding: 9px 4px;
  border-radius: 9px;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  transition: background 0.16s, color 0.16s;
}

.seg button.active {
  color: #241a0e;
  background: linear-gradient(180deg, var(--amber-2), var(--amber));
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(224, 164, 88, 0.2);
}

.scope-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scope-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 13px;
  border-radius: 14px;
  text-align: left;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
  transition: border-color 0.18s, background 0.18s, transform 0.12s;
}

.scope-card:active { transform: scale(0.99); }

.scope-card.active {
  border-color: rgba(224, 164, 88, 0.5);
  background: linear-gradient(180deg, rgba(224, 164, 88, 0.1), rgba(224, 164, 88, 0.035));
}

.scope-ico {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 700;
}

.scope-ico.green { color: #9ad8bb; background: rgba(95, 168, 138, 0.16); }
.scope-ico.blue { color: #a9c8ee; background: rgba(111, 159, 216, 0.16); }

.scope-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.scope-body b { font-size: 14px; font-weight: 600; }
.scope-body small { font-size: 11.5px; color: var(--muted); }

.scope-state {
  flex: 0 0 auto;
  font-style: normal;
  font-size: 10.5px;
  padding: 3px 7px;
  border-radius: 999px;
  color: var(--green);
  background: rgba(95, 168, 138, 0.12);
}

.scope-state.warn { color: #e5b46d; background: rgba(224, 164, 88, 0.12); }

.hint {
  margin: 10px 1px 0;
  font-size: 11.5px;
  line-height: 1.65;
  color: rgba(141, 155, 161, 0.82);
}

.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  padding: 0 22px;
  border-radius: 13px;
  color: #241a0e;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0.04em;
  background: linear-gradient(180deg, var(--amber-2), var(--amber));
  box-shadow: 0 10px 24px rgba(224, 164, 88, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: transform 0.12s, filter 0.18s;
}

.primary:active { transform: scale(0.985); filter: brightness(0.96); }
.primary:disabled { opacity: 0.55; }

.primary.big { width: 100%; height: 52px; font-size: 15.5px; }

.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  padding: 0 20px;
  border-radius: 13px;
  font-size: 14px;
  color: var(--muted);
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.03);
}

.lan-note {
  display: flex;
  gap: 12px;
  margin-top: 22px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
}

.lan-note-ico {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 18px;
  color: var(--amber-2);
  border: 1px solid rgba(224, 164, 88, 0.28);
  background: rgba(224, 164, 88, 0.07);
}

.lan-note b { font-size: 12.5px; color: var(--ink); }
.lan-note p { margin: 4px 0 0; font-size: 11.5px; line-height: 1.65; color: var(--muted); }

/* ============ 对局 ============ */
.game-screen {
  background:
    radial-gradient(90% 55% at 50% -12%, rgba(60, 100, 104, 0.3), transparent 62%),
    linear-gradient(180deg, #0d161a 0%, #090f12 100%);
}

.game-top {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 6px;
}

.game-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: rgba(242, 236, 224, 0.9);
}

.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0 12px;
  overflow: hidden;
}

.player-strip {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  min-height: 44px;
}

.player-strip.bottom { margin-top: 2px; }

.avatar {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 15px;
  line-height: 1;
}

.avatar.black {
  color: #cfd8dc;
  background: radial-gradient(circle at 34% 30%, #4b565b, #161c1f 64%, #0a0d0f);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.avatar.white {
  color: #8a7a5f;
  background: radial-gradient(circle at 34% 30%, #ffffff, #e8e0d2 58%, #bfb5a4);
  border: 1px solid rgba(255, 255, 255, 0.45);
}

.pinfo { flex: 1; min-width: 0; }

.pname {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  font-weight: 600;
}

.pname span:first-child {
  max-width: 60vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pmeta {
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 2px;
  letter-spacing: 0.02em;
}

.badge-you {
  font-size: 9.5px;
  padding: 1px 6px;
  border-radius: 999px;
  color: #241a0e;
  background: var(--amber-2);
  font-weight: 600;
}

.stone-count {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
}

.status-row {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 30px;
  padding: 0 2px 3px;
}

.status-pill {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 5px 15px;
  border-radius: 999px;
  color: var(--amber-2);
  background: rgba(224, 164, 88, 0.1);
  border: 1px solid rgba(224, 164, 88, 0.18);
  transition: color 0.2s, background 0.2s;
}

.status-pill.thinking {
  color: #a9c8ee;
  background: rgba(111, 159, 216, 0.1);
  border-color: rgba(111, 159, 216, 0.2);
}

.status-pill.over {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--line);
}

.turn-timer {
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
}

.turn-timer.urgent {
  color: #f1a08e;
  border-color: rgba(207, 91, 78, 0.4);
  background: rgba(207, 91, 78, 0.1);
}

.board-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px 0;
  overflow: hidden;
}

#board {
  display: block;
  border-radius: 14px;
  box-shadow:
    0 22px 50px rgba(0, 0, 0, 0.4),
    0 2px 0 rgba(255, 255, 255, 0.06) inset;
  touch-action: manipulation;
  cursor: pointer;
}

.game-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 2px;
  padding: 6px max(10px, env(safe-area-inset-left)) calc(env(safe-area-inset-bottom) + 8px) max(10px, env(safe-area-inset-right));
  border-top: 1px solid var(--line);
  background: rgba(8, 13, 16, 0.68);
  backdrop-filter: blur(10px);
}

.bar-btn {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 5px 2px;
  border-radius: 10px;
  font-size: 10.5px;
  color: var(--muted);
}

.bar-btn span {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  font-family: var(--serif);
  font-size: 15px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
}

.bar-btn:active span { background: rgba(255, 255, 255, 0.1); }

.chat-dot {
  position: absolute;
  top: 4px;
  right: 24%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 2px #0a1013;
}

/* ============ 等待 / 结果 ============ */
.lan-wait {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(env(safe-area-inset-top) + 16px) 18px calc(env(safe-area-inset-bottom) + 16px);
  background: rgba(7, 11, 14, 0.78);
  backdrop-filter: blur(7px);
  overflow-y: auto;
}

.wait-card {
  width: 100%;
  max-width: 360px;
  padding: 22px 22px 18px;
  border-radius: 24px;
  text-align: center;
  background: linear-gradient(180deg, #1a262c, #121b20);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  animation: rise 0.28s ease both;
}

.wait-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 650;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(95, 168, 138, 0.5);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(95, 168, 138, 0.45); }
  70% { box-shadow: 0 0 0 9px rgba(95, 168, 138, 0); }
  100% { box-shadow: 0 0 0 0 rgba(95, 168, 138, 0); }
}

.wait-scope {
  display: inline-block;
  margin-top: 10px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 10.5px;
  color: #a9c8ee;
  background: rgba(111, 159, 216, 0.12);
  border: 1px solid rgba(111, 159, 216, 0.2);
}

.wait-scope.lan {
  color: #9ad8bb;
  background: rgba(95, 168, 138, 0.12);
  border-color: rgba(95, 168, 138, 0.2);
}

.wait-sub {
  margin: 9px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.room-code {
  margin: 12px 0 4px;
  font-size: 40px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-indent: 0.2em;
  font-variant-numeric: tabular-nums;
  color: var(--amber-2);
  text-shadow: 0 4px 20px rgba(224, 164, 88, 0.18);
}

.wait-limit {
  font-size: 11px;
  color: var(--muted);
}

.qr-box {
  width: 164px;
  height: 164px;
  margin: 16px auto 12px;
  padding: 8px;
  border-radius: 14px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.qr-box canvas, .qr-box img { display: block; max-width: 100%; height: auto; }

.join-url {
  font-size: 11px;
  color: var(--muted);
  word-break: break-all;
  line-height: 1.5;
  margin: 0 0 13px;
  max-height: 34px;
  overflow: hidden;
}

.wait-warn {
  margin: 0 0 13px;
  padding: 9px 11px;
  border-radius: 10px;
  text-align: left;
  font-size: 10.5px;
  line-height: 1.6;
  color: #e8bd7d;
  background: rgba(224, 164, 88, 0.08);
  border: 1px solid rgba(224, 164, 88, 0.18);
}

.wait-card .ghost {
  width: 100%;
  margin-top: 8px;
  height: 44px;
}

.result-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(5, 8, 10, 0.72);
  backdrop-filter: blur(6px);
}

.result-card {
  width: 100%;
  max-width: 330px;
  padding: 26px 22px 20px;
  border-radius: 24px;
  text-align: center;
  background: linear-gradient(180deg, #1b272d, #121a1f);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  animation: rise 0.3s ease both;
}

.result-seal {
  width: 74px;
  height: 74px;
  margin: 0 auto 12px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 38px;
  font-weight: 700;
  color: #2a1c0d;
  background: linear-gradient(145deg, var(--amber-2), var(--amber));
  box-shadow: 0 14px 30px rgba(224, 164, 88, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transform: rotate(-4deg);
}

.result-seal.lose {
  color: #f2ece0;
  background: linear-gradient(145deg, #5e7378, #38484d);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.3);
}

.result-seal.draw {
  color: #26363b;
  background: linear-gradient(145deg, #e8e2d5, #bfc8c8);
}

.result-card h3 {
  margin: 0;
  font-size: 22px;
  font-family: var(--serif);
  letter-spacing: 0.08em;
}

.result-card p {
  margin: 7px 0 20px;
  font-size: 12px;
  color: var(--muted);
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result-actions .ghost { width: 100%; }

/* ============ 浮层 / Sheet ============ */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(3, 6, 8, 0.55);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.sheet-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.sheet {
  position: fixed;
  z-index: 41;
  left: 50%;
  bottom: 0;
  width: min(100%, 520px);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  border-radius: 24px 24px 0 0;
  background: linear-gradient(180deg, #1a262c, #10191e);
  border: 1px solid var(--line-strong);
  border-bottom: 0;
  box-shadow: 0 -18px 50px rgba(0, 0, 0, 0.45);
  transform: translate(-50%, 105%);
  transition: transform 0.26s cubic-bezier(0.22, 0.8, 0.3, 1);
  padding-bottom: env(safe-area-inset-bottom);
}

.sheet.open { transform: translate(-50%, 0); }

.sheet-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 10px;
}

.sheet-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0.04em;
}

.close-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 20px;
  line-height: 1;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
}

.sheet-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 6px 18px 20px;
}

.opt-label {
  font-size: 12px;
  color: var(--muted);
  margin: 14px 1px 9px;
}

.opt-label:first-child { margin-top: 4px; }

.sheet-foot {
  flex: 0 0 auto;
  padding: 10px 18px 16px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

.menu-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 2px;
}

.menu-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 4px;
  font-size: 14px;
  border-bottom: 1px solid var(--line);
}

.menu-row:last-child { border-bottom: 0; }
.menu-row.danger { color: #e28b7f; }

.switch {
  position: relative;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  transition: background 0.2s;
}

.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #dfe6e8;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.switch.on { background: var(--amber); }
.switch.on::after { transform: translateX(18px); background: #fff9ee; }

/* 棋谱 */
.history {
  display: flex;
  flex-direction: column;
}

.h-row {
  display: grid;
  grid-template-columns: 34px 1fr 1fr;
  align-items: center;
  gap: 8px;
  padding: 9px 6px;
  font-size: 12.5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.h-row .no {
  color: var(--muted);
  font-size: 11px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.h-move {
  display: flex;
  align-items: center;
  gap: 7px;
}

.h-move i {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  display: inline-block;
  flex: 0 0 13px;
}

.h-move.black i {
  background: radial-gradient(circle at 34% 30%, #56646a, #151b1e 65%, #080b0d);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.h-move.white i {
  background: radial-gradient(circle at 34% 30%, #ffffff, #e8e0d2 60%, #c1b7a6);
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.h-empty {
  padding: 40px 0;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
}

/* 聊天 */
.chat-sheet { height: min(72vh, 520px); }

.chat-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.chat-msg {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  max-width: 88%;
}

.chat-msg.mine { align-self: flex-end; align-items: flex-end; }

.chat-msg .who {
  font-size: 10px;
  color: var(--muted);
  padding: 0 4px;
}

.chat-msg .bubble {
  padding: 8px 12px;
  border-radius: 13px 13px 13px 4px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
  word-break: break-word;
}

.chat-msg.mine .bubble {
  border-radius: 13px 13px 4px 13px;
  color: #2a1d0f;
  background: linear-gradient(180deg, var(--amber-2), var(--amber));
  border-color: rgba(224, 164, 88, 0.5);
}

.chat-msg.system {
  align-self: center;
  max-width: 100%;
}

.chat-msg.system .bubble {
  border-radius: 999px;
  font-size: 10.5px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
}

.chat-form {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 10px 14px calc(env(safe-area-inset-bottom) + 12px);
  border-top: 1px solid var(--line);
}

.chat-form input {
  flex: 1;
  height: 42px;
  border-radius: 11px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.05);
  padding: 0 12px;
  font-size: 14px;
  outline: none;
}

.chat-form .primary {
  height: 42px;
  padding: 0 16px;
  font-size: 13px;
}

/* 规则 */
.rules p {
  font-size: 12.5px;
  line-height: 1.8;
  color: rgba(242, 236, 224, 0.88);
  margin: 10px 0;
}

.rules p b { color: var(--amber-2); font-weight: 600; }

.rules ul {
  margin: 4px 0 10px;
  padding-left: 19px;
}

.rules li {
  font-size: 12.5px;
  line-height: 1.8;
  color: rgba(242, 236, 224, 0.82);
  margin-bottom: 3px;
}

.rules .muted, .muted {
  color: var(--muted);
  font-size: 11.5px;
}

/* Toast */
.toast {
  position: fixed;
  z-index: 80;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 88px);
  transform: translate(-50%, 14px);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--ink);
  background: rgba(24, 36, 41, 0.96);
  border: 1px solid var(--line-strong);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: 84vw;
  text-align: center;
}

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

/* ============ 横屏 / 平板 ============ */
@media (orientation: landscape) and (min-width: 720px) {
  .game-top {
    padding-top: calc(env(safe-area-inset-top) + 3px);
    padding-bottom: 2px;
  }

  .game-top .icon-btn {
    width: 34px;
    height: 34px;
    font-size: 22px;
  }

  .game-bar {
    padding-top: 3px;
    padding-bottom: calc(env(safe-area-inset-bottom) + 4px);
  }

  .bar-btn { gap: 1px; padding: 3px 2px; }
  .bar-btn span { width: 26px; height: 26px; font-size: 13px; }

  .stage {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 250px;
    grid-template-rows: auto auto 1fr;
    grid-template-areas:
      "board top"
      "board status"
      "board bottom";
    column-gap: 10px;
    align-items: center;
    padding: 0 16px;
  }

  #strip-top { grid-area: top; align-self: end; }
  #status-row { grid-area: status; }
  #strip-bottom { grid-area: bottom; align-self: start; }
  .board-wrap { grid-area: board; padding: 4px 0 10px; }

  .player-strip {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    min-height: 0;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.025);
  }

  .player-strip .pinfo { width: auto; min-width: 0; }

  .player-strip .avatar {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
    font-size: 13px;
  }

  .player-strip .pname { font-size: 12.5px; }
  .player-strip .pmeta { font-size: 9.5px; }

  .status-row {
    flex-direction: column;
    gap: 7px;
    padding: 6px 0;
  }

  .game-bar { justify-content: center; gap: 8px; }
  .bar-btn { flex: 0 0 74px; }
}

@media (max-width: 360px) {
  .brand h1 { font-size: 40px; }
  .room-code { font-size: 34px; }
  .board-wrap { padding: 1px 0; }
  .game-bar .bar-btn { font-size: 9.5px; }
}

@media (max-height: 700px) {
  .home-inner { gap: 14px; }
  .brand h1 { font-size: 38px; }
  .brand-mark { transform: scale(0.86); margin-bottom: 0; }
  .family-tip { display: none; }
  .mode-card { padding: 12px 14px; }
  .mode-ico { width: 42px; height: 42px; flex-basis: 42px; font-size: 20px; }
}

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ============ 扫码加入 ============ */
.scan-btn {
  width: 100%;
  margin-top: 9px;
  height: 46px;
  color: var(--amber-2);
  border-color: rgba(224, 164, 88, 0.28);
  background: rgba(224, 164, 88, 0.06);
}

.scan-body {
  padding: 4px 18px calc(env(safe-area-inset-bottom) + 22px);
  text-align: center;
}

.scan-frame {
  position: relative;
  width: 78vw;
  height: 78vw;
  max-width: 320px;
  max-height: 320px;
  margin: 8px auto 14px;
  border-radius: 18px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.scan-frame video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

.scan-corner {
  position: absolute;
  width: 28px;
  height: 28px;
  border-color: var(--amber-2);
  border-style: solid;
  border-width: 0;
}

.scan-corner.tl { top: 14px; left: 14px; border-top-width: 3px; border-left-width: 3px; border-top-left-radius: 8px; }
.scan-corner.tr { top: 14px; right: 14px; border-top-width: 3px; border-right-width: 3px; border-top-right-radius: 8px; }
.scan-corner.bl { bottom: 14px; left: 14px; border-bottom-width: 3px; border-left-width: 3px; border-bottom-left-radius: 8px; }
.scan-corner.br { bottom: 14px; right: 14px; border-bottom-width: 3px; border-right-width: 3px; border-bottom-right-radius: 8px; }

.scan-line {
  position: absolute;
  left: 10%;
  right: 10%;
  top: 15%;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, rgba(244, 207, 148, 0.95), transparent);
  box-shadow: 0 0 12px rgba(244, 207, 148, 0.75);
  animation: scanline 2.1s ease-in-out infinite;
}

@keyframes scanline {
  0%, 100% { top: 15%; opacity: 0.35; }
  50% { top: 82%; opacity: 1; }
}

.scan-hint {
  margin: 0 0 12px;
  font-size: 12.5px;
  color: var(--muted);
}

.scan-body .ghost { width: 100%; height: 44px; }
