:root {
  --bg: #07111f;
  --bg-soft: #0d1929;
  --panel: #121f31;
  --panel-2: #18263a;
  --line: #2a3a52;
  --line-soft: rgba(255, 255, 255, 0.08);
  --text: #edf4ff;
  --muted: #98a8bd;
  --muted-2: #627188;
  --green: #25d087;
  --green-dark: #0d6b4a;
  --blue: #5f8cff;
  --red: #ff5b6e;
  --amber: #f5bd45;
  --violet: #9b82ff;
  --felt: #0f6b48;
  --felt-deep: #083824;
  --chip: #f3c44e;
  --radius: 8px;
  --font: "SF Pro Text", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 18% 0%, rgba(95, 140, 255, 0.18), transparent 34rem),
    linear-gradient(180deg, #101827 0%, var(--bg) 44%, #050914 100%);
  color: var(--text);
  font-family: var(--font);
}

body {
  min-height: 100vh;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: var(--radius);
  padding: 10px 14px;
  background: var(--panel-2);
  color: var(--text);
  font-weight: 760;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease, opacity 120ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none;
}

button.primary {
  background: linear-gradient(180deg, #46e39a, #21bf78);
  color: #052515;
}

button.secondary {
  background: #294365;
  color: #eef6ff;
}

button.danger {
  background: linear-gradient(180deg, #ff7381, #ec465d);
  color: #26070b;
}

button.ghost {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  color: var(--muted);
}

button.text-btn,
button.icon-btn {
  min-height: 32px;
  padding: 7px 10px;
}

button.full {
  width: 100%;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #091423;
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(95, 140, 255, 0.22);
}

label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
}

h1,
h2,
p {
  margin: 0;
}

.hidden { display: none !important; }

.app-shell {
  width: min(1360px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

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

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(from 210deg, var(--green), var(--blue), var(--amber), var(--green));
  color: #03130c;
  font-weight: 950;
  box-shadow: 0 10px 30px rgba(37, 208, 135, 0.2);
}

.brand-title {
  font-size: 18px;
  font-weight: 880;
  letter-spacing: 0;
}

.brand-subtitle {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
}

.user-area {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(18, 31, 49, 0.88);
}

#userLabel {
  max-width: 230px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 6px;
  color: #dfe9f8;
  font-size: 13px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(24, 38, 58, 0.96), rgba(16, 28, 45, 0.96));
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.24);
  padding: 18px;
}

.panel.compact {
  padding: 14px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-head h2 {
  font-size: 16px;
}

.section-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
}

.eyebrow {
  color: var(--green);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 430px);
  align-items: center;
  gap: 28px;
  min-height: calc(100vh - 116px);
}

.auth-copy {
  max-width: 620px;
  padding: 30px 8px;
}

.auth-copy h1 {
  margin-top: 14px;
  max-width: 560px;
  font-size: clamp(34px, 6vw, 72px);
  line-height: 0.98;
  letter-spacing: 0;
}

.auth-copy p {
  margin-top: 18px;
  max-width: 460px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.65;
}

.feature-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
}

.feature-row span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: #cfdaea;
  font-size: 13px;
  font-weight: 760;
  padding: 8px 12px;
}

.auth-panel {
  align-self: center;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.tabs button {
  background: #223653;
}

.tabs button.active {
  background: var(--blue);
  color: #07111f;
}

.field {
  margin-bottom: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.toggle-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 4px 0 14px;
}

.toggle-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
  color: #d9e4f4;
}

.toggle-line input {
  width: auto;
  min-height: auto;
}

.error {
  min-height: 18px;
  margin-top: 8px;
  color: var(--red);
  font-size: 13px;
  font-weight: 680;
}

.lobby-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 16px;
  align-items: start;
}

.table-preview {
  min-height: 420px;
  display: grid;
  align-content: space-between;
  overflow: hidden;
}

.preview-felt {
  position: relative;
  height: 260px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  background:
    radial-gradient(ellipse at center, rgba(255, 255, 255, 0.14), transparent 18%),
    linear-gradient(145deg, #14915f, #0c5539 58%, #06271b);
  box-shadow: inset 0 0 44px rgba(0, 0, 0, 0.36);
}

.preview-felt::before,
.preview-felt::after {
  content: "";
  position: absolute;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  top: 26%;
}

.preview-felt::before { left: 10%; }
.preview-felt::after { right: 10%; }

.preview-board {
  position: absolute;
  left: 50%;
  top: 50%;
  display: flex;
  gap: 7px;
  transform: translate(-50%, -50%);
}

.preview-board span {
  width: 44px;
  height: 62px;
  border-radius: 7px;
  background: #f4f6fb;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.24);
}

.preview-copy {
  margin-top: 18px;
}

.preview-copy h2 {
  margin-top: 8px;
  font-size: 30px;
}

.preview-copy p {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.6;
}

.join-panel {
  grid-column: 2;
}

.room-view {
  padding-bottom: 136px;
}

.room-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.status-item {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(9, 20, 35, 0.9);
  color: #d7e2f2;
  font-size: 13px;
  font-weight: 780;
  padding: 8px 12px;
}

.status-item.strong {
  color: #07111f;
  background: var(--amber);
  border-color: transparent;
}

.status-item.warn { border-color: var(--amber); color: var(--amber); }
.status-item.danger { border-color: var(--red); color: var(--red); }

.table-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 14px;
  align-items: start;
}

.table-stage {
  min-width: 0;
}

.felt-table {
  position: relative;
  min-height: clamp(560px, calc(100vh - 190px), 760px);
  overflow: hidden;
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background:
    radial-gradient(ellipse at 50% 50%, rgba(255, 255, 255, 0.08) 0%, transparent 28%),
    radial-gradient(ellipse at 50% 50%, #14895d 0%, #0b5b3d 54%, #073322 76%, #061521 100%);
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.44), 0 24px 80px rgba(0, 0, 0, 0.32);
}

.felt-ring {
  position: absolute;
  inset: 9%;
  border: 14px solid rgba(12, 39, 30, 0.72);
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.08), 0 0 0 1px rgba(255, 255, 255, 0.08);
  pointer-events: none;
}

.seats {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.seat {
  --progress: 0%;
  position: absolute;
  width: 150px;
  min-height: 104px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(123, 148, 184, 0.42);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(24, 38, 58, 0.98), rgba(11, 22, 36, 0.98));
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.28);
  padding: 8px;
}

.seat.empty {
  display: grid;
  place-items: center;
  min-height: 58px;
  background: rgba(5, 15, 25, 0.34);
  border-style: dashed;
  color: rgba(236, 244, 255, 0.42);
  font-size: 12px;
}

.seat.you {
  border-color: rgba(37, 208, 135, 0.72);
  background: linear-gradient(180deg, rgba(21, 71, 52, 0.98), rgba(11, 38, 31, 0.98));
}

.seat.turn {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(245, 189, 69, 0.18), 0 16px 34px rgba(0, 0, 0, 0.3);
}

.seat.turn::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 8px;
  background: conic-gradient(var(--amber) var(--progress), transparent 0);
  opacity: 0.55;
  z-index: -1;
}

.seat.folded {
  opacity: 0.52;
}

.seat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.seat-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 860;
}

.seat-stack {
  margin-top: 4px;
  color: var(--chip);
  font-weight: 840;
  font-size: 14px;
}

.seat-bet {
  min-height: 18px;
  margin-top: 4px;
  color: #95d7ff;
  font-size: 12px;
  font-weight: 720;
}

.seat-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  border-radius: 999px;
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.08);
  color: #cfdae9;
  font-size: 10px;
  font-weight: 850;
}

.tag.host { background: rgba(245, 189, 69, 0.15); color: #ffd67d; }
.tag.btn { background: rgba(95, 140, 255, 0.18); color: #b8ccff; }
.tag.allin { background: rgba(255, 91, 110, 0.18); color: #ffc1c8; }
.tag.offline { color: #c5cede; }

.cards {
  display: flex;
  gap: 5px;
  justify-content: center;
  min-height: 40px;
  margin-top: 7px;
}

.playing-card {
  width: 34px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid #d4d9e4;
  border-radius: 6px;
  background: linear-gradient(145deg, #ffffff, #dfe5ef);
  color: #111927;
  font-size: 12px;
  font-weight: 950;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.24);
}

.playing-card.red { color: #d12d45; }
.playing-card.club { color: #217943; }
.playing-card.diamond { color: #1f75c9; }
.playing-card.spade { color: #202633; }

.playing-card.back {
  border-color: #3668d9;
  color: transparent;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.35) 0 2px, transparent 3px),
    repeating-linear-gradient(45deg, #214aab 0 5px, #163783 5px 10px);
}

.playing-card.empty {
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(5, 17, 27, 0.34);
  box-shadow: none;
}

.playing-card.lg {
  width: clamp(44px, 7vw, 64px);
  height: clamp(62px, 9.8vw, 88px);
  border-radius: 8px;
  font-size: clamp(14px, 2.1vw, 20px);
}

.table-center {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;
  width: min(68%, 540px);
  transform: translate(-50%, -50%);
  text-align: center;
}

.pot-stack {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(2, 16, 24, 0.52);
  padding: 8px 13px;
}

.chip-stack {
  position: relative;
  width: 34px;
  height: 24px;
}

.chip-stack i {
  position: absolute;
  left: 0;
  width: 28px;
  height: 10px;
  border: 2px solid #fff0a8;
  border-radius: 50%;
  background: var(--amber);
}

.chip-stack i:nth-child(1) { top: 0; }
.chip-stack i:nth-child(2) { top: 7px; left: 4px; background: var(--blue); border-color: #cbd8ff; }
.chip-stack i:nth-child(3) { top: 14px; left: 1px; background: var(--red); border-color: #ffd0d5; }

.pot {
  color: #f9fbff;
  font-size: 15px;
  font-weight: 880;
}

.community {
  display: flex;
  justify-content: center;
  gap: clamp(5px, 1vw, 10px);
  min-height: 90px;
}

.meta-line {
  margin-top: 10px;
  color: #b9d7cb;
  font-size: 12px;
  font-weight: 720;
}

.winner-line {
  display: inline-flex;
  margin-top: 10px;
  border-radius: 999px;
  background: rgba(245, 189, 69, 0.16);
  color: #ffe5a6;
  font-size: 12px;
  font-weight: 800;
  padding: 6px 10px;
}

.side-panel {
  display: grid;
  gap: 12px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat-grid div {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
  padding: 10px;
}

.stat-grid span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.stat-grid strong {
  display: block;
  margin-top: 5px;
  color: #f2f7ff;
  font-size: 15px;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.control-grid button {
  min-width: 0;
}

.log {
  max-height: 260px;
  overflow: auto;
  display: grid;
  gap: 7px;
}

.log-entry {
  border-left: 3px solid rgba(95, 140, 255, 0.44);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 0 8px 8px 0;
  color: #cfdae9;
  font-size: 12px;
  line-height: 1.45;
  padding: 7px 9px;
}

.settlement table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.settlement th,
.settlement td {
  border-bottom: 1px solid var(--line-soft);
  padding: 8px 4px;
  text-align: left;
}

.settlement th {
  color: var(--muted);
  font-size: 11px;
}

.settlement .pos { color: var(--green); font-weight: 900; }
.settlement .neg { color: var(--red); font-weight: 900; }

.action-dock {
  position: fixed;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 20;
  width: min(980px, calc(100% - 28px));
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: 180px minmax(280px, 1fr) minmax(320px, 1.2fr);
  gap: 10px;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: rgba(9, 20, 35, 0.94);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(14px);
  padding: 10px;
}

.turn-summary {
  min-width: 0;
}

.turn-summary span,
.turn-summary strong {
  display: block;
}

.turn-summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.turn-summary strong {
  margin-top: 4px;
  color: #fff;
  font-size: 16px;
}

.action-main {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.raise-panel {
  min-width: 0;
}

.quick-bets {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 7px;
}

.quick-bets button {
  min-height: 30px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #dfe8f7;
  font-size: 12px;
}

.raise-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) 82px;
  gap: 8px;
  align-items: center;
}

.raise-row input[type="range"] {
  accent-color: var(--green);
}

.raise-row .amt {
  min-width: 0;
  overflow: hidden;
  text-align: right;
  color: var(--chip);
  font-size: 15px;
  font-weight: 900;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 50;
  max-width: min(92vw, 480px);
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(9, 20, 35, 0.96);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.36);
  padding: 11px 14px;
  color: #f3f7ff;
  font-size: 14px;
  font-weight: 720;
}

@media (max-width: 1100px) {
  .table-layout {
    grid-template-columns: 1fr;
  }

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

  .action-dock {
    grid-template-columns: 1fr;
  }
}

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

  .topbar {
    align-items: flex-start;
  }

  .user-area {
    border-radius: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  #userLabel {
    width: 100%;
    max-width: 210px;
    text-align: right;
  }

  .auth-layout,
  .lobby-layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .auth-copy {
    padding: 18px 0 4px;
  }

  .auth-copy h1 {
    font-size: 42px;
  }

  .join-panel {
    grid-column: auto;
  }

  .form-grid,
  .toggle-grid,
  .side-panel {
    grid-template-columns: 1fr;
  }

  .room-view {
    padding-bottom: 260px;
  }

  .felt-table {
    min-height: 560px;
    border-radius: 18px;
  }

  .felt-ring {
    inset: 13% 4%;
    border-width: 10px;
  }

  .seat {
    width: 122px;
    min-height: 92px;
    padding: 7px;
  }

  .seat.empty {
    width: 92px;
    min-height: 42px;
  }

  .seat-name {
    font-size: 12px;
  }

  .seat-stack {
    font-size: 12px;
  }

  .playing-card {
    width: 29px;
    height: 40px;
    font-size: 11px;
  }

  .playing-card.lg {
    width: 43px;
    height: 60px;
    font-size: 14px;
  }

  .table-center {
    width: 78%;
  }

  .community {
    min-height: 68px;
  }

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

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

  .action-dock {
    bottom: max(8px, env(safe-area-inset-bottom));
    width: calc(100% - 16px);
    padding: 8px;
  }
}

@media (max-width: 430px) {
  .brand-subtitle {
    display: none;
  }

  .auth-copy h1 {
    font-size: 36px;
  }

  .room-status {
    gap: 6px;
  }

  .status-item,
  .room-status .ghost {
    min-height: 34px;
    padding: 7px 9px;
    font-size: 12px;
  }

  .felt-table {
    min-height: 520px;
  }

  .seat {
    width: 112px;
  }

  .table-center {
    width: 86%;
  }

  .raise-row {
    grid-template-columns: 70px minmax(0, 1fr) 68px;
  }
}
