:root {
  --felt-dark: #0d3d2a;
  --felt-mid: #145c3a;
  --gold: #d4af37;
  --gold-light: #f0d878;
  --cream: #f5f0e6;
  --panel: rgba(12, 22, 18, 0.92);
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  --font-ui: 'Manrope', system-ui, sans-serif;
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --nav-h: 52px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100%;
  min-height: 100dvh;
  overflow-x: hidden;
}

body.game-active {
  overflow: hidden;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
}

#app {
  width: 100%;
}

#app:has(.table-wrap) {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

#app:has(.lobby) {
  min-height: 100svh;
  min-height: 100dvh;
}

.lobby-scroll-hint {
  text-align: center;
  font-size: 0.8rem;
  margin-top: -0.25rem;
}

.lobby-scroll-hint a {
  color: rgba(240, 216, 120, 0.75);
  text-decoration: none;
}

.lobby-scroll-hint a:hover {
  color: var(--gold-light);
  text-decoration: underline;
}

body {
  font-family: var(--font-ui);
  color: var(--cream);
  background: #060a08 radial-gradient(ellipse at 50% 0%, #1a2f24 0%, #060a08 70%);
}

/* Lobby */
.lobby {
  min-height: 100svh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem 1rem 2rem;
  box-sizing: border-box;
  background:
    linear-gradient(180deg, rgba(0,0,0,0.5), rgba(0,0,0,0.75)),
    url('../assets/images/table-felt.png') center/cover no-repeat scroll;
}

@media (min-width: 768px) and (hover: hover) {
  .lobby {
    background-attachment: fixed;
  }
}

.lobby-header {
  text-align: center;
  margin-bottom: 1rem;
  padding-top: 0.5rem;
  flex-shrink: 0;
}

.lobby-header h1 {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 5vw, 3rem);
  font-weight: 700;
  color: var(--gold-light);
  text-shadow: 0 2px 20px rgba(212, 175, 55, 0.4);
  letter-spacing: 0.04em;
  line-height: 1.15;
}

.subtitle {
  margin-top: 0.35rem;
  opacity: 0.85;
  font-size: clamp(0.85rem, 2.5vw, 1rem);
  line-height: 1.4;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}

.lobby-panel {
  background: var(--panel);
  border: 1px solid rgba(212, 175, 55, 0.25);
  border-radius: 16px;
  padding: 1.25rem 1.35rem;
  width: min(440px, 100%);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  flex-shrink: 0;
}

.lobby-panel label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: rgba(245, 240, 230, 0.9);
}

.lobby-panel select,
.lobby-panel input[type="number"] {
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(212, 175, 55, 0.2);
  background: rgba(0, 0, 0, 0.35);
  color: var(--cream);
  font-family: inherit;
  font-size: 0.95rem;
}

.inline-inputs {
  display: flex;
  gap: 0.5rem;
}

.lobby-rules {
  text-align: center;
  margin-top: 0.75rem;
  font-size: 0.85rem;
}

.lobby-rules a {
  color: #f0d878;
  text-decoration: none;
}

.lobby-rules a:hover {
  text-decoration: underline;
}

.lobby-error {
  text-align: center;
  margin-top: 0.75rem;
  color: #ff8a80;
  font-size: 0.9rem;
}

.table-nav a.btn-ghost {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}


.hidden {
  display: none !important;
}

/* Table */
.table-wrap {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.table-felt {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 55% at 50% 48%, rgba(20, 92, 58, 0.15), transparent 70%),
    url('../assets/images/table-felt.png') center/cover no-repeat;
  filter: brightness(0.95) saturate(1.1);
}

.table-felt::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0, 0, 0, 0.55) 100%);
  pointer-events: none;
}

.table-content {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  padding-top: 0.5rem;
  padding-bottom: var(--nav-h);
  box-sizing: border-box;
}

.table-controls {
  position: absolute;
  z-index: 20;
  min-width: min(92vw, 340px);
  max-width: calc(100vw - 16px);
}

.table-controls.floating-panel {
  background: var(--panel);
  border: 1px solid rgba(212, 175, 55, 0.25);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

body.game-active #seo-landing {
  display: none;
}

.table-controls.floating-panel--default-br {
  right: 10px;
  bottom: calc(var(--nav-h) + 10px);
  left: auto;
  top: auto;
  transform: none;
  width: min(calc(100vw - 20px), 320px);
}

.table-controls.floating-panel--dragging {
  opacity: 0.96;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.65);
}

.panel-drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.45rem 0.75rem;
  min-height: 2rem;
  background: rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid rgba(212, 175, 55, 0.15);
  cursor: grab;
  user-select: none;
  touch-action: none;
  -webkit-user-select: none;
}

.panel-drag-handle:active {
  cursor: grabbing;
}

.drag-grip {
  width: 28px;
  height: 8px;
  background: radial-gradient(circle, rgba(212, 175, 55, 0.7) 2px, transparent 2px) center / 8px 8px;
}

.drag-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.65;
}

.panel-body {
  padding: 0.65rem 0.75rem;
}

.table-controls .action-bar,
.table-controls .draw-actions,
.table-controls .russian-actions,
.table-controls .wait-msg {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  margin: 0;
}

.table-nav {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 11;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  min-height: var(--nav-h);
  padding: 0.5rem 0.75rem;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
  box-sizing: border-box;
}

.game-hud {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  z-index: 5;
}

.pot-display {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--gold-light);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

.pot-display strong {
  font-size: 1.5rem;
}

.phase-display {
  margin-top: 0.25rem;
  font-size: 0.9rem;
  opacity: 0.85;
}

.hand-hint {
  margin-top: 0.35rem;
  font-size: 0.82rem;
  color: #a8d4b8;
  background: rgba(0, 0, 0, 0.45);
  padding: 0.25rem 0.65rem;
  border-radius: 8px;
  display: inline-block;
}

.board-area {
  position: absolute;
  top: 36%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  gap: 0.35rem;
  z-index: 4;
  pointer-events: none;
}

.board-area .playing-card {
  pointer-events: auto;
}

.seats-ring {
  position: absolute;
  inset: 0;
  pointer-events: none;
  --seat-r-bot: min(24vh, 24vw, 165px);
  --seat-r-human: min(17vh, 20vw, 115px);
}

.player-seat {
  position: absolute;
  left: 50%;
  top: 46%;
  transform:
    translate(-50%, -50%)
    rotate(calc(360deg / var(--seat-n) * var(--seat-i)))
    translateY(calc(-1 * var(--seat-r, min(28vh, 210px))))
    rotate(calc(-360deg / var(--seat-n) * var(--seat-i)));
  text-align: center;
  transition: opacity 0.3s, filter 0.3s;
  z-index: 3;
  pointer-events: auto;
  max-width: min(240px, 42vw);
}

.player-seat.seat-bot {
  --seat-r: var(--seat-r-bot);
}

.player-seat.seat-human {
  --seat-r: var(--seat-r-human);
}

.player-seat.human {
  z-index: 5;
}

.player-seat.human .player-cards {
  margin-bottom: 0.25rem;
}

.player-seat.folded {
  opacity: 0.45;
  filter: grayscale(0.6);
}

.player-seat.active .player-info {
  box-shadow: 0 0 0 2px var(--gold), 0 0 20px rgba(212, 175, 55, 0.5);
}

.player-info {
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 10px;
  padding: 0.35rem 0.65rem;
  margin-bottom: 0.35rem;
  font-size: 0.75rem;
  display: inline-block;
}

.player-name {
  font-weight: 600;
  display: block;
}

.player-chips {
  color: var(--gold-light);
}

.dealer-btn {
  display: inline-block;
  background: var(--gold);
  color: #1a1a1a;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 18px;
  margin-right: 4px;
}

.player-cards {
  display: flex;
  justify-content: center;
  gap: 0.2rem;
  flex-wrap: wrap;
  max-width: 220px;
}

/* Russian layout */
.russian-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 3rem 0.75rem calc(var(--nav-h) + 80px);
  box-sizing: border-box;
}

.russian-dealer h3,
.russian-player h3 {
  font-family: var(--font-display);
  color: var(--gold-light);
  text-align: center;
  margin-bottom: 0.75rem;
  font-size: 1.5rem;
}

.card-row {
  display: flex;
  gap: 0.35rem;
  justify-content: center;
  flex-wrap: wrap;
}

.ante-info, .qualify {
  text-align: center;
  margin-top: 0.75rem;
  font-size: 0.9rem;
  opacity: 0.9;
}

.russian-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: center;
  align-items: center;
}

.draw-actions {
  text-align: center;
}

.draw-actions p {
  margin-bottom: 0.65rem;
  font-size: 0.88rem;
}

.wait-msg {
  text-align: center;
  opacity: 0.9;
  font-size: 0.9rem;
}

@media (max-width: 640px) {
  .lobby {
    padding: 0.75rem 0.75rem 1.5rem;
  }

  .lobby-panel {
    padding: 1rem;
    gap: 0.7rem;
  }

  .lobby-header h1 {
    font-size: 1.5rem;
  }

  .table-controls.floating-panel--default-br {
    right: 6px;
    left: 6px;
    bottom: calc(var(--nav-h) + 6px);
    width: auto;
    min-width: 0;
    max-width: none;
  }

  .table-nav {
    flex-wrap: wrap;
    justify-content: center;
  }

  .table-nav .btn-ghost {
    font-size: 0.8rem;
    padding: 0.45rem 0.65rem;
  }

  .seats-ring {
    --seat-r-bot: min(16vh, 28vw, 88px);
    --seat-r-human: min(12vh, 22vw, 62px);
  }

  .player-seat {
    top: 45%;
    max-width: 30vw;
  }

  .player-info {
    padding: 0.25rem 0.45rem;
    font-size: 0.65rem;
    margin-bottom: 0.2rem;
  }

  .player-name {
    font-size: 0.65rem;
  }

  .player-cards {
    max-width: 100%;
    gap: 0.1rem;
  }

  .board-area {
    top: 34%;
    gap: 0.2rem;
    max-width: 96vw;
    flex-wrap: wrap;
    justify-content: center;
  }

  .game-hud {
    top: 0.35rem;
    max-width: 90vw;
  }

  .pot-display {
    font-size: 1rem;
  }

  .pot-display strong {
    font-size: 1.15rem;
  }

  .phase-display {
    font-size: 0.78rem;
  }

  .hand-hint {
    font-size: 0.72rem;
    max-width: 90vw;
  }

  .panel-drag-handle {
    padding: 0.55rem 0.75rem;
    min-height: 2.35rem;
  }

  .drag-label {
    font-size: 0.72rem;
  }
}

@media (max-width: 380px) {
  .seats-ring {
    --seat-r-bot: min(14vh, 26vw, 76px);
    --seat-r-human: min(10vh, 20vw, 54px);
  }

  .player-seat {
    max-width: 28vw;
  }
}

@media (max-height: 700px) {
  .lobby-header {
    margin-bottom: 0.5rem;
  }

  .lobby-header h1 {
    font-size: 1.45rem;
  }

  .subtitle {
    font-size: 0.82rem;
  }

  .lobby-panel {
    gap: 0.6rem;
    padding: 0.85rem 1rem;
  }

  .btn-lg {
    padding: 0.65rem 1rem;
    margin-top: 0.25rem;
  }

  .player-seat {
    top: 43%;
  }

  .board-area {
    top: 30%;
  }
}
