/* ------------------------------------------------------------------ */
/* Reset & base                                                         */
/* ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Defeat Chrome autofill yellow background + dark-text override */
input:-webkit-autofill,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: #ffffff;
  -webkit-box-shadow: 0 0 0 100px #1e0a3c inset;
  transition: background-color 5000s ease-in-out 0s;
  caret-color: #ffffff;
}

body {
  font-family: var(--font);
  background: var(--table-felt);
  color: #fff;
  height: 100dvh;
  overflow: hidden;
  user-select: none;
  color-scheme: dark;
}

#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
  height: 100dvh;
  padding: 6px 8px 96px;
  gap: 0;
}

.player-area.top    { margin-bottom: 4px; }
.player-area.bottom { margin-top: 4px; }

/* ------------------------------------------------------------------ */
/* Cards                                                               */
/* ------------------------------------------------------------------ */
.card {
  width: var(--card-width);
  height: var(--card-height);
  border-radius: var(--card-radius);
  border: 1.5px solid var(--card-border);
  background: var(--card-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  position: relative;
  /* Settle-back transition (lift-in override comes from :hover rule) */
  transition: transform 0.14s ease, box-shadow 0.18s ease;
  flex-shrink: 0;
}

.card .rank {
  position: absolute;
  top: 5px;
  left: 7px;
  font-size: var(--card-rank-size);
  line-height: 1;
}
.card .suit { font-size: var(--card-suit-size); line-height: 1; }

.card.red   { color: var(--suit-red); }
.card.black { color: var(--suit-black); }

/* Card back — striped pattern over the back color */
.card.back {
  background:
    repeating-linear-gradient(
      var(--card-back-stripe-angle),
      var(--card-back-stripe) 0px,
      var(--card-back-stripe) var(--card-back-stripe-width),
      transparent var(--card-back-stripe-width),
      transparent calc(var(--card-back-stripe-width) * 2)
    ),
    var(--card-back-color);
  border-color: color-mix(in srgb, var(--card-back-color) 60%, black);
}

/* Playable card pulse — lives on ::after so the card element has no animation.
   This keeps hover box-shadow free for smooth transitions without fighting the
   animation restart that caused the settle-back flicker. */
@keyframes card-pulse {
  0%, 100% { box-shadow: 0 0 0 0   rgba(245, 200, 66, 0);    }
  45%       { box-shadow: 0 0 0 4px rgba(245, 200, 66, 0.55),
                          0 0 18px  rgba(245, 200, 66, 0.22); }
}

.card.playable { cursor: pointer; }

.card.playable::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--card-radius);
  pointer-events: none;
  animation: card-pulse 2.2s ease-in-out infinite;
}

/* Stagger the pulse wave across hand positions */
.hand .card.playable:nth-child(2)::after { animation-delay: 0.22s; }
.hand .card.playable:nth-child(3)::after { animation-delay: 0.44s; }
.hand .card.playable:nth-child(4)::after { animation-delay: 0.66s; }
.hand .card.playable:nth-child(5)::after { animation-delay: 0.88s; }

/* Fast lift-in, smooth settle-out (asymmetric via overriding transition on hover) */
.card.playable:hover {
  transform: translateY(var(--card-hover-lift));
  box-shadow: 0 12px 28px rgba(0,0,0,0.5);
  z-index: 10;
  transition: transform 0.08s ease-out, box-shadow 0.08s ease-out;
}
.card.playable:hover::after { animation: none; }

.card.playable:active {
  transform: translateY(calc(var(--card-hover-lift) * 0.6));
  z-index: 10;
  transition: transform 0.06s ease-out;
}

/* Discard mode */
.card.discardable {
  cursor: pointer;
  outline: 2px dashed #e74c3c;
}
.card.discardable:hover {
  transform: translateY(var(--card-hover-lift));
  box-shadow: 0 12px 28px rgba(0,0,0,0.5);
  z-index: 10;
  transition: transform 0.08s ease-out, box-shadow 0.08s ease-out;
}

/* Cards played in trick slots */
.trick-slot .card {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* ------------------------------------------------------------------ */
/* Player areas                                                        */
/* ------------------------------------------------------------------ */
.player-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.player-label {
  font-size: var(--label-font-size);
  font-weight: 600;
  color: var(--label-text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--label-bg);
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

/* Turn the caller pill into a flex column so ::after sits INSIDE the
   background rather than floating below it as a bare block child */
.player-label.caller {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}
.player-label.caller::after {
  content: 'ordered';
  font-size: 8px;
  text-transform: none;
  letter-spacing: 0.07em;
  color: #f5c842;
  font-weight: 600;
  opacity: 0.88;
}

.dealer-chip {
  font-family: var(--font);
  font-size: 16px;
  background: #f5c842;
  color: #1a1135;
  padding: 4px 11px;
  border-radius: 2px;
  letter-spacing: 0.08em;
  box-shadow: 0 0 10px rgba(245,200,66,0.7), 0 0 4px rgba(245,200,66,0.4);
}

/* ------------------------------------------------------------------ */
/* Hands                                                               */
/* ------------------------------------------------------------------ */
.hand {
  display: flex;
  align-items: center;
}

.hand.face-up   { flex-direction: row; }
.hand.face-down { flex-direction: row; }
.hand.vertical  { flex-direction: column; }

/* Overlap cards horizontally for top/bottom hands */
.hand.face-up .card,
.hand.face-down .card {
  margin-left: -24px;
}
.hand.face-up .card:first-child,
.hand.face-down .card:first-child {
  margin-left: 0;
}

/* Overlap cards vertically for side hands */
.hand.vertical .card {
  margin-top: -82px;
}
.hand.vertical .card:first-child {
  margin-top: 0;
}

/* ------------------------------------------------------------------ */
/* Table center                                                        */
/* ------------------------------------------------------------------ */
.middle-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 20px;
  max-height: min(440px, 52vh);
  width: 100%;
  justify-content: center;
}

/* Pin side opponents to the top of the middle row and offset them down to
   roughly where their played card appears (left/right trick slots are
   vertically centered in the trick area).
   Fixed equal widths (card-width) ensure table-center stays viewport-centered
   regardless of player name length. min-width:0 suppresses the default
   min-content floor so white-space:nowrap labels can't widen the column. */
.middle-row .player-area {
  align-self: flex-start;
  margin-top: 50px;
  flex: 0 0 var(--card-width);
  min-width: 0;
}

.table-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-width: 360px;
}

/* ------------------------------------------------------------------ */
/* Combined scoreboard                                                  */
/* ------------------------------------------------------------------ */
#scoreboard {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

/* When inside the action panel, strip its standalone box styling */
#action-panel #scoreboard {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
}

/* Separator line between bid prompt and scoreboard */
#action-panel.has-prompt #scoreboard {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 10px;
}


.score-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--score-text);
  border-left: 2px solid transparent;
  padding-left: 6px;
  margin-left: -8px;
}

.score-team {
  font-size: 16px;
  opacity: 0.75;
  letter-spacing: 0.1em;
  width: 60px;
}

.score-pts {
  font-size: 26px;
  color: #f5c842;
  text-shadow: 0 0 8px rgba(245,200,66,0.5);
  min-width: 28px;
  text-align: right;
}

.score-sep {
  font-size: 14px;
  opacity: 0.55;
}

.avatar-pips {
  display: flex;
  gap: 5px;
  align-items: center;
  justify-content: center;
}

.pip {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1.5px solid rgba(245, 200, 66, 0.35);
  flex-shrink: 0;
  transition: background 0.18s, border-color 0.18s, box-shadow 0.18s;
}

.avatar-pips.team-them .pip {
  border-color: rgba(245, 200, 66, 0.35);
}

.pip.filled {
  background: #f5c842;
  border-color: #f5c842;
  box-shadow: 0 0 5px rgba(245, 200, 66, 0.55);
}

.avatar-pips.team-them .pip.filled {
  background: #f5c842;
  border-color: #f5c842;
  box-shadow: 0 0 5px rgba(245, 200, 66, 0.55);
}

/* Score pips — hidden by default, shown on mobile instead of numbers */
.score-pips {
  display: none;
  gap: 4px;
  align-items: center;
  flex-shrink: 0;
}
.score-pip {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1.5px solid rgba(245, 200, 66, 0.28);
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.score-pip.filled {
  background: #f5c842;
  border-color: #f5c842;
  box-shadow: 0 0 4px rgba(245, 200, 66, 0.55);
}

/* Highlights the row of the team that called trump */
.score-row.calling {
  border-left-color: #f5c842;
}
.score-row.calling .score-pts {
  text-shadow: 0 0 14px rgba(245,200,66,0.8);
}

#trick-area {
  position: relative;
  width: 310px;
  height: 310px;
}

.trick-slot {
  position: absolute;
  width: 95px;
  height: 133px;
}

.trick-slot.top    { top: 0;    left: 50%; transform: translateX(-50%); }
.trick-slot.bottom { bottom: 0; left: 50%; transform: translateX(-50%); }
.trick-slot.left   { left: 0;   top: 50%;  transform: translateY(-50%); }
.trick-slot.right  { right: 0;  top: 50%;  transform: translateY(-50%); }

#trump-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 19px;
  font-weight: 700;
  color: var(--trump-text);
  background: var(--trump-bg);
  padding: 8px 20px;
  border-radius: 2px;
  border: 1px solid rgba(245, 200, 66, 0.35);
  text-shadow: 0 0 8px rgba(245, 200, 66, 0.6);
  /* visibility toggled in JS — always reserves its height */
  visibility: hidden;
}

.trump-caller {
  font-size: 14px;
  opacity: 0.7;
  color: #f5c842;
  letter-spacing: 0.1em;
  text-shadow: none;
}

/* "PREV" button sits below the trump indicator inside .table-center */
#last-trick-btn {
  display: none;
  font-size: 16px;
  padding: 6px 14px;
  background: rgba(0, 0, 0, 0.35);
  color: rgba(232, 213, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 2px;
  letter-spacing: 0.06em;
}
#last-trick-btn:hover { color: #e8d5ff; }

/* Last-trick recall panel */
#last-trick-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -55%);
  z-index: 90;
  background: rgba(18, 8, 40, 0.97);
  border: 1px solid rgba(245, 200, 66, 0.35);
  border-radius: 4px;
  padding: 20px 26px;
  cursor: pointer;
  pointer-events: all;
}

#last-trick-title {
  font-size: 16px;
  color: #f5c842;
  text-align: center;
  margin-bottom: 14px;
  letter-spacing: 0.1em;
}

.lt-grid {
  display: grid;
  grid-template-areas:
    ". top ."
    "left mid right"
    ". bot .";
  grid-template-columns: auto 22px auto;
  grid-template-rows: auto auto auto;
  gap: 8px;
  align-items: center;
  justify-items: center;
}
.lt-slot          { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.lt-slot.lt-top   { grid-area: top; }
.lt-slot.lt-left  { grid-area: left; }
.lt-slot.lt-right { grid-area: right; }
.lt-slot.lt-bot   { grid-area: bot; }

/* Scale cards down inside the panel */
#last-trick-panel .card       { width: 58px; height: 84px; }
#last-trick-panel .card .rank { font-size: 13px; top: 3px; left: 5px; }
#last-trick-panel .card .suit { font-size: 20px; }

.lt-label {
  font-size: 13px;
  opacity: 0.55;
  color: #e8d5ff;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.lt-slot.lt-winner .card {
  outline: 2px solid #f5c842;
  box-shadow: 0 0 10px rgba(245, 200, 66, 0.45);
}

/* Upcard floats in the center of the trick area — no layout impact */
#upcard-area {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}
#upcard-area .label { font-size: 16px; opacity: 0.7; text-transform: uppercase; letter-spacing: 0.1em; }

/* ------------------------------------------------------------------ */
/* Play prompt — now lives in table-center above the trump indicator  */
/* ------------------------------------------------------------------ */
#play-prompt {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--panel-text);
  opacity: 0.75;
  letter-spacing: 0.07em;
  visibility: hidden;
  height: 18px;
}

#play-prompt.active { visibility: visible; }

/* ------------------------------------------------------------------ */
/* Trick display — below the hand, always visible                     */
/* ------------------------------------------------------------------ */
#trick-display {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
}

.trick-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  opacity: 0.65;
  min-width: 30px;
  text-align: center;
}

.trick-label.us   { color: #f5c842; }
.trick-label.them { color: #f5c842; }

.trick-display-sep {
  width: 1px;
  height: 12px;
  background: rgba(255, 255, 255, 0.15);
  margin: 0 2px;
  flex-shrink: 0;
}

/* ------------------------------------------------------------------ */
/* Action panel — anchored to bottom, slides over the player hand.    */
/* Never reaches the trick area or opponent hands.                    */
/* ------------------------------------------------------------------ */
#action-panel {
  position: fixed;
  bottom: 8px;
  left: calc(50% - 220px);  /* calc instead of transform so position:fixed children
                                are viewport-relative, not panel-relative */
  z-index: 50;

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 13px;
  padding: 14px 32px 16px;
  width: 440px;

  background: rgba(18, 8, 40, 0.97);
  color: var(--panel-text);
  font-size: var(--panel-font-size);

  border-radius: 4px;
  border: 1px solid rgba(245, 200, 66, 0.25);
  backdrop-filter: blur(6px);
}

/* Bid prompt active — panel rises above the hand */
#action-panel.has-prompt {
  bottom: 190px;
  padding: 24px 44px 28px;
  gap: 18px;
}

/* Hide scoreboard during bidding — panel needs to clear the upcard */
#action-panel.has-prompt #scoreboard {
  display: none;
}

/* ── Desktop: compact inline score — same style as mobile, centered below player area */
@media (min-width: 501px) {
  #action-panel #scoreboard {
    flex-direction: row;
    gap: 0;
    width: auto;
    align-items: center;
    visibility: visible;  /* overrides parent visibility:hidden when no prompt */
  }
  #action-panel #scoreboard .score-sep  { display: none; }
  #action-panel #scoreboard .score-team { font-size: 10px; width: 30px; opacity: 0.65; letter-spacing: 0.06em; }
  #action-panel #scoreboard .score-pts  { font-size: 20px; min-width: auto; }
  #action-panel #scoreboard .score-row  { gap: 6px; padding-left: 0; margin-left: 0; border-left-width: 0; }
  #action-panel #scoreboard .score-row:first-child {
    padding-right: 14px;
    border-right: 1px solid rgba(255, 255, 255, 0.12);
    margin-right: 14px;
  }
  .avatar-pips .pip { width: 7px; height: 7px; }
  /* Hide the panel shell when there is no bid prompt — scoreboard stays visible */
  #action-panel:not(.has-prompt) { visibility: hidden; }
}

#bid-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: 100%;
}

/* Mini hand shown inside the bid panel */
.bid-hand {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
}
.bid-hand .card {
  width: 54px;
  height: 78px;
  margin-left: -16px;
  pointer-events: none;
  /* override global card transition — these are display-only */
  transition: none;
  animation: none !important;
}
.bid-hand .card:first-child { margin-left: 0; }
.bid-hand .card .rank { font-size: 12px; top: 3px; left: 4px; }
.bid-hand .card .suit { font-size: 19px; }
.dealer-note {
  font-size: 13px;
  color: #f5c842;
  opacity: 0.85;
  letter-spacing: 0.04em;
  text-align: center;
}

/* Gold glow on cards that would become trump if ordered up */
.bid-hand .card.bid-trump {
  outline: 2px solid rgba(245, 200, 66, 0.75);
  box-shadow: 0 0 10px rgba(245, 200, 66, 0.35);
}

#action-panel .prompt { font-weight: 600; line-height: 2; text-align: center; }
.dealer-tag { background: #f5c842; color: #1a1135; padding: 2px 6px; border-radius: 2px; font-size: 14px; vertical-align: middle; margin-right: 4px; }

#action-panel .btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

button {
  padding: 13px 26px;
  border: none;
  border-radius: var(--btn-radius);
  font-family: var(--font);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.1s, box-shadow 0.1s;
  letter-spacing: 0.05em;
}
button:hover  { opacity: 0.88; transform: scale(1.03); }
button:active { transform: scale(0.97); }

.btn-primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  box-shadow: 0 0 12px rgba(245, 200, 66, 0.45);
}
.btn-primary:hover { box-shadow: 0 0 20px rgba(245, 200, 66, 0.7); }

.btn-danger  { background: var(--btn-danger-bg);  color: var(--btn-danger-text); }
.btn-neutral {
  background: var(--btn-neutral-bg);
  color: var(--btn-neutral-text);
  border: 1px solid rgba(255,255,255,0.15);
}
.btn-suit {
  background: var(--btn-neutral-bg);
  color: var(--btn-neutral-text);
  font-size: 18px;
  min-width: 110px;
  border: 1px solid rgba(255,255,255,0.15);
}
.btn-suit.red-suit { color: var(--suit-red); }

.btn-alone {
  background: linear-gradient(135deg, #3d1f6e, #6b3fa0);
  color: #f5c842;
  border: 1px solid rgba(245, 200, 66, 0.4);
  box-shadow: 0 0 8px rgba(245, 200, 66, 0.2);
}
.btn-alone.active {
  background: #f5c842;
  color: #1a1135;
  box-shadow: 0 0 16px rgba(245, 200, 66, 0.7);
}

/* ------------------------------------------------------------------ */
/* Overlay                                                             */
/* ------------------------------------------------------------------ */
#overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 250;
}

#overlay-box {
  background: var(--overlay-bg);
  border: 2px solid var(--overlay-border);
  border-radius: var(--overlay-radius);
  padding: 44px 56px;
  text-align: center;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#overlay-title { font-size: 22px; font-weight: 800; color: #f5c842; text-shadow: 0 0 12px rgba(245,200,66,0.5); }
#overlay-body  { font-size: 18px; opacity: 0.85; line-height: 2.2; }
#overlay-btns  { display: flex; gap: 10px; justify-content: center; margin-top: 8px; flex-wrap: wrap; }

.hist-sep {
  margin: 10px 0 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}
.round-history {
  max-height: 108px;
  overflow-y: auto;
  text-align: left;
  font-size: 14px;
  opacity: 0.80;
  line-height: 2;
}
.round-history.full { max-height: 210px; }
.hist-row { white-space: nowrap; }

/* ------------------------------------------------------------------ */
/* Start screen                                                        */
/* ------------------------------------------------------------------ */
#start-screen {
  position: fixed;
  inset: 0;
  background: var(--table-felt);
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 200;
  overflow-y: auto;
  padding: 20px;
}

#start-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  width: 100%;
  max-width: 620px;
  margin: auto;
}

#logo {
  width: 400px;
  height: 400px;
  object-fit: contain;
  filter: drop-shadow(0 4px 16px rgba(0,0,0,0.35));
  transform: translateX(-10px);
}

/* ── Start-screen footer (Privacy · Terms) ──────────────────────── */
#start-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 4px 0 8px;
  opacity: 0.55;
}
#start-footer:hover { opacity: 0.80; }
.start-footer-sep { color: rgba(232,213,255,0.6); font-size: 11px; }
.btn-link {
  background: none;
  border: none;
  color: rgba(232,213,255,0.9);
  font-family: inherit;
  font-size: 10px;
  cursor: pointer;
  padding: 2px 4px;
  letter-spacing: 0.05em;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(232,213,255,0.35);
}
.btn-link:hover { color: #f5c842; text-decoration-color: rgba(245,200,66,0.5); }

/* ── Auth age / recovery notes ───────────────────────────────────── */
#auth-age-note,
#auth-recovery-note {
  font-size: 9px;
  color: rgba(232,213,255,0.40);
  text-align: center;
  margin-top: 4px;
  letter-spacing: 0.04em;
}

/* ── Danger button ───────────────────────────────────────────────── */
.btn-danger {
  background: transparent;
  border: 1px solid rgba(220, 60, 60, 0.45);
  color: rgba(220, 100, 100, 0.75);
  font-family: inherit;
  font-size: 11px;
  padding: 7px 16px;
  cursor: pointer;
  border-radius: 3px;
  letter-spacing: 0.06em;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  width: 100%;
  margin-top: 6px;
}
.btn-danger:hover {
  background: rgba(200, 40, 40, 0.18);
  border-color: rgba(220, 60, 60, 0.80);
  color: #ff7c7c;
}

/* ── Legal modal content (inside shared overlay) ─────────────────── */
.legal-text {
  font-size: 12px;
  line-height: 1.8;
  color: rgba(232,213,255,0.85);
  text-align: left;
}
.legal-text h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #f5c842;
  margin: 14px 0 4px;
}
.legal-text h3:first-of-type { margin-top: 10px; }
.legal-text p  { margin: 0 0 6px; }
.legal-text ul { margin: 0 0 6px; padding-left: 18px; }
.legal-text li { margin-bottom: 4px; }
.legal-text strong { color: #e8d5ff; }
.legal-updated {
  font-size: 10px;
  color: rgba(232,213,255,0.40);
  margin-bottom: 8px !important;
}

/* ── Name row (avatar preview + nickname input) ──────────────────── */
.name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

#avatar-preview {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  border-radius: 4px;
  border: 2px solid rgba(245,200,66,0.5);
  background: rgba(255,255,255,0.08);
  background-size: cover;
  background-position: center;
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s, opacity 0.12s;
}
#avatar-preview:hover {
  border-color: #f5c842;
  box-shadow: 0 0 10px rgba(245,200,66,0.5);
  opacity: 0.88;
}

.name-row #nickname-input { flex: 1; }

.avatar-opt {
  width: 64px;
  height: 64px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
  cursor: pointer;
  border: 2px solid transparent;
  opacity: 0.55;
  transition: opacity 0.12s, border-color 0.12s, transform 0.1s;
}
.avatar-opt:hover {
  opacity: 0.85;
  transform: scale(1.06);
}
.avatar-opt.selected {
  opacity: 1;
  border-color: #f5c842;
  box-shadow: 0 0 10px rgba(245,200,66,0.5);
  transform: scale(1.06);
}

/* ── Join panel ──────────────────────────────────────────────────── */
#join-panel {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  width: 100%;
}

#join-panel > .room-actions {
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
  margin-bottom: 18px;
}

#join-panel > #join-error {
  margin-top: -14px;
  margin-bottom: 6px;
}

#join-panel.is-logged-in .join-col:first-child,
#join-panel.is-logged-in .join-divider {
  display: none;
}

/* When logged in, only the auth column is visible — re-center it and
   strip the padding that was only needed to clear the divider. */
#join-panel.is-logged-in .join-col:last-child {
  padding-left: 0;
  max-width: 320px;
  margin: 0 auto;
}

/* Invite-link state */
#invite-banner {
  background: rgba(245, 200, 66, 0.12);
  border: 1px solid rgba(245, 200, 66, 0.30);
  border-radius: 6px;
  padding: 10px 16px;
  font-size: 13px;
  text-align: center;
  color: #f5e09a;
  letter-spacing: 0.04em;
  margin-bottom: 18px;
}

#join-panel.has-invite > .room-actions {
  display: none;
}

#guest-join-btn {
  width: 100%;
}

#auth-join-btn {
  width: 100%;
  font-size: 17px !important;
  padding: 12px !important;
}

.join-columns {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  width: 100%;
}

.join-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.join-col:first-child { padding-right: 24px; }
.join-col:last-child  { padding-left:  24px; }

.join-section-label {
  font-size: 11px;
  opacity: 0.50;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  padding-bottom: 8px;
}

.join-divider {
  width: 1px;
  background: rgba(255,255,255,0.10);
  flex-shrink: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.join-divider::after {
  content: 'or';
  position: absolute;
  font-family: var(--font);
  font-size: 11px;
  color: rgba(255,255,255,0.40);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: var(--table-felt);
  padding: 8px 0;
}

#join-panel input, #lobby-panel input {
  font-family: var(--font);
  font-size: 17px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.30);
  border-radius: 2px;
  color: #ffffff;
  -webkit-text-fill-color: #ffffff;
  padding: 13px 18px;
  outline: none;
  width: 100%;
  text-align: center;
  letter-spacing: 0.05em;
}
#join-panel input::placeholder { opacity: 0.65; }
#room-code-input { text-transform: uppercase; max-width: 190px; }

.room-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  width: 100%;
}

#create-btn {
  padding: 8px 20px;
  font-size: 17px;
}

.join-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}
.join-sep { font-size: 13px; opacity: 0.4; }

#join-error {
  font-size: 16px;
  color: #e03030;
  letter-spacing: 0.05em;
}

/* ── Lobby panel ─────────────────────────────────────────────────── */
#lobby-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
}

#room-code-display {
  font-size: 22px;
  color: #f5c842;
  letter-spacing: 0.15em;
}

#share-link-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 2px;
  padding: 8px 14px;
  width: 100%;
}
#share-link {
  font-size: 14px;
  opacity: 0.75;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#copy-btn { font-size: 14px; padding: 6px 12px; flex-shrink: 0; }

#seat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
}
.seat-card {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 3px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.seat-card.your-seat { border-color: rgba(245,200,66,0.4); }
.seat-card.team-us   { border-left: 3px solid rgba(245,200,66,0.5); }
.seat-card.team-them { border-left: 3px solid rgba(224,48,48,0.5); }
.seat-card.available {
  cursor: pointer;
  border-style: dashed;
  opacity: 0.7;
  transition: opacity 0.15s, background 0.15s;
}
.seat-card.available:hover {
  opacity: 1;
  background: rgba(255,255,255,0.10);
}
.seat-label {
  font-size: 14px;
  opacity: 0.65;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.seat-avatar {
  width: 48px;
  height: 48px;
  border-radius: 4px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
}
.seat-avatar.empty { opacity: 0.2; }
.seat-name {
  font-size: 16px;
  color: #e8d5ff;
  min-height: 20px;
}
.seat-name.empty { opacity: 0.3; font-style: italic; }

#start-btn { font-size: 20px; padding: 18px 50px; }

.add-friend-seat-btn {
  font-size: 11px !important;
  padding: 4px 8px !important;
  width: 100%;
  opacity: 0.85;
}
.add-friend-seat-btn:disabled { opacity: 0.5; cursor: default; }

.add-friend-btn {
  font-size: 9px !important;
  padding: 2px 7px !important;
  margin-top: 3px;
  opacity: 0.75;
  letter-spacing: 0.05em;
}
.add-friend-btn:disabled { opacity: 0.45; cursor: default; }

#lobby-status {
  font-size: 16px;
  opacity: 0.65;
  letter-spacing: 0.08em;
}

/* ------------------------------------------------------------------ */
/* Speech bubbles                                                      */
/* ------------------------------------------------------------------ */
/* Dedicated slot below each AI player's label — bubbles live here */
.bubble-slot {
  position: relative;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.speech-bubble {
  position: absolute;
  background: rgba(30, 10, 60, 0.95);
  border: 1px solid rgba(245,200,66,0.5);
  border-radius: 2px;
  padding: 7px 14px;
  font-family: var(--font);
  font-size: 16px;
  color: #e8d5ff;
  pointer-events: none;
  white-space: nowrap;
  animation: bubble-in 0.2s ease, bubble-out 0.3s ease 1.8s forwards;
  z-index: 20;
}

@keyframes bubble-in  { from { opacity: 0; transform: scale(0.8); } to { opacity: 1; transform: scale(1); } }
@keyframes bubble-out { from { opacity: 1; } to { opacity: 0; } }

@keyframes thinking-bounce {
  0%, 70%, 100% { transform: translateY(0)   scale(0.65); opacity: 0.35; }
  35%           { transform: translateY(-5px) scale(1);    opacity: 1;    }
}

.thinking-dots {
  position: absolute;
  display: flex;
  gap: 5px;
  align-items: center;
  justify-content: center;
}
.thinking-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(232, 213, 255, 0.85);
  animation: thinking-bounce 1.1s ease-in-out infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.18s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.36s; }

/* ------------------------------------------------------------------ */
/* Animations                                                          */
/* ------------------------------------------------------------------ */
@keyframes deal-in {
  from { opacity: 0; transform: scale(0.65) translateY(-30px) rotate(-4deg); }
  to   { opacity: 1; transform: scale(1)    translateY(0)     rotate(0deg); }
}
.card.deal-anim { animation: deal-in 0.28s ease; }

/* Directional card-play slide animations — card arrives from the player's side */
@keyframes card-slide-bottom { from { opacity: 0; transform: translate(-50%, calc(-50% + 70px)); } to { opacity: 1; transform: translate(-50%, -50%); } }
@keyframes card-slide-top    { from { opacity: 0; transform: translate(-50%, calc(-50% - 70px)); } to { opacity: 1; transform: translate(-50%, -50%); } }
@keyframes card-slide-left   { from { opacity: 0; transform: translate(calc(-50% - 70px), -50%); } to { opacity: 1; transform: translate(-50%, -50%); } }
@keyframes card-slide-right  { from { opacity: 0; transform: translate(calc(-50% + 70px), -50%); } to { opacity: 1; transform: translate(-50%, -50%); } }

.trick-slot.played-p0 .card { animation: card-slide-bottom 0.22s ease; }
.trick-slot.played-p1 .card { animation: card-slide-left   0.22s ease; }
.trick-slot.played-p2 .card { animation: card-slide-top    0.22s ease; }
.trick-slot.played-p3 .card { animation: card-slide-right  0.22s ease; }

@keyframes trick-win {
  0%   { box-shadow: 0 0 0 0    rgba(245,200,66,0.9), 0 0 0 0   rgba(245,200,66,0.4); }
  50%  { box-shadow: 0 0 0 6px  rgba(245,200,66,0.6), 0 0 20px 8px rgba(245,200,66,0.3); }
  100% { box-shadow: 0 0 0 0    rgba(245,200,66,0),   0 0 0 0   rgba(245,200,66,0); }
}
.trick-slot.winner .card { animation: trick-win 0.7s ease; }

/* ------------------------------------------------------------------ */
/* Utilities                                                           */
/* ------------------------------------------------------------------ */
.hidden { display: none !important; }

/* ------------------------------------------------------------------ */
/* Avatars                                                             */
/* ------------------------------------------------------------------ */
.avatar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.avatar-face {
  width: 50px;
  height: 50px;
  border-radius: 4px;
  border: 2px solid;
}

.avatar-face.team-us {
  background: linear-gradient(135deg, #2d1b5e, #4a2d8e);
  border-color: rgba(245, 200, 66, 0.5);
  box-shadow: 0 0 8px rgba(245, 200, 66, 0.3);
  /* background-image set inline by renderLabels overrides the gradient */
  background-size: cover;
  background-position: center;
}

.avatar-face.team-them {
  background: linear-gradient(135deg, #5e1b1b, #8e2d2d);
  border-color: rgba(224, 48, 48, 0.5);
  box-shadow: 0 0 8px rgba(224, 48, 48, 0.3);
  background-size: cover;
  background-position: center;
}

/* Sitting-out partner during a loner hand */
.player-area.sitting-out .avatar-face {
  opacity: 0.25;
  filter: grayscale(1);
}
.player-area.sitting-out .player-label {
  opacity: 0.3;
}

/* Disconnected player — dimmed avatar + "Away · Xs" notice */
.avatar-face.disconnected {
  opacity: 0.3;
  filter: grayscale(1);
}
.reconnect-notice {
  font-size: 11px;
  letter-spacing: 0.04em;
  color: #ff8a65;
  background: rgba(255, 100, 50, 0.12);
  border: 1px solid rgba(255, 100, 50, 0.3);
  border-radius: 3px;
  padding: 2px 7px;
  margin-top: 3px;
  text-align: center;
  white-space: nowrap;
}

/* ------------------------------------------------------------------ */
/* Corner HUD buttons — settings (top-right) and htp (top-left)      */
/* ------------------------------------------------------------------ */
#settings-btn, #speed-btn {
  position: fixed;
  top: 8px;
  z-index: 210;
  padding: 8px 14px;
  font-size: 18px;
  background: rgba(0, 0, 0, 0.50);
  color: #e8d5ff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  text-align: center;
  letter-spacing: 0;
}
#settings-btn { right: 8px; min-width: 46px; }
#htp-btn      { left: 8px; min-width: 38px; }
#share-btn, #htp-btn {
  position: fixed;
  top: 8px;
  z-index: 210;
  padding: 8px 12px;
  font-size: 18px;
  background: rgba(0, 0, 0, 0.50);
  color: #e8d5ff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  letter-spacing: 0;
}
/* Individual overrides come after the shared rule so they win */
#share-btn { left: 56px; min-width: 38px; font-size: 16px; }
#quit-btn { right: 8px; bottom: 8px; position: fixed; z-index: 210; padding: 8px 14px; font-size: 17px; background: rgba(80,0,0,0.6); color: rgba(255,120,120,0.85); border: 1px solid rgba(200,50,50,0.3); border-radius: 2px; }

/* ── Notification dot (profile button) ──────────────────────────────*/
.notif-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: #f5c842;
  border-radius: 50%;
  margin-left: 5px;
  vertical-align: middle;
  position: relative;
  top: -1px;
  box-shadow: 0 0 5px rgba(245, 200, 66, 0.7);
}

/* ── Friends online count badge ─────────────────────────────────────*/
.count-badge {
  display: inline-block;
  margin-left: 5px;
  background: rgba(124, 77, 255, 0.55);
  border: 1px solid rgba(124, 77, 255, 0.7);
  border-radius: 8px;
  padding: 1px 5px;
  font-size: 7px;
  vertical-align: middle;
  position: relative;
  top: -1px;
  color: #e8d5ff;
  letter-spacing: 0;
}

/* ------------------------------------------------------------------ */
/* Confirm-play card pulse                                             */
/* ------------------------------------------------------------------ */
@keyframes confirm-pulse {
  from { box-shadow: 0 0 10px rgba(245,200,66,0.65), 0 0 0 2px rgba(245,200,66,0.80); }
  to   { box-shadow: 0 0 18px rgba(245,200,66,0.30), 0 0 0 2px rgba(245,200,66,0.35); }
}
.card.confirm-pending {
  box-shadow: 0 0 10px rgba(245,200,66,0.65), 0 0 0 2px rgba(245,200,66,0.80);
  animation: confirm-pulse 0.65s ease-in-out infinite alternate;
}

/* ------------------------------------------------------------------ */
/* Toggle switch                                                       */
/* ------------------------------------------------------------------ */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 24px;
  transition: background 0.2s, border-color 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 2px;
  top: 2px;
  background: rgba(232, 213, 255, 0.55);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}
.toggle-switch input:checked + .toggle-slider {
  background: rgba(120, 60, 210, 0.55);
  border-color: rgba(180, 100, 255, 0.50);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
  background: #e8d5ff;
}

/* ------------------------------------------------------------------ */
/* Touch — eliminate 300 ms tap delay on interactive elements          */
/* ------------------------------------------------------------------ */
button, .card.playable, .card.discardable {
  touch-action: manipulation;
}

/* ------------------------------------------------------------------ */
/* Auth section — optional login/register below join row              */
/* ------------------------------------------------------------------ */
#auth-section {
  /* layout inherited from .join-col — no extra styles needed */
}

#auth-logged-in {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.auth-identity {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
}

#auth-name-display {
  font-size: 19px;
  color: #8aff8a;
  letter-spacing: 0.04em;
}

/* ---- Matchmaking queue UI ---------------------------------------- */
#queue-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

#queue-status-text {
  font-size: 12px;
  color: var(--accent, #ffe066);
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
}

#queue-dots {
  display: inline-block;
  min-width: 1.6em;
}

#auth-section button {
  font-size: 15px;
  padding: 10px 14px;
}

/* Two-column grid for secondary nav buttons */
.auth-menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.auth-menu-grid button {
  padding-left: 8px;
  padding-right: 8px;
}

#avatar-preview-auth {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border-radius: 4px;
  border: 2px solid rgba(245,200,66,0.5);
  background: rgba(255,255,255,0.08);
  background-size: cover;
  background-position: center;
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s, opacity 0.12s;
}
#avatar-preview-auth:hover {
  border-color: #f5c842;
  box-shadow: 0 0 10px rgba(245,200,66,0.5);
  opacity: 0.88;
}

#auth-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

#auth-form input {
  width: 100%;
}

.auth-btn-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  width: 100%;
}

#auth-error {
  font-size: 14px;
  color: #e03030;
  letter-spacing: 0.05em;
}

/* ------------------------------------------------------------------ */
/* Avatar change modal                                                 */
/* ------------------------------------------------------------------ */
#avatar-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
}
#avatar-modal-box {
  background: var(--overlay-bg);
  border: 2px solid var(--overlay-border);
  border-radius: var(--overlay-radius);
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-width: 420px;
  width: calc(100vw - 40px);
}
.avatar-modal-title {
  font-size: 19px;
  font-weight: 700;
  color: #f5c842;
}
#avatar-modal-picker {
  display: flex;
  flex-direction: row;
  gap: 8px;
  overflow-x: auto;
  width: 100%;
  padding: 4px 2px 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(245,200,66,0.3) transparent;
}
#avatar-modal-picker::-webkit-scrollbar { height: 4px; }
#avatar-modal-picker::-webkit-scrollbar-thumb { background: rgba(245,200,66,0.3); border-radius: 2px; }

/* Clickable avatar indicators */
.seat-avatar.changeable,
#area-p0 .avatar-face {
  cursor: pointer;
}
.seat-avatar.changeable:hover { opacity: 0.8; outline: 2px solid rgba(245,200,66,0.6); }
#area-p0 .avatar-face:hover   { outline: 2px solid rgba(245,200,66,0.6); }

/* ------------------------------------------------------------------ */
/* Leaderboard table — shown inside the overlay                        */
/* ------------------------------------------------------------------ */
.lb-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 16px;
}
.lb-table th, .lb-table td {
  padding: 6px 10px;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  white-space: nowrap;
}
.lb-table th {
  font-size: 13px;
  opacity: 0.65;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.lb-table tbody tr:hover { background: rgba(255,255,255,0.04); }
.lb-table td:nth-child(2) { text-align: left; color: #e8d5ff; }

/* ------------------------------------------------------------------ */
/* How to Play modal                                                   */
/* ------------------------------------------------------------------ */
#htp-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 16px;
}

#htp-box {
  background: var(--overlay-bg);
  border: 2px solid var(--overlay-border);
  border-radius: var(--overlay-radius);
  padding: 28px 32px 22px;
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-height: 90vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(245,200,66,0.3) transparent;
}

#htp-title {
  font-size: 18px;
  font-weight: 800;
  color: #f5c842;
  text-align: center;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-shadow: 0 0 12px rgba(245,200,66,0.45);
}

#htp-content { display: flex; flex-direction: column; gap: 16px; }

.htp-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.htp-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: rgba(232,213,255,0.55);
  padding-bottom: 5px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
  margin-bottom: 2px;
}

.htp-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 13px;
  line-height: 1.5;
}

.htp-label {
  flex-shrink: 0;
  width: 68px;
  color: rgba(232,213,255,0.55);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  text-align: right;
}

.htp-value {
  color: #e8d5ff;
  font-size: 13px;
}

.htp-dim {
  opacity: 0.50;
  font-size: 0.88em;
}

.htp-note {
  font-size: 11px;
  color: rgba(232,213,255,0.48);
  font-style: italic;
  padding-left: 78px;
  line-height: 1.5;
}

.htp-score-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 16px;
  font-size: 13px;
  color: #e8d5ff;
  align-items: baseline;
}

.htp-pts {
  font-weight: 700;
  color: #f5c842;
  white-space: nowrap;
  text-align: right;
}

#htp-close { align-self: center; }

.htp-speed-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  color: rgba(232,213,255,0.65);
  letter-spacing: 0.06em;
  cursor: pointer;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.htp-speed-row input[type="checkbox"] {
  width: 15px; height: 15px;
  accent-color: #f5c842;
  cursor: pointer;
}

/* ------------------------------------------------------------------ */
/* Friends panel (inside overlay)                                      */
/* ------------------------------------------------------------------ */
#overlay-body {
  max-height: 55vh;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(245,200,66,0.3) transparent;
}


.lobby-btn-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.friends-add-row {
  display: flex;
  gap: 8px;
  width: 100%;
  margin-bottom: 4px;
}
.friends-add-row input {
  flex: 1;
  font-family: var(--font);
  font-size: 16px;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 2px;
  color: #ffffff;
  -webkit-text-fill-color: #ffffff;
  padding: 9px 12px;
  outline: none;
  letter-spacing: 0.04em;
  text-align: center;
  min-width: 0;
}
.friends-add-row input::placeholder { opacity: 0.60; }

.friends-section-title {
  font-size: 13px;
  opacity: 0.65;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  text-align: left;
  width: 100%;
  margin-top: 10px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.friend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  width: 100%;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  line-height: 1.2;
}
.friend-name   { flex: 1; font-size: 17px; color: #e8d5ff; text-align: left; }
.friend-status { font-size: 13px; opacity: 0.60; white-space: nowrap; }
.friend-actions { display: flex; gap: 4px; }
button.friend-accept, button.friend-decline, button.friend-invite {
  font-size: 14px; padding: 6px 10px;
}

.online-dot, .offline-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.online-dot  { background: #4caf50; box-shadow: 0 0 5px rgba(76,175,80,0.6); }
.offline-dot { background: rgba(255,255,255,0.2); }

.friends-empty {
  font-size: 14px;
  opacity: 0.60;
  font-style: italic;
  text-align: center;
  padding: 12px 0;
}

/* ------------------------------------------------------------------ */
/* Notification toast                                                  */
/* ------------------------------------------------------------------ */
#notif-toast {
  position: fixed;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 400;
  background: rgba(18, 8, 40, 0.97);
  border: 1px solid rgba(245, 200, 66, 0.55);
  border-radius: 4px;
  padding: 14px 20px;
  max-width: 340px;
  width: calc(100vw - 32px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: bubble-in 0.2s ease;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}
#notif-toast-body {
  font-size: 17px;
  color: #e8d5ff;
  text-align: center;
  line-height: 1.6;
}
#notif-toast-btns {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ================================================================== */
/* Mobile portrait  (≤ 500 px wide)                                    */
/* ================================================================== */
@media (max-width: 500px) {

  /* Redefine design tokens for smaller screen */
  :root {
    --card-width:       64px;
    --card-height:      90px;
    --card-rank-size:   16px;
    --card-suit-size:   20px;
    --label-font-size:  12px;
    --panel-font-size:  15px;
    --card-hover-lift:  -14px;
  }

  /* Extra bottom padding makes room for the fixed action panel        */
  #app { padding: 4px 4px 148px; justify-content: flex-start; }

  .middle-row { flex: 1; }

  .player-area.top    { margin-bottom: 2px; }
  .player-area.bottom { margin-top:   2px; }

  /* ---- Card overlaps for smaller mobile cards --------------------- */
  .hand.face-up .card, .hand.face-down .card { margin-left: -18px; }
  .hand.face-up .card:first-child, .hand.face-down .card:first-child { margin-left: 0; }
  .hand.vertical .card { margin-top: -60px; }
  .hand.vertical .card:first-child { margin-top: 0; }

  /* ---- Middle row: collapse the gap and let table-center shrink ---- */
  .middle-row {
    gap: 10px;
    max-height: min(300px, 46vh);
  }
  /* Lock side players to equal card-width columns so table-center
     stays perfectly viewport-centered regardless of player name length.
     min-width: 0 overrides the default min-content minimum so long
     names (white-space: nowrap) can't push the column wider than 64px. */
  .middle-row .player-area { margin-top: 30px; flex: 0 0 64px; min-width: 0; }
  .table-center { min-width: 0; }

  /* ---- Trick area: 200×200 ---------------------------------------- */
  #trick-area { width: 200px; height: 200px; }

  /* Trick slots scale to match card size */
  .trick-slot           { width: 64px; height: 90px; }
  .trick-slot.top       { top:    0;  left: 50%; transform: translateX(-50%); }
  .trick-slot.bottom    { bottom: 0;  left: 50%; transform: translateX(-50%); }
  .trick-slot.left      { left:   0;  top:  50%; transform: translateY(-50%); }
  .trick-slot.right     { right:  0;  top:  50%; transform: translateY(-50%); }

  /* ---- Avatars: smaller on mobile ---------------------------------- */
  .avatar-face { width: 34px; height: 34px; }
  .bubble-slot { height: 24px; }

  /* ---- Trump indicator -------------------------------------------- */
  #trump-indicator { font-size: 12px; padding: 5px 12px; }
  .trump-caller    { font-size: 10px; }

  /* ---- Play prompt + trick display --------------------------------- */
  #play-prompt { font-size: 11px; height: 16px; }
  #trick-display { height: 24px; }
  .trick-label { font-size: 9px; }

  /* ---- More room at the top for the partner avatar ----------------- */
  #app { padding-top: 20px; }

  /* ---- Action panel: full-width, lower bottom offset --------------- */
  #action-panel {
    left: 8px;
    transform: none;
    width: calc(100vw - 16px);
    padding: 10px 18px 12px;
    bottom: 6px;
    gap: 10px;
  }
  #action-panel.has-prompt {
    bottom: 148px;
    padding: 12px 24px 14px;
    gap: 10px;
  }
  #action-panel.has-prompt #scoreboard {
    display: none;
  }

  /* ---- Buttons ----------------------------------------------------- */
  button       { font-size: 16px; padding: 11px 18px; }
  .btn-suit    { min-width: 72px; font-size: 16px; }
  .btn-alone   { font-size: 16px; }
  #settings-btn, #speed-btn { font-size: 16px; padding: 6px 10px; }
  #last-trick-btn { font-size: 13px; padding: 5px 10px; }
  #last-trick-panel { padding: 14px 18px; }
  #last-trick-title { font-size: 13px; }
  #last-trick-panel .card { width: 46px; height: 66px; }
  #last-trick-panel .card .rank { font-size: 11px; }
  #last-trick-panel .card .suit { font-size: 16px; }

  /* ---- Misc text --------------------------------------------------- */
  #htp-btn, #share-btn  { font-size: 14px; padding: 6px 10px; }
  #htp-box  { padding: 22px 20px 18px; }
  .dealer-chip    { font-size: 12px; padding: 3px 7px; }
  .speech-bubble  { font-size: 14px; padding: 5px 10px; }
  .avatar-pips .pip { width: 7px; height: 7px; }

  /* Mobile scoreboard — compact inline numbers, no pips */
  #scoreboard  { flex-direction: row; gap: 0; width: auto; align-items: center; }
  .score-sep   { display: none; }
  .score-team  { font-size: 9px; width: 26px; opacity: 0.65; letter-spacing: 0.06em; }
  .score-pts   { font-size: 18px; min-width: auto; }
  .score-row   { gap: 5px; padding-left: 0; margin-left: 0; border-left-width: 0; }
  /* Thin divider between the two score groups */
  #scoreboard .score-row:first-child {
    padding-right: 12px;
    border-right: 1px solid rgba(255, 255, 255, 0.12);
    margin-right: 12px;
  }

  /* No dark panel box when there's no bid prompt — score pips float on felt */
  #action-panel:not(.has-prompt) {
    background: transparent;
    border-color: transparent;
    backdrop-filter: none;
    padding: 6px 18px 8px;
    gap: 5px;
  }

  /* ---- Overlay ----------------------------------------------------- */
  #overlay-box   { padding: 28px 24px; max-width: calc(100vw - 24px); }
  #overlay-title { font-size: 19px; }
  #overlay-body  { font-size: 14px; }

  /* ---- Start screen ------------------------------------------------ */
  #logo              { width: 300px; height: 300px; }
  #start-box p       { font-size: 14px; }
  #start-btn         { font-size: 17px; padding: 14px 36px; }
  #start-box         { max-width: calc(100vw - 32px); }
  #join-panel input  { font-size: 14px; padding: 11px 14px; }
  .join-sep          { font-size: 13px; }
  #join-error        { font-size: 13px; }
  #room-code-display { font-size: 18px; }
  #share-link        { font-size: 13px; }
  #copy-btn          { font-size: 13px; padding: 5px 10px; }
  .seat-label        { font-size: 12px; }
  .seat-name         { font-size: 14px; }
  #lobby-status      { font-size: 13px; }

  /* ---- Two-column layout: stack on mobile -------------------------- */
  .join-columns      { flex-direction: column; gap: 16px; }
  .join-col:first-child { padding-right: 0; }
  .join-col:last-child  { padding-left:  0; }
  .join-divider {
    width: 100%;
    height: 1px;
    flex-direction: row;
  }
  .join-divider::after { padding: 0 10px; }
  #auth-section button { font-size: 14px; padding: 9px 12px; }
}

/* ================================================================== */
/* Mobile landscape  (short screens — phones on their side)           */
/* ================================================================== */
@media (max-height: 480px) and (orientation: landscape) {

  :root {
    --card-width:       56px;
    --card-height:      80px;
    --card-rank-size:   15px;
    --card-suit-size:   18px;
    --label-font-size:  11px;
    --panel-font-size:  14px;
    --card-hover-lift:  -10px;
  }

  #app { padding: 2px 8px 80px; }

  .player-area.top    { margin-bottom: 1px; }
  .player-area.bottom { margin-top:   1px; }

  .hand.face-up .card, .hand.face-down .card { margin-left: -16px; }
  .hand.face-up .card:first-child, .hand.face-down .card:first-child { margin-left: 0; }
  .hand.vertical .card { margin-top: -52px; }
  .hand.vertical .card:first-child { margin-top: 0; }

  .middle-row {
    gap: 14px;
    max-height: min(240px, 52vh);
  }
  .middle-row .player-area { margin-top: 25px; flex: 0 0 56px; min-width: 0; }
  .table-center { min-width: 0; }

  #trick-area { width: 190px; height: 190px; }
  .trick-slot { width: 60px; height: 84px; }
  .trick-slot.top    { top: 0;    left: 50%; transform: translateX(-50%); }
  .trick-slot.bottom { bottom: 0; left: 50%; transform: translateX(-50%); }
  .trick-slot.left   { left: 0;   top: 50%;  transform: translateY(-50%); }
  .trick-slot.right  { right: 0;  top: 50%;  transform: translateY(-50%); }

  .avatar-face { width: 28px; height: 28px; }
  .bubble-slot { height: 20px; }

  #trump-indicator { font-size: 11px; padding: 4px 10px; gap: 3px; }
  .trump-caller    { font-size: 9px; }

  #play-prompt { font-size: 10px; height: 14px; }
  #trick-display { height: 20px; gap: 4px; }
  .trick-label { font-size: 8px; }

  #action-panel {
    bottom: 4px;
    padding: 8px 22px 10px;
    gap: 9px;
  }
  #action-panel.has-prompt {
    bottom: 120px;
    padding: 10px 28px 12px;
    gap: 8px;
  }
  #action-panel.has-prompt #scoreboard {
    display: none;
  }

  button     { font-size: 14px; padding: 9px 16px; }
  .btn-suit  { min-width: 64px; font-size: 14px; }
  .btn-alone { font-size: 14px; }
  #settings-btn, #speed-btn { font-size: 14px; padding: 5px 9px; }
  #last-trick-btn { font-size: 12px; padding: 4px 8px; }
  #last-trick-panel { padding: 10px 14px; }
  #last-trick-panel .card { width: 40px; height: 58px; }
  #last-trick-panel .card .rank { font-size: 9px; }
  #last-trick-panel .card .suit { font-size: 13px; }

  .dealer-chip   { font-size: 11px; padding: 2px 6px; }
  .speech-bubble { font-size: 12px; padding: 4px 9px; }
  .score-pts     { font-size: 19px; }
  .score-team    { font-size: 11px; width: 30px; }
  .avatar-pips .pip { width: 6px; height: 6px; }
  .score-sep     { font-size: 11px; }

  #overlay-box   { padding: 22px 28px; }
  #overlay-title { font-size: 18px; }
  #overlay-body  { font-size: 13px; }

  #start-box h1 { font-size: 24px; }
  #start-box p  { font-size: 13px; }
  #start-btn    { font-size: 14px; padding: 12px 28px; }
}

/* ================================================================== */
/* Touch devices — disable hover lift so cards don't stay raised      */
/* after a tap                                                         */
/* ================================================================== */
@media (hover: none) {
  .card.playable:hover,
  .card.discardable:hover {
    transform: none;
    box-shadow: none;
    transition: none;
    z-index: auto;
  }
}

/* ================================================================== */
/* Mobile bid panel — compact bid-hand so upcard stays visible above  */
/* ================================================================== */
@media (max-width: 500px) {
  .bid-hand .card {
    width: 44px;
    height: 63px;
    margin-left: -12px;
  }
  .bid-hand .card:first-child { margin-left: 0; }
  .bid-hand .card .rank { font-size: 10px; top: 2px; left: 3px; }
  .bid-hand .card .suit { font-size: 14px; }
}
