:root {
  color-scheme: dark;
  --bg: #10151a;
  --panel: #182028;
  --panel-2: #202b35;
  --felt: #156a55;
  --felt-dark: #0f493d;
  --line: rgba(255, 255, 255, 0.12);
  --text: #f7f4ed;
  --muted: #a9b5bf;
  --gold: #f2c46d;
  --red: #e85d5a;
  --green: #31c48d;
  --blue: #79b8ff;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  overflow-x: hidden;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 10%, rgba(49, 196, 141, 0.18), transparent 28rem),
    linear-gradient(145deg, #10151a 0%, #18232b 45%, #0c1115 100%);
  color: var(--text);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.app-shell {
  width: min(1180px, 100vw);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  background: url("./assets/chip.svg") center / cover no-repeat;
}

.brand-title {
  font-size: 18px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.brand-subtitle,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.view-grid {
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 16px;
  align-items: start;
}

.panel,
.seat,
.action-dock,
.auth-card {
  border: 1px solid var(--line);
  background: rgba(24, 32, 40, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.panel,
.auth-card {
  min-width: 0;
  border-radius: 8px;
  padding: 16px;
}

.auth-wrap {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 36px);
}

.auth-card {
  width: min(440px, 100%);
}

.auth-tabs,
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.auth-tabs button,
.segmented button {
  min-height: 40px;
  color: var(--muted);
  border-radius: 6px;
  background: transparent;
}

.auth-tabs .active,
.segmented .active {
  color: var(--text);
  background: rgba(255, 255, 255, 0.12);
}

.form {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: 12px;
}

.field input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  outline: 0;
}

.field input:focus {
  border-color: rgba(242, 196, 109, 0.8);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 8px;
  padding: 0 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
  transition: transform 0.16s ease, background 0.16s ease;
}

.btn:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.16);
}

.btn.primary {
  color: #1d1609;
  background: var(--gold);
}

.btn.green {
  color: #061b13;
  background: var(--green);
}

.btn.red {
  background: var(--red);
}

.btn.full {
  width: 100%;
}

.btn.compact {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.section-title {
  margin: 0 0 12px;
  font-size: 18px;
}

.stat-row,
.player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.stat-row:last-child,
.player-row:last-child {
  border-bottom: 0;
}

.stat-row > span,
.stat-row > strong,
.player-row > * {
  min-width: 0;
  overflow-wrap: anywhere;
}

.room-code {
  font-size: 30px;
  font-weight: 900;
  color: var(--gold);
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.invite-card {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid rgba(242, 196, 109, 0.45);
  border-radius: 8px;
  background: rgba(242, 196, 109, 0.08);
}

.invite-label {
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
}

.invite-title {
  margin-top: 4px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.invite-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 50%;
  color: #111;
  font-weight: 900;
  background: linear-gradient(135deg, #f8d57a, #f8f4d8);
}

.player-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.player-name {
  max-width: 100%;
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lobby-status {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
  border-radius: 8px;
  padding: 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.07);
}

.lobby-status strong {
  color: var(--gold);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  color: var(--muted);
  font-size: 12px;
  background: rgba(255, 255, 255, 0.08);
}

.badge.hot {
  color: #1d1609;
  background: var(--gold);
}

.table-wrap {
  display: grid;
  gap: 12px;
}

.poker-table {
  position: relative;
  width: 100%;
  min-height: 620px;
  overflow: hidden;
  border: 14px solid #5a3420;
  border-radius: 46%;
  background:
    radial-gradient(ellipse at center, rgba(255, 255, 255, 0.08), transparent 48%),
    linear-gradient(145deg, var(--felt), var(--felt-dark));
  box-shadow: inset 0 0 0 9px rgba(255, 255, 255, 0.08), var(--shadow);
}

.table-center {
  position: absolute;
  inset: 27% 18%;
  display: grid;
  place-items: center;
  text-align: center;
}

.pot {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  border-radius: 999px;
  padding: 0 14px;
  background: rgba(0, 0, 0, 0.25);
}

.cards {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.card {
  display: grid;
  place-items: center;
  width: 54px;
  height: 76px;
  border-radius: 8px;
  color: #121416;
  font-weight: 900;
  background: #f8f5ec;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.24);
}

.card.red-suit {
  color: #c83135;
}

.card.back {
  color: transparent;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.16) 25%, transparent 25%) 0 0 / 12px 12px,
    #263848;
}

.seat {
  position: absolute;
  display: grid;
  gap: 4px;
  width: 150px;
  min-height: 84px;
  border-radius: 8px;
  padding: 10px;
}

.seat.turn {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(242, 196, 109, 0.22), var(--shadow);
}

.seat .player-main {
  gap: 8px;
}

.seat .avatar {
  width: 32px;
  height: 32px;
  flex-basis: 32px;
  font-size: 13px;
}

.seat-0 { left: 50%; bottom: 28px; transform: translateX(-50%); }
.seat-1 { left: 8%; bottom: 22%; }
.seat-2 { left: 8%; top: 22%; }
.seat-3 { left: 50%; top: 28px; transform: translateX(-50%); }
.seat-4 { right: 8%; top: 22%; }
.seat-5 { right: 8%; bottom: 22%; }
.seat-6 { left: 30%; top: 10%; }
.seat-7 { right: 30%; top: 10%; }
.seat-8 { right: 30%; bottom: 10%; }

.private-hand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 92px;
}

.action-dock {
  position: sticky;
  bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(5, minmax(72px, 1fr));
  gap: 8px;
  border-radius: 8px;
  padding: 10px;
}

.action-status {
  grid-column: 1 / -1;
  color: var(--gold);
  font-size: 13px;
  font-weight: 800;
}

.raise-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  grid-column: span 2;
}

.raise-box input {
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
}

.message {
  margin-top: 12px;
  min-height: 24px;
  color: var(--gold);
  font-size: 13px;
}

.settlement {
  display: grid;
  gap: 8px;
}

.settlement-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}

.admin-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.admin-metrics div {
  display: grid;
  gap: 4px;
  min-height: 70px;
  align-content: center;
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.07);
}

.admin-metrics strong {
  font-size: 24px;
  color: var(--gold);
}

.admin-metrics span,
.admin-lists h3 {
  color: var(--muted);
  font-size: 12px;
}

.admin-lists h3 {
  margin: 16px 0 4px;
}

@media (max-width: 860px) {
  .app-shell {
    padding: 12px;
  }

  .view-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .brand-subtitle {
    display: none;
  }

  .poker-table {
    min-height: min(520px, calc(100svh - 220px));
    border-width: 10px;
    border-radius: 30px;
  }

  .table-center {
    inset: 27% 8%;
  }

  .seat {
    width: 118px;
    min-height: 78px;
    padding: 8px;
  }

  .seat-1,
  .seat-2 {
    left: 2%;
  }

  .seat-4,
  .seat-5 {
    right: 2%;
  }

  .action-dock {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .raise-box {
    grid-column: span 2;
  }
}

@media (max-width: 520px) {
  .app-shell {
    padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .brand-title {
    font-size: 16px;
  }

  .toolbar {
    width: 100%;
    justify-content: stretch;
  }

  .toolbar .btn {
    flex: 1;
    min-width: calc(50% - 4px);
    padding: 0 8px;
  }

  .room-code {
    font-size: 25px;
  }

  .card {
    width: 45px;
    height: 64px;
  }

  .seat {
    width: 96px;
    min-height: 68px;
    font-size: 12px;
    padding: 7px;
  }

  .seat .avatar {
    width: 28px;
    height: 28px;
    flex-basis: 28px;
  }

  .seat .muted,
  .seat .badge {
    font-size: 11px;
  }

  .seat-0 {
    bottom: 12px;
  }

  .seat-1,
  .seat-2 {
    left: 0;
  }

  .seat-4,
  .seat-5 {
    right: 0;
  }

  .action-dock {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 8px;
  }

  .action-dock .btn {
    min-height: 40px;
    padding: 0 8px;
  }
}

@media (max-width: 380px) {
  .panel,
  .auth-card {
    padding: 12px;
  }

  .poker-table {
    min-height: 470px;
  }

  .seat {
    width: 86px;
    padding: 6px;
  }

  .card {
    width: 40px;
    height: 58px;
    font-size: 13px;
  }
}
