:root {
  --bg: #070b12;
  --panel: #121a28;
  --line: #223149;
  --text: #e9eef7;
  --muted: #93a1b8;
  --gold: #e2b75f;
  --gold-soft: #f7dc9c;
  --red: #d34747;
  --green: #1f7a54;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, Segoe UI, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 50% -10%, #1a2940 0%, #0a1019 55%, #05080d 100%);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* ---------- 大厅 ---------- */
.lobby { align-items: center; justify-content: center; padding: 24px; overflow: auto; }
.lobby-card {
  width: min(92vw, 420px);
  background: linear-gradient(180deg, #131c2c, #0c121c);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .5);
}
.logo { color: var(--gold); letter-spacing: 8px; text-align: center; font-size: 16px; }
h1 { margin: 10px 0 4px; text-align: center; font-size: 30px; letter-spacing: 3px; }
.sub { margin: 0 0 18px; text-align: center; color: var(--muted); font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; font-size: 13px; color: var(--muted); }
.grow { flex: 1; }
input, select {
  background: #0a111b;
  border: 1px solid #26364f;
  border-radius: 10px;
  padding: 11px 12px;
  color: var(--text);
  font-size: 15px;
  outline: none;
  width: 100%;
}
input:focus, select:focus { border-color: var(--gold); }
button {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 15px;
  font-weight: 700;
  color: #0b1018;
  background: var(--gold);
  transition: filter .15s, transform .05s;
}
button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }
button.secondary { background: #22314a; color: var(--text); }
button.mini { padding: 5px 10px; font-size: 12px; border-radius: 8px; background: #1c2940; color: var(--text); }
button.danger { background: #3a1e25; color: #ffb4b4; }
button.block { width: 100%; margin-top: 12px; }
button.mini.active { background: var(--gold); color: #111; }
.create-row { display: flex; gap: 10px; align-items: flex-end; margin-top: 16px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 20px 0 8px; }
.divider::before, .divider::after { content: ''; height: 1px; background: var(--line); flex: 1; }
.join-row { display: flex; gap: 10px; }
.join-row input { flex: 1; text-transform: uppercase; letter-spacing: 5px; text-align: center; font-weight: 800; }
.error { color: #ff8080; font-size: 13px; min-height: 18px; margin: 10px 0 0; }
.hint { color: var(--muted); font-size: 12px; text-align: center; margin: 10px 0 0; line-height: 1.5; }

/* ---------- 游戏 ---------- */
.game { padding: 10px 14px 12px; gap: 6px; }
.topbar { display: flex; align-items: center; gap: 10px; }
.room-pill {
  background: #101826;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.room-pill b { color: var(--gold); letter-spacing: 3px; font-size: 15px; }
.top-actions { display: flex; gap: 6px; margin-left: auto; }
.street-chip {
  font-size: 11px;
  color: #9fb2a7;
  background: rgba(0, 0, 0, .32);
  border: 1px solid rgba(255, 255, 255, .08);
  padding: 2px 10px;
  border-radius: 999px;
}
.my-hand { font-size: 12px; color: var(--gold-soft); min-height: 16px; font-weight: 600; }
.turnline { height: 3px; background: #101826; border-radius: 99px; overflow: hidden; margin-top: 2px; }
.turnline i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--gold), var(--gold-soft));
  transition: width .1s linear;
}

.table-wrap { position: relative; flex: 1; min-height: 0; margin-top: 4px; }
.felt {
  position: absolute;
  inset: 12% 9% 16%;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 36%, #1d6b4c 0%, #14503a 55%, #0d3a2a 100%);
  border: 10px solid #241a12;
  box-shadow:
    inset 0 0 70px rgba(0, 0, 0, .55),
    0 24px 60px rgba(0, 0, 0, .5),
    0 0 0 1px rgba(255, 255, 255, .04);
}
.center {
  position: absolute;
  left: 50%; top: 45%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  width: min(64%, 560px);
  pointer-events: none;
  z-index: 2;
}
.pot {
  font-size: 13px;
  color: #cfe3d7;
  background: rgba(0, 0, 0, .45);
  border: 1px solid rgba(255, 255, 255, .12);
  padding: 4px 12px;
  border-radius: 999px;
  font-weight: 600;
}
.board { display: flex; gap: 6px; justify-content: center; }
.result {
  font-size: 14px;
  font-weight: 800;
  color: #ffe6a3;
  text-align: center;
  text-shadow: 0 2px 12px rgba(0, 0, 0, .7);
  min-height: 20px;
  line-height: 1.45;
}

/* 扑克牌 */
.card {
  width: 46px; height: 64px;
  border-radius: 7px;
  background: #f6f2e8;
  color: #17181c;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .45);
  user-select: none;
  flex: none;
}
.card .r { font-size: 16px; }
.card .s { font-size: 16px; margin-top: 3px; }
.card.red { color: #c0392b; }
.card.back {
  background:
    repeating-linear-gradient(45deg, #244b7a 0 6px, #1b3a61 6px 12px);
  border: 1px solid #3a6ba5;
}
.card.empty {
  background: rgba(255, 255, 255, .045);
  border: 1px dashed rgba(255, 255, 255, .2);
  box-shadow: none;
}
.card.big { width: 56px; height: 78px; }
.card.big .r { font-size: 19px; }
.card.big .s { font-size: 19px; }

/* 座位 */
#seats { position: absolute; inset: 0; z-index: 3; }
.seat {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 132px;
  transition: opacity .2s;
}
.seat.pos-0 { left: 50%; top: 87%; }
.seat.pos-1 { left: 9%; top: 70%; }
.seat.pos-2 { left: 7%; top: 27%; }
.seat.pos-3 { left: 50%; top: 7%; }
.seat.pos-4 { left: 93%; top: 27%; }
.seat.pos-5 { left: 91%; top: 70%; }

.seat-cards { display: flex; gap: 4px; min-height: 44px; align-items: flex-end; }
.seat.me .card { width: 52px; height: 72px; }
.seat.me .card .r, .seat.me .card .s { font-size: 19px; }

.seat-plate {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  background: rgba(6, 10, 16, .74);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 10px;
  padding: 3px 10px;
  min-width: 92px;
  backdrop-filter: blur(4px);
}
.name-row { display: flex; align-items: center; gap: 4px; max-width: 100%; }
.seat .name {
  font-size: 12px;
  color: #cfd8e6;
  max-width: 106px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.seat .stack { font-size: 14px; font-weight: 800; color: var(--gold); }
.seat.me .seat-plate { border-color: rgba(226, 183, 95, .8); }
.seat.me .name::after { content: ' · 你'; color: var(--gold); font-size: 10px; }
.seat.empty { opacity: .28; }
.seat.folded { opacity: .45; }
.seat.sitout { opacity: .55; }
.seat.acting .seat-plate {
  box-shadow: 0 0 0 2px var(--gold), 0 0 22px rgba(226, 183, 95, .45);
}
.seat.winner .seat-plate {
  border-color: #6ee7a8;
  box-shadow: 0 0 18px rgba(110, 231, 168, .55);
}
.seat-bet {
  background: rgba(0, 0, 0, .6);
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  color: #cdd8e6;
  white-space: nowrap;
}
.seat-bet.act {
  color: #ffe6a3;
  border-color: rgba(226, 183, 95, .45);
  background: rgba(60, 45, 15, .6);
}
.dealer {
  flex: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  color: #111;
  font-size: 10px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .45);
}
.tag {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .5px;
  padding: 1px 7px;
  border-radius: 999px;
}
.allin-tag { bottom: -13px; background: #7a2230; color: #ffd0d0; }
.fold-tag { bottom: -13px; background: #2a3242; color: #9aa8bd; }
.sitout-tag { bottom: -13px; background: #25304a; color: #9fb3d9; }

/* ---------- 底部 ---------- */
.bottom { display: flex; gap: 10px; align-items: stretch; margin-top: 4px; }
.action-bar {
  flex: 1;
  background: rgba(12, 18, 28, .88);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-height: 64px;
}
.btn-act { padding: 10px 18px; border-radius: 10px; font-size: 15px; }
.btn-fold { background: #3a1e25; color: #ffb4b4; }
.btn-check { background: #1f3a2c; color: #b9f0cf; }
.btn-raise { background: var(--gold); color: #111; }
.raise-box { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 260px; }
.raise-box input[type="range"] { flex: 1; accent-color: var(--gold); }
.raise-amount { font-weight: 800; color: var(--gold); min-width: 62px; text-align: right; font-size: 15px; }
.preset { background: #1c2940; color: #cfd8e6; font-size: 12px; padding: 6px 10px; border-radius: 8px; }
.waiting { color: var(--muted); font-size: 14px; margin: auto; }
.waiting b { color: var(--text); }
.my-clock {
  margin-left: auto;
  font-weight: 800;
  color: var(--gold);
  font-size: 15px;
  min-width: 42px;
  text-align: right;
}
.my-clock.urgent { color: #ff8080; animation: clockpulse .8s infinite; }
@keyframes clockpulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }

.log-panel {
  width: 300px;
  max-width: 38vw;
  background: rgba(8, 12, 19, .7);
  border: 1px solid #1c2940;
  border-radius: 14px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.55;
  color: #a9b7cc;
  overflow-y: auto;
  max-height: 118px;
}

.conn-banner {
  position: fixed;
  top: 8px; left: 50%;
  transform: translateX(-50%);
  background: #5a1f2a;
  color: #ffd6d6;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 999px;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
}
.toast {
  position: fixed;
  left: 50%; bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: #22314a;
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 99;
  max-width: 80vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 760px) {
  .game { padding: 8px; }
  .topbar { gap: 6px; flex-wrap: nowrap; }
  .top-actions { gap: 4px; }
  .room-pill { padding: 4px 8px; font-size: 11px; white-space: nowrap; gap: 5px; }
  .room-pill b { font-size: 13px; letter-spacing: 1px; }
  .hand-info { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  button.mini { padding: 4px 7px; font-size: 11px; }
  .card { width: 34px; height: 48px; }
  .card .r, .card .s { font-size: 12px; }
  .card.big { width: 38px; height: 52px; }
  .card.big .r, .card.big .s { font-size: 14px; }
  .seat { width: 92px; }
  .seat.me .card { width: 44px; height: 62px; }
  .seat.me .card .r, .seat.me .card .s { font-size: 15px; }
  .seat .name { font-size: 11px; max-width: 66px; }
  .seat .stack { font-size: 12px; }
  .seat-plate { min-width: 70px; padding: 2px 7px; }
  .seat .name::after { display: none; }
  .seat.pos-0 { left: 50%; top: 86%; }
  .seat.pos-1 { left: 17%; top: 72%; }
  .seat.pos-2 { left: 15%; top: 25%; }
  .seat.pos-3 { left: 50%; top: 6%; }
  .seat.pos-4 { left: 85%; top: 25%; }
  .seat.pos-5 { left: 83%; top: 72%; }
  .bottom { flex-direction: column; gap: 6px; }
  .action-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 8px;
    min-height: 0;
  }
  .action-bar > .btn-act { width: 100%; }
  .raise-box {
    grid-column: 1 / -1;
    min-width: 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    width: 100%;
  }
  .raise-box input[type="range"] { grid-column: 1 / 3; width: 100%; }
  .raise-amount { grid-column: 3; text-align: right; }
  .raise-box .btn-raise { grid-column: 1 / -1; }
  .waiting { grid-column: 1 / -1; }
  .btn-act { padding: 9px 12px; font-size: 14px; }
  .preset { padding: 7px 6px; font-size: 11px; }
  .log-panel { width: 100%; max-width: none; max-height: 58px; padding: 6px 8px; font-size: 11px; }
  .center { width: 78%; top: 44%; gap: 6px; }
  .felt { inset: 9% 3% 13%; border-width: 6px; }
  .pot { font-size: 12px; padding: 3px 10px; }
  .result { font-size: 12px; }
}

@media (max-height: 620px) {
  .card { width: 34px; height: 47px; }
  .card.big { width: 42px; height: 58px; }
  .seat.me .card { width: 42px; height: 58px; }
  .seat-cards { min-height: 40px; }
  .log-panel { max-height: 70px; }
}
