:root {
  color-scheme: dark;
  --bg: #071014;
  --bg-2: #0b1a20;
  --panel: rgba(12, 27, 34, .82);
  --panel-2: rgba(8, 19, 24, .94);
  --line: rgba(164, 213, 214, .13);
  --text: #e9f5f3;
  --muted: #92aeb2;
  --gold: #f2c14e;
  --gold-2: #d99a29;
  --green: #178d63;
  --green-2: #0b6c4e;
  --shadow: 0 24px 70px rgba(0, 0, 0, .48);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 0%, rgba(23, 141, 99, .23), transparent 34%),
    radial-gradient(circle at 85% 10%, rgba(242, 193, 78, .12), transparent 34%),
    linear-gradient(145deg, var(--bg), var(--bg-2) 65%, #05100e);
}
button, input, select, output { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.app-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 18px;
  align-items: center;
  padding: 18px clamp(16px, 4vw, 48px);
  background: rgba(4, 10, 13, .72);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  font-size: 26px;
  color: #08120f;
  background: linear-gradient(145deg, var(--gold), var(--gold-2));
  box-shadow: 0 10px 26px rgba(242, 193, 78, .22);
}
.brand h1, .panel-block h2, .modal-card h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: .03em;
}
.brand h1 { font-size: 24px; }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.header-stats { display: flex; gap: 10px; }
.stat-chip {
  min-width: 104px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .035);
}
.stat-chip span { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.stat-chip strong { display: block; margin-top: 2px; font-size: 17px; font-variant-numeric: tabular-nums; }
.header-actions { display: flex; gap: 10px; }
.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.main-nav::-webkit-scrollbar { display: none; }
.main-nav a {
  padding: 8px 11px;
  border-radius: 9px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  white-space: nowrap;
  transition: color .16s, background .16s;
}
.main-nav a:hover, .main-nav a[aria-current="page"] { color: #fff7e0; background: rgba(242,193,78,.12); }

.button {
  border: 0;
  border-radius: 11px;
  padding: 11px 18px;
  color: var(--text);
  background: rgba(255, 255, 255, .07);
  transition: transform .16s ease, filter .16s ease, background .16s ease;
}
.button:hover { transform: translateY(-1px); filter: brightness(1.08); }
.button.primary {
  color: #101a16;
  font-weight: 750;
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  box-shadow: 0 10px 28px rgba(242, 193, 78, .2);
}
.button.secondary { border: 1px solid var(--line); background: rgba(255, 255, 255, .05); }

.game-layout {
  width: min(1600px, 100%);
  margin: 0 auto;
  padding: clamp(14px, 3vw, 32px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 22px;
  flex: 1;
}
.table-panel, .side-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.table-panel { display: flex; flex-direction: column; }
.online-lobby {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(260px, 340px);
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.02);
}
.lobby-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(4,10,13,.5);
}
.lobby-card h2, .lobby-card h3 { margin: 0 0 8px; font-family: Georgia, serif; color: #fff3d4; }
.lobby-card p { margin: 0 0 14px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.lobby-card label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; }
.lobby-card input {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: #102028;
}
.lobby-actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.join-row { display: flex; gap: 7px; min-width: 200px; }
.join-row input { width: 92px; text-transform: uppercase; letter-spacing: .08em; }
.online-status { margin-top: 11px; color: var(--muted); font-size: 12px; }
.online-status.connected { color: #7ff0ba; }
.open-rooms-card { grid-column: 1 / -1; }
.open-rooms { display: grid; gap: 10px; max-height: 260px; overflow-y: auto; }
.open-room {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.035);
}
.open-room-title { min-width: 0; }
.open-room-title strong { display: block; overflow: hidden; color: #fff7e0; text-overflow: ellipsis; white-space: nowrap; }
.open-room-title span { color: var(--muted); font-size: 12px; }
.open-room-meta { color: #cbe2df; font-size: 12px; white-space: nowrap; }
.open-room .button { padding: 9px 15px; white-space: nowrap; }
.empty-rooms { color: var(--muted); font-size: 13px; }
.room-card { display: grid; gap: 10px; }
.room-code {
  padding: 12px;
  border-radius: 12px;
  color: #101a16;
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  text-align: center;
  font-size: 30px;
  font-weight: 850;
  letter-spacing: .2em;
}
.room-players { display: grid; gap: 7px; }
.room-player {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 9px;
  background: rgba(255,255,255,.04);
  color: #cbe2df;
  font-size: 13px;
}
.hidden { display: none !important; }
.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .025);
}
.table-info { display: flex; gap: 10px; flex-wrap: wrap; }
.table-info span {
  padding: 5px 10px;
  border-radius: 8px;
  color: var(--gold);
  background: rgba(242, 193, 78, .1);
  font-size: 13px;
  font-weight: 650;
}
.turn-info { color: var(--muted); font-size: 14px; text-align: right; }
.turn-info.active { color: #7ff0ba; }

.poker-stage {
  position: relative;
  padding: clamp(12px, 3vw, 32px);
  min-height: clamp(480px, 62vh, 740px);
}
.table-oval { position: relative; width: min(980px, 100%); aspect-ratio: 1.58; margin: 0 auto; }
.table-rim {
  position: absolute;
  inset: 6%;
  border-radius: 50%;
  background: linear-gradient(145deg, #4a2f23, #2a1a16 52%, #573728);
  box-shadow: 0 34px 80px rgba(0, 0, 0, .5), inset 0 0 0 2px rgba(255,255,255,.05);
}
.table-felt {
  position: absolute;
  inset: 8.5%;
  border-radius: 50%;
  display: grid;
  place-content: center;
  gap: 12px;
  background: radial-gradient(circle at 50% 43%, #1ea575, var(--green-2) 68%, #065039);
  box-shadow: inset 0 0 50px rgba(0, 0, 0, .42);
}
.table-felt::after {
  content: "";
  position: absolute;
  inset: 13%;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.07);
}
.pot-area {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 auto;
  padding: 7px 14px;
  border-radius: 999px;
  color: #f7ffe9;
  background: rgba(0, 0, 0, .24);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.09);
}
.pot-label { color: #bdf2d2; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; }
.pot-area strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.stage-badge {
  position: relative;
  z-index: 2;
  margin: 0 auto;
  padding: 4px 11px;
  width: fit-content;
  border-radius: 8px;
  color: #dff8e9;
  background: rgba(0,0,0,.22);
  font-size: 12px;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.community {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(5, minmax(46px, 66px));
  justify-content: center;
  gap: 8px;
  min-height: 86px;
}

.card {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: .7;
  border-radius: 8px;
  color: #17212b;
  background: linear-gradient(160deg, #ffffff, #dfe6e9);
  box-shadow: 0 7px 17px rgba(0,0,0,.25);
}
.card span { font-size: clamp(15px, 2vw, 22px); font-weight: 800; line-height: 1; }
.card.red { color: #b8322c; }
.card.back {
  background: repeating-linear-gradient(45deg, #234a52 0 8px, #1b3a42 8px 16px), #234a52;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.14), 0 7px 17px rgba(0,0,0,.25);
}
.card.back::after { content: "♠"; color: rgba(255,255,255,.45); font-size: 20px; }

.seats { position: absolute; inset: 0; }
.seat {
  position: absolute;
  width: clamp(128px, 20%, 174px);
  transform: translate(-50%, -50%);
  display: grid;
  gap: 6px;
}
.seat[data-seat="0"] { left: 50%; top: 96%; }
.seat[data-seat="1"] { left: 89%; top: 73%; }
.seat[data-seat="2"] { left: 91%; top: 31%; }
.seat[data-seat="3"] { left: 50%; top: 6%; }
.seat[data-seat="4"] { left: 9%; top: 31%; }
.seat[data-seat="5"] { left: 11%; top: 73%; }
.player-card {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-2);
  box-shadow: 0 12px 30px rgba(0,0,0,.3);
  transition: border-color .2s, box-shadow .2s, transform .2s;
}
.seat.active .player-card {
  border-color: rgba(127,240,186,.72);
  box-shadow: 0 0 0 2px rgba(127,240,186,.22), 0 18px 44px rgba(0,0,0,.38);
  transform: translateY(-2px);
}
.seat.folded .player-card { opacity: .48; filter: grayscale(.45); }
.seat.winner .player-card { border-color: rgba(242,193,78,.85); box-shadow: 0 0 0 2px rgba(242,193,78,.25); }
.player-top { display: flex; align-items: center; justify-content: space-between; gap: 7px; }
.player-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 700; }
.dealer-button {
  width: 21px;
  height: 21px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #221a08;
  background: #fff;
  font-size: 10px;
  font-weight: 900;
}
.player-stack { color: var(--gold); font-size: 13px; font-variant-numeric: tabular-nums; }
.player-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 5px; }
.player-cards .card { aspect-ratio: .72; }
.player-cards .card span { font-size: 14px; }
.player-status { min-height: 16px; color: var(--muted); font-size: 11px; }
.bet-chip {
  width: fit-content;
  margin: 0 auto;
  padding: 4px 10px;
  border-radius: 999px;
  color: #fff7e0;
  background: linear-gradient(135deg, rgba(242,193,78,.9), rgba(180,109,27,.9));
  font-size: 12px;
  font-weight: 750;
}
.bet-chip:empty { display: none; }

.action-panel { border-top: 1px solid var(--line); padding: 15px 18px 18px; background: rgba(4,10,13,.68); }
.action-message { margin-bottom: 12px; color: var(--muted); }
.bet-controls { display: grid; grid-template-columns: 100px 1fr 150px; gap: 10px; }
.bet-controls .raise-control { display: grid; grid-template-columns: 1fr 78px; align-items: center; gap: 9px; min-width: 0; }
.action {
  border: 0;
  min-height: 47px;
  border-radius: 12px;
  color: #fff;
  font-weight: 760;
  box-shadow: 0 12px 28px rgba(0,0,0,.2);
  transition: transform .15s, filter .15s;
}
.action:disabled { cursor: not-allowed; opacity: .42; filter: grayscale(.35); }
.action:not(:disabled):hover { transform: translateY(-1px); filter: brightness(1.08); }
.action.fold { background: linear-gradient(135deg, #a34638, #7b2d23); }
.action.passive { background: linear-gradient(135deg, #4d6b78, #334a54); }
.action.aggressive { background: linear-gradient(135deg, #178d63, #0a5f43); }
.raise-control input { width: 100%; accent-color: var(--gold); }
.raise-control output { color: var(--gold); font-weight: 750; text-align: right; font-variant-numeric: tabular-nums; }
.quick-bets { display: flex; gap: 7px; margin-top: 10px; flex-wrap: wrap; }
.quick-bets button {
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  background: rgba(255,255,255,.04);
  font-size: 12px;
}
.quick-bets button:hover { color: var(--text); background: rgba(255,255,255,.09); }
.quick-bets button:disabled { opacity: .35; }
.next-row { display: flex; justify-content: flex-end; margin-top: 12px; }
.next-row button { min-width: 190px; }

.side-panel { display: flex; flex-direction: column; }
.panel-block { padding: 18px; border-bottom: 1px solid var(--line); }
.panel-block h2 { font-size: 18px; margin-bottom: 13px; color: #fff3d4; }
.table-summary { display: grid; gap: 9px; font-size: 14px; }
.summary-row { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); }
.summary-row strong { color: var(--text); font-variant-numeric: tabular-nums; text-align: right; }
.history-block { flex: 1; min-height: 0; display: flex; flex-direction: column; border-bottom: 0; }
.history {
  flex: 1;
  min-height: 260px;
  max-height: 52vh;
  overflow-y: auto;
  display: grid;
  gap: 8px;
  align-content: start;
  padding-right: 4px;
}
.history::-webkit-scrollbar { width: 7px; }
.history::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 99px; }
.history-item {
  padding: 9px 11px;
  border-left: 3px solid rgba(242,193,78,.55);
  border-radius: 8px;
  background: rgba(255,255,255,.035);
  color: #cbe2df;
  font-size: 13px;
  line-height: 1.42;
}

.app-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 16px clamp(16px, 4vw, 48px);
  color: #759094;
  border-top: 1px solid var(--line);
  font-size: 12px;
}

.modal {
  width: min(520px, calc(100% - 30px));
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 0;
  color: var(--text);
  background: var(--panel-2);
  box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(2,6,8,.78); backdrop-filter: blur(6px); }
.modal-card { padding: 24px; display: grid; gap: 15px; }
.modal-card h2 { font-size: 24px; color: #fff3d4; }
.modal-card label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.modal-card select { padding: 11px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); background: #102028; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.result-card #result-body { display: grid; gap: 10px; color: #cbe2df; }
.result-line { display: flex; justify-content: space-between; gap: 12px; padding: 9px 11px; border-radius: 9px; background: rgba(255,255,255,.04); }
.rules-card ul { margin: 0; padding-left: 21px; display: grid; gap: 9px; color: #cbe2df; line-height: 1.5; }

@media (max-width: 1220px) {
  .game-layout { grid-template-columns: 1fr; }
  .history { max-height: 320px; }
}
@media (max-width: 900px) {
  .app-header { grid-template-columns: 1fr; }
  .header-stats { order: 3; width: 100%; }
  .stat-chip { flex: 1; min-width: 0; }
  .bet-controls { grid-template-columns: 1fr 1fr; }
  .bet-controls .raise-control { grid-column: 1 / -1; grid-row: 2; }
  .online-lobby { grid-template-columns: 1fr; }
  .open-room { grid-template-columns: 1fr; align-items: start; }
  .open-room .button { width: 100%; }
}
@media (max-width: 700px) {
  .poker-stage { padding: 8px; min-height: 610px; }
  .table-oval { aspect-ratio: .78; }
  .table-rim, .table-felt { inset: 4%; border-radius: 34%; }
  .table-felt { padding: 54px 8px 150px; align-content: start; }
  .community { grid-template-columns: repeat(5, 15vw); gap: 4px; }
  .seat { width: 122px; }
  .seat[data-seat="1"] { left: 91%; top: 82%; }
  .seat[data-seat="2"] { left: 82%; top: 18%; }
  .seat[data-seat="3"] { left: 50%; top: 3%; }
  .seat[data-seat="4"] { left: 18%; top: 18%; }
  .seat[data-seat="5"] { left: 9%; top: 82%; }
  .app-footer { flex-direction: column; }
  .modal-card { padding: 19px; }
}
