:root {
  --bg: #101418;
  --panel: rgba(20, 25, 30, .82);
  --panel-strong: rgba(12, 16, 20, .92);
  --line: rgba(255, 255, 255, .12);
  --text: #f7f2e8;
  --muted: rgba(247, 242, 232, .68);
  --gold: #d7b35a;
  --green: #26a269;
  --blue: #4aa3df;
  --red: #d35f5f;
  --violet: #a58ce6;
  --card-radius: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--text);
  font-family: "Microsoft YaHei", system-ui, sans-serif;
  background: #101418;
}

button, input { font: inherit; }
button {
  border: 0;
  border-radius: var(--card-radius);
  padding: 10px 14px;
  color: #121712;
  background: var(--gold);
  font-weight: 800;
  cursor: pointer;
}
button.secondary { color: var(--text); background: rgba(255,255,255,.1); border: 1px solid var(--line); }
button.icon { width: 40px; height: 40px; padding: 0; display: grid; place-items: center; }
button:disabled { opacity: .48; cursor: not-allowed; }
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  padding: 12px 13px;
  color: var(--text);
  background: rgba(0,0,0,.28);
  outline: none;
}

.app-shell { min-height: 100vh; }
.layout {
  width: min(1360px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 18px 0 28px;
}
.topbar {
  display: grid;
  grid-template-columns: 260px 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  background: var(--panel-strong);
  position: sticky;
  top: 10px;
  z-index: 20;
  backdrop-filter: blur(12px);
}
.brand-title { font-size: 24px; font-weight: 950; color: var(--gold); }
.brand-subtitle, .muted { color: var(--muted); }
.brand-block {
  display: grid;
  justify-items: start;
  padding: 0;
  background: transparent;
  color: inherit;
}
.nav-tabs { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.nav-tabs button.active { background: var(--text); }
.user-chip { display: flex; align-items: center; gap: 10px; justify-content: flex-end; }
.avatar { width: 42px; height: 42px; border-radius: 50%; border: 2px solid var(--gold); background: linear-gradient(135deg, #233, #456); }

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, .75fr);
  gap: 14px;
  margin-top: 14px;
}
.panel {
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  background: var(--panel);
  box-shadow: 0 18px 60px rgba(0,0,0,.22);
  padding: 16px;
}
.panel h2 { margin: 0 0 12px; font-size: 20px; }
.section-gap { margin-top: 14px; }

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}
.auth-card { width: min(440px, 100%); }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 16px 0; }
.auth-error { min-height: 22px; color: #ff8585; font-weight: 700; margin-top: 10px; }
.form-stack { display: grid; gap: 12px; }
.form-stack label { display: grid; gap: 6px; color: var(--muted); }

.hero {
  min-height: 330px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 16px;
  overflow: hidden;
}
.hero-copy { align-self: end; padding-bottom: 10px; }
.hero h1 { margin: 0; font-size: clamp(34px, 5vw, 62px); line-height: 1.02; letter-spacing: 0; }
.hero p { max-width: 720px; color: var(--muted); font-size: 16px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.panel-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.dealer-preview { min-height: 300px; position: relative; }
#dealerSpine { width: 100%; height: 330px; }

.game-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.game-card {
  min-height: 180px;
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  background: rgba(255,255,255,.065);
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}
.game-card header { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.game-card h3 { margin: 0; font-size: 20px; }
.game-card p { color: var(--muted); margin: 8px 0 0; line-height: 1.45; }
.badge { color: #101418; background: var(--gold); border-radius: 999px; padding: 4px 8px; font-size: 12px; font-weight: 900; white-space: nowrap; }
.badge.green { background: var(--green); color: white; }
.badge.blue { background: var(--blue); }
.badge.violet { background: var(--violet); }
.game-meta { display: flex; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 13px; margin-top: 12px; }

.side-stack { display: grid; gap: 14px; }
.single-grid { margin-top: 14px; display: grid; gap: 14px; }
.section-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 14px; }
.section-header h2, .section-header p { margin-top: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { padding: 12px; border: 1px solid var(--line); border-radius: var(--card-radius); background: rgba(255,255,255,.06); }
.stat strong { display: block; font-size: 22px; color: var(--gold); }
.list { display: grid; gap: 8px; }
.list-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.list-row:last-child { border-bottom: 0; }
.rank { color: var(--gold); font-weight: 900; min-width: 28px; }
.gain { color: #78d98f; }
.loss { color: #ff8585; }

.room-grid { display: grid; gap: 10px; }
.room-card {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  background: rgba(255,255,255,.06);
  padding: 12px;
}
.room-card h3 { margin: 0 0 4px; }
.room-card p { margin: 0; }
.room-meta { display: flex; align-items: center; gap: 10px; }
.room-create-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.empty-state {
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: var(--card-radius);
  color: var(--muted);
  text-align: center;
}
.leaderboard-table { display: grid; gap: 8px; }
.leader-row {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid rgba(255,255,255,.08);
  padding: 12px 0;
}
.profile-card { display: flex; align-items: center; gap: 14px; }
.profile-card h3 { margin: 0; font-size: 24px; }
.profile-avatar { width: 72px; height: 72px; }
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  color: var(--muted);
}
.game-placeholder { min-height: 520px; }
.game-stage-placeholder {
  min-height: 320px;
  display: grid;
  place-items: center;
  border-radius: var(--card-radius);
  border: 1px solid var(--line);
  background: radial-gradient(circle at center, rgba(215,179,90,.18), transparent 58%), rgba(255,255,255,.05);
}
.game-stage-placeholder span { font-size: 42px; color: var(--gold); font-weight: 900; }

.mini-game-panel { min-height: 620px; }
.number-tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(88px, 1fr));
  gap: 12px;
  margin: 28px auto;
  max-width: 620px;
}
.number-tile {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 2px solid rgba(215,179,90,.62);
  border-radius: 8px;
  background: rgba(255,255,255,.08);
  color: var(--gold);
  font-size: 48px;
  font-weight: 950;
}
.expression-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 10px;
  max-width: 860px;
  margin: 0 auto;
}
.expression-keypad {
  display: grid;
  grid-template-columns: repeat(7, minmax(44px, 1fr));
  gap: 8px;
  max-width: 860px;
  margin: 14px auto 0;
}
.expression-keypad button {
  min-height: 44px;
  padding: 8px 10px;
}
.poker-layout, .landlords-layout {
  display: grid;
  gap: 18px;
  padding: 12px 0;
}
.compact-hand {
  min-height: 132px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px;
  background: rgba(0,0,0,.16);
  padding: 12px;
}
.game-toolbar {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}
.joker-card {
  align-content: center;
  gap: 6px;
  color: #17211f;
  overflow: hidden;
}
.joker-card span {
  font-size: 15px;
  line-height: 1;
  color: #17211f;
}
.joker-card strong {
  font-size: 11px;
  line-height: 1;
  letter-spacing: 0;
  max-width: 100%;
  white-space: nowrap;
}
.red-joker span,
.red-joker strong {
  color: #b6252f;
}

.landlords-panel { min-height: 720px; }
.landlords-status {
  grid-template-columns: repeat(3, max-content);
  justify-content: center;
  margin-bottom: 14px;
}
.landlords-table {
  display: grid;
  gap: 14px;
  border: 10px solid #4b3424;
  border-radius: 24px;
  background: radial-gradient(ellipse at center, rgba(255,255,255,.11), transparent 62%), #16513f;
  box-shadow: inset 0 0 70px rgba(0,0,0,.36);
  padding: 16px;
}
.ai-seats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.center-play {
  min-height: 150px;
  place-items: center;
}
.player-hand-panel {
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px;
  background: rgba(0,0,0,.16);
  padding: 12px;
}
.selectable-hand {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  row-gap: 18px;
  column-gap: 0;
  padding-left: 30px;
}
.hand-card {
  padding: 0;
  background: transparent;
  border: 0;
  transform: translateY(0);
  transition: transform .14s ease, filter .14s ease;
  margin-left: -30px;
  position: relative;
  z-index: 1;
}
.hand-card:hover {
  z-index: 4;
}
.hand-card.selected {
  transform: translateY(-16px);
  filter: drop-shadow(0 0 10px rgba(215,179,90,.65));
  z-index: 5;
}
.hand-card:disabled {
  opacity: 1;
  cursor: default;
}
.landlords-actions {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0,0,0,.2);
  padding: 12px;
}

.texas-panel {
  min-height: 720px;
}
.texas-table {
  min-height: 560px;
  display: grid;
  gap: 18px;
  align-content: center;
  border: 12px solid #4b3424;
  border-radius: 28px;
  background: radial-gradient(ellipse at center, rgba(255,255,255,.13), transparent 62%), #184f42;
  box-shadow: inset 0 0 80px rgba(0,0,0,.38), 0 18px 60px rgba(0,0,0,.22);
  padding: 18px;
}
.texas-status {
  grid-template-columns: repeat(5, max-content);
  justify-content: center;
}
.board-zone {
  display: grid;
  place-items: center;
}
.seat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.texas-actions {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0,0,0,.2);
  padding: 12px;
}
.texas-actions-top {
  position: sticky;
  top: 86px;
  z-index: 16;
  margin-bottom: 14px;
  backdrop-filter: blur(10px);
}
.texas-seat-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.folded-seat {
  opacity: .58;
}
.action-log {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0,0,0,.18);
  padding: 12px;
}
.action-log h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.blackjack-room {
  display: grid;
  grid-template-columns: minmax(280px, 38%) minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}
.blackjack-dealer-panel {
  min-height: 680px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  background: #151a1f;
  box-shadow: inset 0 0 60px rgba(255,255,255,.03), 0 18px 60px rgba(0,0,0,.22);
  padding: 16px;
  overflow: hidden;
}
.blackjack-dealer-panel header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.blackjack-dealer-panel h2 {
  margin: 0 0 4px;
}
.dealer-interactive {
  width: 100%;
  min-height: 520px;
  cursor: pointer;
}
.dealer-dialogue {
  min-height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(215,179,90,.35);
  border-radius: 8px;
  background: rgba(0,0,0,.24);
  color: var(--gold);
  font-weight: 900;
  text-align: center;
  padding: 10px 12px;
}
.blackjack-table-panel {
  position: relative;
  min-height: 680px;
  overflow: hidden;
  border: 12px solid #513722;
  border-radius: 24px;
  background: radial-gradient(ellipse at center, rgba(255,255,255,.12), transparent 58%), #14614a;
  box-shadow: inset 0 0 70px rgba(0,0,0,.34), 0 18px 60px rgba(0,0,0,.28);
  padding: 16px;
}
.blackjack-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  position: relative;
  z-index: 4;
}
.blackjack-top h2 { margin: 0 0 4px; }
.blackjack-top p { margin: 0; }
.table-status {
  display: grid;
  grid-template-columns: repeat(3, max-content);
  gap: 8px;
  align-items: start;
  color: var(--muted);
  font-weight: 800;
}
.table-status span {
  min-height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 8px;
  background: rgba(0,0,0,.22);
  padding: 6px 10px;
  white-space: nowrap;
}
.table-status strong { color: var(--gold); }
.card-shoe {
  position: absolute;
  right: 28px;
  top: 108px;
  width: 86px;
  height: 120px;
  border-radius: 10px;
  background: linear-gradient(135deg, #7f1d2d, #261116);
  border: 3px solid var(--gold);
  box-shadow: -7px 7px 0 rgba(0,0,0,.22), -14px 14px 0 rgba(0,0,0,.16);
  transform: rotate(8deg);
}
.card-shoe::after {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,.28);
}
.hand-zone {
  position: relative;
  z-index: 4;
  min-height: 170px;
  display: grid;
  justify-items: center;
  align-content: start;
}
.dealer-hand { margin-top: 72px; }
.player-hand { margin-top: 36px; }
.hand-label {
  color: var(--text);
  font-weight: 900;
  margin-bottom: 10px;
}
.hand-label span { color: var(--gold); }
.cards-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 112px;
}
.playing-card {
  position: relative;
  width: 74px;
  height: 104px;
  border-radius: 8px;
  background: #f7f2e8;
  color: #17211f;
  display: grid;
  place-items: center;
  box-shadow: 0 7px 18px rgba(0,0,0,.26);
  border: 1px solid rgba(0,0,0,.12);
  font-weight: 950;
  animation: deal-in .28s ease-out both;
}
.playing-card .card-corner {
  position: absolute;
  left: 8px;
  top: 7px;
  display: grid;
  justify-items: center;
  gap: 0;
  font-size: 18px;
  line-height: .9;
}
.playing-card .card-corner small {
  font-size: 14px;
  line-height: 1;
}
.playing-card span { font-size: 20px; }
.playing-card strong { font-size: 28px; line-height: 1; }
.red-card { color: #b6252f; }
.card-back {
  background: repeating-linear-gradient(45deg, rgba(255,255,255,.18) 0 4px, transparent 4px 8px), #7f1d2d;
  border: 3px solid var(--gold);
}
.blackjack-controls {
  position: relative;
  z-index: 4;
  display: grid;
  gap: 10px;
  justify-items: center;
  margin-top: 12px;
}
.bet-group, .move-group {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}
.advice {
  min-height: 24px;
  color: var(--gold);
  font-weight: 900;
}
@keyframes deal-in {
  from { opacity: 0; transform: translate(90px, -64px) rotate(10deg) scale(.82); }
  to { opacity: 1; transform: translate(0, 0) rotate(0) scale(1); }
}

@media (max-width: 980px) {
  .topbar, .main-grid, .hero { grid-template-columns: 1fr; }
  .blackjack-room { grid-template-columns: 1fr; }
  .blackjack-dealer-panel { min-height: 560px; }
  .dealer-interactive { min-height: 400px; }
  .nav-tabs { justify-content: flex-start; }
  .user-chip { justify-content: flex-start; }
  .game-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 620px) {
  .layout { width: min(100vw - 18px, 1360px); padding-top: 8px; }
  .game-grid, .stat-grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: 34px; }
  .section-header, .room-card { flex-direction: column; align-items: stretch; }
  .room-create-actions { justify-content: flex-start; }
  .leader-row { grid-template-columns: 42px 1fr auto; }
  .number-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .expression-form { grid-template-columns: 1fr; }
  .expression-keypad { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .blackjack-dealer-panel { min-height: 460px; padding: 12px; }
  .dealer-interactive { min-height: 310px; }
  .blackjack-table-panel { border-width: 8px; border-radius: 18px; min-height: 560px; }
  .blackjack-top { flex-direction: column; }
  .table-status { grid-template-columns: 1fr; width: 100%; }
  .table-status span { justify-items: start; }
  .texas-table { min-height: auto; border-width: 8px; border-radius: 18px; padding: 12px; }
  .texas-status, .seat-grid { grid-template-columns: 1fr; }
  .landlords-table { border-width: 8px; border-radius: 18px; padding: 12px; }
  .landlords-status, .ai-seats { grid-template-columns: 1fr; }
  .selectable-hand { padding-left: 24px; row-gap: 16px; }
  .hand-card { margin-left: -24px; }
  .playing-card { width: 58px; height: 82px; }
  .card-shoe { width: 64px; height: 90px; top: 128px; right: 14px; }
  .dealer-hand { margin-top: 52px; }
  .player-hand { margin-top: 24px; }
}
