:root {
  --bg: #0c1017;
  --bg2: #111826;
  --panel: #17202f;
  --panel2: #1d2839;
  --line: #26344a;
  --text: #e8eef8;
  --dim: #93a3ba;
  --gold: #e8a24a;
  --gold2: #f2c078;
  --red: #e05a4e;
  --green: #3ecf8e;
  --board: #e8c98f;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 700px at 60% -10%, #1b2740 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--gold2); text-decoration: none; }
button { font-family: inherit; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: linear-gradient(180deg, #223148, #1a2434); color: var(--text);
  cursor: pointer; font-size: 14px; transition: .15s;
}
.btn:hover { border-color: #3a4d6b; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.primary { background: linear-gradient(180deg, #f0b463, #dd9236); border-color: #c9832e; color: #2a1a06; font-weight: 700; }
.btn.ghost { background: transparent; }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 22px; border-bottom: 1px solid var(--line); background: rgba(12,16,23,.75);
  backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 17px; margin: 0; letter-spacing: .5px; }
.topbar .sub { color: var(--dim); font-size: 12px; }
.topbar .spacer { flex: 1; }
.code-chip {
  font-family: ui-monospace, Consolas, monospace; font-size: 14px;
  background: #0e1622; border: 1px solid var(--line); border-radius: 9px; padding: 6px 10px;
  letter-spacing: 1px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); display: inline-block; }
.dot.on { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.wait { background: var(--gold); }

/* ---------- 大厅 ---------- */
.hero { max-width: 980px; margin: 0 auto; padding: 46px 22px 10px; }
.hero h2 { font-size: 40px; margin: 0 0 10px; letter-spacing: 2px; }
.hero h2 span { color: var(--gold); }
.hero p { color: var(--dim); margin: 0 0 26px; line-height: 1.8; }
.lobby-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.join-box { display: flex; gap: 8px; align-items: center; }
.join-box input {
  width: 130px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: #0e1622; color: var(--text); font-family: ui-monospace, monospace; letter-spacing: 1px;
}
.join-box input:focus { outline: none; border-color: var(--gold); }
.cards { max-width: 980px; margin: 26px auto 60px; padding: 0 22px; display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.card {
  background: linear-gradient(180deg, var(--panel), #131c29); border: 1px solid var(--line);
  border-radius: 16px; padding: 20px; position: relative; overflow: hidden;
}
.card h3 { margin: 0 0 6px; font-size: 19px; }
.card p { color: var(--dim); font-size: 13px; line-height: 1.7; margin: 0 0 16px; }
.card .tag { position: absolute; top: 16px; right: 16px; font-size: 11px; padding: 3px 8px; border-radius: 20px; background: #22314a; color: var(--gold2); }
.card.disabled { opacity: .55; }
.mini-board { font-size: 26px; letter-spacing: 3px; color: var(--gold); margin-bottom: 8px; }
.foot { color: #5d6b80; font-size: 12px; text-align: center; padding: 20px; }

/* ---------- 手机（大厅） ---------- */
@media (max-width: 640px) {
  .hero { padding: 26px 16px 6px; }
  .hero h2 { font-size: 27px; letter-spacing: 1px; line-height: 1.32; word-break: break-word; }
  .hero p { font-size: 13px; line-height: 1.75; margin-bottom: 18px; }
  .join-box { flex-wrap: wrap; gap: 8px; }
  .join-box .prefix { flex: 1 1 100%; font-size: 12px; }
  .join-box input { flex: 1 1 auto; min-width: 0; }
  .join-box button { flex: 0 0 auto; }
  .btn.big { width: 100%; }
  .foot-note { font-size: 11px; padding: 0 16px 18px; }
}

/* ---------- 房间 ---------- */
.room { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; padding: 20px; max-width: 1180px; margin: 0 auto; }
@media (max-width: 900px) {
  .room { grid-template-columns: 1fr; padding: 10px; }
  .topbar { padding: 10px 12px; flex-wrap: wrap; gap: 8px; }
  .topbar h1 { font-size: 15px; }
}
.board-wrap { display: flex; justify-content: center; align-items: flex-start; }
canvas#board { border-radius: 14px; box-shadow: 0 18px 50px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.05) inset; touch-action: manipulation; }
.panel { display: flex; flex-direction: column; gap: 12px; }
.block { background: linear-gradient(180deg, var(--panel), #131c29); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.block h4 { margin: 0 0 10px; font-size: 12px; color: var(--dim); font-weight: 600; letter-spacing: 1px; }
.seat { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; background: #0f1826; border: 1px solid transparent; }
.seat + .seat { margin-top: 8px; }
.seat.active { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(232,162,74,.25); }
.seat .who { font-size: 14px; }
.seat .meta { font-size: 11px; color: var(--dim); margin-left: auto; }
.seat .color-dot { width: 10px; height: 10px; border-radius: 50%; }
.seat .color-dot.red { background: var(--red); }
.seat .color-dot.black { background: #cfd8e6; }
.status {
  border-radius: 10px; padding: 11px 13px; font-size: 14px;
  background: #0f1826; border: 1px solid var(--line); min-height: 42px; display: flex; align-items: center;
}
.status.turn-me { border-color: var(--gold); color: var(--gold2); }
.status.bad { border-color: var(--red); color: #ff9a90; }
.moves { height: 210px; overflow-y: auto; font-size: 13px; line-height: 1.9; padding-right: 4px; }
.moves .row { display: grid; grid-template-columns: 26px 1fr 1fr; gap: 4px; border-radius: 6px; padding: 1px 4px; }
.moves .row.cur { background: rgba(232,162,74,.16); }
.moves .row .n { color: #5d6b80; }
.moves .r { color: #f0a8a0; }
.moves .b { color: #cfe0f5; }
.moves .empty { color: #5d6b80; font-size: 12px; }
.share { display: flex; gap: 8px; }
.share input {
  flex: 1; min-width: 0; padding: 9px 10px; border-radius: 9px; border: 1px solid var(--line);
  background: #0e1622; color: var(--dim); font-size: 12px; font-family: ui-monospace, monospace;
}
.hint { color: #6b7c93; font-size: 12px; line-height: 1.7; margin-top: 8px; }

/* 特效层 */
#fx { position: fixed; inset: 0; pointer-events: none; display: flex; align-items: center; justify-content: center; z-index: 60; }
#fx .shout {
  font-family: "KaiTi", "STKaiti", "Microsoft YaHei", serif;
  font-size: clamp(64px, 14vw, 190px); font-weight: 900; letter-spacing: 12px;
  color: #ffd18a; text-shadow: 0 0 30px rgba(255,150,40,.85), 0 0 90px rgba(255,90,20,.6), 0 8px 30px rgba(0,0,0,.6);
  opacity: 0; transform: scale(.6) rotate(-6deg);
}
#fx .shout.go { animation: shout 1.15s cubic-bezier(.2,.9,.2,1) forwards; }
#fx .shout.small { font-size: clamp(40px, 8vw, 96px); letter-spacing: 6px; color: #ffb3a6; text-shadow: 0 0 26px rgba(255,60,40,.8), 0 0 70px rgba(255,60,20,.5); }
@keyframes shout {
  0%   { opacity: 0; transform: scale(1.9) rotate(-8deg); filter: blur(14px); }
  22%  { opacity: 1; transform: scale(1) rotate(-3deg); filter: blur(0); }
  70%  { opacity: 1; transform: scale(1.04) rotate(-3deg); }
  100% { opacity: 0; transform: scale(1.15) rotate(-3deg); }
}
.shake { animation: shake .5s; }
@keyframes shake {
  0%,100% { transform: translate(0,0); }
  20% { transform: translate(-6px, 3px); }
  40% { transform: translate(5px, -4px); }
  60% { transform: translate(-4px, -2px); }
  80% { transform: translate(3px, 3px); }
}
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(20px);
  background: #1c2839; border: 1px solid var(--line); color: var(--text);
  padding: 11px 18px; border-radius: 12px; font-size: 14px; opacity: 0;
  transition: .25s; pointer-events: none; z-index: 70; box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- UNO ---------- */
.uno { display: grid; grid-template-rows: auto auto; gap: 14px; align-content: start; }
.opps { display: flex; gap: 10px; flex-wrap: wrap; }
.opp {
  background: linear-gradient(180deg, var(--panel), #131c29); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 14px; min-width: 120px;
}
.opp.active { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(232,162,74,.3); }
.opp .n { font-size: 14px; }
.opp .c { font-size: 12px; color: var(--dim); margin-top: 3px; }
.opp .cards { display: flex; gap: -8px; margin-top: 6px; }
.table { position: relative; border-radius: 18px; padding: 22px 18px 26px; background: radial-gradient(600px 300px at 50% 0%, #1d2b40, #101823 70%); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 16px; align-items: center; }
.pile { display: flex; gap: 34px; align-items: center; }
.deck {
  width: 92px; height: 132px; border-radius: 12px; cursor: pointer;
  background: repeating-linear-gradient(45deg, #24344d, #24344d 6px, #1b2839 6px, #1b2839 12px);
  border: 2px dashed #3a4d6b; display: flex; align-items: center; justify-content: center;
  color: var(--dim); font-size: 13px; text-align: center; user-select: none;
}
.deck:hover { border-color: var(--gold); color: var(--gold2); }
.ucard {
  width: 92px; height: 132px; border-radius: 12px; position: relative; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #fff; box-shadow: 0 8px 22px rgba(0,0,0,.45);
  border: 3px solid rgba(255,255,255,.9); user-select: none;
  transition: transform .12s, box-shadow .12s;
}
.ucard.r { background: linear-gradient(160deg, #e2503f, #b0261c); }
.ucard.y { background: linear-gradient(160deg, #efb02c, #c98a00); }
.ucard.g { background: linear-gradient(160deg, #35b46a, #177c43); }
.ucard.b { background: linear-gradient(160deg, #3d7fe0, #1f4ea8); }
.ucard.w { background: conic-gradient(from 210deg, #e2503f, #efb02c, #35b46a, #3d7fe0, #e2503f); }
.ucard .v { font-size: 34px; text-shadow: 0 2px 6px rgba(0,0,0,.4); }
.ucard .v.sm { font-size: 22px; letter-spacing: 0; }
.ucard .corner { position: absolute; top: 6px; left: 8px; font-size: 13px; opacity: .9; }
.ucard .corner2 { position: absolute; bottom: 6px; right: 8px; font-size: 13px; opacity: .85; }
.ucard.playable { border-color: #ffd79a; box-shadow: 0 0 0 2px rgba(255,215,154,.5), 0 10px 24px rgba(0,0,0,.5); transform: translateY(-4px); cursor: pointer; }
.ucard.playable:hover { transform: translateY(-12px); box-shadow: 0 0 0 3px rgba(255,215,154,.8), 0 16px 30px rgba(0,0,0,.6); }
.ucard.dim { filter: grayscale(.45) brightness(.72); }
.hand { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; padding: 8px 4px; min-height: 150px; align-items: flex-end; }
.picker { position: fixed; inset: 0; background: rgba(6,10,16,.72); display: flex; align-items: center; justify-content: center; z-index: 80; }
.picker .box { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px; text-align: center; }
.picker h3 { margin: 0 0 14px; font-size: 16px; }
.picker .swatches { display: flex; gap: 12px; }
.sw { width: 62px; height: 62px; border-radius: 12px; cursor: pointer; border: 3px solid rgba(255,255,255,.85); }
.sw.r { background: #d33a2c; } .sw.y { background: #e0a41c; } .sw.g { background: #2c9e5c; } .sw.b { background: #2f68c8; }
.log { font-size: 12px; color: var(--dim); line-height: 1.8; }

/* ---------- 大厅 / 选玩法 ---------- */
.btn.big { font-size: 17px; padding: 14px 30px; border-radius: 14px; }
.hero code { background: rgba(255,255,255,.08); padding: 2px 6px; border-radius: 6px; font-size: 13px; }
.pick {
  grid-column: 1 / 2; background: linear-gradient(180deg, #16202e, #101823);
  border: 1px solid var(--line); border-radius: 18px; padding: 34px 30px;
  display: flex; flex-direction: column; align-items: center; gap: 18px; min-height: 420px; justify-content: center;
}
.pick h2 { margin: 0; font-size: 24px; }
.pick-grid { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.pick-card {
  width: 210px; padding: 22px 18px; border-radius: 16px; cursor: pointer; text-align: center;
  background: linear-gradient(180deg, #1b2738, #131c29); border: 1px solid var(--line);
  color: var(--text); font-family: inherit; transition: transform .14s, border-color .14s, box-shadow .14s;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.pick-card:hover { transform: translateY(-4px); border-color: var(--gold); box-shadow: 0 12px 30px rgba(0,0,0,.45); }
.pick-card .ic { font-size: 40px; line-height: 1.1; color: var(--gold2); }
.pick-card b { font-size: 17px; }
.pick-card i { font-style: normal; font-size: 12px; color: var(--dim); }
.tagline { font-weight: 400; font-size: 12px; color: var(--dim); margin-left: 6px; }
.seat-ctl { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.seat-ctl select {
  background: #101a26; color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 7px 10px; font-family: inherit; font-size: 13px;
}

/* ---------- 大厅：自定义房间名 ---------- */
.lobby-code {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 14px; font-size: 13px; color: var(--dim);
}
.lobby-code label { color: var(--dim); }
.lobby-code #prefixHost { color: #8aa0b8; font-family: ui-monospace, monospace; font-size: 13px; }
.lobby-code input {
  min-width: 160px; padding: 9px 12px; border-radius: 10px;
  background: #101a26; border: 1px solid var(--line); color: var(--text);
  font-family: ui-monospace, monospace; font-size: 13px; outline: none;
}
.lobby-code input:focus { border-color: var(--gold); }
/* ---------- 手机：大厅地址行 ---------- */
@media (max-width: 640px) {
  .lobby-code { align-items: flex-start; row-gap: 6px; }
  .lobby-code #prefixHost { flex: 1 1 100%; word-break: break-all; line-height: 1.4; }
  .lobby-code input { flex: 1 1 100%; min-width: 0; width: 100%; }
  .lobby-code .sub { flex: 1 1 100%; }
}
