body {
  margin: 0;
  font-family: "Aptos", "Aptos (Body)", "Calibri (Body)", sans-serif;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: #F8F9FA;
  color: #343A40;
  --font-size: 18px;
  --font-size-large: 21px;
  --font-size-xlarge: 23px;
  --font-size-biggest: 31px;
  --font-size-larger: 23px;
}

/* Join queue / lobby: fluid width; seated play keeps fixed snap tiers in media queries below. */
body:not(:has(#game[style*="display: flex"])) {
  width: 100%;
  min-width: 0;
  max-width: none;
  height: auto;
  min-height: 100vh;
  max-height: none;
  align-items: stretch;
  overflow-x: hidden;
  overflow-y: auto;
}

body:not(:has(#game[style*="display: flex"])) #waiting-section {
  align-self: stretch;
  width: 100%;
  max-width: none;
  flex: 1 1 auto;
}

body:not(:has(#game[style*="display: flex"])) .join-queue-status {
  max-width: none;
}

#game {
  display: none;
}

#game {
  flex: 1;
  flex-direction: column;
}

#waiting-section {
  display: flex;
}

#header {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
}

/* Default Styles (Width >= 500px) */
#row-1 {
  height: 40px;
  display: flex;
  border: 1px solid #333;
}

#row-2-3 {
  height: 80px;
  display: flex;
  border: 1px solid #333;
}

#rows-4-5 {
  height: 80px;
  border: 1px solid #333;
  background-color: #ccc;
}

#row-6 {
  height: 40px;
  display: flex;
  border: 1px solid #333;
}

#rows-7-8 {
  height: 110px;
  border: 1px solid #333;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: nowrap;
  min-width: 0;
}

#cards-section {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 0 8px;
}

#rows-9-10 {
  height: 110px;
  min-height: 110px;
  max-height: 110px;
  border: 1px solid #333;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-width: 0;
  max-width: 100%;
}

#row-11 {
  min-height: 44px;
  height: auto;
  box-sizing: border-box;
  display: flex;
  border: 1px solid #333;
  align-items: center;
  justify-content: space-around;
  flex-shrink: 0;
}

/* Bottom panel: tabbed Chat + Profile (replaces rows-12-15 and row-16) */
.bottom-panel {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  border: 1px solid #333;
  min-height: 200px;
}

.bottom-panel .tab-radio {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.bottom-panel-content {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
}

.bottom-panel .tab-panel {
  display: none;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  border-bottom: none;
}

#tab-emoji:checked ~ .bottom-panel-content .tab-panel-emoji,
#tab-profile:checked ~ .bottom-panel-content .tab-panel-profile {
  display: flex;
}

.emoji-chat-split {
  display: flex;
  flex: 1;
  min-height: 0;
}

.chat-display {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  background-color: #EAEAEA;
  border-right: 1px solid #333;
  /* Midway between Pool/Chips labels (12px) and previous 18px chat size → 15px */
  font-size: calc(12px * 1.25);
  color: #343A40;
}

.chat-display .chat-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
}

.chat-display .chat-portrait {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  background-size: cover;
  background-position: center;
  border-radius: 50%;
  overflow: hidden;
}

.emoji-picker {
  width: 50%;
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 6px;
  padding: 8px;
  background-color: #EAEAEA;
  overflow-y: auto;
}

.emoji-picker .chat-button {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  padding: 0;
  background-color: #EAEAEA;
  border: 1px solid #adb5bd;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Segoe UI Emoji', 'Apple Color Emoji', sans-serif;
}

.emoji-picker .chat-button:hover {
  background-color: #dee2e6;
}

.tab-panel-player {
  padding: 12px;
  align-items: center;
  justify-content: center;
  background: #fff;
}

.tab-panel-player .detailed-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.tab-panel-player .detailed-portrait {
  width: 64px;
  height: 64px;
  background-size: cover;
  background-position: center;
  border-radius: 50%;
  overflow: hidden;
}

.tab-panel-player .detail-actions { display: flex; gap: 8px; margin: 0; }

.tab-panel-player .detail-action {
  font-size: var(--font-size);
  padding: 4px 8px;
  background-color: #f0f0f0;
  border-radius: 4px;
}

.tab-panel-player .detail-action.empty {
  background-color: #dee2e6;
  color: #868e96;
}

.bottom-tab-bar {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  background: #dee2e6;
  border-top: 1px solid #333;
  min-height: 44px;
  overflow-x: auto;
}

.bottom-tab-bar label,
.bottom-tab-bar .tab-thumb-label {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  font-size: var(--font-size);
  cursor: pointer;
  border-right: 1px solid #adb5bd;
  background: #e9ecef;
  flex-shrink: 0;
  white-space: nowrap;
}

.bottom-tab-bar label:hover,
.bottom-tab-bar .tab-thumb-label:hover {
  background: #ced4da;
}

#tab-emoji:checked ~ .bottom-tab-bar label[for="tab-emoji"] {
  background: #404040;
  color: #fff;
  font-weight: bold;
}

.bottom-tab-bar .tab-thumb-label.selected {
  background: #404040;
  color: #fff;
}

.bottom-tab-bar .tab-thumb-label.folded {
  opacity: 0.5;
}

.bottom-tab-bar .tab-label-emoji { min-width: 3em; }

.bottom-tab-bar .tab-thumb {
  width: 28px;
  height: 28px;
  background-size: cover;
  background-position: center;
  border-radius: 50%;
  overflow: hidden;
}

.player-list-thumbs {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  /* Use remaining width in the tab bar and scroll inside this row so all
     player thumbnails stay reachable (Chat label stays flex-shrink: 0). */
  flex: 1 1 0;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.detailed-portrait {
  width: 50px;
  height: 50px;
  background-size: cover;
  background-position: center;
  border-radius: 50%;
  overflow: hidden;
}

.header-section {
  border: 1px solid #333;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-sizing: border-box;
}

#bullpen-bluff {
  flex: 1 1 auto;
  min-width: 0;
  background-color: #28a745;
  font-family: "Aptos", "Aptos (Body)", sans-serif;
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #404040;
  text-align: center;
  text-shadow: 0 -2px 0 rgba(255, 255, 255, 0.5), 0 2px 0 rgba(0, 0, 0, 0.35);
  border-width: 3px;
  border-style: solid;
  border-top-color: rgba(255, 255, 255, 0.5);
  border-left-color: rgba(255, 255, 255, 0.5);
  border-bottom-color: rgba(0, 0, 0, 0.4);
  border-right-color: rgba(0, 0, 0, 0.4);
  box-shadow: inset 3px 3px 6px rgba(255, 255, 255, 0.2), inset -3px -3px 6px rgba(0, 0, 0, 0.25);
}

.game-sound-box {
  flex: 0 0 auto;
  width: 40px;
  min-width: 40px;
  padding: 0 4px;
  cursor: pointer;
  background-color: #A3A9AF;
  color: #000000;
  border-width: 2px;
  border-style: solid;
  border-top-color: rgba(255, 255, 255, 0.2);
  border-left-color: rgba(255, 255, 255, 0.2);
  border-bottom-color: rgba(0, 0, 0, 0.5);
  border-right-color: rgba(0, 0, 0, 0.5);
  box-shadow: inset 2px 2px 4px rgba(255, 255, 255, 0.1), inset -2px -2px 4px rgba(0, 0, 0, 0.3);
}
.game-sound-box .game-sound-emoji {
  font-size: 1.25rem;
  line-height: 1;
}

#connection-status {
  flex: 0 0 25%;
  background-color: #A3A9AF;
  color: #000000;
  border-width: 2px;
  border-style: solid;
  border-top-color: rgba(255, 255, 255, 0.2);
  border-left-color: rgba(255, 255, 255, 0.2);
  border-bottom-color: rgba(0, 0, 0, 0.5);
  border-right-color: rgba(0, 0, 0, 0.5);
  box-shadow: inset 2px 2px 4px rgba(255, 255, 255, 0.1), inset -2px -2px 4px rgba(0, 0, 0, 0.3);
}

#connection-status .connection-label,
#connection-status #connection-value {
  color: #000000;
}

#connection-status #connection-value.connection-ok {
  color: #18662B;
  font-size: 1.25em;
  font-weight: bold;
  -webkit-text-stroke: 1px #18662B;
  text-stroke: 1px #18662B;
  filter: drop-shadow(0 0 0.5px #18662B);
}

#connection-status .connection-label {
  font-size: 12px;
  margin-right: 0.35em;
}

#connection-status #connection-value {
  font-size: var(--font-size);
  font-weight: bold;
}

.profile-box, .chips-box, .dealer-pool-box, .player-pool-box {
  flex: 0 0 25%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  background-color: #EAEAEA;
  font-size: var(--font-size);
  border-width: 2px;
  border-style: solid;
  border-top-color: rgba(255, 255, 255, 0.8);
  border-left-color: rgba(255, 255, 255, 0.8);
  border-bottom-color: rgba(0, 0, 0, 0.15);
  border-right-color: rgba(0, 0, 0, 0.15);
  box-shadow: inset 2px 2px 4px rgba(255, 255, 255, 0.5), inset -2px -2px 4px rgba(0, 0, 0, 0.08);
}

#profile-box {
  background-color: #EAEAEA;
  color: #000000;
  justify-content: center;
  align-items: center;
  box-shadow: none;
}

.profile-you {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  overflow: hidden;
  background-size: cover;
  background-position: center;
  min-height: 0;
  background-color: transparent;
}

#your-chips-image, #dealer-pool-image, #player-pool-image {
  width: 50px;
  height: 50px;
  background-size: cover;
}

#player-name {
  font-size: var(--font-size-large);
  text-align: center;
  color: #000000;
  font-weight: bold;
}

#your-chips-label, #dealer-pool-label, #player-pool-label {
  font-size: 12px;
  text-align: center;
}

#your-chips, #dealer-pool, #player-pool {
  font-size: var(--font-size-large);
  text-align: center;
  color: #000000;
  font-weight: bold;
  min-width: 0;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Fixed pixel box — do not scale with viewport (wide screens were flexing emoji and hiding chip counts). */
#your-chips-emoji, #dealer-pool-emoji, #player-pool-emoji {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  min-width: 32px;
  max-width: 32px;
  min-height: 32px;
  max-height: 32px;
  font-size: 22px;
  text-align: center;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-sizing: border-box;
}

.join-queue-status {
  margin-top: 10px;
  font-size: 0.95rem;
  color: #0b57d0;
  max-width: 320px;
  text-align: center;
}

.join-queue-button-busy,
.join-queue-button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.tab-panel-player .detailed-public-id {
  font-size: 0.95rem;
  color: #495057;
}

.chips-box.pool-box-decrease,
.dealer-pool-box.pool-box-decrease,
.player-pool-box.pool-box-decrease {
  background-color: #FF1744 !important;
  animation: value-flash 1s ease-in-out 6;
}

.chips-box.pool-box-increase,
.dealer-pool-box.pool-box-increase,
.player-pool-box.pool-box-increase {
  background-color: #f1c40f !important;
  animation: value-flash 1s ease-in-out 6;
}

@keyframes value-flash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.status-col {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background-color: #A3A9AF;
  color: #000000;
  font-size: var(--font-size);
  box-sizing: border-box;
}

.status-col .status-label {
  font-size: 12px;
  margin-right: 0.35em;
}

.hand-example {
  margin: 0 0 4px 0;
  font-size: 1rem;
}

.hand-example-cards {
  display: flex;
  gap: 4px;
  margin: 0 0 12px 0;
}

.hand-example-cards .card {
  width: 40px;
  height: 55px;
  max-width: 40px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2px 0;
  line-height: 1.1;
  overflow: hidden;
}

.hand-example-cards .card .suit-emoji {
  margin: 0 0 2px 0;
  font-size: 18px;
}

.hand-example-cards .card .suit-emoji:last-child {
  display: none;
}

/* Game Rules: hand rankings typography */
.game-rules-content h2#hand-rankings {
  font-size: 1.15rem;
}

.game-rules-content h3 {
  font-size: 1rem;
}

.status-col .status-label,
#table-value, #phase-value, #timer-value {
  color: #000000;
}

#table-value, #phase-value, #timer-value {
  font-weight: bold;
}

#phase-value.phase-value-scoreboard {
  display: inline-block;
  padding-right: 8px;
  box-sizing: border-box;
}

#row-6 .col-1-2 {
  flex: 0 0 25%;
  border: 1px solid #333;
}

#row-6 .col-3-6 {
  flex: 0 0 50%;
  border: 1px solid #333;
}

#row-6 .col-7-8 {
  flex: 0 0 25%;
  border: 1px solid #333;
}

.card {
  width: 14%;
  max-width: 72px;
  height: 95px;
  margin: 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  border: 1px solid #000;
  font-size: var(--font-size);
  perspective: 800px;
}

.card .suit-emoji {
  font-size: 27px;
  margin: 0 0 1em 0;
}

.card .suit-emoji.suit-red {
  color: #ee0000;
}

.card .suit-emoji.suit-black {
  color: #040404;
}

.card .suit-emoji:last-child {
  display: none; /* Hide the second suit emoji */
}

.card .suit-left, .card .suit-right {
  position: absolute;
  width: 20px;
  height: 20px;
  background-size: contain;
  background-repeat: no-repeat;
}

.card .suit-left {
  top: 5px;
  left: 5px;
}

.card .suit-right {
  bottom: 5px;
  right: 5px;
}

.face-up {
  background-image: none;
}

/* Non-WILD: suit top, rank bottom — same positions as WILD */
.card-face-normal {
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  overflow: hidden;
}
.card-face-normal .card-suit-top {
  position: absolute;
  left: 0;
  right: 0;
  top: 4px;
  text-align: center;
  font-size: 27px;
  line-height: 1;
}
.card-face-normal .card-suit-top.suit-red { color: #ee0000; }
.card-face-normal .card-suit-top.suit-black { color: #040404; }
.card-face-normal .card-rank {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 4px;
  text-align: center;
  line-height: 1;
}

/* Wild card (3): suit top, WILD center, rank bottom — all inside card */
.card-face-wild {
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  overflow: hidden;
}

.card-face-wild .card-suit-top {
  position: absolute;
  left: 0;
  right: 0;
  top: 4px;
  text-align: center;
  font-size: 27px;
  line-height: 1;
}
.card-face-wild .card-suit-top.suit-red { color: #ee0000; }
.card-face-wild .card-suit-top.suit-black { color: #040404; }

.card-face-wild .card-wild {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  color: #000000;
  font-weight: bold;
  font-size: 0.875em;
  text-align: center;
  line-height: 1.2;
}

.card-face-wild .card-rank {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 4px;
  text-align: center;
  line-height: 1;
}

.card-back {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  background-color: #3a5c2e;
  background-image: url('images/card_back.png?v=5');
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
  border-radius: inherit;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

.winning-card {
  border: 2px solid gold;
}

/* Fly-in: cards start above and fade in */
.card-fly-in {
  transform: translateY(-50px);
  opacity: 0;
  transition: transform 0.35s ease, opacity 0.35s ease;
}
.card-fly-in.card-visible {
  transform: translateY(0);
  opacity: 1;
}
#cards-section .card-fly-in:nth-child(1) { transition-delay: 0ms; }
#cards-section .card-fly-in:nth-child(2) { transition-delay: 50ms; }
#cards-section .card-fly-in:nth-child(3) { transition-delay: 100ms; }
#cards-section .card-fly-in:nth-child(4) { transition-delay: 150ms; }
#cards-section .card-fly-in:nth-child(5) { transition-delay: 200ms; }

/* Flip: front stays fixed (always visible); only the back rotates away */
.card-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}
.card-side {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* Front face: behind back, no transform — painted immediately, no delay */
.card-side.card-front {
  z-index: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.card-side.card-front .card-face-wild,
.card-side.card-front .card-face-normal {
  position: absolute;
  inset: 0;
}
/* Back face: on top, rotates away to reveal front */
.card-side.card-back {
  z-index: 1;
  transform-style: preserve-3d;
  transform: rotateY(0deg);
  transition: transform 0.4s ease;
  will-change: transform;
  backface-visibility: hidden;
}
.card.flipped .card-side.card-back,
.card-inner.flipped .card-side.card-back {
  transform: rotateY(180deg);
}

.pocket-card {
  width: 72px;
  height: 95px;
  max-width: 72px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 5px 0;
  border: 2px solid #000;
}

.pocket-card .suit-emoji {
  font-size: 27px;
  margin: 0 0 1em 0;
}

.pocket-card .suit-emoji.suit-red {
  color: #ee0000;
}

.pocket-card .suit-emoji.suit-black {
  color: #040404;
}

.pocket-card .suit-emoji:last-child {
  display: none; /* Hide the second suit emoji */
}

.side-image-wrap {
  width: 70px;
  height: 70px;
  min-width: 70px;
  max-width: 70px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 4px;
}

.side-image {
  width: 70px;
  height: 70px;
  min-width: 70px;
  max-width: 70px;
  object-fit: cover;
  object-position: center;
  display: block;
}

.action-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 2px;
  min-width: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Flash keyframes from ramirummy (went-out-flash, meld-flash, pulse, steal-bounce) */
@keyframes went-out-flash {
  0%, 100% { box-shadow: 0 0 0 0 rgba(110, 231, 183, 0.35); opacity: 1; }
  50% { box-shadow: 0 0 16px 4px rgba(110, 231, 183, 0.25); opacity: 0.95; }
}
@keyframes meld-flash {
  0%, 100% { box-shadow: 0 1px 2px rgba(0,0,0,0.25); }
  50% { box-shadow: 0 0 0 2px #6ee7b7, 0 0 8px #6ee7b7; }
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(5, 150, 105, 0); }
}
@keyframes steal-bounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* When it's your turn, pulse the action buttons (same as ramirummy .btn-go-out) */
.action-buttons.action-buttons-pulse {
  animation: pulse 2s infinite;
}

.action-button {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.action-button-square {
  height: 36px;
  min-height: 36px;
  margin: 2px 4px;
  padding: 2px 8px;
  min-width: 0;
  font-size: calc(var(--font-size) * 0.9);
  color: #ffffff;
  font-weight: bold;
  background-color: #404040;
  border: none;
  cursor: pointer;
  border-radius: 10px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.action-button-square:hover:not(:disabled) {
  background-color: #ced4da;
  color: #212529;
}

/* Coarse pointers (phones, many tablets): avoid sticky :hover looking “selected/grey”. */
@media (pointer: coarse) {
  .action-button-square:hover:not(:disabled) {
    background-color: #404040;
    color: #ffffff;
  }
  .join-queue-button:hover {
    background-color: #2d2d2d;
  }
}

.action-button-square:focus {
  outline: none;
}

.action-button-square:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}

.action-button-square:active:not(:disabled) {
  transform: scale(0.98);
}

.action-button-square:disabled {
  background-color: #6c757d;
  cursor: not-allowed;
}

.chat-window {
  flex: 4;
  border-right: 1px solid #333;
  overflow-y: auto;
  padding: 5px;
  background-color: #EAEAEA;
  color: #343A40;
  font-size: var(--font-size);
}

.chat-window .chat-portrait {
  width: var(--font-size);
  height: var(--font-size);
  background-size: cover;
  display: inline-block;
  vertical-align: middle;
  margin-right: 5px;
}

.player-details {
  flex: 3;
  border-right: 1px solid #333;
  overflow-y: auto;
  padding: 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.player-list {
  flex: 1;
  overflow-y: auto;
  padding: 5px;
  order: -1;
}

.player-item {
  height: 28px;
  display: flex;
  align-items: center;
  margin: 2px 0;
}

.player-item .portrait {
  width: 30px;
  height: 30px;
  background-size: cover;
  margin-right: 5px;
}

.player-item.folded {
  opacity: 0.5;
  background-color: #ccc;
}

.detailed-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.tab-panel-player .detailed-name {
  font-weight: 700;
}

.tab-panel-player .detailed-public-id {
  margin-top: 4px;
  font-size: calc(var(--font-size) * 0.95);
}

.tab-panel-player .detailed-stats-label {
  font-weight: 700;
}

.tab-panel-player .profile-rival-action {
  margin-top: 12px;
  display: flex;
  justify-content: center;
  width: 100%;
}

.detailed-portrait {
  width: 50px;
  height: 50px;
  background-size: cover;
}

.detail-actions {
  display: flex;
  gap: 5px;
  margin: 5px 0;
}

.detail-action {
  font-size: var(--font-size);
  padding: 2px 5px;
  background-color: #f0f0f0;
}

.detail-action.empty {
  background-color: #ccc;
}

.rival-checkbox {
  margin-top: 5px;
}

.chat-button {
  font-size: var(--font-size);
  padding: 5px;
  font-family: 'Segoe UI Emoji', 'Apple Color Emoji', sans-serif;
  border-radius: 10px;
}

.chat-button.depressed {
  transform: scale(0.95);
  background-color: #333333;
}

.winning-hand {
  margin-top: 10px;
  font-size: var(--font-size);
  color: #333;
}

#winner-readout-container {
  display: none;
  height: 70px;
  width: 100%;
  min-width: 0;
  border: 1px solid #333;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  box-sizing: border-box;
}

#winner-readout {
  text-align: center;
  font-size: var(--font-size);
  font-weight: bold;
  color: #000000;
  padding: 10px;
  background-color: #e0e0e0;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  overflow: hidden;
}
#winner-readout .winner-portrait {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  display: inline-block;
  vertical-align: middle;
}

#winner-readout.winner-waiting {
  background-color: #A3A9AF;
  color: #000000;
}

#winner-readout.winner-announce {
  background-color: #f1c40f;
  color: #000000;
}

#winner-readout.winner-flash {
  animation: winner-flash 1s ease-in-out 12;
}

@keyframes winner-flash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

#your-chips.pool-value-flash-6,
#dealer-pool.pool-value-flash-6,
#player-pool.pool-value-flash-6 {
  animation: value-flash 1s ease-in-out 6;
}

#your-chips-emoji.pool-emoji-flash-6,
#dealer-pool-emoji.pool-emoji-flash-6,
#player-pool-emoji.pool-emoji-flash-6 {
  animation: value-flash 1s ease-in-out 6;
}

#scoreboard #winner-readout-container {
  display: flex;
}

#scoreboard #rows-9-10 {
  display: none;
}


  .minimal-lobby {
    position: relative;
    min-height: 100vh;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    margin: 0;
    padding: 32px 0 32px;
    box-sizing: border-box;
    overflow-y: auto;
    overflow-x: clip;
    -webkit-overflow-scrolling: touch;
    background-color: #F2F2F2;
  }

  .join-queue-hero {
    max-width: 312px;
    width: 58.75%;
    height: auto;
    margin-bottom: 8px;
    display: block;
  }

  .join-queue-title {
    font-family: "Aptos", "Aptos (Body)", sans-serif;
    color: #5a5a5a;
    font-size: 3.25rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    margin: 0 0 24px 0;
    text-align: center;
    text-shadow: 0 -2px 0 rgba(255, 255, 255, 0.5), 0 2px 0 rgba(0, 0, 0, 0.35);
  }

  .waiting-links {
    margin: 64px 0 12px 0;
    display: flex;
    gap: 12px;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: baseline;
  }
  .join-queue-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    max-width: 26rem;
    margin: 0 auto;
    padding: 0 16px;
    box-sizing: border-box;
  }
  .join-queue-actions .join-queue-top-links {
    justify-content: flex-start;
    padding-left: 0;
    padding-right: 0;
  }
  .join-queue-actions .join-queue-button {
    align-self: center;
  }
  .join-queue-actions .join-queue-status {
    text-align: left;
    align-self: stretch;
    max-width: none;
    width: 100%;
    margin-top: 2em;
  }
  .join-queue-top-links {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    text-align: center;
    padding-left: 16px;
    padding-right: 16px;
    margin: 1.25rem 0 12px 0;
  }
  .join-queue-top-links .waiting-links-sep {
    opacity: 0.6;
    user-select: none;
  }
  .join-queue-top-links .waiting-link strong {
    font-size: inherit;
    font-weight: 600;
  }
  .join-queue-promo {
    margin: calc(12px + 1.35em) auto 0;
    padding: 0 16px;
    max-width: 26rem;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    color: #3d3d3d;
    line-height: 1.45;
  }
  .join-queue-promo strong {
    font-weight: 700;
    color: #2d2d2d;
  }
  .join-queue-promo .waiting-link {
    color: #0b57d0;
    text-decoration: underline;
    font-weight: 600;
  }
  .waiting-links .waiting-link {
    color: #3d3d3d;
    text-decoration: underline;
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    display: inline-flex;
    align-items: baseline;
  }
  .waiting-links .waiting-link:hover {
    text-decoration: underline;
  }

  .sound-toggle-wrap {
    display: inline-flex;
    align-items: baseline;
    cursor: pointer;
  }
  .sound-toggle-emoji {
    background-color: #3d3d3d;
    color: #e8e8e8;
    font-size: 0.9rem;
    margin-left: 4px;
    padding: 2px 4px;
    display: inline-block;
    vertical-align: baseline;
    line-height: 1;
    border-radius: 2px;
  }
  .sound-toggle-emoji.sound-on {
    font-size: 1.125rem;
  }

  .join-queue-tagline {
    margin: 8px 0 0.75rem 0;
    font-size: 0.825rem;
    font-weight: 600;
    color: #2d2d2d;
    text-align: center;
  }
  .minimal-lobby .join-queue-status {
    font-size: 0.825rem;
  }
  .join-queue-tagline .waiting-link {
    color: #3d3d3d;
    text-decoration: underline;
    font-weight: 600;
    font-size: inherit;
    white-space: nowrap;
  }
  .join-queue-button {
    margin-top: 16px;
    padding: 14px 48px;
    font-size: 1.25rem;
    font-weight: bold;
    font-family: "Aptos", "Aptos (Body)", sans-serif;
    background-color: #2d2d2d;
    color: #ffffff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  }

  .join-queue-button:hover {
    background-color: #1a1a1a;
  }

  .join-queue-button:active {
    transform: scale(0.98);
  }


/* Media Query for Width < 500px */
@media screen and (max-width: 499px) {
  #game {
    width: 380px;
  }

  #row-1 {
    height: 40px;
    display: flex;
    border: 1px solid #333;
  }

  #row-2-3 {
    height: 80px;
    display: flex;
    border: 1px solid #333;
  }

  #rows-4-5 {
    height: 80px;
    border: 1px solid #333;
    background-color: #ccc;
  }

  #row-6 {
    height: 40px;
    display: flex;
    border: 1px solid #333;
  }

  #rows-7-8 {
    height: 110px;
    border: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    min-width: 0;
  }

  #cards-section {
    width: 100%;
    display: flex;
    justify-content: space-between;
  }

  #rows-9-10 {
    height: 110px;
    border: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  #row-11 {
    min-height: 44px;
    height: auto;
    display: flex;
    border: 1px solid #333;
    align-items: center;
    justify-content: space-around;
  }

  #rows-12-15 {
    height: 200px;
    display: flex;
    border: 1px solid #333;
  }

  #row-16 {
    height: 40px;
    display: flex;
    border: 1px solid #333;
    align-items: center;
    justify-content: space-around;
    gap: 5px;
  }

  .header-section {
    border: 1px solid #333;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
  }

  #bullpen-bluff {
    flex: 1 1 auto;
    min-width: 0;
    background-color: #28a745;
    font-family: "Aptos", "Aptos (Body)", sans-serif;
    font-size: 1.55rem;
    font-weight: 800;
    color: #404040;
    text-shadow: 0 -2px 0 rgba(255, 255, 255, 0.5), 0 2px 0 rgba(0, 0, 0, 0.35);
  }

  #connection-status {
    flex: 0 0 25%;
    background-color: #A3A9AF;
    color: #000000;
  }

  .profile-box, .chips-box, .dealer-pool-box, .player-pool-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    background-color: #EAEAEA;
    font-size: var(--font-size);
  }

  #profile-box {
    background-color: #EAEAEA;
  }

  .profile-you {
    width: 50px;
    height: 50px;
    background-size: cover;
  }

  #your-chips-image, #dealer-pool-image, #player-pool-image {
    width: 50px;
    height: 50px;
    background-size: cover;
  }

  #player-name {
    font-size: var(--font-size-large);
    text-align: center;
    color: #000000;
    font-weight: bold;
  }

  #your-chips-label, #dealer-pool-label, #player-pool-label,
  #your-chips, #dealer-pool, #player-pool {
    font-size: var(--font-size-large);
    text-align: center;
  }

  .chat-display {
    /* Midway between label size (--font-size-large) and 1.5× that */
    font-size: calc(var(--font-size-large) * 1.25);
  }

  #your-chips-emoji, #dealer-pool-emoji, #player-pool-emoji {
    width: 30px;
    height: 30px;
    min-width: 30px;
    max-width: 30px;
    min-height: 30px;
    max-height: 30px;
    font-size: 20px;
  }

  .status-col {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background-color: #A3A9AF;
    color: #000000;
    font-size: var(--font-size);
  }

  #row-6 .col-1-2 {
    flex: 0 0 25%;
    border: 1px solid #333;
  }

  #row-6 .col-3-6 {
    flex: 0 0 50%;
    border: 1px solid #333;
  }

  #row-6 .col-7-8 {
    flex: 0 0 25%;
    border: 1px solid #333;
  }

  .card {
    width: 16%;
    height: 95px;
    margin: 0 2%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    border: 1px solid #000000;
  }

  .card .suit-emoji {
    font-size: 27px;
    margin: 0 0 1em 0;
  }

  .card .suit-emoji.suit-red { color: #ee0000; }
  .card .suit-emoji.suit-black { color: #040404; }

  .card .suit-emoji:last-child {
    display: none;
  }

  .card .suit-left, .card .suit-right {
    position: absolute;
    width: 20px;
    height: 20px;
    background-size: contain;
    background-repeat: no-repeat;
  }

  .card .suit-left {
    top: 5px;
    left: 5px;
  }

  .card .suit-right {
    bottom: 5px;
    right: 5px;
  }

  .face-up {
    background-image: none;
  }

  .card-back {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%; height: 100%;
    background-color: #3a5c2e;
    background-image: url('images/card_back.png?v=5');
    background-repeat: no-repeat;
    background-position: center;
    background-size: 100% 100%;
    border-radius: inherit;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }

  .winning-card {
    border: 2px solid gold;
  }

  .pocket-card {
    width: 16%;
    height: 95px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 5px 0;
    border: 2px solid #000000;
  }

  .pocket-card .suit-emoji {
    font-size: 27px;
    margin: 0 0 1em 0;
  }

  .pocket-card .suit-emoji.suit-red { color: #ee0000; }
  .pocket-card .suit-emoji.suit-black { color: #040404; }

  .pocket-card .suit-emoji:last-child {
    display: none;
  }

  .side-image {
    width: 95px;
    height: 95px;
    background-size: cover;
    background-repeat: no-repeat;
  }

  .action-button {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .action-button-square {
    height: 36px;
    min-height: 36px;
    margin: 2px 4px;
    padding: 2px 8px;
    font-size: calc(var(--font-size) * 0.9);
    color: white;
    font-weight: bold;
    background-color: #404040;
    border: none;
    cursor: pointer;
    border-radius: 10px;
  }
  .action-button-square:hover:not(:disabled) {
    background-color: #ced4da;
    color: #212529;
  }

  .action-button-square:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
  }

  .chat-window {
    flex: 4;
    border-right: 1px solid #333;
    overflow-y: auto;
    padding: 5px;
    background-color: transparent;
    color: #343A40;
    font-size: var(--font-size);
  }

  .chat-window .chat-portrait {
    width: var(--font-size);
    height: var(--font-size);
    background-size: cover;
    display: inline-block;
    vertical-align: middle;
    margin-right: 5px;
  }

  .player-details {
    flex: 3;
    border-right: 1px solid #333;
    overflow-y: auto;
    padding: 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .player-list {
    flex: 1;
    overflow-y: auto;
    padding: 5px;
    order: -1;
  }

  .player-item {
    height: 28px;
    display: flex;
    align-items: center;
    margin: 2px 0;
  }

  .player-item .portrait {
    width: 30px;
    height: 30px;
    background-size: cover;
    margin-right: 5px;
  }

  .player-item.folded {
    opacity: 0.5;
    background-color: #ccc;
  }

  .detailed-profile {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .detailed-portrait {
    width: 50px;
    height: 50px;
    background-size: cover;
  }

  .detail-actions {
    display: flex;
    gap: 5px;
    margin: 5px 0;
  }

  .detail-action {
    font-size: var(--font-size);
    padding: 2px 5px;
    background-color: #f0f0f0;
  }

  .detail-action.empty {
    background-color: #ccc;
  }

  .rival-checkbox {
    margin-top: 5px;
  }

  .chat-button {
    font-size: var(--font-size);
    padding: 5px;
    font-family: 'Segoe UI Emoji', 'Apple Color Emoji', sans-serif;
  }

  .chat-button.depressed {
    transform: scale(0.95);
    background-color: #333333;
  }

  .winning-hand {
    margin-top: 10px;
    font-size: var(--font-size);
    color: #333;
  }

  #winner-readout-container {
    display: none;
    height: 70px;
    width: 100%;
    min-width: 0;
    border: 1px solid #333;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    box-sizing: border-box;
  }

  #winner-readout {
    text-align: center;
    font-size: var(--font-size);
    font-weight: bold;
    color: #000000;
    padding: 10px;
    background-color: #e0e0e0;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
  }

  #scoreboard #winner-readout-container {
    display: flex;
  }

  #scoreboard #rows-9-10 {
    display: none;
  }
}

/* ========== 0–480px: snap to 320px (game play only), smaller fonts ========== */
@media screen and (max-device-width: 480px) and (orientation: portrait),
       screen and (max-width: 480px) {
  body:has(#game[style*="display: flex"]) {
    width: 320px;
    min-width: 320px;
    max-width: 320px;
    height: 640px;
    min-height: 640px;
    max-height: 640px;
    margin: 0 auto;
    overflow: hidden;
  }
  #game {
    width: 100%;
    height: 100%;
    min-height: 0;
    --font-size: 14px;
    --font-size-large: 16px;
    --font-size-xlarge: 18px;
    --font-size-biggest: 24px;
    --font-size-larger: 18px;
  }
  #row-6 {
    height: 32px;
    min-height: 32px;
    max-height: 32px;
    font-size: 0.75rem;
  }
  #rows-7-8 { height: 70px; }
  #cards-section { justify-content: space-between; gap: 6px; padding: 0 4px; }
  #cards-section .card {
    width: 46px;
    height: 62px;
    margin: 0;
    flex-shrink: 0;
  }
  .card .suit-emoji { font-size: 18px; }
  #rows-9-10 {
    height: 70px;
    min-height: 70px;
    max-height: 70px;
  }
  .side-image {
    width: 46px;
    height: 46px;
    min-width: 0;
    flex-shrink: 1;
    border-radius: 50%;
    overflow: hidden;
    background-position: center;
  }
  .pocket-card {
    width: 46px;
    height: 62px;
    margin: 0;
    flex-shrink: 0;
  }
  .pocket-card .suit-emoji { font-size: 18px; }
  #row-11 {
    min-height: 32px;
    height: auto;
    padding: 2px 0;
  }
  .action-buttons { gap: 2px; flex-wrap: nowrap; align-items: center; }
  .action-button-square {
    height: 28px;
    min-height: 28px;
    max-height: 30px;
    margin: 0 2px;
    padding: 0 6px;
    font-size: calc(0.7rem * 0.9);
    line-height: 1.1;
    min-width: 0;
  }
  .bottom-panel { min-height: 160px; }
  .bottom-panel-content { min-height: 120px; }
  .bottom-panel .tab-panel { min-height: 120px; }
  .bottom-tab-bar { min-height: 38px; }
  .bottom-tab-bar label,
  .bottom-tab-bar .tab-thumb-label { padding: 4px 6px; font-size: 0.75rem; }
  .bottom-tab-bar .tab-thumb { width: 24px; height: 24px; }
  .profile-you { width: 36px; height: 36px; border-radius: 50%; overflow: hidden; }
  .header-section { font-size: 0.75rem; }
  /* Was 0.7rem — too small; doubled for chips / dealer pool / side-bet icons on 320px layout */
  #your-chips-emoji, #dealer-pool-emoji, #player-pool-emoji {
    width: 28px;
    height: 28px;
    min-width: 28px;
    max-width: 28px;
    min-height: 28px;
    max-height: 28px;
    font-size: 18px;
  }
  #winner-readout-container { min-width: 0; overflow: hidden; }
  #winner-readout { min-width: 0; max-width: 100%; padding: 6px 8px; overflow: hidden; }
}

/* ========== 481–1040px: snap to 480×900 (game play only) ========== */
@media (min-width: 481px) and (max-width: 1040px) {
  body:has(#game[style*="display: flex"]) {
    justify-content: flex-start;
    align-items: center;
    overflow-y: auto;
    overflow-x: hidden;
    zoom: calc(100vw / 480);
  }
  body:not(:has(#game[style*="display: flex"])) {
    zoom: 1;
    align-items: stretch;
  }
  #game {
    width: 480px;
    min-height: 900px;
    height: 900px;
    max-height: 900px;
    margin: 0 auto;
    flex: 0 0 auto;
    box-shadow: 0 0 0 3px #333;
  }
}

/* ========== 1041px+: card sections and cards scale with viewport height ========== */
@media (min-width: 1041px) {
  body:not(:has(#game[style*="display: flex"])) {
    align-items: stretch;
  }
  body:not(:has(#game[style*="display: flex"])) #waiting-section.minimal-lobby {
    width: 100%;
    max-width: none;
    align-self: stretch;
  }
  #game { min-height: 90vh; }
  #rows-7-8 {
    flex: 1;
    min-height: 14vh;
    height: auto;
    align-items: center;
  }
  #rows-9-10 {
    flex: 1;
    min-height: 14vh;
    height: auto;
    max-height: none;
  }
  #cards-section .card {
    height: 12vh;
    width: calc(12vh * 72 / 95);
    max-width: 140px;
    min-height: 80px;
  }
  .pocket-card {
    height: 12vh;
    width: calc(12vh * 72 / 95);
    max-width: 140px;
    min-width: 72px;
    min-height: 80px;
  }
  .side-image {
    width: 12vh;
    height: 12vh;
    min-width: 70px;
    max-width: 120px;
    min-height: 70px;
    max-height: 120px;
  }
  .bottom-panel { flex: 1; min-height: 240px; }

  /* Keep pool icons same fixed band as <1040px — no vw/clamp growth on wide monitors. */
  #your-chips-emoji, #dealer-pool-emoji, #player-pool-emoji {
    width: 32px;
    height: 32px;
    min-width: 32px;
    max-width: 32px;
    min-height: 32px;
    max-height: 32px;
    font-size: 22px;
    line-height: 1;
  }
  .emoji-picker .chat-button {
    font-size: var(--font-size-xlarge);
    width: 2.25rem;
    height: 2.25rem;
    min-width: 2.25rem;
    min-height: 2.25rem;
  }
}
