:root {
  --red: #e05b4c;
  --yellow: #e8b53a;
  --blue: #4c8fe0;
  --green: #4faa60;
  --ink: #10171a;
  --panel: #18231f;
  --line: rgba(255, 255, 255, 0.14);
  --text: #eef5f0;
  --muted: #9db2a8;
  --accent: #ffd166;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; background: #0d1412; color: var(--text);
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  overscroll-behavior: none; touch-action: manipulation;
}
#app { position: relative; width: 100%; height: 100%; overflow: hidden; }
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* ---------- 大厅 ---------- */
#lobby { align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; }
.logo {
  margin: 0; font-size: clamp(30px, 9vw, 52px); letter-spacing: .12em;
  color: var(--accent); text-shadow: 0 6px 0 rgba(0, 0, 0, .45);
}
.sub { margin: 0; color: var(--muted); font-size: 14px; }
.lobby-btns { display: flex; flex-direction: column; gap: 12px; width: min(420px, 92vw); margin-top: 8px; }
.big-btn {
  padding: 16px 18px; font-size: 19px; font-weight: 700; color: #241a06;
  background: linear-gradient(180deg, #ffe08a, #f0b740); border: 0; border-radius: 14px;
  box-shadow: 0 5px 0 #a97a1e, 0 10px 20px rgba(0, 0, 0, .35); cursor: pointer;
  touch-action: manipulation;
}
.big-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #a97a1e; }
.big-btn:disabled { filter: grayscale(.8) brightness(.7); cursor: not-allowed; box-shadow: none; transform: none; }
.howto { width: min(520px, 92vw); color: var(--muted); font-size: 13px; text-align: left; line-height: 1.6; }
.howto summary { color: var(--accent); cursor: pointer; }

/* ---------- 牌桌 ---------- */
#table { padding: max(8px, env(safe-area-inset-top)) 10px max(8px, env(safe-area-inset-bottom)); gap: 6px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.opp { display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #9fe0b0, #3f7a52); color: #10201a; font-weight: 800;
}
.opp-info { display: flex; flex-direction: column; line-height: 1.15; font-size: 13px; }
.opp-info span { color: var(--muted); font-size: 12px; }
.flags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.flag {
  padding: 4px 9px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, .06);
}
.flag.red { color: #ffb3aa; border-color: #e05b4c; }
.flag.yellow { color: #ffe08a; border-color: #e8b53a; }
.flag.blue { color: #a9ccff; border-color: #4c8fe0; }
.flag.green { color: #a8e8b8; border-color: #4faa60; }

.middle { display: flex; align-items: center; justify-content: center; gap: 26px; flex: 1; min-height: 0; }
.pile { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.pile-label { font-size: 11px; color: var(--muted); }
.pile-btn { background: none; border: 0; padding: 0; cursor: pointer; display: grid; gap: 6px; justify-items: center; }
.card-back, .card {
  width: 74px; height: 108px; border-radius: 10px; display: grid; place-items: center;
  background: #24332c; border: 2px solid rgba(255, 255, 255, .2);
  box-shadow: 0 4px 10px rgba(0, 0, 0, .45);
}
.card-back {
  background:
    repeating-linear-gradient(45deg, #2f463b 0 6px, #263a31 6px 12px);
  border-color: #3f5d4d;
}
.card.big { width: 96px; height: 140px; font-size: 30px; font-weight: 800; }
.card { color: #0e1512; position: relative; }
.card.red { background: linear-gradient(160deg, #ff8a7a, #d0412f); }
.card.yellow { background: linear-gradient(160deg, #ffe08a, #d9a521); }
.card.blue { background: linear-gradient(160deg, #8ec2ff, #2f6fc4); }
.card.green { background: linear-gradient(160deg, #9ae2a8, #3d8a4e); }
.card.wild { background: linear-gradient(135deg, #e05b4c, #e8b53a, #4c8fe0, #4faa60); }
.card .corner { position: absolute; top: 5px; left: 7px; font-size: 12px; font-weight: 700; opacity: .85; }
.card .face { font-size: 26px; line-height: 1; }

.hint { margin: 0; text-align: center; font-size: 13px; color: var(--accent); min-height: 18px; }
.log { margin: 0; text-align: center; font-size: 11.5px; color: var(--muted); min-height: 15px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.hand-wrap { overflow: hidden; }
.hand {
  display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; padding: 6px 2px 10px;
  scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; touch-action: pan-x;
}
.hand::-webkit-scrollbar { height: 4px; }
.hand::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .18); border-radius: 4px; }
.hand .card { flex: 0 0 auto; width: 66px; height: 96px; font-size: 22px; scroll-snap-align: start; }
.hand .card.playable { outline: 3px solid var(--accent); outline-offset: 1px; transform: translateY(-6px); }
.hand .card.dim { opacity: .52; }
.hand .card { cursor: pointer; }

.actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.act {
  padding: 11px 16px; border-radius: 12px; font-size: 15px; font-weight: 700;
  color: #10201a; background: #cfe8d6; border: 0; box-shadow: 0 3px 0 #7f9c88; cursor: pointer;
  touch-action: manipulation;
}
.act:active { transform: translateY(2px); box-shadow: 0 1px 0 #7f9c88; }
.act:disabled { opacity: .38; box-shadow: none; transform: none; cursor: not-allowed; }
.act.danger { background: #ffc7bd; box-shadow: 0 3px 0 #a5534a; }
.act.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); box-shadow: none; }

/* ---------- 弹层 ---------- */
.overlay {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(6, 10, 9, .72); backdrop-filter: blur(3px); z-index: 10;
}
.panel {
  width: min(360px, 90vw); padding: 22px; border-radius: 18px; text-align: center;
  background: var(--panel); border: 1px solid var(--line); box-shadow: 0 20px 50px rgba(0, 0, 0, .5);
}
.panel h2 { margin: 0 0 8px; font-size: 22px; color: var(--accent); }
.color-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0 14px; }
.color-btn { padding: 18px; border-radius: 12px; border: 0; font-size: 17px; font-weight: 800; color: #0e1512; cursor: pointer; }
.color-btn.red { background: #e05b4c; }
.color-btn.yellow { background: #e8b53a; }
.color-btn.blue { background: #4c8fe0; }
.color-btn.green { background: #4faa60; }
.over-btns { display: grid; gap: 10px; margin-top: 6px; }

@media (max-height: 620px) {
  .card.big { width: 76px; height: 112px; font-size: 24px; }
  .hand .card { width: 56px; height: 82px; font-size: 19px; }
  .middle { gap: 18px; }
}

/* ---------- 好友房 ---------- */
.join-box { display: flex; gap: 8px; align-items: center; width: min(420px, 92vw); }
.code-input {
  flex: 1; min-width: 0; padding: 12px 14px; border-radius: 12px; font-size: 18px;
  letter-spacing: .18em; text-transform: uppercase; color: var(--text);
  background: #101a16; border: 1px solid var(--line); outline: none;
}
.code-input:focus { border-color: var(--accent); }
#room { align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center; }
.room-title { margin: 0; font-size: 24px; color: var(--accent); }
.room-code-row { display: flex; align-items: center; gap: 12px; }
.room-code {
  font-size: clamp(30px, 11vw, 44px); font-weight: 800; letter-spacing: .28em;
  color: #fff; text-shadow: 0 4px 0 rgba(0,0,0,.4);
}
.room-players {
  list-style: none; margin: 6px 0; padding: 0; width: min(420px, 92vw);
  display: grid; gap: 8px;
}
.room-players li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; border-radius: 12px; background: rgba(255,255,255,.05);
  border: 1px solid var(--line); font-size: 15px;
}
.room-players b { color: var(--accent); font-size: 13px; font-weight: 700; }
.room-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; width: min(420px, 92vw); }
.room-actions .big-btn { flex: 1 1 140px; }
