:root {
  --ink: #1c1410;
  --muted: #6b5648;
  --paper: #f3e6d4;
  --paper-2: #e8d5bc;
  --vermillion: #c23b22;
  --vermillion-deep: #8f2414;
  --gold: #c9a227;
  --gold-soft: #e6c96a;
  --felt: #1f5c45;
  --felt-deep: #143d2e;
  --cream-line: rgba(28, 20, 16, 0.12);
  --shadow: 0 18px 50px rgba(28, 20, 16, 0.18);
  --radius: 18px;
  --font-display: "ZCOOL XiaoWei", "Songti SC", serif;
  --font-body: "Noto Sans SC", "PingFang SC", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background: #2a1c14;
}

#bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(201, 162, 39, 0.28), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(194, 59, 34, 0.22), transparent 50%),
    linear-gradient(165deg, #3a2418 0%, #1a100c 45%, #10261c 100%);
}
#bg::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.08;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cpath d='M0 60h120M60 0v120' stroke='%23fff' stroke-width='.5' fill='none'/%3E%3C/svg%3E");
}

#app {
  width: min(1100px, calc(100% - 24px));
  margin: 0 auto;
  padding: 20px 0 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  animation: rise 0.6s ease both;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 52px; height: 52px; border-radius: 14px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--gold-soft), var(--vermillion));
  color: #fff; font-family: var(--font-display); font-size: 28px;
  box-shadow: 0 8px 24px rgba(194, 59, 34, 0.35);
}
.brand h1 {
  margin: 0; font-family: var(--font-display); font-size: clamp(28px, 5vw, 40px);
  letter-spacing: 0.04em; color: #f8efdf;
}
.tagline { margin: 2px 0 0; color: rgba(248, 239, 223, 0.65); font-size: 13px; }

.user-box {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 999px;
  background: rgba(243, 230, 212, 0.12);
  color: #f8efdf; backdrop-filter: blur(8px);
}
.user-box img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: #543; }
.user-box .meta { line-height: 1.2; }
.user-box .meta strong { display: block; font-size: 14px; }
.user-box .meta span { font-size: 12px; opacity: 0.75; }

.panel {
  background: linear-gradient(180deg, var(--paper), var(--paper-2));
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  animation: rise 0.55s ease both;
}
.panel h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 400;
}
.lead { margin: 0 0 18px; color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; min-height: 1.2em; }

.login-actions { display: grid; gap: 14px; max-width: 360px; }
.guest-wrap { display: grid; gap: 10px; }

label {
  display: grid; gap: 6px; margin-bottom: 12px;
  font-size: 13px; color: var(--muted);
}
input, select {
  width: 100%;
  border: 1px solid var(--cream-line);
  background: rgba(255,255,255,0.55);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  color: var(--ink);
  outline: none;
}
input:focus, select:focus {
  border-color: rgba(194, 59, 34, 0.45);
  box-shadow: 0 0 0 3px rgba(194, 59, 34, 0.12);
}

.btn {
  appearance: none; border: 0; cursor: pointer;
  border-radius: 12px; padding: 12px 18px;
  font: inherit; font-weight: 600;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  text-decoration: none; text-align: center; display: inline-block;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: linear-gradient(135deg, var(--vermillion), var(--vermillion-deep));
  color: #fff;
  box-shadow: 0 10px 24px rgba(194, 59, 34, 0.28);
}
.btn-secondary {
  background: linear-gradient(135deg, #2f6b52, #1d4737);
  color: #f4fff8;
}
.btn-qq {
  background: linear-gradient(135deg, #12b7f5, #0b7db8);
  color: #fff;
}
.btn-ghost {
  background: transparent; color: var(--ink);
  border: 1px solid var(--cream-line);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.lobby-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.card-block {
  padding: 8px;
}
.room-list-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 18px;
}
.room-list-head h3 { margin: 0; font-size: 16px; }
.room-list {
  list-style: none; margin: 10px 0 0; padding: 0;
  display: grid; gap: 8px; max-height: 280px; overflow: auto;
}
.room-list li {
  display: flex; justify-content: space-between; gap: 10px; align-items: center;
  padding: 12px 14px; border-radius: 12px;
  background: rgba(255,255,255,0.4);
  border: 1px solid var(--cream-line);
}
.room-list button { padding: 8px 12px; font-size: 13px; }

.room-meta {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.room-actions-top { display: flex; gap: 8px; flex-wrap: wrap; }
.muted { color: var(--muted); margin: 4px 0 0; font-size: 13px; }

.table {
  position: relative;
  min-height: 320px;
  border-radius: 999px / 180px;
  background:
    radial-gradient(circle at 50% 40%, rgba(255,255,255,0.08), transparent 40%),
    linear-gradient(160deg, var(--felt), var(--felt-deep));
  border: 10px solid #6b3f24;
  box-shadow: inset 0 0 60px rgba(0,0,0,0.35), 0 16px 40px rgba(0,0,0,0.25);
  margin: 10px 0 16px;
  overflow: hidden;
}
.pot {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%);
  color: #f6f0d8; font-weight: 700; letter-spacing: 0.06em;
  background: rgba(0,0,0,0.28); padding: 8px 16px; border-radius: 999px;
  animation: pulseSoft 2.4s ease-in-out infinite;
}
.seats {
  position: absolute; inset: 18px;
}
.seat {
  position: absolute; width: 120px; text-align: center; color: #f7f1e4;
  transform: translate(-50%, -50%);
  transition: transform 0.25s ease, filter 0.25s ease;
}
.seat.turn { filter: drop-shadow(0 0 10px rgba(230, 201, 106, 0.85)); transform: translate(-50%, -50%) scale(1.05); }
.seat.folded { opacity: 0.45; }
.seat .avatar {
  width: 48px; height: 48px; border-radius: 50%; margin: 0 auto 6px;
  background: #4a3124; border: 2px solid var(--gold);
  display: grid; place-items: center; font-weight: 700; overflow: hidden;
}
.seat .avatar img { width: 100%; height: 100%; object-fit: cover; }
.seat .name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat .chips { font-size: 12px; opacity: 0.85; }
.seat .badge {
  display: inline-block; margin-top: 4px; font-size: 11px;
  background: rgba(0,0,0,0.35); padding: 2px 8px; border-radius: 999px;
}
.seat .mini-cards { display: flex; justify-content: center; gap: 3px; margin-top: 6px; }

.card-face, .card-back {
  width: 42px; height: 60px; border-radius: 6px;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
  box-shadow: 0 4px 10px rgba(0,0,0,0.25);
}
.card-face {
  background: #fffaf2; color: #1c1410; border: 1px solid #ddd0bc;
}
.card-face.red { color: #c23b22; }
.card-back {
  background:
    linear-gradient(135deg, rgba(255,255,255,0.15), transparent),
    repeating-linear-gradient(45deg, #7a1f18 0 4px, #9b2b20 4px 8px);
  border: 1px solid #5c1610;
}

.my-cards {
  display: flex; justify-content: center; gap: 10px; min-height: 70px; margin-bottom: 12px;
}
.my-cards .card-face, .my-cards .card-back {
  width: 64px; height: 92px; font-size: 16px; border-radius: 10px;
  animation: dealIn 0.35s ease both;
}

.actions {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 14px;
}
.actions .btn { min-width: 88px; }
.compare-targets {
  width: 100%; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 6px;
}

.log-wrap h3 { margin: 0 0 8px; font-size: 15px; }
.game-log {
  list-style: none; margin: 0; padding: 12px;
  max-height: 160px; overflow: auto;
  background: rgba(255,255,255,0.35); border-radius: 12px;
  border: 1px solid var(--cream-line);
  font-size: 13px; color: var(--muted);
}
.game-log li { padding: 4px 0; border-bottom: 1px dashed rgba(0,0,0,0.06); }
.game-log li:last-child { border-bottom: 0; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: rgba(28,20,16,0.92); color: #fff; padding: 12px 18px;
  border-radius: 12px; z-index: 50; max-width: min(90vw, 420px);
  animation: rise 0.25s ease both;
}

.hidden { display: none !important; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes dealIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes pulseSoft {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.04); }
}

@media (max-width: 820px) {
  .lobby-grid { grid-template-columns: 1fr; }
  .table { border-radius: 28px; min-height: 380px; }
  .seat { width: 96px; }
  .seat .avatar { width: 40px; height: 40px; }
}
