*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #070b14;
  --surface: rgba(255, 255, 255, 0.042);
  --surface-h: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.09);
  --border-h: rgba(255, 255, 255, 0.2);
  --text: rgba(221, 227, 245, 0.92);
  --muted: #58698e;
  --bj: #1fae63;
  --bj-glow: rgba(31, 174, 99, 0.25);
  --red: #e05252;
  --gold: #e8c23a;
}

html,
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Space Grotesk", system-ui, sans-serif;
  min-height: 100vh;
}
body {
  display: flex;
  flex-direction: column;
}

.betaNotice {
  width: 100%;
  height: 22px;
  line-height: 22px;
  color: rgba(180, 240, 205, 0.75);
  border-bottom: 1px solid rgba(31, 174, 99, 0.2);
  padding: 0 12px;
  text-align: center;
  font-size: 11px;
  user-select: none;
}
.betaNoticeLink {
  color: rgba(90, 210, 150, 0.9);
  text-decoration: underline;
}
.betaNoticeLink:hover {
  color: rgba(180, 240, 205, 1);
}

header {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  background: rgba(7, 11, 20, 0.82);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.hdr-home {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  transition: color 0.15s;
}
.hdr-home:hover {
  color: var(--text);
}
.hdr-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
}
.hdr-title {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--bj);
}
.hdr-info {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.hdr-chips {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--gold);
  font-weight: 700;
}
.hdr-code {
  letter-spacing: 0.08em;
  font-weight: 600;
}
.hdr-ad-btn {
  padding: 0.3rem 0.65rem;
  font-size: 0.78rem;
  border-radius: 100px;
  line-height: 1;
  gap: 0.3rem;
}
.hdr-profile {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.5rem 0.25rem 0.25rem;
  border-radius: 100px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}
.hdr-profile img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
}
.profile-menu-btn {
  font-size: 0.65rem;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 0 0 0.1rem;
  transition:
    color 0.15s,
    transform 0.15s;
}
.profile-menu-btn:hover {
  color: var(--text);
}
.profile-menu-btn.open {
  transform: rotate(180deg);
}

.profile-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: var(--bg);
  border: 1px solid var(--border-h);
  border-radius: 12px;
  padding: 0.4rem;
  display: none;
  flex-direction: column;
  gap: 0.15rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  z-index: 120;
}
.profile-dropdown.open {
  display: flex;
}
.profile-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background 0.12s;
}
.profile-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.06);
}
.profile-dropdown-item.profile-dropdown-danger {
  color: var(--red);
}
.profile-dropdown-item.profile-dropdown-danger:hover {
  background: rgba(224, 82, 82, 0.1);
}

/* ============== Settings modal ============== */
#settings-modal {
  background: rgba(7, 11, 20, 0.92);
  backdrop-filter: blur(10px);
}
.settings-card {
  max-width: 420px;
  align-items: stretch;
  text-align: left;
}
#settings-modal .settings-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 2rem 2rem 1.75rem;
}
.settings-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}
.settings-modal-head h2 {
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.2rem;
}
.settings-close-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.2rem;
}
.settings-close-btn:hover {
  color: var(--text);
}

.settings-group {
  border-top: 1px solid var(--border);
  padding-top: 0.9rem;
  margin-top: 0.9rem;
}
.settings-group:first-of-type {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}
.settings-group-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.6rem;
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0;
}
.settings-row-copy label {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text);
}
.settings-row-copy p {
  font-size: 0.74rem;
  color: var(--muted);
  margin-top: 0.1rem;
}
.settings-row-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}
.settings-row-control-volume input[type="range"] {
  width: 110px;
}
.settings-row-control select,
.settings-row-control input[type="text"] {
  font-family: inherit;
  font-size: 0.82rem;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text);
}
.settings-row-control input[type="text"] { width: 140px; outline: none; }
.settings-row-control input[type="text"]:focus { border-color: var(--border-h); }
.settings-empty {
  font-size: 0.8rem;
  color: var(--muted);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  inset: 0;
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition: background 0.15s;
}
.toggle-slider::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}
.toggle-switch input:checked + .toggle-slider {
  background: var(--bj);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(18px);
}

/* ============== Lobby screen ============== */
#lobby-screen {
  max-width: 460px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 3rem;
}

.lobby-hero {
  text-align: center;
  margin-bottom: 1.75rem;
}
.lobby-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.3rem 0.75rem;
  border-radius: 100px;
  background: rgba(31, 174, 99, 0.1);
  border: 1px solid rgba(31, 174, 99, 0.25);
  color: var(--bj);
  margin-bottom: 0.9rem;
}
.lobby-hero h1 {
  font-family: "Fraunces", Georgia, serif;
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 0.6rem;
  background: linear-gradient(135deg, var(--text) 25%, var(--bj) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.lobby-hero p {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.6;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.25rem 1.35rem;
  margin-bottom: 1rem;
}
.panel-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.panel-title button {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
}
.panel-title button:hover {
  color: var(--text);
}

.field {
  margin-bottom: 0.9rem;
}
.field label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input[type="text"],
input[type="number"] {
  width: 100%;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
input:focus {
  border-color: var(--border-h);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  padding: 0.7rem 1.1rem;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition:
    opacity 0.15s,
    transform 0.1s,
    background 0.15s,
    border-color 0.15s;
}
.btn:active {
  transform: scale(0.98);
}
.btn:disabled {
  opacity: 0.4;
  cursor: default;
}
.btn-full {
  width: 100%;
}
.btn-bj {
  background: var(--bj);
  color: #06210f;
}
.btn-bj:hover:not(:disabled) {
  opacity: 0.9;
}
.btn-bj-outline {
  background: transparent;
  border: 1px solid rgba(31, 174, 99, 0.4);
  color: var(--bj);
}
.btn-bj-outline:hover {
  background: rgba(31, 174, 99, 0.1);
}
.btn-ghost {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-ghost:hover {
  border-color: var(--border-h);
}

.or-divider {
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
  margin: 1rem 0;
  position: relative;
}
.or-divider::before,
.or-divider::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 38%;
  height: 1px;
  background: var(--border);
}
.or-divider::before {
  left: 0;
}
.or-divider::after {
  right: 0;
}

.err-msg {
  font-size: 0.78rem;
  color: var(--red);
  margin-top: 0.6rem;
  min-height: 1.1em;
}

.panel-open-tables {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.9rem;
}
.panel-open-tables-refresh-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
}
.panel-open-tables-refresh-btn:hover {
  color: var(--text);
}
.panel-open-tables-list {
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
  padding: 0.5rem 0;
}

.table-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.6rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 0.5rem;
  font-size: 0.82rem;
}
.table-item img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
}
.table-item .ti-name {
  flex: 1;
  font-weight: 600;
}
.table-item .ti-count {
  color: var(--muted);
}
.table-item button {
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  background: var(--bj);
  border: none;
  color: #06210f;
  cursor: pointer;
}

#lobby-players {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.lp-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.6rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
}
.lp-row img {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.06);
}
.lp-row .lp-name {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 600;
}
.lp-row .lp-host {
  font-size: 0.65rem;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.lp-row .lp-chips {
  font-size: 0.78rem;
  color: var(--gold);
  font-weight: 700;
}

.wait-msg {
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
  padding: 0.6rem 0;
}

/* ============== Overlays ============== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 5, 10, 0.75);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 1.5rem;
}
.overlay.open {
  display: flex;
}
.overlay-box {
  background: var(--bg);
  border: 1px solid var(--border-h);
  border-radius: 18px;
  padding: 1.75rem;
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.overlay-box h2 {
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.2rem;
  margin-bottom: 0.2rem;
}
.modal-sub {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 0.3rem;
}

/* ============== Game screen ============== */
#game-screen {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
#game-screen.active {
  display: flex;
}
#lobby-screen.hidden {
  display: none;
}

.table-felt {
  flex: 1;
  background: radial-gradient(
    ellipse at 50% 0%,
    #0e2a1a 0%,
    #071711 70%,
    #050d0a 100%
  );
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 1rem 1rem;
  position: relative;
  overflow-y: auto;
}

.dealer-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 1.75rem;
}
.dealer-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}
.hand-value {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--gold);
  min-height: 1.2em;
}
.dealer-row {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.hand-row {
  display: flex;
  gap: -8px;
  min-height: 112px;
}

.deck-stack {
  position: relative;
  width: 72px;
  height: 104px;
  flex-shrink: 0;
}
.deck-card {
  position: absolute;
  inset: 0;
  border-radius: 7px;
  background: repeating-linear-gradient(
    45deg,
    #123a26,
    #123a26 6px,
    #0d2c1c 6px,
    #0d2c1c 12px
  );
  border: 2px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45);
}
.deck-card:nth-child(1) {
  transform: translate(0, 0);
}
.deck-card:nth-child(2) {
  transform: translate(2px, -2px);
}
.deck-card:nth-child(3) {
  transform: translate(4px, -4px);
  box-shadow:
    0 4px 14px rgba(31, 174, 99, 0.35),
    0 3px 10px rgba(0, 0, 0, 0.45);
}

.card {
  width: 72px;
  height: 104px;
  border-radius: 9px;
  background: #f4f1ea;
  color: #1a1a1a;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 6px 7px;
  font-weight: 800;
  font-size: 1.1rem;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45);
  margin-left: 14px;
  flex-shrink: 0;
}
.card:first-child {
  margin-left: 0;
}
.card.red {
  color: #c22;
}
.card.black {
  color: #181818;
}
.card .cr-bottom {
  align-self: flex-end;
  transform: rotate(180deg);
}
.card.back {
  background: repeating-linear-gradient(
    45deg,
    #123a26,
    #123a26 6px,
    #0d2c1c 6px,
    #0d2c1c 12px
  );
  border: 2px solid rgba(255, 255, 255, 0.15);
}

.seats-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.25rem;
  width: 100%;
}
.seat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.7rem 0.9rem;
  border-radius: 14px;
  min-width: 140px;
}
.seat.active-turn {
  background: rgba(31, 174, 99, 0.1);
  border: 1px solid rgba(31, 174, 99, 0.35);
  box-shadow: 0 0 20px var(--bj-glow);
}
.seat-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.seat-head img {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
}
.seat-name {
  font-size: 0.78rem;
  font-weight: 700;
}
.seat-value {
  font-size: 0.72rem;
  color: var(--gold);
  font-weight: 700;
  min-height: 1.1em;
}
.seat-bet {
  font-size: 0.68rem;
  color: var(--muted);
}
.seat-result {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 100px;
  margin-top: 2px;
}
.seat-result.win,
.seat-result.blackjack {
  background: rgba(31, 174, 99, 0.18);
  color: var(--bj);
}
.seat-result.push {
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}
.seat-result.lose {
  background: rgba(224, 82, 82, 0.18);
  color: var(--red);
}
.seat .hand-row {
  min-height: 92px;
}
.seat .card {
  width: 58px;
  height: 84px;
  font-size: 0.92rem;
  margin-left: 10px;
}

/* ============== My panel (bottom) ============== */
.my-panel {
  border-top: 1px solid var(--border);
  padding: 1rem 1.25rem calc(1rem + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}

.my-panel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.my-chips {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 800;
  color: var(--gold);
  font-size: 0.95rem;
}
.my-bet {
  font-size: 0.8rem;
  color: var(--muted);
}

.chip-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.chip-btn {
  flex: 1;
  min-width: 54px;
  font-family: inherit;
  font-weight: 800;
  font-size: 0.82rem;
  padding: 0.6rem 0.4rem;
  border-radius: 50px;
  border: 2px solid rgba(232, 194, 58, 0.4);
  background: radial-gradient(circle at 35% 30%, #2a2410, #171307);
  color: var(--gold);
  cursor: pointer;
  transition:
    transform 0.1s,
    border-color 0.15s;
}
.chip-btn:hover {
  border-color: var(--gold);
}
.chip-btn:active {
  transform: scale(0.95);
}
.chip-btn.selected {
  border-color: var(--bj);
  color: var(--bj);
}

.bet-amount-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
}
.bet-reset-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.35rem 0.7rem;
  border-radius: 50px;
  border: 1px solid rgba(232, 194, 58, 0.3);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  cursor: pointer;
  transition:
    border-color 0.15s,
    color 0.15s,
    transform 0.1s,
    background 0.15s;
}
.bet-reset-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(232, 194, 58, 0.08);
}
.bet-reset-btn:active {
  transform: scale(0.96);
}

.bet-custom-row {
  display: flex;
  gap: 0.5rem;
}
.bet-custom-input {
  flex: 1;
  min-width: 0;
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  border: 2px solid rgba(232, 194, 58, 0.4);
  background: radial-gradient(circle at 35% 30%, #2a2410, #171307);
  color: var(--gold);
}
.bet-custom-input:focus {
  outline: none;
  border-color: var(--gold);
}
.bet-custom-input::-webkit-outer-spin-button,
.bet-custom-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.bet-custom-input[type="number"] {
  -moz-appearance: textfield;
}
.bet-custom-row .btn {
  flex-shrink: 0;
}

.action-controls {
  display: flex;
  gap: 0.6rem;
}
.btn-action {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 0.75rem;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}
.btn-action:hover:not(:disabled) {
  border-color: var(--border-h);
  background: rgba(255, 255, 255, 0.08);
}
.btn-action:disabled {
  opacity: 0.35;
  cursor: default;
}
#hit-btn {
  border-color: rgba(31, 174, 99, 0.4);
  color: var(--bj);
}
#double-btn {
  border-color: rgba(232, 194, 58, 0.4);
  color: var(--gold);
}

.result-banner {
  text-align: center;
  font-weight: 800;
  font-size: 1rem;
  padding: 0.6rem;
  border-radius: 10px;
}
.result-banner.win,
.result-banner.blackjack {
  background: rgba(31, 174, 99, 0.15);
  color: var(--bj);
}
.result-banner.push {
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}
.result-banner.lose {
  background: rgba(224, 82, 82, 0.15);
  color: var(--red);
}

@media (max-width: 480px) {
  #lobby-screen {
    padding: 1.5rem 0.9rem 2.5rem;
  }
  .seat {
    min-width: 110px;
    padding: 0.5rem 0.6rem;
  }
  .card {
    width: 44px;
    height: 64px;
  }
}
