/* ════════════════════════════════════════════════════════════
   UNO · 深夜牌桌（Casino Noir）
   深色呢绒桌面 + 金色点缀 + 高饱和卡牌
   ════════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Bungee&family=Noto+Sans+SC:wght@400;500;700;900&display=swap');

:root {
  --felt-1: #16222f;
  --felt-2: #0a111b;
  --panel: rgba(16, 24, 36, 0.82);
  --panel-line: rgba(255, 255, 255, 0.08);
  --gold: #e8b64c;
  --gold-soft: rgba(232, 182, 76, 0.55);
  --ink: #e9eef5;
  --ink-dim: #9fb0c3;
  --red: #e33d3d;
  --yellow: #f5c118;
  --green: #34b758;
  --blue: #2f7ce8;
  --danger: #ff5d5d;
  --ok: #52d98a;
  --radius: 14px;
  --font-display: 'Bungee', 'Noto Sans SC', sans-serif;
  --font-body: 'Noto Sans SC', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--felt-2);
  overflow: hidden;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
.hidden { display: none !important; }

.screen { position: fixed; inset: 0; }

/* ═══════════════ 开局设置 ═══════════════ */
#setup-screen { display: flex; align-items: stretch; justify-content: center; overflow-y: auto; }
.setup-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 90% 70% at 50% 30%, rgba(56, 88, 130, 0.35), transparent 65%),
    radial-gradient(ellipse 120% 90% at 50% 110%, rgba(232, 182, 76, 0.08), transparent 50%),
    linear-gradient(180deg, var(--felt-1), var(--felt-2));
}
.setup-bg::after { /* 噪点纹理 */
  content: ''; position: absolute; inset: 0; opacity: 0.05; pointer-events: none;
  background-image: repeating-conic-gradient(rgba(255,255,255,.6) 0 0.0001%, transparent 0.0002% 0.0004%);
  background-size: 220px 220px;
}
.setup-card {
  position: relative; width: min(460px, 92vw);
  margin: auto; /* 滚动容器内安全居中（矮屏不裁顶） */
  background: var(--panel); border: 1px solid var(--panel-line);
  border-radius: 22px; padding: 34px 36px 28px; text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(10px);
  animation: rise-in 0.6s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}
@keyframes rise-in { from { transform: translateY(26px) scale(0.97); opacity: 0; } }

.logo-big {
  font-family: var(--font-display);
  font-size: 76px; line-height: 1;
  transform: skewY(-5deg) rotate(-4deg);
  color: var(--red);
  text-shadow:
    0 2px 0 #fff, 0 4px 0 rgba(0,0,0,.35),
    -4px 4px 0 var(--yellow), -8px 8px 0 var(--blue), -12px 12px 18px rgba(0,0,0,.5);
  letter-spacing: 2px;
  animation: logo-pop 0.8s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
@keyframes logo-pop { from { transform: skewY(-5deg) rotate(-4deg) scale(0.3); opacity: 0; } }
.tagline { color: var(--ink-dim); margin: 18px 0 24px; font-size: 14px; letter-spacing: 1px; }

.setup-form { display: flex; flex-direction: column; gap: 13px; text-align: left; margin-bottom: 24px; }
.field { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.field-label { color: var(--ink-dim); font-size: 14px; flex-shrink: 0; }
#player-name, select {
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--panel-line);
  color: var(--ink); border-radius: 9px; padding: 8px 12px; font-size: 14px;
  font-family: inherit; outline: none; min-width: 200px; text-align: center;
}
#player-name:focus, select:focus { border-color: var(--gold-soft); }
select option { background: #17222f; }

.stepper { display: flex; align-items: center; gap: 14px; }
.stepper button {
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.07); border: 1px solid var(--panel-line);
  font-size: 19px; color: var(--gold); transition: all 0.15s;
}
.stepper button:hover { background: var(--gold); color: #1a1408; }
#player-count { font-size: 21px; font-weight: 900; min-width: 30px; text-align: center; }

.primary-btn {
  width: 100%; padding: 13px; border-radius: 12px;
  background: linear-gradient(180deg, #f2c45c, #d99a26);
  color: #221804; font-size: 17px; font-weight: 900; letter-spacing: 3px;
  box-shadow: 0 6px 20px rgba(232, 182, 76, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transition: transform 0.12s, box-shadow 0.12s;
}
.primary-btn:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(232, 182, 76, 0.45), inset 0 1px 0 rgba(255,255,255,0.5); }
.primary-btn:active { transform: translateY(0); }
.ghost-btn {
  padding: 11px 20px; border-radius: 12px; font-size: 15px; font-weight: 700;
  background: rgba(255, 255, 255, 0.07); border: 1px solid var(--panel-line); color: var(--ink);
  transition: all 0.15s;
}
.ghost-btn:hover { background: rgba(255, 255, 255, 0.14); }
.danger-btn {
  padding: 12px 20px; border-radius: 12px; font-size: 15px; font-weight: 900;
  background: linear-gradient(180deg, #ff7070, #d92f2f); color: #fff;
  box-shadow: 0 6px 18px rgba(217, 47, 47, 0.4);
}
.danger-btn:hover { transform: translateY(-2px); }
.link-btn { margin-top: 14px; color: var(--ink-dim); font-size: 13px; text-decoration: underline; }
.link-btn:hover { color: var(--gold); }

/* ═══════════════ 顶栏 ═══════════════ */
#game-screen { display: flex; flex-direction: column; }
#topbar {
  height: 52px; flex-shrink: 0; display: flex; align-items: center; gap: 18px;
  padding: 0 16px; background: var(--panel); border-bottom: 1px solid var(--panel-line);
  backdrop-filter: blur(8px); z-index: 30;
}
.logo-small {
  font-family: var(--font-display); font-size: 22px; color: var(--red);
  transform: rotate(-4deg); text-shadow: 0 1px 0 #fff, -2px 2px 0 var(--yellow);
}
.top-info {
  display: flex; align-items: center; gap: 10px;
  color: var(--ink-dim); font-size: 13px; white-space: nowrap;
  min-width: 0; flex-shrink: 1; overflow: hidden;
}
#round-info { flex-shrink: 0; }
#status-hint {
  color: var(--gold); font-size: 12.5px; letter-spacing: 0.5px;
  overflow: hidden; text-overflow: ellipsis;
}
.score-strip { display: flex; gap: 8px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.score-chip {
  display: flex; align-items: center; gap: 6px; padding: 4px 10px 4px 5px;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--panel-line);
  border-radius: 99px; font-size: 12px; white-space: nowrap; flex-shrink: 0;
}
.score-chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.score-chip b { color: var(--gold); }
.score-chip.leading { border-color: var(--gold-soft); }
.top-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; font-size: 15px;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--panel-line);
  color: var(--ink-dim); transition: all 0.15s;
}
.icon-btn:hover { color: var(--gold); border-color: var(--gold-soft); }
.icon-btn.muted { text-decoration: line-through; opacity: 0.55; }

/* ═══════════════ 牌桌 ═══════════════ */
#table-wrap { flex: 1; display: flex; min-height: 0; }
#table {
  flex: 1; position: relative; overflow: hidden;
  background:
    radial-gradient(ellipse 75% 62% at 50% 42%, rgba(48, 78, 116, 0.45), rgba(20, 32, 48, 0.2) 60%, transparent 75%),
    radial-gradient(ellipse 120% 100% at 50% 120%, rgba(0, 0, 0, 0.5), transparent 55%),
    linear-gradient(180deg, #101a27, #0a121d);
}
#table::before { /* 桌面细纹 */
  content: ''; position: absolute; inset: 0; opacity: 0.04; pointer-events: none;
  background-image: repeating-linear-gradient(45deg, transparent 0 6px, rgba(255,255,255,.5) 6px 7px, transparent 7px 12px);
}
#table::after { /* 中央金环 */
  content: ''; position: absolute; left: 50%; top: 44%;
  width: 420px; height: 420px; transform: translate(-50%, -50%);
  border-radius: 50%; border: 1.5px solid rgba(232, 182, 76, 0.10);
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.35), 0 0 60px rgba(232, 182, 76, 0.03);
  pointer-events: none;
}

/* ── 对手铭牌（JS 弧线布局） ── */
.op-plaque {
  position: absolute; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 10px 7px; border-radius: 14px; z-index: 5;
  background: var(--panel); border: 1px solid var(--panel-line);
  transition: border-color 0.25s, box-shadow 0.25s, opacity 0.2s;
  min-width: 96px;
}
.op-plaque.active {
  border-color: var(--gold);
  box-shadow: 0 0 0 1.5px var(--gold-soft), 0 0 26px rgba(232, 182, 76, 0.28);
  animation: plaque-breathe 1.6s ease-in-out infinite;
}
@keyframes plaque-breathe { 50% { box-shadow: 0 0 0 1.5px var(--gold-soft), 0 0 40px rgba(232, 182, 76, 0.45); } }
.op-head { display: flex; align-items: center; gap: 6px; }
.op-name { font-size: 12.5px; font-weight: 700; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.op-count { font-size: 11px; color: var(--ink-dim); }
.op-fan { position: relative; height: 30px; width: 100%; display: flex; justify-content: center; }
.uno-badge {
  font-family: var(--font-display); font-size: 11px; color: #ffd94d;
  background: rgba(217, 47, 47, 0.9); padding: 2px 8px; border-radius: 99px;
  transform: rotate(-6deg); box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  animation: uno-pop 0.4s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}
@keyframes uno-pop { from { transform: scale(0) rotate(-30deg); } }
.catch-btn {
  margin-top: 3px; font-size: 11.5px; font-weight: 900; padding: 4px 10px; border-radius: 99px;
  background: var(--danger); color: #fff; animation: catch-pulse 0.7s ease-in-out infinite;
}
@keyframes catch-pulse { 50% { transform: scale(1.12); box-shadow: 0 0 18px rgba(255, 93, 93, 0.8); } }

/* ── 中央区 ── */
#center-area {
  position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%);
  display: flex; align-items: center; gap: 44px; z-index: 6;
}
#dir-indicator {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font-size: 66px; color: rgba(232, 182, 76, 0.22); z-index: 0;
  animation: spin-slow 9s linear infinite; pointer-events: none;
}
#dir-indicator.ccw { animation-direction: reverse; }
@keyframes spin-slow { to { transform: translate(-50%, -50%) rotate(360deg); } }
#draw-pile, #discard-area { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.pile-label { font-size: 11px; color: var(--ink-dim); letter-spacing: 2px; margin-top: 4px; }
.pile-count {
  position: absolute; top: -9px; right: -9px; z-index: 5;
  background: var(--gold); color: #221804; font-size: 11px; font-weight: 900;
  min-width: 24px; height: 24px; border-radius: 99px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
#draw-pile { cursor: default; transition: transform 0.15s; }
#draw-pile.can-draw { cursor: pointer; }
#draw-pile.can-draw:hover { transform: scale(1.06); }
#draw-pile.can-draw::after {
  content: '摸牌'; position: absolute; inset: -6px; border: 1.5px dashed var(--gold-soft);
  border-radius: 12px; animation: catch-pulse 1.4s infinite;
}

/* ── 摸牌堆：整齐厚实的层叠牌堆（单向偏移 + 投影，模拟真实牌堆） ── */
#deck-stack {
  position: relative;
  width: var(--cw); height: var(--ch);
  --cw: 92px; --ch: 136px;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.55)) drop-shadow(0 3px 6px rgba(0, 0, 0, 0.4));
}
#deck-stack .card { position: absolute; left: 0; top: 0; --cw: 92px; --ch: 136px; }
#deck-stack .deck-top { z-index: 10; }
#discard-pile { position: relative; width: var(--cw); height: var(--ch); --cw: 92px; --ch: 136px; }
#discard-pile .card { position: absolute; left: 0; top: 0; }
#color-beacon {
  position: absolute; right: -58px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; border-radius: 50%; z-index: 7;
  background: #888; box-shadow: 0 0 16px currentColor;
  border: 3px solid rgba(255, 255, 255, 0.75); transition: background 0.3s;
}
#color-beacon.red { background: var(--red); color: var(--red); }
#color-beacon.yellow { background: var(--yellow); color: var(--yellow); }
#color-beacon.green { background: var(--green); color: var(--green); }
#color-beacon.blue { background: var(--blue); color: var(--blue); }

/* ── 自己区域（状态提示已收进顶栏，不再压画面） ── */
#my-area {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 0 12px 10px;
}
#my-hand {
  display: flex; justify-content: center; align-items: flex-end;
  min-height: 152px; max-width: 96vw; padding: 0 8px;
}
#my-hand .card-slot { transition: transform 0.18s ease, margin 0.18s ease; }
#my-hand.tight .card-slot { margin-left: -34px !important; }
#my-hand .card-slot:first-child { margin-left: 0 !important; }
.card-slot.playable { cursor: pointer; }
.card-slot.playable:hover { transform: translateY(-26px) scale(1.06); z-index: 20; }
.card-slot.dimmed .card { filter: brightness(0.55) saturate(0.7); }
.card-slot.bluff-hint:hover::after {
  content: '⚠ 诈牌：你持有当前颜色，可被质疑';
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: rgba(20, 12, 8, 0.95); color: var(--danger); font-size: 11px;
  padding: 4px 9px; border-radius: 7px; white-space: nowrap; z-index: 30;
  border: 1px solid rgba(255, 93, 93, 0.4);
}
#my-row { display: flex; align-items: center; gap: 16px; }
#my-plaque {
  display: flex; align-items: center; gap: 10px; padding: 7px 16px;
  background: var(--panel); border: 1px solid var(--panel-line); border-radius: 99px;
  transition: all 0.25s;
}
#my-plaque.active { border-color: var(--gold); box-shadow: 0 0 22px rgba(232, 182, 76, 0.3); }
.avatar { font-size: 22px; }
.plaque-text { display: flex; flex-direction: column; line-height: 1.25; }
#my-name { font-size: 13.5px; font-weight: 700; }
#my-score { font-size: 11.5px; color: var(--gold); }

/* ═══════════════ 卡牌 ═══════════════ */
.card {
  --cw: 74px; --ch: 110px;
  width: var(--cw); height: var(--ch);
  border-radius: calc(var(--cw) * 0.11);
  background: #f4f6f8;
  padding: calc(var(--cw) * 0.055);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.45);
  position: relative;
  flex-shrink: 0;
}
.card-inner {
  position: relative; width: 100%; height: 100%;
  border-radius: calc(var(--cw) * 0.08);
  overflow: hidden;
}
.card.red .card-inner { background: linear-gradient(160deg, #f04848, #cc2424); }
.card.yellow .card-inner { background: linear-gradient(160deg, #ffd23e, #e8a800); }
.card.green .card-inner { background: linear-gradient(160deg, #3ec963, #1f9443); }
.card.blue .card-inner { background: linear-gradient(160deg, #4189f2, #1f5fd0); }
.card.black .card-inner { background: linear-gradient(160deg, #333c48, #14181f); }

.card .ellipse {
  position: absolute; left: 50%; top: 50%;
  width: 150%; height: 58%;
  transform: translate(-50%, -50%) rotate(-32deg);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 0 0 calc(var(--cw) * 0.03) rgba(0, 0, 0, 0.08);
}
.card.black .ellipse {
  background: conic-gradient(from 0deg,
    var(--red) 0 25%, var(--blue) 0 50%, var(--yellow) 0 75%, var(--green) 0 100%);
  opacity: 0.96;
  box-shadow: 0 0 0 calc(var(--cw) * 0.025) rgba(255,255,255,0.25);
}
.card .face {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: calc(var(--cw) * 0.52);
  color: var(--face-color, #fff);
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.4);
  transform: skewX(-6deg);
  z-index: 2;
}
.card.red .face { --face-color: var(--red); }
.card.yellow .face { --face-color: #d9a400; }
.card.green .face { --face-color: var(--green); }
.card.blue .face { --face-color: var(--blue); }
.card.black.wild .face { color: transparent; }
.card.black.wild4 .face { color: #111; text-shadow: 1px 1px 0 rgba(255,255,255,.4); }
.card .corner {
  position: absolute; font-family: var(--font-display);
  font-size: calc(var(--cw) * 0.17); color: #fff; z-index: 3;
  text-shadow: 1px 1px 0 rgba(0,0,0,.45);
}
.card .corner.tl { top: 6%; left: 9%; }
.card .corner.br { bottom: 6%; right: 9%; transform: rotate(180deg); }
.card.black .corner { color: #fff; }

/* ── 卡背：UNO 官方样式（黑底 · 红色斜椭圆 · 白色斜体 UNO 字标 · 红色描边框） ── */
.card.back { padding: calc(var(--cw) * 0.055); }
.card.back .card-inner {
  background: #101116;
  border: 1.5px solid rgba(237, 28, 36, 0.85); /* 官方红色描边框 */
}
.card.back .card-inner::before { /* 内侧细红框，营造印刷边框感 */
  content: ''; position: absolute; inset: 3.5%;
  border: 1px solid rgba(237, 28, 36, 0.35);
  border-radius: calc(var(--cw) * 0.06);
  z-index: 4; pointer-events: none;
}
.card.back .ellipse {
  background: linear-gradient(165deg, #ff2e36 0%, #e5192e 45%, #c8101f 100%);
  box-shadow: inset 0 calc(var(--cw) * 0.02) calc(var(--cw) * 0.05) rgba(255, 255, 255, 0.28),
              inset 0 calc(var(--cw) * -0.03) calc(var(--cw) * 0.06) rgba(90, 0, 5, 0.5);
  opacity: 1;
}
.card.back .face {
  color: #fff;
  font-family: 'Arial Black', 'Avenir Next Heavy', 'Helvetica Neue', var(--font-body);
  font-weight: 900;
  font-style: italic;
  font-size: calc(var(--cw) * 0.30);
  letter-spacing: calc(var(--cw) * -0.012);
  text-shadow: calc(var(--cw) * 0.025) calc(var(--cw) * 0.025) 0 rgba(120, 0, 6, 0.55);
  transform: skewX(-10deg) rotate(-16deg); /* 与椭圆轴向一致的倾斜字标 */
  z-index: 3;
}

/* 尺寸档位 */
.card.sz-hand { --cw: 74px; --ch: 110px; }
.card.sz-discard { --cw: 92px; --ch: 136px; }
.card.sz-mini { --cw: 30px; --ch: 44px; border-radius: 5px; box-shadow: 0 2px 5px rgba(0,0,0,.5); }
.card.sz-fly { --cw: 92px; --ch: 136px; }
.op-fan .card { --cw: 24px; --ch: 36px; border-radius: 4px; margin-left: -14px; box-shadow: 0 1px 4px rgba(0,0,0,.5); }
.op-fan .card:first-child { margin-left: 0; }

/* 可出高亮 */
.card-slot.playable .card { box-shadow: 0 0 0 2.5px var(--gold-soft), 0 6px 16px rgba(0, 0, 0, 0.5); }
.card-slot.playable:hover .card { box-shadow: 0 0 0 3px var(--gold), 0 14px 26px rgba(0, 0, 0, 0.55); }

/* ═══════════════ 战报 ═══════════════ */
#log-panel {
  width: 250px; flex-shrink: 0; display: flex; flex-direction: column;
  background: var(--panel); border-left: 1px solid var(--panel-line); z-index: 20;
}
.log-title {
  padding: 10px 14px; font-size: 13px; font-weight: 700; letter-spacing: 3px;
  color: var(--gold); border-bottom: 1px solid var(--panel-line);
}
#log-list { flex: 1; overflow-y: auto; padding: 8px 12px; font-size: 12.5px; line-height: 1.5; }
#log-list::-webkit-scrollbar { width: 4px; }
#log-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }
.log-item { padding: 4px 6px; border-radius: 6px; color: var(--ink-dim); animation: log-in 0.3s both; }
.log-item.me { color: var(--ink); background: rgba(232, 182, 76, 0.07); }
.log-item.hl { color: var(--gold); }
.log-item.bad { color: var(--danger); }
@keyframes log-in { from { opacity: 0; transform: translateX(8px); } }
.c-red { color: #ff7b7b; } .c-yellow { color: #ffd75e; } .c-green { color: #6fe39a; } .c-blue { color: #7ab5ff; }

/* ═══════════════ UNO 大按钮 ═══════════════ */
#uno-flash {
  position: fixed; left: 50%; top: 38%; transform: translate(-50%, -50%); z-index: 120;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
#uno-flash-btn {
  font-family: var(--font-display); font-size: 74px; line-height: 1;
  color: #ffd94d; background: radial-gradient(circle at 35% 30%, #ff6b5e, #c81e1e 75%);
  padding: 26px 54px; border-radius: 30px; transform: rotate(-6deg);
  box-shadow: 0 16px 50px rgba(200, 30, 30, 0.55), inset 0 3px 0 rgba(255,255,255,.35);
  animation: uno-shake 0.5s ease-in-out infinite;
  text-shadow: 3px 3px 0 rgba(0,0,0,.4);
}
@keyframes uno-shake {
  0%, 100% { transform: rotate(-6deg) scale(1); }
  50% { transform: rotate(-3deg) scale(1.07); }
}
#uno-flash-timer { width: 190px; height: 7px; border-radius: 4px; overflow: hidden; background: rgba(0,0,0,0.5); }
#uno-flash-timer i { display: block; height: 100%; background: var(--gold); animation-name: uno-timer; animation-timing-function: linear; animation-fill-mode: forwards; }
@keyframes uno-timer { from { width: 100%; } to { width: 0%; } }

/* ═══════════════ 提示气泡（不遮牌桌：收在顶栏下方，小体积） ═══════════════ */
#toast-layer {
  position: fixed; top: 58px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 6px; z-index: 130; align-items: center;
  pointer-events: none;
}
.toast {
  padding: 7px 16px; border-radius: 99px; font-size: 13px; font-weight: 700;
  max-width: 72vw; text-align: center;
  background: rgba(12, 18, 28, 0.92); border: 1px solid var(--panel-line);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.35s cubic-bezier(0.2, 1.2, 0.4, 1) both;
}
.toast.warn { border-color: rgba(255, 93, 93, 0.5); color: #ffb3b3; }
.toast.good { border-color: rgba(82, 217, 138, 0.5); color: #a9f0c4; }
.toast.gold { border-color: var(--gold-soft); color: var(--gold); }
.toast.fade-out { animation: toast-out 0.4s both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-14px) scale(0.9); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-10px); } }

/* ═══════════════ 弹窗 ═══════════════ */
#modal-mask {
  position: fixed; inset: 0; background: rgba(4, 8, 14, 0.72); z-index: 140;
  backdrop-filter: blur(3px); animation: fade-in 0.25s both;
}
@keyframes fade-in { from { opacity: 0; } }
.modal {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 150; width: min(430px, 92vw);
  background: linear-gradient(180deg, #1a2634, #121a26);
  border: 1px solid var(--panel-line); border-radius: 20px;
  padding: 26px 26px 22px; text-align: center;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.7);
  animation: modal-pop 0.35s cubic-bezier(0.2, 1.3, 0.4, 1) both;
}
@keyframes modal-pop { from { transform: translate(-50%, -46%) scale(0.92); opacity: 0; } }
.modal h3 { font-size: 19px; margin-bottom: 14px; letter-spacing: 1px; }
.modal-desc { color: var(--ink-dim); font-size: 13.5px; margin-bottom: 16px; line-height: 1.6; }
.modal-btns { display: flex; gap: 10px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }

.color-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.color-btn {
  height: 84px; border-radius: 16px; font-size: 22px; font-weight: 900; color: #fff;
  text-shadow: 1px 2px 0 rgba(0,0,0,.35); transition: transform 0.13s, box-shadow 0.13s;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.3), 0 5px 16px rgba(0,0,0,.35);
}
.color-btn.red { background: linear-gradient(180deg, #f05555, #c92222); }
.color-btn.yellow { background: linear-gradient(180deg, #ffd43e, #e3a600); color: #6b5200; text-shadow: 1px 1px 0 rgba(255,255,255,.35); }
.color-btn.green { background: linear-gradient(180deg, #43cd68, #1d9140); }
.color-btn.blue { background: linear-gradient(180deg, #4b91f4, #1e5ccd); }
.color-btn:hover { transform: translateY(-3px) scale(1.03); box-shadow: inset 0 2px 0 rgba(255,255,255,.3), 0 10px 22px rgba(0,0,0,.45); }

#drawn-card-slot { display: flex; justify-content: center; padding: 8px 0; }
.mini-hand { display: flex; justify-content: center; flex-wrap: wrap; gap: 5px; padding: 6px 0; }
.mini-hand .card { --cw: 34px; --ch: 50px; }

.countdown { height: 5px; border-radius: 3px; overflow: hidden; background: rgba(255,255,255,0.09); margin-top: 16px; }
.countdown i { display: block; height: 100%; background: var(--danger); animation-name: cd; animation-timing-function: linear; animation-fill-mode: forwards; }
@keyframes cd { from { width: 100%; } to { width: 0%; } }

/* 局末结算表 */
.round-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.round-table th { color: var(--ink-dim); font-weight: 500; padding: 5px 6px; border-bottom: 1px solid var(--panel-line); font-size: 12px; }
.round-table td { padding: 7px 6px; border-bottom: 1px solid rgba(255,255,255,0.04); }
.round-table tr.winner td { color: var(--gold); font-weight: 900; background: rgba(232, 182, 76, 0.06); }
.round-table .leftover-cards { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; }
.round-table .leftover-cards .card { --cw: 22px; --ch: 33px; border-radius: 4px; }
.pts-plus { color: var(--ok); font-weight: 900; }
.big-gain { font-family: var(--font-display); font-size: 40px; color: var(--gold); margin: 6px 0; text-shadow: 0 3px 0 rgba(0,0,0,.4); }

.rules-modal { width: min(560px, 94vw); max-height: 84vh; display: flex; flex-direction: column; }
.rules-body {
  overflow-y: auto; text-align: left; font-size: 13.5px; line-height: 1.9; color: var(--ink-dim);
  padding-right: 6px;
}
.rules-body b { color: var(--ink); }
.rules-body::-webkit-scrollbar { width: 4px; }
.rules-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); }

/* 排行榜 */
.podium { display: flex; flex-direction: column; gap: 7px; margin: 12px 0 4px; }
.rank-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 14px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--panel-line); border-radius: 12px;
}
.rank-row.first { border-color: var(--gold-soft); background: rgba(232, 182, 76, 0.1); }
.rank-medal { font-size: 20px; width: 26px; text-align: center; }
.rank-name { flex: 1; text-align: left; font-weight: 700; }
.rank-score { font-family: var(--font-display); font-size: 16px; color: var(--gold); }

/* ═══════════════ 飞牌动画层 ═══════════════ */
#fx-layer { position: fixed; inset: 0; z-index: 110; pointer-events: none; }
.flying-card { position: absolute; will-change: transform, opacity; z-index: 111; transition: transform 0.38s cubic-bezier(0.3, 0.7, 0.3, 1), opacity 0.38s; }
.flying-card.fast { transition-duration: 0.26s; }

/* ── 手机/窄屏对手牌行（由 JS 判定加 mobile-row 类，桌面弧线布局不受影响） ── */
#opponents.mobile-row {
  position: absolute; top: 8px; left: 6px; right: 6px;
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 6px; z-index: 8;
}
#opponents.mobile-row .op-plaque {
  position: static; transform: none;
  flex-direction: row; align-items: center; gap: 5px;
  min-width: 0; padding: 5px 10px; border-radius: 99px;
}
#opponents.mobile-row .op-head { gap: 4px; }
#opponents.mobile-row .op-name { max-width: 60px; font-size: 11.5px; }
#opponents.mobile-row .op-count { font-size: 10.5px; }
#opponents.mobile-row .op-fan { display: none; }
#opponents.mobile-row .avatar { font-size: 16px; }
#opponents.mobile-row .uno-badge { font-size: 9.5px; padding: 1px 7px; }
#opponents.mobile-row .catch-btn { margin-top: 0; font-size: 10.5px; padding: 4px 9px; }

/* ── 手机横屏：对手左侧竖列（专业牌局形态，由 JS 加 side-col 类） ── */
#opponents.side-col {
  position: absolute; left: 8px; top: 54px; bottom: 102px;
  width: 158px; display: flex; flex-direction: column; flex-wrap: wrap;
  align-content: flex-start; gap: 6px; z-index: 8; overflow: hidden;
}
#opponents.side-col .op-plaque {
  position: static; transform: none;
  flex-direction: row; align-items: center; gap: 5px;
  min-width: 0; padding: 4px 9px; border-radius: 99px;
  width: fit-content;
}
#opponents.side-col .op-head { gap: 4px; }
#opponents.side-col .op-name { max-width: 56px; font-size: 11px; }
#opponents.side-col .op-count { font-size: 10px; }
#opponents.side-col .op-fan { display: none; }
#opponents.side-col .avatar { font-size: 15px; }
#opponents.side-col .uno-badge { font-size: 9px; padding: 1px 6px; }
#opponents.side-col .catch-btn { margin-top: 0; font-size: 10px; padding: 3px 8px; }

/* ═══════════════ 竖屏旋转引导（手机竖屏进入对局时显示） ═══════════════ */
#rotate-hint {
  position: absolute; inset: 0; z-index: 300; display: none;
  flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; text-align: center; padding: 30px;
  background:
    radial-gradient(ellipse 90% 70% at 50% 30%, rgba(56, 88, 130, 0.35), transparent 65%),
    linear-gradient(180deg, #131c29, #0a111b);
}
#rotate-hint h2 { font-size: 21px; letter-spacing: 3px; margin-top: 6px; }
#rotate-hint p { color: var(--ink-dim); font-size: 13.5px; }
.rotate-phone {
  width: 46px; height: 82px; border: 3px solid var(--gold); border-radius: 10px;
  position: relative; opacity: 0.9;
  animation: rotate-phone 2s ease-in-out infinite;
}
.rotate-phone span {
  position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%);
  width: 16px; height: 3px; border-radius: 2px; background: var(--gold);
}
@keyframes rotate-phone {
  0%, 12% { transform: rotate(0deg); }
  55%, 72% { transform: rotate(-90deg); }
  100% { transform: rotate(0deg); }
}
#rotate-continue {
  margin-top: 14px; color: var(--ink-dim); font-size: 13px; text-decoration: underline;
}
#rotate-continue:active { color: var(--gold); }
@media (max-width: 760px) and (orientation: portrait) {
  body:not(.allow-portrait) #rotate-hint { display: flex; }
}

/* ═══════════════ 响应式 ═══════════════ */
/* 中屏（平板）：战报改为抽屉，默认隐藏 */
#log-toggle, #log-close { display: none; }

@media (max-width: 1100px) {
  #log-panel {
    position: fixed; top: 0; right: 0; bottom: 0;
    width: min(78vw, 300px); z-index: 135;
    transform: translateX(105%);
    transition: transform 0.28s cubic-bezier(0.3, 0.8, 0.3, 1);
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    border-left: 1px solid var(--panel-line);
    box-shadow: -12px 0 40px rgba(0, 0, 0, 0.5);
  }
  #log-panel.open { transform: translateX(0); }
  #log-toggle { display: flex; align-items: center; justify-content: center; }
  #log-close {
    display: flex; margin-left: auto; font-size: 13px; color: var(--ink-dim);
    width: 26px; height: 26px; border-radius: 7px; align-items: center; justify-content: center;
  }
  .log-title { display: flex; align-items: center; gap: 8px; }
}

/* 矮屏（横屏手机/小窗口）：压缩设置卡片 */
@media (max-height: 560px) {
  .setup-card { padding: 18px 22px 16px; border-radius: 16px; }
  .logo-big { font-size: 44px; }
  .tagline { margin: 8px 0 12px; font-size: 12px; }
  .setup-form { gap: 8px; margin-bottom: 14px; }
  #player-name, select { padding: 6px 10px; font-size: 13px; }
  .primary-btn { padding: 10px; font-size: 15px; }
}

/* ═══════════════ 手机端完整适配（≤760px，桌面布局不受影响） ═══════════════ */
@media (max-width: 760px) {
  html, body { overscroll-behavior: none; }
  body { -webkit-user-select: none; user-select: none; }
  button, .card-slot, #draw-pile { touch-action: manipulation; }
  #game-screen { padding-top: env(safe-area-inset-top); }

  /* ── 顶栏：紧凑单行 ── */
  #topbar { height: 48px; gap: 8px; padding: 0 10px; }
  .logo-small { font-size: 17px; }
  #round-info { display: none; } /* 窄屏只留状态文字 */
  .top-info { flex: 0 1 auto; max-width: 40vw; }
  .score-strip { gap: 5px; }
  .score-chip { font-size: 11px; padding: 3px 8px 3px 4px; }
  .icon-btn { width: 38px; height: 38px; font-size: 16px; }

  /* ── 中央牌堆：缩小下移 ── */
  #center-area { top: 41%; gap: 16px; }
  #deck-stack, #deck-stack .card { --cw: 64px; --ch: 95px; }
  .card.sz-discard, #discard-pile { --cw: 64px; --ch: 95px; }
  #dir-indicator { font-size: 46px; }
  #color-beacon { width: 22px; height: 22px; right: -34px; border-width: 2.5px; }
  .pile-label { font-size: 10px; letter-spacing: 1.5px; }
  .pile-count { min-width: 20px; height: 20px; font-size: 10px; top: -7px; right: -7px; }
  #table::after { width: 250px; height: 250px; }

  /* ── 手牌：拇指区，触控友好 ── */
  #my-area { padding: 0 4px calc(8px + env(safe-area-inset-bottom)); gap: 0; }
  #my-hand {
    min-height: 94px; max-width: 100vw;
    overflow-x: auto; overflow-y: hidden;
    justify-content: center; justify-content: safe center;
    scrollbar-width: none;
  }
  #my-hand::-webkit-scrollbar { display: none; }
  .card.sz-hand { --cw: 52px; --ch: 77px; }
  #my-hand.tight .card-slot { margin-left: -34px !important; }
  .card-slot.playable:active { transform: translateY(-16px) scale(1.06); }
  #my-plaque { padding: 5px 12px; }
  .avatar { font-size: 18px; }
  #my-name { font-size: 12.5px; }
  #my-score { font-size: 10.5px; }

  /* ── UNO 大按钮：移至拇指热区 ── */
  #uno-flash { top: auto; bottom: calc(150px + env(safe-area-inset-bottom)); }
  #uno-flash-btn { font-size: 46px; padding: 14px 30px; border-radius: 22px; }
  #uno-flash-timer { width: 150px; }

  /* ── 提示气泡 ── */
  #toast-layer { top: 60px; width: 94vw; }
  .toast { font-size: 13px; padding: 8px 16px; text-align: center; }

  /* ── 弹窗：全宽触控优化 ── */
  .modal {
    width: 92vw; padding: 20px 16px 18px;
    max-height: 84dvh; display: flex; flex-direction: column;
  }
  .modal h3 { font-size: 17px; }
  .modal-desc { font-size: 12.5px; }
  .modal-btns { gap: 8px; }
  .modal-btns .primary-btn { padding: 12px 18px; font-size: 15px; letter-spacing: 2px; }
  .modal-btns .ghost-btn, .modal-btns .danger-btn { padding: 11px 16px; font-size: 14px; }
  .color-grid { gap: 9px; }
  .color-btn { height: 64px; font-size: 19px; }
  .round-table { font-size: 12px; }
  .round-table .leftover-cards .card { --cw: 18px; --ch: 27px; }
  .big-gain { font-size: 32px; }
  .rank-row { padding: 8px 10px; }
}

/* ═══ 手机横屏 · 专业牌局形态（按高度判定，覆盖 844×390 等横屏手机） ═══
   布局：左列对手 | 中央牌堆（右移避开左列）| 底部手牌横贯 | 铭牌左下 */
@media (max-width: 920px) and (max-height: 500px) and (orientation: landscape) {
  html, body { overscroll-behavior: none; }
  body { -webkit-user-select: none; user-select: none; }
  button, .card-slot, #draw-pile { touch-action: manipulation; }
  #game-screen { padding-top: env(safe-area-inset-top); }

  #topbar { height: 44px; gap: 8px; padding: 0 10px; }
  .logo-small { font-size: 17px; }
  #round-info { display: none; }
  #status-hint { font-size: 12px; }
  .score-strip { gap: 4px; }
  .score-chip { font-size: 10.5px; padding: 2px 7px 2px 4px; }
  .icon-btn { width: 34px; height: 34px; font-size: 14px; }

  /* 对手左列（side-col 由 JS 加类） */
  #opponents.side-col { top: 50px; bottom: 96px; left: 6px; gap: 5px; }

  /* 中央牌堆：右移避开左列 */
  #center-area { left: 56%; top: 47%; gap: 16px; }
  #deck-stack, #deck-stack .card { --cw: 58px; --ch: 86px; }
  .card.sz-discard, #discard-pile { --cw: 58px; --ch: 86px; }
  #dir-indicator { font-size: 40px; }
  #color-beacon { width: 18px; height: 18px; right: -28px; }
  .pile-label { font-size: 10px; }
  #table::after { left: 56%; width: 260px; height: 260px; }

  /* 底部手牌横贯 + 铭牌左下 */
  #my-area { padding: 0 6px calc(5px + env(safe-area-inset-bottom)); gap: 0; align-items: flex-start; }
  #my-hand { min-height: 76px; max-width: 100vw; align-self: stretch; justify-content: center; }
  #my-row { padding-left: 6px; gap: 10px; }
  .card.sz-hand { --cw: 46px; --ch: 68px; }
  #my-hand.tight .card-slot { margin-left: -30px !important; }
  #my-plaque { padding: 4px 10px; }
  .avatar { font-size: 15px; }
  #my-name { font-size: 11.5px; }
  #my-score { font-size: 10px; }

  #uno-flash { top: auto; bottom: calc(88px + env(safe-area-inset-bottom)); }
  #uno-flash-btn { font-size: 34px; padding: 10px 22px; }
  #uno-flash-timer { width: 120px; }
  #toast-layer { top: 50px; }

  .modal { width: 88vw; max-height: 90dvh; }
  .color-btn { height: 52px; font-size: 17px; }
}
