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

:root {
  --bg: #0f1110;
  --table-green: #144027;
  --card-bg: linear-gradient(135deg, #1a2e28 0%, #0d2118 100%);
  --gold: #d4a574;
  --gold-bright: #f0c674;
  --red: #c0392b;
  --green: #27ae60;
  --white: #f0f0f0;
  --muted: #7a8a78;
  --card-white: #f5f1e7;
  --shadow: rgba(0, 0, 0, 0.5);
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

html, body {
  height: 100%;
  width: 100%;
  overflow-x: hidden;
}

body {
  background: var(--bg);
  color: var(--white);
  font-family: var(--font);
  display: flex;
  justify-content: center;
  min-height: 100vh;
}

/* ─── OVERLAY ─── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.overlay.show { display: flex; }

.message-box {
  background: var(--table-green);
  padding: 2rem 3rem;
  border-radius: 12px;
  text-align: center;
  border: 2px solid var(--gold);
  box-shadow: 0 0 30px rgba(0,0,0,0.8);
  animation: scaleIn 0.3s ease;
}
.message-box p {
  font-size: 1.2rem;
  margin-bottom: 1rem;
  color: var(--gold-bright);
  font-weight: 600;
  white-space: pre-line;
  line-height: 1.55;
}
.message-box button {
  background: var(--gold);
  color: #1a1a1a;
  border: none;
  padding: 0.5rem 2rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 1rem;
}

.message-actions { display: flex; justify-content: center; gap: 0.65rem; }
.message-box .message-cancel { display: none; color: #f0f0f0; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.28); }
.message-box .message-cancel.show { display: inline-block; }

.overlay.hand-result {
  align-items: flex-end;
  padding: 1rem 1rem max(112px, calc(92px + env(safe-area-inset-bottom, 0px)));
  background: linear-gradient(to bottom, transparent 68%, rgba(0,0,0,0.42));
  pointer-events: none;
}

.overlay.hand-result .message-box {
  width: min(620px, calc(100% - 1rem));
  padding: 0.8rem 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  pointer-events: auto;
}

.overlay.hand-result .message-box p { margin: 0; font-size: 0.95rem; }
.overlay.hand-result .message-box button { flex: 0 0 auto; }

@media (max-width: 620px) {
  .overlay.hand-result { padding: 0.5rem 0.5rem max(154px, calc(142px + env(safe-area-inset-bottom, 0px))); }
  .overlay.hand-result .message-box { width: 100%; padding: 0.65rem 0.75rem; gap: 0.65rem; }
  .overlay.hand-result .message-box p { font-size: 0.78rem; line-height: 1.3; }
  .overlay.hand-result .message-box button { padding: 0.5rem 0.8rem; font-size: 0.82rem; }
}

@keyframes scaleIn {
  from { transform: scale(0.8); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

/* ─── HEADER ─── */
#game-header {
  width: 100%;
  max-width: 1200px;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  background: linear-gradient(135deg, var(--gold), var(--gold-bright));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.game-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.mode-selector {
  display: flex;
  gap: 0.25rem;
}

.mode-btn {
  background: rgba(255,255,255,0.08);
  color: var(--muted);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s;
}
.mode-btn.active {
  background: var(--gold);
  color: #1a1a1a;
  border-color: var(--gold);
}
.mode-btn:hover:not(.active) {
  background: rgba(255,255,255,0.15);
}

.sound-toggle {
  min-height: 34px;
  padding: 0.45rem 0.7rem;
  color: var(--gold-bright);
  background: rgba(255,255,255,0.045);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  touch-action: manipulation;
}

.sound-toggle:hover {
  background: rgba(255,255,255,0.1);
}

.level-info, .blind-display {
  font-size: 0.9rem;
  color: var(--gold);
  font-weight: 500;
}
.hand-count {
  color: var(--muted);
  font-size: 0.85rem;
  margin-left: 0.5rem;
}

/* ─── GAME TABLE ─── */
#game-table {
  width: 100%;
  max-width: 1200px;
  display: grid;
  grid-template-columns: 1fr 280px;
  grid-template-rows: auto auto auto;
  gap: 0.5rem;
  padding: 0 1.5rem 1rem;
  height: calc(100vh - 140px);
}

/* Player Areas */
.player-area {
  height: auto;
  border-radius: 8px;
  position: relative;
}
.bot-area {
  grid-column: 1;
  grid-row: 1;
  justify-self: center;
  width: 100%;
  max-width: 500px;
}
.human-area {
  grid-column: 1;
  grid-row: 3;
  justify-self: center;
  width: 100%;
  max-width: 500px;
}

.player-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: rgba(0,0,0,0.4);
  border-radius: 8px;
}
.player-avatar {
  flex-shrink: 0;
}

/* Photo Frames */
.photo-container {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: var(--card-bg);
  border: 3px solid var(--gold);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.photo-container.portrait-trigger { cursor: zoom-in; }
.photo-container.portrait-trigger:focus-visible { outline: 3px solid #f3d273; outline-offset: 3px; }
.photo-container.photo-upload-trigger { cursor: pointer; }
.photo-container.photo-upload-trigger:focus-visible { outline: 3px solid #f3d273; outline-offset: 3px; }
.photo-plus { position: absolute; z-index: 4; left: 50%; bottom: 2px; transform: translateX(-50%); display: grid; place-items: center; width: 25px; height: 25px; border: 2px solid #fff0aa; border-radius: 50%; color: #173628; background: #edcb65; box-shadow: 0 2px 7px rgba(0,0,0,.55); font-size: 1.15rem; font-weight: 900; line-height: 1; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }
.photo-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  position: relative;
  z-index: 1;
}
.clothing-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  opacity: 0.05;
  background: linear-gradient(to bottom, transparent 35%, rgba(8, 40, 24, .5));
  border-radius: 50%;
  transition: opacity 0.5s;
}
.clothing-overlay.light {
  opacity: 0.12;
}
.clothing-overlay.medium {
  opacity: 0.22;
}
.clothing-overlay.heavy {
  opacity: 0.34;
}
.clothing-overlay.nude {
  opacity: 0.48;
}
.clothing-status {
  position: absolute;
  bottom: 3px;
  font-size: 0.55rem;
  background: rgba(0,0,0,0.7);
  color: var(--gold);
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 600;
  white-space: nowrap;
  z-index: 3;
}

.player-details {
  flex: 1;
  min-width: 0;
}
.player-name {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  color: var(--gold-bright);
}
.dealer-button {
  display: none;
  width: 24px;
  height: 24px;
  margin: 0.2rem auto;
  place-items: center;
  border: 2px solid #f1e7c4;
  border-radius: 50%;
  color: #17140d;
  background: #f4d77f;
  box-shadow: 0 3px 8px rgba(0,0,0,.35);
  font-size: .68rem;
  font-weight: 950;
}
.dealer-button.show { display: grid; }
.stack-display {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
.stack-val {
  color: var(--gold);
  font-weight: 700;
}

/* Clothing Bar */
.clothing-bar-container {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
}
.clothing-bar {
  height: 100%;
  background: var(--gold);
  transition: width 0.5s ease;
  border-radius: 3px;
}

.human-area .player-info {
  flex-direction: row-reverse;
  text-align: right;
}

/* Bet Display */
.bet-area {
  text-align: center;
  padding: 0.5rem;
  font-weight: 700;
  color: var(--gold-bright);
  font-size: 0.95rem;
}
.bot-bet { grid-column: 1; justify-self: center; }
.human-bet { grid-column: 1; justify-self: center; }

.chip-stack {
  display: inline-block;
  background: rgba(0,0,0,0.5);
  padding: 4px 12px;
  border-radius: 12px;
  border: 1px solid var(--gold);
  min-width: 60px;
}

.visual-chip-stack,
.chip-stack {
  display: flex;
  min-height: 38px;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
  background: transparent;
  border: 0;
  padding: 0;
}

.chip-column {
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  filter: drop-shadow(0 5px 4px rgba(0,0,0,0.4));
  position: relative;
}

.poker-chip {
  position: relative;
  display: block;
  width: 31px;
  height: 31px;
  margin-top: -22px;
  border: 2px solid var(--chip-dark);
  border-radius: 50%;
  background:
    radial-gradient(circle at center, var(--chip-light) 0 12%, #f3e5c6 13% 20%, var(--chip) 21% 52%, transparent 53%),
    repeating-conic-gradient(from 0deg, #f5ead2 0deg 11deg, var(--chip) 11deg 42deg, #f5ead2 42deg 53deg, var(--chip) 53deg 90deg);
  box-shadow:
    inset 0 0 0 2px rgba(255,255,255,0.18),
    inset 0 -3px 5px rgba(0,0,0,0.32),
    0 2px 0 var(--chip-dark),
    0 4px 4px rgba(0,0,0,0.35);
}

.poker-chip::before {
  content: '';
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(255,255,255,0.72);
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px rgba(0,0,0,0.18);
}

.poker-chip::after {
  content: '';
  position: absolute;
  inset: 2px 4px 16px 7px;
  border-radius: 50%;
  background: rgba(255,255,255,0.28);
  filter: blur(1px);
}

.chip-value {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: #231d18;
  font-size: 6px;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 1px rgba(255,255,255,0.4);
}

.chip-count {
  position: absolute;
  left: 50%;
  bottom: -15px;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.72);
  font-size: 0.58rem;
  font-weight: 700;
  white-space: nowrap;
}

.chip-red { --chip-light: #ee6b5e; --chip: #bb332d; --chip-dark: #681712; }
.chip-blue { --chip-light: #65a8e8; --chip: #246fb4; --chip-dark: #123c68; }
.chip-green { --chip-light: #62bd86; --chip: #25865a; --chip-dark: #12492f; }
.chip-black { --chip-light: #737b84; --chip: #30353a; --chip-dark: #111417; }
.chip-white { --chip-light: #ffffff; --chip: #e8e3d7; --chip-dark: #aaa59a; }
.chip-purple { --chip-light: #bd83e6; --chip: #74439e; --chip-dark: #3d2058; }

.pot-stack {
  min-width: 36px;
  margin-right: 0.2rem;
}

/* ─── COMMUNITY AREA ─── */
.community-area {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem 1rem;
  background: var(--card-bg);
  border-radius: 16px;
  border: 2px solid rgba(212,165,116,0.15);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4), inset 0 0 40px rgba(0,0,0,0.3);
}

.pot-display {
  margin-bottom: 0.5rem;
}
.pot-chips {
  background: rgba(0,0,0,0.6);
  padding: 0.5rem 1.5rem;
  border-radius: 20px;
  border: 2px solid var(--gold);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
}
.pot-label {
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.pot-amount {
  color: var(--gold-bright);
  font-size: 1.3rem;
}
.community-cards {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}
.phase-indicator {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}
.hand-strength {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

/* ─── CARD STYLES ─── */
.card {
  width: 58px;
  height: 82px;
  border-radius: 6px;
  background: var(--card-white);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  transition: transform 0.3s, opacity 0.3s;
  user-select: none;
}
.card.red {
  color: #c0392b;
}
.card.black {
  color: #1a1a1a;
}
.card.face-down {
  background: repeating-linear-gradient(
    45deg,
    #1a5276,
    #1a5276 5px,
    #154360 5px,
    #154360 10px
  );
  color: transparent;
  border: 2px solid #2980b9;
}
.card .rank {
  font-size: 1rem;
}
.card .suit {
  font-size: 1.4rem;
  line-height: 1;
}

.hole-cards {
  display: flex;
  gap: 0.4rem;
  margin: 0.35rem 0;
  min-height: 52px;
}

.hole-cards .card {
  width: 38px;
  height: 50px;
}

.card.face-down > * {
  visibility: hidden;
}

/* Human cards are face up */
.human-hand .card {
  animation: flipIn 0.4s ease;
}

@keyframes flipIn {
  from { transform: rotateY(90deg); opacity: 0; }
  to   { transform: rotateY(0);    opacity: 1; }
}

.card.deal-card {
  animation: dealCard .42s cubic-bezier(.2,.75,.3,1) both;
}

@keyframes dealCard {
  from { opacity: 0; transform: translateY(-18px) rotateY(82deg) scale(.92); }
  to { opacity: 1; transform: translateY(0) rotateY(0) scale(1); }
}

/* ─── SIDEBAR ─── */
.sidebar {
  grid-column: 2;
  grid-row: 1 / 3;
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.05);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow: hidden;
}
.sidebar h3 {
  color: var(--gold);
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}
.hand-log {
  flex: 1;
  overflow-y: auto;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
}
.hand-log-entry {
  padding: 0.35rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}
.hand-log-entry.win {
  color: var(--green);
}
.hand-log-entry.loss {
  color: var(--red);
}

.chip-legend {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.1rem 0.5rem;
  color: rgba(255,255,255,0.58);
  font-size: 0.68rem;
}

.chip-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.legend-chip {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 1px dashed rgba(255,255,255,0.85);
  border-radius: 50%;
  background: var(--chip);
  box-shadow: inset 0 0 0 2px var(--chip-dark);
}

/* ─── CONTROLS ─── */
.controls-panel {
  width: 100%;
  max-width: 1200px;
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
}

.action-buttons {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}
.action-btn {
  padding: 0.6rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  min-width: 100px;
}
.action-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.fold-btn {
  background: var(--red);
  color: white;
}
.fold-btn:hover:not(:disabled) {
  background: #e74c3c;
}
.check-btn {
  background: var(--muted);
  color: white;
}
.check-btn:hover:not(:disabled) {
  background: #95a5a6;
}
.call-btn {
  background: var(--gold);
  color: #1a1a1a;
}
.call-btn:hover:not(:disabled) {
  background: var(--gold-bright);
}
.raise-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  background: transparent;
  padding: 0;
}
#raise-amount {
  color: var(--gold-bright);
}
#raise-slider {
  width: 140px;
  accent-color: var(--gold);
}
.raise-btn {
  background: linear-gradient(135deg, var(--gold), var(--gold-bright));
  color: #1a1a1a;
}
.raise-btn:hover {
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
}

.new-hand-btn {
  background: var(--gold);
  color: #1a1a1a;
  border: none;
  padding: 0.75rem 2rem;
  border-radius: 8px;
  font-weight: 700;
  font-size: 1.1rem;
  cursor: pointer;
  display: none;
}
.new-hand-btn.visible {
  display: block;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212,165,116,0.4); }
  50%      { box-shadow: 0 0 0 10px rgba(212,165,116,0); }
}

/* ─── GAME OVER OVERLAY within table ─── */
.game-over-banner {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
  z-index: 50;
  border-radius: 8px;
}
.game-over-banner.show {
  display: flex;
}
.game-over-banner h2 {
  font-size: 2rem;
  color: var(--gold-bright);
}
.game-over-banner button {
  padding: 0.75rem 2rem;
  background: var(--gold);
  color: #1a1a1a;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  font-size: 1.1rem;
  cursor: pointer;
}

/* Tablet / Mobile */
@media (max-width: 768px) {
  #game-table {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto;
  }
  .sidebar {
    grid-column: 1;
    grid-row: 4;
    max-height: 150px;
  }
  .title {
    font-size: 1.2rem;
  }
  .photo-container {
    width: 60px;
    height: 60px;
  }
  .action-btn {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    min-width: 70px;
  }
  #raise-slider {
    width: 100px;
  }
}

/* scrollbar */
::-webkit-scrollbar {
  width: 4px;
}
::-webkit-scrollbar-track, ::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.05);
  border-radius: 4px;
}
::--webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
}

/* ─── RESPONSIVE TABLE REDESIGN ─── */
:root {
  --panel: rgba(10, 18, 15, 0.88);
  --panel-border: rgba(240, 198, 116, 0.16);
  --felt-edge: #091d15;
}

html, body {
  height: auto;
  min-height: 100%;
}

html {
  background: #080b0a;
  color-scheme: dark;
}

body {
  align-items: flex-start;
  padding-bottom: calc(112px + env(safe-area-inset-bottom, 0px));
  background:
    radial-gradient(circle at 50% 0%, rgba(34, 94, 65, 0.26), transparent 42rem),
    linear-gradient(150deg, #080b0a 0%, #101713 50%, #070908 100%);
}

#app {
  width: 100%;
  min-height: 100vh;
}

#game-header {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.1rem 1.25rem 0.9rem;
  border-bottom: 1px solid rgba(255,255,255,0.055);
}

.title {
  font-size: clamp(1.3rem, 2.4vw, 1.85rem);
  letter-spacing: 0.075em;
}

.game-info {
  justify-content: flex-end;
}

.mode-selector {
  padding: 0.2rem;
  background: rgba(255,255,255,0.045);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 10px;
}

.mode-btn {
  min-height: 34px;
  padding: 0.45rem 0.9rem;
  border: 0;
  border-radius: 7px;
  touch-action: manipulation;
}

.level-info {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 38px;
  padding: 0.35rem 0.7rem;
  background: rgba(255,255,255,0.035);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 9px;
}

#game-table {
  width: calc(100% - 2rem);
  max-width: 1180px;
  height: auto;
  min-height: 560px;
  margin: 1rem auto 1.5rem;
  padding: 1rem;
  grid-template-columns: 235px minmax(390px, 1fr) 235px;
  grid-template-rows: minmax(390px, auto) 118px;
  gap: 1rem;
  border: 1px solid rgba(240,198,116,0.12);
  border-radius: 28px;
  background:
    radial-gradient(ellipse at center, rgba(37, 105, 69, 0.96), rgba(16, 62, 40, 0.98) 56%, var(--felt-edge) 100%);
  box-shadow:
    0 30px 80px rgba(0,0,0,0.48),
    inset 0 0 0 7px rgba(0,0,0,0.18),
    inset 0 0 80px rgba(0,0,0,0.24);
}

.player-area {
  align-self: center;
  width: 100%;
  min-width: 0;
}

.bot-area,
.human-area {
  grid-row: 1;
  max-width: none;
}

.bot-area { grid-column: 1; }
.human-area { grid-column: 3; }

.player-info,
.human-area .player-info {
  min-height: 295px;
  padding: 1rem;
  flex-direction: column;
  justify-content: center;
  gap: 0.85rem;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  box-shadow: 0 16px 34px rgba(0,0,0,0.26);
  backdrop-filter: blur(10px);
}

.player-details {
  width: 100%;
}

.photo-container {
  width: 78px;
  height: 78px;
  border-width: 2px;
  box-shadow: 0 0 0 5px rgba(212,165,116,0.08);
}

.player-name {
  margin: 0;
  font-size: 1.05rem;
}

.stack-display {
  margin: 0.5rem 0 0.65rem;
  color: rgba(255,255,255,0.68);
}

.stack-display span,
#bot-stack {
  color: var(--gold-bright);
  font-size: 1rem;
  font-weight: 800;
}

.hole-cards {
  justify-content: center;
  min-height: 66px;
  margin: 0.55rem 0;
}

.hole-cards .card {
  width: 48px;
  height: 64px;
}

.clothing-bar-container {
  height: 5px;
}

.bet-area {
  height: 0;
  padding: 0;
  overflow: hidden;
}

.community-area {
  grid-column: 2;
  grid-row: 1;
  min-height: 360px;
  padding: 2rem;
  gap: 1.35rem;
  background: rgba(5, 28, 18, 0.28);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 45%;
  box-shadow:
    inset 0 0 55px rgba(0,0,0,0.24),
    0 0 0 6px rgba(0,0,0,0.08);
}

.pot-chips {
  padding: 0.6rem 1.4rem;
  border: 1px solid rgba(240,198,116,0.72);
  background: rgba(5,10,8,0.72);
  box-shadow: 0 8px 22px rgba(0,0,0,0.24);
}

.community-cards {
  min-height: 86px;
  align-items: center;
}

.card {
  box-shadow: 0 8px 16px rgba(0,0,0,0.28);
}

.phase-indicator {
  padding: 0.3rem 0.75rem;
  color: rgba(255,255,255,0.72);
  background: rgba(0,0,0,0.22);
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.sidebar {
  grid-column: 1 / 4;
  grid-row: 2;
  min-height: 0;
  padding: 0.8rem 1rem;
  display: grid;
  grid-template-columns: 130px 1fr;
  align-items: start;
  background: rgba(6,12,9,0.62);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 14px;
}

.sidebar h3 {
  padding-top: 0.2rem;
  font-size: 0.78rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.hand-log {
  max-height: 82px;
  padding-left: 1rem;
  border-left: 1px solid rgba(255,255,255,0.07);
}

.controls-panel {
  position: fixed;
  z-index: 80;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom, 0px));
  width: min(760px, calc(100% - 24px));
  min-height: 78px;
  padding: 0.7rem 0.85rem;
  transform: translateX(-50%);
  background: rgba(8,13,11,0.93);
  border: 1px solid rgba(240,198,116,0.2);
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.58);
  backdrop-filter: blur(18px);
}

.action-buttons {
  width: 100%;
  flex-wrap: nowrap;
}

.action-btn {
  min-width: 92px;
  min-height: 46px;
  padding: 0.65rem 1.2rem;
  border-radius: 11px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.13);
  touch-action: manipulation;
}

.action-btn:hover:not(:disabled),
.new-hand-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.raise-slider-wrapper {
  flex: 1;
  min-width: 230px;
  padding: 0 0.5rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.7rem;
}

#raise-slider {
  width: 100%;
}

.raise-btn {
  min-width: 105px;
}

.new-hand-btn {
  width: min(360px, 100%);
  min-height: 48px;
  border-radius: 12px;
}

.message-box {
  width: min(440px, calc(100% - 2rem));
  padding: 1.8rem;
  border-radius: 20px;
  background: linear-gradient(145deg, #173d2a, #0b2117);
}

@media (max-width: 900px) {
  body { padding-bottom: calc(105px + env(safe-area-inset-bottom, 0px)); }

  #game-header {
    padding: 0.85rem 1rem;
  }

  #game-table {
    width: calc(100% - 1.25rem);
    max-width: 680px;
    min-height: 0;
    margin-top: 0.65rem;
    padding: 0.75rem;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto;
    gap: 0.7rem;
    border-radius: 22px;
  }

  .bot-area,
  .community-area,
  .human-area,
  .sidebar {
    grid-column: 1;
  }

  .bot-area { grid-row: 1; }
  .community-area { grid-row: 2; }
  .human-area { grid-row: 3; }
  .sidebar { grid-row: 4; }

  .player-info,
  .human-area .player-info {
    min-height: 0;
    padding: 0.75rem 0.9rem;
    flex-direction: row;
    justify-content: flex-start;
    gap: 0.9rem;
    text-align: left;
    border-radius: 14px;
  }

  .human-area .player-info {
    flex-direction: row-reverse;
    text-align: right;
  }

  .photo-container {
    width: 64px;
    height: 64px;
  }

  .player-details {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    column-gap: 0.8rem;
  }

  .player-name { grid-column: 1; }
  .hole-cards { grid-column: 2; grid-row: 1 / 3; margin: 0; min-height: 52px; }
  .stack-display { grid-column: 1; margin: 0.25rem 0 0.45rem; }
  .clothing-bar-container { grid-column: 1; }

  .hole-cards .card {
    width: 38px;
    height: 50px;
  }

  .community-area {
    min-height: 245px;
    padding: 1.25rem 0.75rem;
    gap: 1rem;
    border-radius: 28px;
  }

  .community-cards .card {
    width: 48px;
    height: 68px;
  }

  .sidebar {
    min-height: 72px;
    max-height: 118px;
    grid-template-columns: 110px 1fr;
  }
}

@media (max-width: 620px) {
  body { padding-bottom: calc(142px + env(safe-area-inset-bottom, 0px)); }

  #game-header {
    align-items: flex-start;
  }

  .game-info {
    width: 100%;
    justify-content: space-between;
    gap: 0.55rem;
  }

  .level-info {
    flex: 1;
    justify-content: center;
    font-size: 0.78rem;
  }

  #game-table {
    width: calc(100% - 0.75rem);
    padding: 0.5rem;
    border-radius: 18px;
  }

  .player-info,
  .human-area .player-info {
    padding: 0.65rem;
  }

  .photo-container {
    width: 56px;
    height: 56px;
  }

  .community-area {
    min-height: 220px;
  }

  .community-cards {
    gap: 0.3rem;
  }

  .community-cards .card {
    width: 43px;
    height: 61px;
  }

  .controls-panel {
    bottom: max(6px, env(safe-area-inset-bottom, 0px));
    width: calc(100% - 12px);
    padding: 0.55rem;
    border-radius: 15px;
  }

  .action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem;
  }

  .action-btn {
    min-width: 0;
    min-height: 42px;
  }

  .raise-slider-wrapper {
    grid-column: 1 / 3;
    min-width: 0;
    padding: 0;
  }

  .sidebar {
    display: block;
  }

  .sidebar h3 {
    margin-bottom: 0.35rem;
  }

  .hand-log {
    padding-left: 0;
    border-left: 0;
  }
}

@media (max-width: 360px) {
  .title {
    width: 100%;
    font-size: 1.18rem;
  }

  .mode-selector {
    flex: 1;
  }

  .mode-btn {
    min-width: 0;
    flex: 1;
    padding-inline: 0.55rem;
  }

  .level-info {
    width: 100%;
    flex-basis: 100%;
  }

  .player-info,
  .human-area .player-info {
    gap: 0.5rem;
  }

  .photo-container {
    width: 48px;
    height: 48px;
  }

  .player-name {
    font-size: 0.92rem;
  }

  .stack-display {
    font-size: 0.78rem;
  }

  .hole-cards {
    gap: 0.25rem;
  }

  .hole-cards .card {
    width: 34px;
    height: 46px;
  }

  .community-cards .card {
    width: 38px;
    height: 55px;
  }

  .action-btn {
    padding-inline: 0.6rem;
    font-size: 0.8rem;
  }

  .raise-slider-wrapper {
    grid-template-columns: 46px 1fr 74px;
    gap: 0.4rem;
    font-size: 0.82rem;
  }

  .raise-slider-wrapper .raise-btn {
    min-width: 0;
    width: 100%;
  }
}

@media (orientation: landscape) and (max-height: 540px) {
  body {
    padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  }

  #game-header {
    padding-block: 0.55rem;
  }

  #game-table {
    margin-block: 0.45rem 1rem;
  }

  .controls-panel {
    min-height: 66px;
    padding-block: 0.45rem;
  }

  .action-btn,
  .new-hand-btn {
    min-height: 44px;
  }
}

/* Live chip stacks sit below each player panel. */
.bet-area {
  height: 42px;
  min-height: 42px;
  padding: 0.35rem 0 0;
  overflow: visible;
}

.poker-chip {
  animation: chipDrop 180ms ease-out both;
}

.chip-column:nth-child(2) .poker-chip { animation-delay: 25ms; }
.chip-column:nth-child(3) .poker-chip { animation-delay: 50ms; }

@keyframes chipDrop {
  from { opacity: 0; transform: translateY(-8px) scale(0.92); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 620px) {
  .sound-toggle {
    min-width: 44px;
    min-height: 44px;
    padding-inline: 0.55rem;
  }

  .bet-area {
    height: 38px;
    min-height: 38px;
  }

  .poker-chip {
    width: 28px;
    height: 28px;
    margin-top: -20px;
  }

  .chip-legend {
    justify-content: flex-start;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.15rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .poker-chip { animation: none; }
  .card.deal-card { animation-duration: 1ms; animation-delay: 0s !important; }
}

.start-screen {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 1rem;
  overflow-y: auto;
  background:
    radial-gradient(circle at 50% 42%, rgba(33, 112, 74, 0.4), transparent 38%),
    linear-gradient(145deg, rgba(3, 8, 6, 0.96), rgba(8, 18, 13, 0.98));
  backdrop-filter: blur(12px);
  transition: opacity 220ms ease, visibility 220ms ease;
}

.start-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.start-card {
  width: min(540px, 100%);
  padding: clamp(1.3rem, 4vw, 2.25rem);
  border: 1px solid rgba(224, 199, 119, 0.56);
  border-radius: 26px;
  color: #f7f4e9;
  text-align: center;
  background: linear-gradient(155deg, rgba(29, 47, 38, 0.98), rgba(11, 21, 16, 0.98));
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.62), inset 0 1px rgba(255,255,255,.08);
}

.start-mark {
  display: grid;
  place-items: center;
  width: 82px;
  aspect-ratio: 1;
  margin: 0 auto 1.1rem;
  border: 3px solid #efd47f;
  border-radius: 50%;
  color: #fff4c8;
  font-size: 2.7rem;
  background: radial-gradient(circle at 35% 25%, #2f8c5f, #163f2d 62%, #07120d);
  box-shadow: 0 12px 30px rgba(0,0,0,.45), 0 0 35px rgba(91, 191, 131, .14);
}

.start-card h2 { margin: 0.35rem 0 0.55rem; font-size: clamp(1.8rem, 6vw, 2.6rem); }
.start-card .start-instructions { margin: 0 auto 1.25rem; max-width: 38ch; color: #d6e0d6; line-height: 1.5; }
.start-choices { display: grid; gap: .7rem; text-align: left; }
.start-choice {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: .2rem 1rem;
  width: 100%;
  min-height: 82px;
  padding: .95rem 1.15rem;
  border: 1px solid rgba(238, 207, 137, .48);
  border-radius: 16px;
  color: #fff8e6;
  text-align: left;
  background: linear-gradient(110deg, rgba(34, 75, 52, .96), rgba(18, 44, 31, .96));
  box-shadow: inset 0 1px rgba(255,255,255,.09), 0 8px 20px rgba(0,0,0,.15);
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}
.start-choice:last-child { background: linear-gradient(110deg, rgba(52, 55, 43, .96), rgba(31, 37, 30, .96)); }
.start-choice:hover { transform: translateY(-2px); border-color: #f2d88b; }
.start-choice:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.start-choice:disabled { cursor: wait; opacity: .72; transform: none; }
.start-choice-title { font-family: Georgia, serif; font-size: clamp(1.15rem, 3.4vw, 1.4rem); font-weight: 700; }
.start-choice-detail { grid-column: 1; color: #d4ddcf; font-size: .86rem; line-height: 1.35; }
.start-choice-arrow { grid-column: 2; grid-row: 1 / span 2; color: #f3d88b; font-size: 1.55rem; }
.start-card .start-save-note { margin: 1rem 0 0; color: #a8bbac; font-size: .78rem; line-height: 1.4; }
@media (max-width: 420px) {
  .start-mark { width: 64px; margin-bottom: .7rem; font-size: 2.2rem; }
  .start-choice { min-height: 76px; padding: .8rem .9rem; }
  .start-choice-detail { font-size: .8rem; }
}
@media (prefers-reduced-motion: reduce) {
  .start-choice { transition: none; }
}

/* Challenge opponents */
.bot-initials {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: white;
  font-size: clamp(1rem, 3vw, 1.55rem);
  font-weight: 900;
  letter-spacing: 0.06em;
  background: radial-gradient(circle at 35% 28%, color-mix(in srgb, var(--character-color) 78%, white), var(--character-color) 56%, #16191d 100%);
  text-shadow: 0 2px 5px #000;
}
.bot-initials[hidden] { display: none; }
.clothing-overlay[hidden], .clothing-status[hidden], .clothing-bar-container[hidden] { display: none; }
.photo-container img[alt="Cash game opponent emblem"] { object-fit: contain; padding: 3px; background: radial-gradient(circle, #164b32, #07150f); }

.photo-container img[src=""] { display: none; }
.bot-title { color: #c8b474; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em; }

.hand-result-inline {
  display: none;
  width: 100%;
  margin: 0.55rem 0 0;
  padding: 0.75rem;
  border: 1px solid rgba(240,198,116,.68);
  border-radius: 12px;
  color: #f0c674;
  background: linear-gradient(145deg, rgba(23,61,42,.98), rgba(8,28,18,.98));
  box-shadow: 0 10px 24px rgba(0,0,0,.3);
  text-align: center;
}

.hand-result-inline.show { display: block; animation: scaleIn 180ms ease-out; }
.community-area { position: relative; padding-bottom: 7rem; }
.community-area .hand-result-inline {
  position: absolute;
  left: 50%;
  bottom: 18px;
  z-index: 4;
  width: min(420px, calc(100% - 2rem));
  min-height: 78px;
  margin: 0;
  transform: translateX(-50%);
}

.community-area .hand-result-inline.show {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.8rem;
  animation: resultReveal 180ms ease-out;
}

.community-area .hand-result-inline p { margin: 0; }

@keyframes resultReveal {
  from { opacity: 0; transform: translate(-50%, 7px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
.hand-result-inline p { margin: 0 0 0.6rem; font-size: 0.78rem; font-weight: 700; line-height: 1.35; white-space: pre-line; }
.hand-result-inline button {
  min-height: 36px;
  padding: 0.4rem 0.85rem;
  border: 0;
  border-radius: 999px;
  color: #171208;
  background: linear-gradient(#f6dc8d, #c99d38);
  font-weight: 900;
  cursor: pointer;
}

.restart-game {
  min-height: 38px;
  padding: 0.4rem 0.75rem;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 9px;
  color: #f2e7c6;
  background: rgba(255,255,255,.055);
  font-weight: 800;
  cursor: pointer;
}

.restart-game:hover { border-color: rgba(240,198,116,.7); background: rgba(240,198,116,.1); }
.restart-game:focus-visible { outline: 2px solid #f0c674; outline-offset: 2px; }

.bot-subtitle {
  min-height: 1.5rem;
  max-width: min(92vw, 570px);
  margin: 0.4rem auto 0;
  padding: 0.38rem 0.8rem;
  border: 1px solid transparent;
  border-radius: 999px;
  color: transparent;
  text-align: center;
  font-size: 0.85rem;
  transition: 180ms ease;
}

.bot-subtitle.show {
  color: #fff8dd;
  border-color: rgba(213, 182, 103, 0.42);
  background: rgba(8, 12, 10, 0.8);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.character-picker {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  place-items: center;
  padding: clamp(0.7rem, 2vw, 1.5rem);
  background: rgba(3, 7, 6, 0.92);
  backdrop-filter: blur(12px);
}

.character-picker.show { display: grid; }

.character-picker-panel {
  width: min(1100px, 100%);
  max-height: calc(100dvh - 2rem);
  overflow: auto;
  padding: clamp(1rem, 2.5vw, 1.8rem);
  border: 1px solid rgba(213, 182, 103, 0.48);
  border-radius: 22px;
  background: linear-gradient(145deg, #17221d, #0d1411);
  box-shadow: 0 30px 80px #000;
}

.picker-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.picker-heading h2 { margin: 0.15rem 0 0; color: #fff9e8; font-size: clamp(1.5rem, 4vw, 2.35rem); }
.eyebrow { color: #d8bd72; font-size: 0.82rem; font-weight: 900; letter-spacing: 0.16em; text-transform: uppercase; }
.character-picker-panel > p { margin: 0.65rem 0 1.25rem; color: #d0d8d3; font-size: 1.02rem; line-height: 1.45; }
.picker-close, .preview-voice, .configure-voice, .choose-character { min-height: 42px; border-radius: 999px; padding: 0.55rem 0.75rem; font-weight: 800; cursor: pointer; }
.picker-close, .preview-voice, .configure-voice { border: 1px solid #758078; color: #edf3ef; background: transparent; }
.choose-character { border: 1px solid #e0c777; color: #17130a; background: linear-gradient(#f6dc8d, #c99d38); }

.character-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.8rem; }
.character-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 0.65rem;
  padding: 1rem;
  border: 1px solid color-mix(in srgb, var(--character-color) 45%, #38433d);
  border-radius: 16px;
  background: linear-gradient(155deg, color-mix(in srgb, var(--character-color) 13%, #18221d), #101713 65%);
  position: relative;
  overflow: hidden;
  isolation: isolate;
  transition: transform 220ms ease, border-color 220ms ease, box-shadow 220ms ease, filter 220ms ease;
}
.character-card::after {
  content: '';
  position: absolute;
  z-index: 0;
  inset: -70% -35%;
  opacity: 0;
  transform: translateX(-65%) rotate(18deg);
  background: linear-gradient(90deg, transparent 38%, rgba(255,255,255,.13) 50%, transparent 62%);
  transition: opacity 180ms ease, transform 520ms cubic-bezier(.2,.75,.2,1);
  pointer-events: none;
}
.character-card > * { position: relative; z-index: 1; }
.character-card.completed { box-shadow: inset 0 0 0 1px rgba(111,214,145,.45); }
.completed-badge { position: absolute; top: .7rem; right: .7rem; padding: .22rem .45rem; border-radius: 999px; color: #bdf0ca; background: rgba(25,104,55,.72); font-size: .65rem; font-weight: 900; }

.character-medallion {
  display: grid;
  place-items: center;
  width: 58px;
  aspect-ratio: 1;
  border: 3px solid color-mix(in srgb, var(--character-color) 70%, white);
  border-radius: 50%;
  color: white;
  background: radial-gradient(circle at 35% 25%, color-mix(in srgb, var(--character-color) 80%, white), var(--character-color) 60%, #171b19);
  box-shadow: 0 7px 18px rgba(0,0,0,.35);
  font-weight: 900;
  overflow: hidden;
  padding: 0;
  cursor: zoom-in;
}

.character-medallion img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 300ms cubic-bezier(.2,.75,.2,1), filter 220ms ease; }
.character-medallion span { display: none; }

.character-copy { flex: 1; }
.character-copy h3 { margin: 0; color: #fff; font-size: 1.18rem; line-height: 1.2; }
.character-copy strong { color: var(--character-color); font-size: 0.92rem; }
.character-copy p { margin: 0.45rem 0 0; color: #d0d8d3; font-size: 0.94rem; line-height: 1.42; }
.opponent-progress { margin-top: .55rem; color: #f0d77f; font-size: .82rem; font-weight: 800; line-height: 1.35; }
.character-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.45rem; }

@media (hover: hover) and (pointer: fine) {
  .character-card:hover {
    z-index: 2;
    transform: translateY(-6px) scale(1.012);
    border-color: color-mix(in srgb, var(--character-color) 76%, #f8dda0);
    box-shadow: 0 16px 34px rgba(0,0,0,.4), inset 0 0 22px color-mix(in srgb, var(--character-color) 11%, transparent);
    filter: brightness(1.04);
  }
  .character-card:hover::after { opacity: 1; transform: translateX(65%) rotate(18deg); }
  .character-card:hover .character-medallion img { transform: scale(1.09); filter: saturate(1.08) contrast(1.03); }
}

@media (min-width: 901px) {
  .character-picker { padding: clamp(.5rem, 1.4vh, 1rem); }
  .character-picker-panel {
    width: min(1180px, 98vw);
    height: min(820px, calc(100dvh - clamp(1rem, 2.8vh, 2rem)));
    max-height: none;
    padding: clamp(.75rem, 1.8vh, 1.25rem);
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    overflow: hidden;
  }
  .character-picker-panel > p { margin: clamp(.3rem, 1vh, .65rem) 0 clamp(.55rem, 1.5vh, 1rem); }
  .character-grid { min-height: 0; grid-template-rows: repeat(2, minmax(0, 1fr)); gap: clamp(.45rem, 1.1vh, .8rem); }
  .character-card { gap: clamp(.3rem, .8vh, .6rem); padding: clamp(.6rem, 1.2vh, .9rem); }
  .character-medallion { width: clamp(48px, 7vh, 62px); }
  .character-copy h3 { font-size: clamp(1.08rem, 2.15vh, 1.24rem); }
  .character-copy strong { font-size: clamp(.86rem, 1.65vh, .98rem); }
  .character-copy p { margin-top: clamp(.22rem, .55vh, .4rem); font-size: clamp(.86rem, 1.62vh, .96rem); line-height: 1.34; }
  .opponent-progress { margin-top: clamp(.25rem, .62vh, .45rem); font-size: clamp(.76rem, 1.42vh, .86rem); }
  .character-actions { justify-content: end; grid-template-columns: repeat(2, minmax(82px, 106px)); }
  .character-actions button { min-height: 32px; padding: .22rem .5rem; font-size: .78rem; }
}

.portrait-viewer {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: none;
  place-items: center;
  padding: 1rem;
  background: rgba(2, 6, 4, .92);
  backdrop-filter: blur(12px);
}
.portrait-viewer.show { display: grid; }
.portrait-viewer-panel { position: relative; width: min(620px, 96vw); border: 1px solid rgba(224,199,119,.62); border-radius: 22px; overflow: hidden; background: #0b1510; box-shadow: 0 30px 90px #000; }
.portrait-viewer-panel > img { display: block; width: 100%; max-height: min(72vh, 650px); aspect-ratio: 1; object-fit: cover; background: #101a15; }
.portrait-close { position: absolute; top: .65rem; right: .65rem; z-index: 1; width: 44px; height: 44px; border: 1px solid rgba(255,255,255,.65); border-radius: 50%; color: #fff; background: rgba(3,8,5,.78); font-size: 1.8rem; cursor: pointer; }
.portrait-viewer-footer { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: .8rem; padding: .8rem 1rem 1rem; text-align: center; }
.portrait-viewer-footer h2 { margin: 0; color: #fff8e4; font-size: 1.2rem; }
.portrait-viewer-footer span { color: #cdbd88; font-size: .75rem; font-weight: 800; }
.portrait-viewer-footer button { width: 44px; height: 44px; border: 1px solid #8d825f; border-radius: 50%; color: #fff; background: #17231d; font-size: 1.7rem; cursor: pointer; }
.portrait-viewer-footer .portrait-upload { display: inline-flex; width: auto; height: 36px; align-items: center; justify-content: center; margin-top: .55rem; padding: 0 .9rem; border-radius: 999px; color: #171208; background: linear-gradient(#f6dc8d,#c99d38); font-size: .78rem; font-weight: 900; }
.portrait-viewer-footer .portrait-upload[hidden] { display: none; }

.voice-picker {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: none;
  place-items: center;
  padding: 1rem;
  background: rgba(3,7,6,.88);
  backdrop-filter: blur(10px);
}
.voice-picker.show { display: grid; }
.voice-picker-panel { width: min(520px, 100%); padding: 1.5rem; border: 1px solid rgba(224,199,119,.58); border-radius: 20px; background: linear-gradient(145deg,#172b21,#0b1711); box-shadow: 0 25px 70px #000; }
.voice-picker-panel h2 { margin: .3rem 0 .5rem; }
.voice-picker-panel p { margin-bottom: 1rem; color: #bac5be; line-height: 1.45; }
.voice-picker-panel label { display: block; margin-bottom: .35rem; color: #efd47f; font-weight: 800; }
.voice-picker-panel select { width: 100%; min-height: 48px; padding: .65rem; border: 1px solid #728078; border-radius: 10px; color: #fff; background: #0c1712; }
.voice-picker-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: .55rem; margin-top: 1rem; }
.voice-picker-actions button { min-height: 42px; padding: .55rem .9rem; border-radius: 999px; border: 1px solid #768179; color: #fff; background: transparent; font-weight: 800; cursor: pointer; }
#voice-save { color: #171208; border-color: #efd47f; background: linear-gradient(#f6dc8d,#c99d38); }

@media (max-width: 900px) {
  .character-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .character-card, .character-card::after, .character-medallion img { transition: none; }
  .character-card:hover { transform: none; }
}

@media (max-width: 560px) {
  .character-picker { padding: 0; align-items: stretch; }
  .character-picker-panel { max-height: 100dvh; border-radius: 0; padding: 1rem; }
  .picker-heading { align-items: flex-start; }
  .picker-close { padding-inline: 0.7rem; }
  .character-grid { grid-template-columns: 1fr; }
  .character-card { display: grid; grid-template-columns: 58px 1fr; }
  .character-actions { grid-column: 1 / -1; }
  .bot-title { font-size: 0.7rem; }
  .portrait-viewer { padding: .4rem; }
  .portrait-viewer-panel { width: 100%; border-radius: 16px; }
}

/* Fluid sizing and authentic playing-card presentation. */
html { min-width: 280px; min-height: 100%; }
body { min-height: 100dvh; overflow-x: hidden; }

@media (min-width: 901px) {
  body {
    display: block;
    width: 100%;
    min-height: 100vh;
    min-height: 100svh;
    padding-bottom: 0;
  }

  #app {
    width: 100%;
    min-height: 100vh;
    min-height: 100svh;
  }

  #game-table {
    width: min(1180px, calc(100vw - clamp(1rem, 3vw, 3rem)));
    grid-template-columns:
      clamp(190px, 21vw, 235px)
      minmax(0, 1fr)
      clamp(190px, 21vw, 235px);
    padding: clamp(0.7rem, 1.5vw, 1rem);
    gap: clamp(0.55rem, 1.4vw, 1rem);
  }

  .community-area { padding: clamp(1rem, 2vw, 2rem); }

  .controls-panel {
    position: relative;
    left: auto;
    bottom: auto;
    transform: none;
    margin: -0.65rem auto 1.25rem;
  }
}

.card {
  position: relative;
  width: clamp(44px, 5vw, 58px);
  aspect-ratio: 0.707;
  height: auto;
  overflow: hidden;
  border: 1px solid rgba(30, 30, 30, 0.26);
  border-radius: clamp(5px, 0.7vw, 8px);
  box-shadow: 0 7px 15px rgba(0,0,0,.34), inset 0 0 0 1px rgba(255,255,255,.72);
}

.card-rank {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(1rem, 2.3vw, 1.35rem);
  font-weight: 800;
  line-height: 1;
}

.card.black { color: #151515; }

.card-suit {
  font-size: clamp(1.25rem, 3vw, 1.8rem);
  line-height: 1;
}

.card.card-back,
.card.face-down {
  border: 3px solid #f6f0df;
  background:
    repeating-conic-gradient(from 45deg, rgba(255,255,255,.26) 0 10deg, transparent 10deg 20deg) 50% / 12px 12px,
    repeating-linear-gradient(45deg, #153c85 0 4px, #d5dfef 4px 5px, #2459a7 5px 9px, #d5dfef 9px 10px);
  color: transparent;
  box-shadow:
    0 7px 15px rgba(0,0,0,.42),
    inset 0 0 0 2px #183d78,
    inset 0 0 0 4px rgba(255,255,255,.72),
    inset 0 0 0 6px #183d78;
}

.card.card-back::before,
.card.face-down::before {
  content: '';
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(255,255,255,.9);
  border-radius: 3px;
  background:
    radial-gradient(circle, rgba(255,255,255,.65) 0 1px, transparent 1.5px) 0 0 / 6px 6px,
    rgba(15, 55, 126, .65);
  box-shadow: 0 0 0 2px rgba(8,38,92,.8);
}

.card.card-back::after,
.card.face-down::after {
  content: '♠';
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  width: 44%;
  aspect-ratio: 1;
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 50%;
  color: #eef3fb;
  font-size: clamp(0.8rem, 1.7vw, 1.15rem);
  background: #173e82;
  text-shadow: 0 1px 2px #061a38;
}

.card.card-slot {
  border: 1px dashed rgba(255,255,255,.23);
  background: rgba(0,0,0,.12);
  box-shadow: inset 0 0 14px rgba(0,0,0,.15);
}

.hole-cards .card {
  width: clamp(38px, 4.2vw, 48px);
  aspect-ratio: 0.74;
  height: auto;
}

@media (max-width: 900px) {
  #game-table { width: min(680px, calc(100vw - 1rem)); }
  .community-cards .card { width: clamp(42px, 8vw, 52px); height: auto; }
  .hole-cards .card { width: clamp(37px, 6.5vw, 44px); height: auto; }
  .hand-result-inline { margin-top: 0.65rem; }
}

@media (max-width: 480px) {
  #game-header { padding-inline: max(0.55rem, env(safe-area-inset-left)); }
  #game-table { width: calc(100vw - 0.5rem); margin-inline: auto; }
  .community-area { padding-inline: 0.4rem; }
  .community-cards { flex-wrap: nowrap; gap: clamp(0.16rem, 1vw, 0.3rem); }
  .community-cards .card { width: clamp(36px, 11.4vw, 45px); height: auto; }
  .hole-cards .card { width: clamp(34px, 10vw, 40px); height: auto; }
  .card-rank { font-size: clamp(0.86rem, 4.2vw, 1.05rem); }
  .card-suit { font-size: clamp(1.05rem, 5.2vw, 1.35rem); }
  .card.card-back::before, .card.face-down::before { inset: 6px; }
  .restart-game { min-width: 44px; min-height: 44px; padding-inline: 0.55rem; }
  .community-area { padding-bottom: 6.5rem; }
  .community-area .hand-result-inline {
    bottom: 10px;
    width: calc(100% - 0.8rem);
    min-height: 74px;
    padding: 0.55rem 0.65rem;
    gap: 0.55rem;
  }
  .community-area .hand-result-inline p { font-size: 0.72rem; }
  .community-area .hand-result-inline button { padding-inline: 0.65rem; }
}

@media (orientation: landscape) and (max-height: 600px) {
  #game-table { min-height: 0; }
  .community-area { min-height: 190px; gap: 0.55rem; padding-block: 0.7rem; }
  .sidebar { display: none; }
}
