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

:root {
  --bg: #0a0a0a;
  --bg-surface: #141414;
  --bg-card: #1a1a1a;
  --table-felt: #0d1f15;
  --table-felt-light: #132a1c;
  --text-primary: #e8e0d0;
  --text-secondary: #888;
  --text-dim: #555;
  --accent: #d4a843;
  --accent-glow: rgba(212, 168, 67, 0.3);
  --success: #2ecc71;
  --warning: #f39c12;
  --danger: #e74c3c;
  --card-border: #8b7355;
  --bid-highlight: #d4a843;
  --radius: 8px;
  --radius-lg: 12px;
}

html, body {
  height: 100%;
  /* Mobile browsers shrink the visible viewport when the URL bar
     slides up / down; 100dvh tracks that live so fullscreen layouts
     don't leave strips of empty page above or below the UI. */
  height: 100dvh;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

#app {
  height: 100%;
  width: 100%;
  position: relative;
}

/* ── Screens ── */
.screen {
  display: none;
  height: 100%;
  width: 100%;
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.screen.active {
  display: flex;
  flex-direction: column;
  opacity: 1;
}

.screen.screen-fade-in {
  animation: screen-in 0.35s ease-out;
}

@keyframes screen-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ── Lobby ── */
.lobby-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3.5rem 1rem 1.5rem;
  background: radial-gradient(ellipse at center, #1a1a1a 0%, #0a0a0a 70%);
  width: 100%;
  overflow-y: auto;
}

.game-title {
  /* Scale title with the viewport so it doesn't dominate small
     phones or look lost on big screens. Clamped at 2.25rem on the
     small end and 4rem on the large end. */
  font-size: clamp(2.25rem, 10vw, 4rem);
  font-weight: 700;
  letter-spacing: 0.25em;
  color: var(--accent);
  text-shadow: 0 0 40px var(--accent-glow);
  margin-bottom: 0.25rem;
  text-align: center;
}

.game-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  letter-spacing: 0.2em;
  margin-bottom: 2.5rem;
}

.lobby-form {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

input[type="text"],
input[type="number"] {
  background: var(--bg-surface);
  border: 1px solid #333;
  color: var(--text-primary);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

input:focus {
  border-color: var(--accent);
}

#room-code-input {
  text-transform: uppercase;
  letter-spacing: 0.3em;
  text-align: center;
  font-weight: 600;
  /* flex: 1 1 0 + min-width: 0 so the input shrinks freely inside
     the row; without min-width: 0 flex items default to min-content,
     which for an <input> is the `size` attribute width — that's what
     was pushing the Join button past the viewport edge. */
  flex: 1 1 0;
  min-width: 0;
  width: 100%;
}

.join-row {
  display: flex;
  gap: 0.5rem;
  width: 100%;
  min-width: 0;
}

.join-row .btn {
  flex-shrink: 0;
  padding: 0.75rem 1.1rem;
}

.divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--text-dim);
  font-size: 0.8rem;
  margin: 0.5rem 0;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #333;
}

/* ── Buttons ── */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  touch-action: manipulation;
  min-height: 44px;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--accent);
  color: #111;
}

.btn-primary:hover:not(:disabled) {
  background: #e0b54e;
}

.btn-secondary {
  background: #2a2a2a;
  color: var(--text-primary);
  border: 1px solid #444;
}

.btn-secondary:hover:not(:disabled) {
  background: #333;
}

.btn-bid {
  background: #1e2a1e;
  color: var(--success);
  border: 1px solid #2a4a2a;
  padding: 0.6rem 0.8rem;
  font-size: 0.85rem;
  font-weight: 700;
  flex: 1;
  min-height: 44px;
  transition: all 0.15s, box-shadow 0.2s;
  /* Kill the sticky outline left behind after a tap on mobile;
     keyboard focus still gets a visible ring via :focus-visible. */
  -webkit-tap-highlight-color: transparent;
}

.btn-bid:focus { outline: none; }
.btn-bid:focus-visible {
  outline: 2px solid var(--success);
  outline-offset: 2px;
}

/* Hover styling only applies on devices that truly hover (mouse /
   trackpad) — touch devices leave :hover stuck on tapped elements. */
@media (hover: hover) {
  .btn-bid:hover:not(:disabled) {
    background: #2a3a2a;
    border-color: var(--success);
    box-shadow: 0 0 8px rgba(46, 204, 113, 0.2);
  }
}

.btn-bid.active-bid {
  background: var(--accent);
  color: #111;
  border-color: var(--accent);
}

.btn-custom-go {
  flex: 0;
  min-width: 60px;
}

.btn-link {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.5rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.2s;
  min-height: auto;
}

.btn-link:hover {
  color: var(--accent);
}

.btn-back {
  position: absolute;
  top: 1rem;
  left: 1rem;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.5rem;
  transition: color 0.2s;
}

.btn-back:hover {
  color: var(--accent);
}

.btn-home {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.45rem 0.75rem;
  color: var(--text-primary);
  background: rgba(10, 10, 10, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  text-decoration: none;
  /* Works for both <a> and <button> uses of .btn-home. */
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
  z-index: 10;
}

.btn-home:hover,
.btn-home:focus-visible {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(10, 10, 10, 0.9);
  outline: none;
}

.btn-more-time {
  margin-top: 0.4rem;
  padding: 0.35rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  min-height: 30px;
  align-self: center;
}

.btn-more-time:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-more-time:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.hidden {
  display: none !important;
}

/* ── Room Screen ── */
.room-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3.5rem 1rem 1.5rem;
  background: radial-gradient(ellipse at center, #1a1a1a 0%, #0a0a0a 70%);
  width: 100%;
  overflow-y: auto;
}

.room-title {
  font-size: 1rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  margin-bottom: 0.5rem;
}

.room-code {
  font-size: clamp(2.25rem, 10vw, 3.25rem);
  font-weight: 700;
  letter-spacing: 0.35em;
  color: var(--accent);
  text-shadow: 0 0 30px var(--accent-glow);
  margin-bottom: 0.25rem;
  cursor: pointer;
}

.room-hint {
  color: var(--text-dim);
  font-size: 0.8rem;
  margin-bottom: 2rem;
}

.players-list {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.player-slot {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-surface);
  border-radius: var(--radius);
  border: 1px solid #2a2a2a;
  animation: slot-in 0.3s ease-out;
}

@keyframes slot-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.player-slot.is-host {
  border-color: var(--accent);
}

.player-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
  box-shadow: 0 0 6px rgba(46, 204, 113, 0.4);
}

.player-dot.disconnected {
  background: var(--danger);
  box-shadow: 0 0 6px rgba(231, 76, 60, 0.4);
}

.player-slot-name {
  flex: 1;
  font-weight: 500;
}

.player-slot-badge {
  font-size: 0.7rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.bot-badge {
  color: var(--text-secondary);
}

.bot-tag {
  font-size: 0.55em;
  font-weight: 400;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  vertical-align: middle;
}

.room-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.waiting-msg {
  color: var(--text-dim);
  font-size: 0.85rem;
}

/* ── Game Screen ── */
#game-screen {
  /* Explicitly size the radial ellipse to 140% × 110% so it fully
     covers the viewport in both landscape and portrait. With the
     default `farthest-corner` sizing, wide landscape phones ended
     up with pure-black strips at the left/right edges where the
     gradient had already faded to #080f0b. */
  background:
    radial-gradient(ellipse 140% 110% at 50% 45%,
      var(--table-felt-light) 0%,
      var(--table-felt) 55%,
      #080f0b 100%);
  overflow: hidden;
}

#game-screen.active {
  display: flex;
  flex-direction: column;
}

/* ── Result Banner (card won / card passed) ── */
.result-banner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  padding-top: 50%;
  pointer-events: none;
  animation: banner-in 0.35s ease-out;
}

.result-banner.hidden {
  display: none;
}

@keyframes banner-in {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.result-banner-inner {
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  border-radius: var(--radius-lg);
  padding: 1rem 1.5rem;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  max-width: 85%;
}

.result-banner-inner.won {
  border-color: var(--accent);
  box-shadow: 0 0 40px var(--accent-glow), 0 0 80px rgba(212, 168, 67, 0.15);
  animation: result-won-glow 0.6s ease-out;
}

.result-banner-inner.won.result-me {
  box-shadow: 0 0 50px var(--accent-glow), 0 0 100px rgba(212, 168, 67, 0.2);
}

.result-banner-inner.passed {
  border-color: rgba(255, 255, 255, 0.1);
  opacity: 0.7;
}

@keyframes result-won-glow {
  0% { box-shadow: 0 0 0 rgba(212, 168, 67, 0); transform: scale(0.95); }
  50% { box-shadow: 0 0 60px var(--accent-glow), 0 0 120px rgba(212, 168, 67, 0.3); transform: scale(1.02); }
  100% { transform: scale(1); }
}

.result-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.result-title.won { color: var(--accent); }
.result-title.passed { color: var(--text-dim); }

.result-detail {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.result-detail .result-price {
  color: var(--accent);
  font-weight: 700;
}

/* Opponents Bar */
.opponents-bar {
  display: flex;
  gap: 0.4rem;
  /* Left/right padding leaves room for the absolutely-positioned
     leave button and deck-peek/help icon cluster on either side so
     the centered opponent cards never slide underneath them. */
  padding: 0.4rem 3.25rem;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 0 0 auto;
  justify-content: center;
  width: 100%;
  /* Hide the bar entirely when there are no opponent cards so we
     don't reserve dead space on solo test games. The :empty selector
     fires because renderOpponents() sets innerHTML = '' when nobody
     else is at the table. */
}

.opponents-bar:empty {
  display: none;
}

.opponents-bar::-webkit-scrollbar {
  display: none;
}

.opponent-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.4rem 0.6rem;
  background: rgba(0, 0, 0, 0.4);
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.08);
  min-width: 80px;
  flex-shrink: 0;
  transition: border-color 0.3s, box-shadow 0.3s, opacity 0.3s;
}

.opponent-card.is-winning {
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}

.opponent-card.is-broke {
  opacity: 0.4;
}

.opponent-card.disconnected {
  opacity: 0.3;
}

.opponent-card.just-won-card {
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--accent-glow), 0 0 40px rgba(212, 168, 67, 0.15);
}

.opponent-name {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70px;
}

.opponent-budget {
  font-size: 0.65rem;
  color: var(--success);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.opponent-score {
  font-size: 0.65rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.opponent-cards-won {
  font-size: 0.6rem;
  color: var(--text-dim);
}

.opponent-progress {
  width: 100%;
  height: 3px;
  background: #222;
  border-radius: 2px;
  margin-top: 0.25rem;
  overflow: hidden;
}

.opponent-progress-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.6s ease;
}

.opponent-progress-fill.low    { background: var(--success); }
.opponent-progress-fill.mid    { background: var(--warning); }
.opponent-progress-fill.high   { background: var(--danger); }

/* Auction Area */
.auction-area {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Pack content from the top so the card always sits above the
     timer and more-time button instead of drifting into the
     player-controls stack underneath. */
  justify-content: flex-start;
  /* Top padding reserves space for the absolutely-positioned leave
     button and deck-peek/help icon cluster so round-info doesn't
     slide underneath them when the opponents-bar is empty/hidden. */
  padding: 3rem 0.75rem 0.5rem;
  min-height: 0;
  width: 100%;
  overflow: hidden;
}

/* When there are opponents the opponents-bar eats its own top gutter
   and provides the icon clearance, so we can slim the auction-area
   top padding back down. */
.opponents-bar:not(:empty) + .auction-area {
  padding-top: 0.75rem;
}

.round-info {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 0.4rem;
  flex: 0 0 auto;
}

.current-card-container {
  position: relative;
  /* Take all of the leftover vertical space between round-info and
     the bid-info/timer row, and center the card inside it. The card
     itself scales with available height via clamp(), so this
     container shrinks/grows with the viewport. */
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-bottom: 0.5rem;
}

/* ── Cards ── */
.card {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  font-weight: 700;
  position: relative;
  user-select: none;
  transition: transform 0.3s, box-shadow 0.3s;
}

.card-small {
  width: 46px;
  height: 58px;
  font-size: 0.7rem;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.06);
  flex-direction: column;
  gap: 1px;
  padding: 3px 2px;
  overflow: hidden;
}

.card-large {
  /* Scale the card with the viewport instead of jumping between
     fixed breakpoints. Width follows height via aspect-ratio so the
     card keeps its playing-card proportions regardless of screen
     size, and the clamp() upper bound prevents it from getting
     absurdly large on desktop. max-height/max-width let the flex
     parent shrink it if there's not enough room. */
  aspect-ratio: 104 / 144;
  height: clamp(128px, 32vh, 240px);
  width: auto;
  max-height: 100%;
  max-width: 100%;
  font-size: 1rem;
  box-shadow:
    0 4px 24px rgba(0, 0, 0, 0.6),
    0 0 40px var(--accent-glow),
    inset 0 1px 0 rgba(255,255,255,0.1);
  border: 2px solid rgba(255, 255, 255, 0.15);
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.5rem;
}

.card-large .card-pts-label {
  font-size: 0.5rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.7;
  margin-left: 2px;
}

.card-player-name {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  /* Break only at word boundaries so multi-word names stack instead of
     mid-word wrapping. Long single-word names are shrunk via .name-shrink-* */
  word-break: normal;
  overflow-wrap: normal;
  hyphens: none;
  max-width: 100%;
  padding: 0 2px;
}

.card-player-name.name-shrink-sm { font-size: 0.82rem; letter-spacing: -0.01em; }
.card-player-name.name-shrink-md { font-size: 0.72rem; letter-spacing: -0.02em; }
.card-player-name.name-shrink-lg { font-size: 0.62rem; letter-spacing: -0.02em; }

.card-player-value {
  font-size: 0.7rem;
  font-weight: 600;
  opacity: 0.75;
}

.card-sm-name {
  font-size: 0.45rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  text-align: center;
  line-height: 1.3;
  letter-spacing: 0;
}

.card-sm-value {
  font-size: 0.55rem;
  font-weight: 700;
  opacity: 0.75;
}

/* Card corner pips — value top-left, position bottom-right */
.card-large::before {
  position: absolute;
  font-size: 0.55rem;
  font-weight: 600;
  opacity: 0.5;
  content: attr(data-value);
  top: 6px;
  left: 8px;
}

/* Card color tiers — clear descending hierarchy
   100: gold (max premium)
   98:  warm bronze/copper (premium but below gold)
   95:  cool silver-blue (still premium)
   92:  standard steel (not premium)
   88:  muted slate
   85:  dull dark                                   */
.card-tier-85  { background: linear-gradient(145deg, #1e1e20, #2a2a2e); color: #787880; border-color: rgba(60, 60, 65, 0.4); }
.card-tier-88  { background: linear-gradient(145deg, #242830, #323840); color: #8890a0; border-color: rgba(80, 90, 110, 0.35); }
.card-tier-92  { background: linear-gradient(145deg, #2a3440, #3a4854); color: #a0b4c4; border-color: rgba(100, 140, 170, 0.3); }
.card-tier-95  { background: linear-gradient(145deg, #404060, #585880); color: #dcdcf0; border-color: rgba(170, 170, 220, 0.45); }
.card-tier-98  { background: linear-gradient(145deg, #5a3818, #7a5228); color: #fce4c0; border-color: rgba(200, 140, 70, 0.55); }
.card-tier-100 { background: linear-gradient(145deg, #7a600a, #aa8810); color: #fffae0; border-color: rgba(220, 180, 60, 0.6); }

.card-large.card-tier-95 {
  box-shadow:
    0 4px 24px rgba(0, 0, 0, 0.6),
    0 0 35px rgba(170, 170, 230, 0.22),
    0 0 60px rgba(150, 150, 210, 0.1),
    inset 0 1px 0 rgba(255,255,255,0.15);
  border-color: rgba(170, 170, 220, 0.45);
}

.card-large.card-tier-98 {
  box-shadow:
    0 4px 24px rgba(0, 0, 0, 0.6),
    0 0 45px rgba(200, 140, 60, 0.3),
    0 0 70px rgba(180, 120, 50, 0.12),
    inset 0 1px 0 rgba(255,255,255,0.15);
  border-color: rgba(200, 140, 70, 0.55);
}

.card-large.card-tier-100 {
  box-shadow:
    0 4px 24px rgba(0, 0, 0, 0.6),
    0 0 60px rgba(220, 180, 40, 0.4),
    0 0 90px rgba(240, 200, 60, 0.15),
    inset 0 1px 0 rgba(255,255,255,0.2);
  border-color: rgba(230, 190, 70, 0.6);
}

/* Position label — bottom-right of card */
.card-pos-label {
  position: absolute;
  bottom: 4px;
  right: 6px;
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  opacity: 0.6;
  letter-spacing: 0.03em;
}

.card-large .card-pos-label {
  bottom: 6px;
  right: 8px;
  font-size: 0.65rem;
  opacity: 0.5;
}

/* Card entrance animation */
.card-enter {
  animation: card-enter 0.4s ease-out;
}

@keyframes card-enter {
  from {
    opacity: 0;
    transform: scale(0.6) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Outbid shake + flash */
.anim-outbid .card-large {
  animation: outbid-shake 0.4s ease-out;
}

@keyframes outbid-shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-6px); }
  30% { transform: translateX(5px); }
  45% { transform: translateX(-4px); }
  60% { transform: translateX(3px); }
  75% { transform: translateX(-1px); }
}

.anim-outbid-flash {
  animation: outbid-flash 0.5s ease-out;
}

@keyframes outbid-flash {
  0% { color: var(--danger); transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* Bid Info */
.bid-info {
  text-align: center;
  margin-bottom: 0.4rem;
  min-height: 2.25rem;
  flex: 0 0 auto;
  width: 100%;
}

.bid-status {
  font-size: 0.95rem;
  color: var(--text-primary);
  min-height: 1.5em;
}

.bid-amount {
  font-weight: 700;
  color: var(--accent);
  font-size: 1.3rem;
}

.bid-leader {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.15rem;
}

.bid-you-winning {
  color: var(--success);
  font-weight: 600;
}

.no-bids-prompt {
  color: var(--text-dim);
  font-size: 0.85rem;
  animation: pulse-dim 2s ease-in-out infinite;
}

@keyframes pulse-dim {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* Timer */
.timer-container {
  /* Match the width of the bid-buttons row below so it's visually
     connected to the controls the player is about to hit, instead
     of being a thin centered strip that looks unrelated. */
  width: 100%;
  max-width: 520px;
  padding: 0 0.5rem;
  position: relative;
  transition: opacity 0.3s;
  flex: 0 0 auto;
  margin-bottom: 0.25rem;
}

.timer-bar {
  width: 100%;
  height: 6px;
  background: #222;
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.timer-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: var(--timer-pct, 100%);
  background: var(--timer-color, var(--success));
  border-radius: 3px;
  transition: width 0.1s linear, background-color 0.5s;
}

.timer-bar.timer-critical {
  animation: timer-shake 0.3s ease-in-out infinite;
}

.timer-bar.timer-critical::after {
  animation: timer-pulse 0.5s ease-in-out infinite;
}

@keyframes timer-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 6px var(--danger); }
  50% { opacity: 0.5; box-shadow: 0 0 16px var(--danger); }
}

@keyframes timer-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-1px); }
  75% { transform: translateX(1px); }
}

.timer-text {
  display: block;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.3rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  transition: color 0.3s, transform 0.2s;
}

.timer-text.timer-critical-text {
  color: var(--danger);
  font-size: 0.95rem;
  animation: timer-text-pulse 0.5s ease-in-out infinite;
}

@keyframes timer-text-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Game Top Actions (help + deck peek) */
.game-top-actions {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: flex;
  gap: 0.4rem;
  z-index: 15;
}

.btn-icon-leave {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 15;
}

.btn-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s, border-color 0.15s;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--accent);
}

.btn-icon:active {
  transform: scale(0.92);
}

/* Deck Peek Overlay */
.deck-overlay,
.help-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.94);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.deck-overlay.hidden,
.help-overlay.hidden {
  display: none;
}

.help-overlay:not(.hidden) {
  display: flex;
  flex-direction: column;
}

.help-overlay .instructions-container {
  background: transparent;
  width: 100%;
}

.deck-overlay-content {
  min-height: 100%;
  padding: 3rem 1rem 2rem;
  max-width: 520px;
  margin: 0 auto;
  position: relative;
}

.deck-overlay-title {
  color: var(--accent);
  text-align: center;
  font-size: 1.4rem;
  margin-bottom: 1.25rem;
  margin-top: 0.25rem;
}

.deck-section {
  margin-bottom: 1.5rem;
}

.deck-section-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 0.5rem;
  text-align: center;
}

.deck-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
}

.deck-grid .card-small {
  width: 100%;
  height: auto;
  aspect-ratio: 0.78;
  min-width: 0;
}

.deck-grid .card-sm-name {
  font-size: 0.45rem;
}

.deck-grid .card-sm-value {
  font-size: 0.55rem;
}

.deck-grid .card-discarded {
  opacity: 0.55;
  filter: grayscale(0.3);
}

.deck-claimed-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.deck-claimed-row {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  padding: 0.5rem 0.6rem;
}

.deck-claimed-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.deck-claimed-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}

.deck-claimed-pts {
  font-size: 0.7rem;
  color: var(--accent);
  font-weight: 600;
}

.deck-claimed-cards {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 3px;
}

.deck-claimed-cards .card-small {
  width: 100%;
  height: auto;
  aspect-ratio: 0.78;
  min-width: 0;
}

.deck-claimed-cards .card-sm-name {
  font-size: 0.45rem;
}

.deck-claimed-cards .card-sm-value {
  font-size: 0.55rem;
}

.deck-card-price-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.deck-card-price {
  font-size: 0.5rem;
  color: var(--accent);
  margin-top: 1px;
  font-weight: 600;
}

.deck-empty-msg {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-align: center;
  padding: 0.5rem;
  font-style: italic;
}

/* Player Controls (sticky bottom) */
.player-controls {
  flex: 0 0 auto;
  padding: 0.5rem 0.75rem 0.6rem;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  width: 100%;
}

.my-info {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 0.5rem;
}

.my-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-label {
  font-size: 0.65rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.budget-value {
  color: var(--success);
  transition: color 0.3s;
}

.budget-value.low-budget {
  color: var(--warning);
}

.budget-value.broke {
  color: var(--danger);
}

.score-value {
  color: var(--accent);
}

.score-stat {
  min-width: 90px;
}

.my-score-bar {
  width: 100%;
  height: 3px;
  background: #222;
  border-radius: 2px;
  margin-top: 0.2rem;
  overflow: hidden;
}

.my-score-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.my-score-fill.score-glow {
  box-shadow: 0 0 8px var(--accent-glow), 0 0 16px rgba(212, 168, 67, 0.2);
  background: linear-gradient(90deg, var(--accent), #e8c44e);
}

.bid-controls {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.bid-buttons {
  display: flex;
  gap: 0.3rem;
}

.custom-bid-row {
  display: flex;
  gap: 0.3rem;
  align-items: center;
}

.custom-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  flex-shrink: 0;
}

.custom-bid-row input {
  flex: 1;
  padding: 0.5rem;
  min-width: 0;
  font-size: 0.9rem;
}

/* ── Game Over ── */
.gameover-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: radial-gradient(ellipse at center, #1a1a1a 0%, #0a0a0a 70%);
  gap: 1rem;
  position: relative;
  overflow: hidden;
}

.winner-title {
  font-size: 2rem;
  color: var(--accent);
  text-shadow: 0 0 40px var(--accent-glow);
  text-align: center;
  animation: winner-entrance 0.8s ease-out;
}

@keyframes winner-entrance {
  from { opacity: 0; transform: scale(0.5) translateY(20px); }
  60% { transform: scale(1.08) translateY(-4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.win-reason {
  color: var(--text-secondary);
  font-size: 0.85rem;
  animation: fade-in 0.6s 0.3s ease-out both;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.final-scores {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 1rem 0;
}

.score-entry {
  animation: score-row-in 0.4s ease-out both;
}

.score-entry:nth-child(1) { animation-delay: 0.4s; }
.score-entry:nth-child(2) { animation-delay: 0.55s; }
.score-entry:nth-child(3) { animation-delay: 0.7s; }
.score-entry:nth-child(4) { animation-delay: 0.85s; }
.score-entry:nth-child(5) { animation-delay: 1.0s; }

.score-row {
  display: flex;
  align-items: center;
  padding: 0.6rem 1rem;
  background: var(--bg-surface);
  border-radius: var(--radius);
  border: 1px solid #2a2a2a;
  gap: 0.75rem;
}

@keyframes score-row-in {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

.score-row.is-winner {
  border-color: var(--accent);
  background: rgba(212, 168, 67, 0.08);
  box-shadow: 0 0 20px var(--accent-glow);
}

.score-toggle {
  font-size: 0.7rem;
  color: var(--text-dim);
  width: 1rem;
  text-align: center;
  flex-shrink: 0;
}

.score-team {
  display: none;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.5rem 0.75rem 0.6rem;
  justify-content: center;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid #2a2a2a;
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  max-height: 50vh;
  overflow-y: auto;
}

.score-team.expanded {
  display: flex;
}

.score-row.team-open {
  border-radius: var(--radius) var(--radius) 0 0;
}

.score-team .card-small {
  width: 44px;
  height: 56px;
}

.score-rank {
  font-size: 0.8rem;
  color: var(--text-dim);
  width: 1.5rem;
  text-align: center;
}

.score-row.is-winner .score-rank {
  color: var(--accent);
  font-size: 1rem;
}

.score-name {
  flex: 1;
  font-weight: 500;
}

.score-points {
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.score-budget {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* ── Confetti ── */
.confetti-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.confetti-piece {
  position: absolute;
  width: 8px;
  height: 8px;
  top: -10px;
  opacity: 0;
  animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
  0% { opacity: 1; transform: translateY(0) rotate(0deg) scale(1); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translateY(100vh) rotate(1080deg) scale(0.5); }
}

@keyframes confetti-drift {
  0% { opacity: 1; transform: translateY(0) translateX(0) rotate(0deg); }
  50% { transform: translateY(50vh) translateX(20px) rotate(540deg); }
  70% { opacity: 0.8; }
  100% { opacity: 0; transform: translateY(100vh) translateX(-10px) rotate(1080deg); }
}

/* ── Study Overlay ── */
.study-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
}

.study-overlay.hidden {
  display: none;
}

.study-content {
  text-align: center;
  padding: 1.5rem;
  max-width: 100%;
  max-height: 100%;
  overflow-y: auto;
}

.study-content h2 {
  color: var(--accent);
  margin-bottom: 0.5rem;
  font-size: 1.4rem;
}

.study-content p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
}

/* Ready bar (used in both study overlay and game-over screen) */
.ready-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem auto 0;
}

.ready-bar .btn {
  min-width: 180px;
}

.ready-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
}

.ready-count {
  font-weight: 600;
  color: var(--text-primary);
}

.ready-dot { color: var(--text-dim); }

.ready-countdown {
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.study-deck {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  margin: 0 auto 1.5rem;
  max-width: 440px;
  width: 100%;
}

.study-deck .card-small {
  width: 100%;
  height: auto;
  aspect-ratio: 0.78;
  min-width: 0;
  opacity: 0;
  animation: study-card-in 0.3s ease-out forwards;
}

.study-deck .card-sm-name {
  font-size: 0.45rem;
}

.study-deck .card-sm-value {
  font-size: 0.55rem;
}

@keyframes study-card-in {
  from { opacity: 0; transform: scale(0.5) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.study-deck .card-small {
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

@media (hover: hover) {
  .study-deck .card-small:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
    z-index: 2;
  }
}

.study-deck .card-small:active {
  transform: scale(1.1);
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--danger);
  color: white;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  max-width: 90%;
  text-align: center;
}

.toast.visible {
  opacity: 1;
}

/* ── Reconnect Overlay ── */
.reconnect-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.reconnect-content {
  text-align: center;
  color: var(--text-secondary);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #333;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Rotate-to-portrait gate ──
   Auction is designed for portrait phones. On short landscape
   viewports (i.e. a phone held sideways) we show a full-screen
   "rotate your phone" nudge. Desktop, tablets, and anything with
   a decent height are unaffected. */
.rotate-overlay {
  display: none;
}

@media (orientation: landscape) and (max-height: 500px) {
  .rotate-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at center, #1a1a1a 0%, #0a0a0a 70%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    padding: 1rem;
  }

  .rotate-content {
    text-align: center;
    color: var(--text-primary);
    max-width: 320px;
  }

  .rotate-icon {
    font-size: 3rem;
    color: var(--accent);
    margin-bottom: 0.75rem;
    animation: rotate-nudge 1.8s ease-in-out infinite;
    display: inline-block;
  }

  .rotate-title {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    margin-bottom: 0.4rem;
  }

  .rotate-sub {
    font-size: 0.8rem;
    color: var(--text-secondary);
  }
}

@keyframes rotate-nudge {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-90deg); }
}

/* ── Last-player-standing overlay ── */
.last-player-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 180;
  padding: 1.25rem;
  backdrop-filter: blur(4px);
  animation: fade-in 0.2s ease-out;
}

.last-player-overlay.hidden { display: none; }

.last-player-card {
  background: var(--bg-surface);
  border: 1px solid rgba(212, 168, 67, 0.35);
  border-radius: var(--radius-lg);
  padding: 1.75rem 1.5rem;
  max-width: 340px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.last-player-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
}

.last-player-sub {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 1.1rem;
}

.last-player-count {
  font-size: 3.25rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.last-player-hint {
  font-size: 0.72rem;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ── Animations ── */
@keyframes bid-pulse {
  0% { box-shadow: 0 0 0 0 var(--accent-glow); }
  50% { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

@keyframes card-awarded {
  0% { transform: scale(1); opacity: 1; box-shadow: 0 0 20px var(--accent-glow); }
  25% { transform: scale(1.12); opacity: 1; box-shadow: 0 0 50px var(--accent-glow); }
  100% { transform: scale(0.15) translateY(-40px); opacity: 0; }
}

@keyframes card-passed {
  0% { transform: scale(1) translateY(0); opacity: 1; }
  100% { transform: scale(0.6) translateY(50px); opacity: 0; filter: grayscale(1); }
}

@keyframes score-pop {
  0% { transform: scale(1); }
  30% { transform: scale(1.35); color: var(--accent); }
  60% { transform: scale(0.95); }
  100% { transform: scale(1); }
}

@keyframes budget-flash {
  0% { color: var(--danger); transform: scale(1.1); }
  50% { transform: scale(0.95); }
  100% { transform: scale(1); }
}

.anim-bid-pulse {
  animation: bid-pulse 0.5s ease-out;
}

.anim-card-awarded {
  animation: card-awarded 0.7s ease-in forwards;
}

.anim-card-passed {
  animation: card-passed 0.5s ease-in forwards;
}

.anim-score-pop {
  animation: score-pop 0.5s ease;
}

.anim-budget-flash {
  animation: budget-flash 0.6s ease;
}

/* ── Instructions Screen ── */
.instructions-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem;
  padding-top: 3.5rem;
  background: radial-gradient(ellipse at center, #1a1a1a 0%, #0a0a0a 70%);
  overflow-y: auto;
  position: relative;
}

.instructions-title {
  font-size: 1.5rem;
  color: var(--accent);
  margin-bottom: 1.5rem;
  letter-spacing: 0.1em;
}

.instructions-body {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding-bottom: 2rem;
}

.rule-section h3 {
  font-size: 0.95rem;
  color: var(--accent);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.rule-section p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.rule-section strong {
  color: var(--text-primary);
}

.rule-section ol,
.rule-section ul {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
  padding-left: 1.2rem;
}

.rule-section li {
  margin-bottom: 0.25rem;
}

.rule-note {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-align: center;
  margin-top: 0.4rem;
}

.card-table {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin: 0.5rem 0;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.card-table-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
  gap: 0.75rem;
}

.ct-value {
  color: var(--text-primary);
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.ct-count {
  color: var(--text-dim);
}

.ct-names {
  color: var(--text-secondary);
  font-size: 0.78rem;
  text-align: right;
  flex: 1;
  line-height: 1.4;
}

/* ── Responsive ── */
@media (min-width: 480px) {
  /* card-large width/height removed — now clamped by .card-large's
     own aspect-ratio + height: clamp(), which handles all screen
     sizes without stepped breakpoints. */

  .card-player-name {
    font-size: 1.1rem;
  }

  .card-player-name.name-shrink-sm { font-size: 0.95rem; }
  .card-player-name.name-shrink-md { font-size: 0.82rem; }
  .card-player-name.name-shrink-lg { font-size: 0.72rem; }

  .card-player-value {
    font-size: 0.8rem;
  }

  .card-small {
    width: 50px;
    height: 64px;
  }

  .card-sm-name {
    font-size: 0.5rem;
  }

  .card-sm-value {
    font-size: 0.6rem;
  }

  .opponent-card {
    min-width: 100px;
    padding: 0.5rem 0.8rem;
  }

  /* .game-title size is now driven by clamp() in its base rule, so
     the old fixed 4rem override here is gone. */

  .bid-amount {
    font-size: 1.5rem;
  }
}

@media (min-width: 768px) {
  .card-player-name {
    font-size: 1.3rem;
  }

  .card-player-name.name-shrink-sm { font-size: 1.1rem; }
  .card-player-name.name-shrink-md { font-size: 0.95rem; }
  .card-player-name.name-shrink-lg { font-size: 0.82rem; }

  .card-player-value {
    font-size: 0.9rem;
  }

  .opponents-bar {
    gap: 0.75rem;
    padding: 0.75rem;
  }

  .opponent-card {
    min-width: 120px;
  }

  .bid-buttons {
    gap: 0.5rem;
  }

  .btn-bid {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
  }

  .player-controls {
    padding: 0.75rem 1.5rem;
  }

  .result-banner {
    padding-top: 30%;
  }
}

/* ── Short viewports (landscape phones / small laptops) ──
 * The card itself is already fluid via clamp()/aspect-ratio, so we
 * only need to trim the surrounding chrome here — padding, font
 * sizes, and the top-of-screen icon buttons — so it fits comfortably
 * when the viewport is short (anything under ~560px tall, e.g. a
 * phone in landscape). */
@media (max-height: 560px) {
  .opponents-bar {
    padding: 0.3rem;
    gap: 0.3rem;
  }

  .opponent-card {
    min-width: 80px;
    padding: 0.3rem 0.5rem;
    font-size: 0.75rem;
  }

  .auction-area {
    padding: 0.35rem 0.5rem 0.25rem;
  }

  .round-info {
    font-size: 0.65rem;
    margin-bottom: 0.2rem;
  }

  .bid-info {
    margin-bottom: 0.25rem;
    min-height: 1.75rem;
  }

  .bid-status { font-size: 0.8rem; }
  .bid-amount { font-size: 1rem; }

  .player-controls {
    padding: 0.4rem 0.6rem 0.5rem;
  }

  .my-info { gap: 1rem; margin-bottom: 0.35rem; }
  .stat-value { font-size: 0.95rem; }

  .btn-bid {
    padding: 0.5rem 0.6rem;
    font-size: 0.8rem;
    min-height: 38px;
  }

  .game-top-actions { top: 0.35rem; right: 0.35rem; }
  .btn-icon-leave { top: 0.35rem; left: 0.35rem; }

  .btn-icon {
    width: 30px;
    height: 30px;
    font-size: 0.85rem;
  }
}

/* ── Narrow viewports (portrait phones under ~380px wide) ──
 * Keep bid buttons from wrapping awkwardly by tightening their
 * padding and font-size on the smallest phones. */
@media (max-width: 380px) {
  .btn-bid {
    padding: 0.55rem 0.35rem;
    font-size: 0.78rem;
  }

  .bid-buttons { gap: 0.25rem; }

  .opponents-bar {
    padding: 0.35rem;
    gap: 0.3rem;
  }

  .opponent-card {
    min-width: 82px;
    padding: 0.35rem 0.5rem;
  }
}

/* ── Mode Selection Screen ── */
.mode-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3.5rem 1.25rem 1.5rem;
  background: radial-gradient(ellipse at center, #1a1a1a 0%, #0a0a0a 70%);
  width: 100%;
  overflow-y: auto;
}

.mode-title {
  font-size: 1rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  margin-bottom: 2rem;
}

.mode-cards {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  max-width: 340px;
}

.mode-card {
  background: var(--bg-surface);
  border: 1px solid #2a2a2a;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  font-family: inherit;
  color: var(--text-primary);
}

.mode-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--accent-glow);
  transform: translateY(-2px);
}

.mode-card:active {
  transform: translateY(0) scale(0.98);
}

.mode-card-badge {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}

.mode-card-badge.badge-x {
  color: #6ec6ff;
}

.mode-card-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.15em;
  margin-bottom: 0.5rem;
}

.x-accent {
  color: #6ec6ff;
  text-shadow: 0 0 12px rgba(110, 198, 255, 0.4);
}

.mode-card-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 0.75rem;
}

.mode-card-desc strong {
  color: var(--text-primary);
}

.mode-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mode-card-meta {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.mode-card-help {
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.15s;
}

.mode-card-help:hover {
  color: var(--accent);
}

.mode-card-x {
  border-color: rgba(110, 198, 255, 0.15);
}

.mode-card-x:hover {
  border-color: #6ec6ff;
  box-shadow: 0 0 20px rgba(110, 198, 255, 0.2);
}

/* ── AuctionX Game Theme ── */
#game-screen.mode-auctionx {
  background:
    radial-gradient(ellipse 140% 110% at 50% 45%,
      #0c1525 0%,
      #080e1a 55%,
      #040810 100%);
}

/* ── Duplicate Warning ── */
.duplicate-warning {
  font-size: 0.72rem;
  color: var(--warning);
  font-weight: 600;
  margin-top: 0.25rem;
  letter-spacing: 0.04em;
}

/* ── Lineup Overlay ── */
.lineup-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
}

.lineup-overlay.hidden { display: none; }

.lineup-overlay-content {
  width: 90%;
  max-width: 400px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 1.5rem 1rem 1.25rem;
  position: relative;
  background: rgba(20, 20, 20, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
}

.lineup-overlay-title {
  color: var(--accent);
  text-align: center;
  font-size: 1.1rem;
  margin-bottom: 1.25rem;
  margin-top: 0.25rem;
}

.lineup-formation {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  align-items: center;
  padding: 0.5rem 0;
}

.lineup-row {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.lineup-slot-empty {
  border: 1.5px dashed rgba(255, 255, 255, 0.12) !important;
  background: rgba(255, 255, 255, 0.02) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
}

.slot-label {
  font-size: 0.5rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.4;
}

.pos-gk-empty .slot-label  { color: #2ecc71; }
.pos-def-empty .slot-label  { color: #3498db; }
.pos-mid-empty .slot-label  { color: #f39c12; }
.pos-att-empty .slot-label  { color: #e74c3c; }

.lineup-summary {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 1rem;
  font-weight: 600;
}

/* Position category tints on small cards */
.card-small.pos-gk  { box-shadow: 0 0 6px rgba(46, 204, 113, 0.3); }
.card-small.pos-def  { box-shadow: 0 0 6px rgba(52, 152, 219, 0.3); }
.card-small.pos-mid  { box-shadow: 0 0 6px rgba(243, 156, 18, 0.3); }
.card-small.pos-att  { box-shadow: 0 0 6px rgba(231, 76, 60, 0.3); }

.lineup-bench {
  margin-top: 0.25rem;
}

/* ── My Lineup Button ── */
.my-lineup-btn {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}

.my-lineup-btn:hover {
  color: var(--accent);
  background: rgba(255, 255, 255, 0.05);
}

.my-name {
  max-width: 70px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.my-lineup-chevron {
  font-size: 0.6rem;
  opacity: 0.5;
}
