:root {
  --hs-gold: #f5c85b;
  --hs-cyan: #52e5de;
  --hs-green: #08745f;
  --hs-panel: rgba(4, 12, 21, .90);
  --hs-top: env(safe-area-inset-top, 0px);
  --hs-bottom: env(safe-area-inset-bottom, 0px);
}

html, body, #game {
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  min-height: 100dvh !important;
  max-height: 100dvh !important;
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  background:
    radial-gradient(circle at 50% 35%, rgba(25,185,152,.20), transparent 36%),
    radial-gradient(circle at 14% 80%, rgba(37,99,235,.14), transparent 34%),
    linear-gradient(145deg, #01050a, #07151d 55%, #020407) !important;
}

#game {
  isolation: isolate;
  background:
    radial-gradient(ellipse at 50% 46%, rgba(23,160,126,.13), transparent 46%),
    repeating-linear-gradient(135deg, transparent 0 18px, rgba(255,255,255,.009) 19px 20px);
}

.ambient-light {
  background:
    radial-gradient(circle at 50% 40%, rgba(45,212,191,.22), transparent 39%),
    radial-gradient(circle at 18% 78%, rgba(59,130,246,.11), transparent 31%),
    radial-gradient(circle at 84% 22%, rgba(245,200,91,.10), transparent 27%) !important;
}

.topbar, .room-panel, .audio-controls, .action-panel {
  backdrop-filter: blur(16px) saturate(145%);
  -webkit-backdrop-filter: blur(16px) saturate(145%);
}

.topbar {
  border: 1px solid rgba(82,229,222,.24) !important;
  background: linear-gradient(145deg, rgba(9,24,35,.9), rgba(1,7,13,.92)) !important;
  box-shadow: 0 12px 32px rgba(0,0,0,.42), inset 0 1px rgba(255,255,255,.08) !important;
}

.title { color: #fff8dc; text-shadow: 0 0 18px rgba(245,200,91,.22); }
.phase { color: var(--hs-cyan) !important; }

.table {
  border-color: #21140c !important;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(34,197,154,.34), transparent 34%),
    repeating-radial-gradient(ellipse at center, rgba(255,255,255,.018) 0 1px, transparent 2px 7px),
    linear-gradient(145deg, #0b8b70, #065745 53%, #02362c) !important;
  box-shadow:
    inset 0 0 0 7px #936b3d,
    inset 0 0 0 9px rgba(245,200,91,.16),
    inset 0 0 65px rgba(0,0,0,.74),
    0 42px 95px rgba(0,0,0,.9),
    0 0 38px rgba(16,185,129,.12) !important;
}

.table::before {
  border-color: rgba(245,200,91,.16) !important;
  box-shadow: inset 0 0 35px rgba(0,0,0,.18), 0 0 20px rgba(245,200,91,.05) !important;
}

.logo { color: rgba(255,247,214,.10) !important; }

.avatar {
  position: relative;
  overflow: hidden;
  border-color: rgba(245,200,91,.74) !important;
  background:
    radial-gradient(circle at 35% 28%, rgba(255,255,255,.18), transparent 24%),
    linear-gradient(145deg, #334155, #111827 60%, #030712) !important;
  box-shadow: 0 9px 22px rgba(0,0,0,.52), inset 0 1px rgba(255,255,255,.12) !important;
}

.avatar::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.12);
  pointer-events: none;
}

.seat.active .avatar {
  border-color: var(--hs-cyan) !important;
  box-shadow: 0 0 0 4px rgba(82,229,222,.13), 0 0 25px rgba(82,229,222,.62), 0 9px 22px rgba(0,0,0,.5) !important;
}

.player-info {
  border-color: rgba(255,255,255,.13) !important;
  background: linear-gradient(145deg, rgba(13,25,37,.94), rgba(1,7,13,.95)) !important;
  box-shadow: 0 8px 18px rgba(0,0,0,.42), inset 0 1px rgba(255,255,255,.07);
}

.chips { color: var(--hs-gold) !important; }

.card, .mini-card {
  border: 1px solid rgba(255,255,255,.7);
  filter: saturate(1.08) contrast(1.04);
}

.card {
  background: linear-gradient(150deg, #fffef6, #e8e2d3) !important;
  box-shadow: 0 13px 28px rgba(0,0,0,.58), inset 0 1px rgba(255,255,255,.8), 0 0 0 1px rgba(0,0,0,.12) !important;
}

.pot {
  color: #fff6cf;
  border: 1px solid rgba(245,200,91,.42) !important;
  background: linear-gradient(145deg, rgba(71,45,8,.9), rgba(8,7,3,.94)) !important;
  box-shadow: 0 10px 24px rgba(0,0,0,.46), 0 0 18px rgba(245,200,91,.12) !important;
}

.action-panel {
  padding: 7px !important;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 17px;
  background: linear-gradient(145deg, rgba(8,20,30,.90), rgba(1,7,12,.93));
  box-shadow: 0 12px 30px rgba(0,0,0,.5), inset 0 1px rgba(255,255,255,.07);
}

.action-btn {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.18) !important;
  border-radius: 13px !important;
  background: linear-gradient(150deg, #263444, #0a111b) !important;
  box-shadow: 0 7px 16px rgba(0,0,0,.38), inset 0 1px rgba(255,255,255,.1) !important;
  color: #fff !important;
  font-weight: 900 !important;
  transition: transform .14s ease, filter .14s ease, border-color .14s ease;
}

.action-btn:not(:disabled):active { transform: translateY(2px) scale(.97); }
.action-btn:not(:disabled) { border-color: rgba(82,229,222,.46) !important; }
.action-btn.fold:not(:disabled) { background: linear-gradient(145deg,#8b1d2c,#3f0b14) !important; }
.action-btn.call:not(:disabled), .action-btn.check:not(:disabled) { background: linear-gradient(145deg,#047e69,#03483e) !important; }
.action-btn.raise:not(:disabled) { background: linear-gradient(145deg,#2563a8,#12345e) !important; }
.action-btn.allin:not(:disabled), .deal-btn:not(:disabled) { background: linear-gradient(145deg,#d79a22,#7c4b08) !important; color:#fffbea !important; }

.action-btn:disabled { opacity: .34 !important; filter: grayscale(.45); }

.mode-overlay, .lobby-overlay, .buyin-overlay {
  background:
    radial-gradient(circle at 50% 36%, rgba(20,184,166,.17), transparent 34%),
    rgba(1,5,9,.90) !important;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.mode-box, .lobby-box, .buyin-box {
  border: 1px solid rgba(82,229,222,.27) !important;
  border-radius: 26px !important;
  background: linear-gradient(145deg, rgba(17,32,44,.96), rgba(2,9,15,.97)) !important;
  box-shadow: 0 28px 80px rgba(0,0,0,.68), inset 0 1px rgba(255,255,255,.08) !important;
}

.mode-card, .lobby-card {
  border: 1px solid rgba(255,255,255,.12) !important;
  border-radius: 20px !important;
  background:
    radial-gradient(circle at 50% 0, rgba(82,229,222,.08), transparent 42%),
    linear-gradient(145deg, rgba(22,37,49,.9), rgba(4,12,20,.94)) !important;
  box-shadow: 0 11px 26px rgba(0,0,0,.34), inset 0 1px rgba(255,255,255,.06);
}

.mode-card:hover, .mode-card:focus-visible {
  border-color: rgba(82,229,222,.68) !important;
  transform: translateY(-3px);
  box-shadow: 0 16px 32px rgba(0,0,0,.42), 0 0 22px rgba(82,229,222,.12);
}

.mode-icon { filter: drop-shadow(0 7px 9px rgba(0,0,0,.5)); }
.mode-title, .lobby-title { color: var(--hs-cyan) !important; }

.lobby-btn, .buyin-actions button {
  min-height: 46px;
  border-radius: 13px !important;
  background: linear-gradient(135deg,#0f8c76,#075985) !important;
  box-shadow: 0 8px 18px rgba(0,0,0,.38);
}

.winner-banner {
  border-color: rgba(245,200,91,.65) !important;
  background: linear-gradient(145deg, rgba(104,69,12,.96), rgba(20,12,2,.97)) !important;
  box-shadow: 0 18px 48px rgba(0,0,0,.55), 0 0 30px rgba(245,200,91,.2) !important;
}

@media (max-width: 800px) and (orientation: portrait) {
  .topbar {
    top: calc(4px + var(--hs-top)) !important;
    left: 5px !important;
    right: 5px !important;
    min-height: 52px;
    padding: 6px 8px !important;
    grid-template-columns: auto 1fr auto !important;
  }

  .topbar .title { font-size: 11px !important; }
  .topbar .blind { font-size: 9px !important; }
  .topbar .phase { font-size: 9px !important; }

  .room-panel {
    top: calc(62px + var(--hs-top)) !important;
    left: 6px !important;
    padding: 5px 8px !important;
    border-radius: 10px !important;
    font-size: 9px !important;
  }

  .audio-controls {
    top: calc(62px + var(--hs-top)) !important;
    right: 6px !important;
  }

  .audio-btn { width: 36px; min-width: 36px !important; height: 32px !important; border-radius: 10px !important; }

  .table-wrap {
    top: 48% !important;
    width: 88vw !important;
    height: 58vh !important;
    max-height: 510px !important;
    transform: translate(-50%,-50%) rotateX(51deg) !important;
  }

  .table { border-width: 12px !important; }
  .logo { transform: translate(-50%,-50%) rotateX(-51deg) !important; font-size: 24px !important; }
  .community { top: 45% !important; gap: 3px !important; transform: translate(-50%,-50%) rotateX(-51deg) !important; }
  .community .card { width: clamp(45px, 13vw, 54px) !important; padding: 4px !important; font-size: 14px !important; border-radius: 7px !important; }
  .community .card .suit { font-size: 25px !important; }

  .seat { width: 86px !important; transform: translate(-50%,-50%) rotateX(-51deg) !important; }
  .avatar { width: 42px !important; height: 42px !important; font-size: 14px !important; border-width: 2px !important; }
  .player-info { min-width: 72px !important; max-width: 86px !important; padding: 3px 4px !important; font-size: 8px !important; }
  .player-name, .chips { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .seat-1 { top: 96% !important; }
  .seat-2 { left: 15% !important; top: 77% !important; }
  .seat-3 { left: 8% !important; top: 39% !important; }
  .seat-4 { left: 34% !important; top: 7% !important; }
  .seat-5 { left: 66% !important; top: 7% !important; }
  .seat-6 { left: 92% !important; top: 39% !important; }
  .seat-7, #opp-seat-5 { left: 85% !important; top: 77% !important; }

  .opponent-cards { transform: translate(-50%,-50%) rotateX(-51deg) !important; gap: 3px !important; }
  .mini-card { width: 24px !important; height: 35px !important; }
  .opp-2 { left: 24% !important; top: 69% !important; }
  .opp-3 { left: 20% !important; top: 39% !important; }
  .opp-4 { left: 38% !important; top: 19% !important; }
  .opp-5 { left: 62% !important; top: 19% !important; }
  .opp-6 { left: 80% !important; top: 39% !important; }
  .opp-7 { left: 76% !important; top: 69% !important; }

  #deck { right: 2% !important; top: 53% !important; transform: rotateX(-51deg) rotateZ(-8deg) scale(.56) !important; }
  .pot, #pot { top: 59% !important; transform: translate(-50%,-50%) rotateX(-51deg) !important; min-width: 90px !important; font-size: 11px !important; }

  .hole-cards {
    bottom: calc(100px + var(--hs-bottom)) !important;
    gap: 8px !important;
  }

  .hole-card { width: clamp(60px, 18vw, 72px) !important; }

  .action-panel {
    left: 5px !important;
    right: 5px !important;
    bottom: calc(5px + var(--hs-bottom)) !important;
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: auto !important;
    gap: 5px !important;
    transform: none !important;
  }

  .action-btn {
    width: 100% !important;
    min-width: 0 !important;
    height: 40px !important;
    padding: 0 3px !important;
    font-size: 9px !important;
  }

  .deal-btn { grid-column: 1 / -1; }
  #houseWagerControl { grid-column: 1 / -1; justify-content: center; }

  .mode-box {
    width: calc(100vw - 22px) !important;
    max-height: calc(100dvh - 22px);
    padding: 22px 14px !important;
  }

  .mode-options { gap: 12px !important; }
  .mode-card { min-height: 142px; padding: 16px 12px !important; }
  .mode-icon { font-size: 39px !important; }
  .mode-title { font-size: 17px !important; }
  .mode-desc { font-size: 12px !important; line-height: 1.35; }

  .lobby-box, .buyin-box {
    width: calc(100vw - 20px) !important;
    max-height: calc(100dvh - 20px);
    overflow: auto;
    padding: 18px 13px !important;
  }
}

@media (max-width: 950px) and (orientation: landscape) {
  .table-wrap { filter: drop-shadow(0 23px 30px rgba(0,0,0,.55)); }
  .action-panel { padding: 5px !important; }
  .action-btn { min-height: 42px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
