/* ════════════════════════════════════════════
   Pit: El Mercado · TuJuegas
   Sistema visual coherente con la landing principal.
   ════════════════════════════════════════════ */

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

:root {
  --bg:       #080b14;
  --bg2:      #0e1422;
  --bg3:      #141c2e;
  --surface:  rgba(20,28,46,0.7);
  --surface2: rgba(14,20,34,0.6);
  --border:   rgba(255,255,255,0.07);
  --border2:  rgba(255,255,255,0.12);
  --text:     #e8eaf0;
  --text2:    #8892a4;
  --text3:    #4a5568;
  --gold:     #f0c060;
  --gold-l:   #ffd98a;
  --gold-d:   #b08030;
  --purple:   #7c3aed;
  --purple-l: #a78bfa;
  --green:    #34d399;
  --red:      #f87171;
  --blue:     #60a5fa;
  --accent:   var(--gold);
  --radius:   14px;
  --radius-sm:10px;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Space Grotesk', sans-serif;
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

/* ── Cosmic background (mismo del landing) ── */
#bg-canvas {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0;
}

/* ════════════════════════════════════════════
   HEADER
   ════════════════════════════════════════════ */
.pit-header {
  position: relative; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  background: rgba(8,11,20,0.65);
}
.pit-header .head-left { display: flex; align-items: center; gap: 18px; min-width: 0; }
.pit-header .back-link {
  color: var(--text2);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: color .15s;
}
.pit-header .back-link:hover { color: var(--text); }
.pit-header h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 1px;
  background: linear-gradient(135deg, #fff 30%, var(--gold));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  text-transform: uppercase;
  white-space: nowrap;
}
.pit-header h1 small {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 400;
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--text2);
  -webkit-text-fill-color: var(--text2);
  margin-left: 6px;
}
.pit-header .room-code-badge {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 4px;
  color: var(--gold);
  background: rgba(240,192,96,0.07);
  border: 1px solid rgba(240,192,96,0.25);
  border-radius: 8px;
  padding: 7px 14px;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}
.pit-header .room-code-badge:hover { background: rgba(240,192,96,0.12); }

/* ════════════════════════════════════════════
   LAYOUT
   ════════════════════════════════════════════ */
.pit-main {
  position: relative; z-index: 5;
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 24px 32px;
  display: grid;
  gap: 16px;
}

/* ════════════════════════════════════════════
   PANEL (lobby + utility container)
   ════════════════════════════════════════════ */
.panel {
  background: linear-gradient(180deg, var(--surface), var(--surface2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  backdrop-filter: blur(10px);
}
.panel-title {
  font-family: 'Outfit', sans-serif;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 3px;
  color: var(--text2);
  margin-bottom: 12px;
}

/* ════════════════════════════════════════════
   BUTTONS
   ════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 22px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Outfit', sans-serif;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform .1s, box-shadow .15s, opacity .15s, background .15s;
  text-decoration: none;
  justify-content: center;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--gold), #ff8c42);
  color: #1a1206;
  box-shadow: 0 6px 18px rgba(240,192,96,0.28);
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 8px 24px rgba(240,192,96,0.42);
  transform: translateY(-1px);
}

.btn-ghost {
  background: rgba(255,255,255,0.05);
  color: var(--text);
  border: 1px solid var(--border2);
}
.btn-ghost:hover:not(:disabled) { background: rgba(255,255,255,0.1); }

.btn-danger {
  background: linear-gradient(135deg, var(--red), #b91c1c);
  color: #fff;
}

.btn-bell {
  margin-left: auto;
  background: linear-gradient(135deg, var(--purple), #a855f7);
  color: #fff;
  padding: 13px 26px;
  font-size: 13px;
  box-shadow:
    0 0 0 1px rgba(167,139,250,0.4),
    0 6px 22px rgba(124,58,237,0.4);
  position: relative;
  overflow: hidden;
}
.btn-bell::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: conic-gradient(from 0deg, transparent, var(--gold), transparent);
  opacity: 0;
  animation: bellRing 1s linear infinite;
  border-radius: inherit;
}
.btn-bell.active::before { opacity: 0.7; }
.btn-bell.active {
  animation: bellShake 0.4s ease-in-out infinite alternate;
  box-shadow:
    0 0 0 1px rgba(240,192,96,0.6),
    0 0 32px rgba(240,192,96,0.6),
    0 0 64px rgba(124,58,237,0.5);
}
.btn-bell > * { position: relative; z-index: 1; }
@keyframes bellRing { to { transform: rotate(360deg); } }
@keyframes bellShake {
  from { transform: translateX(-2px) rotate(-1deg); }
  to   { transform: translateX(2px) rotate(1deg); }
}

.btn-bot {
  padding: 7px 14px;
  font-size: 14px;
  letter-spacing: 0;
  line-height: 1;
}

/* ════════════════════════════════════════════
   LOBBY
   ════════════════════════════════════════════ */
.lobby-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 2.6rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.25em;
  text-align: center;
  padding: 18px 8px;
  background: rgba(240,192,96,0.04);
  border: 1px dashed rgba(240,192,96,0.25);
  border-radius: var(--radius-sm);
  text-shadow: 0 0 20px rgba(240,192,96,0.3);
}
.lobby-hint {
  text-align: center;
  color: var(--text2);
  font-size: 0.85rem;
  margin: 12px 0 14px;
}

/* Player list (lobby + scoreboard fallback) */
.player-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: background .15s, border-color .15s;
}
.player-row:hover {
  background: rgba(255,255,255,0.03);
  border-color: var(--border);
}
.player-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border2);
  background: var(--bg3);
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  transition: border-color .15s;
}
.player-avatar.disconnected { opacity: 0.35; filter: grayscale(1); }

.bot-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e2a44, #0f172a);
  border: 2px solid var(--border2);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.player-info { flex: 1; min-width: 0; }
.player-name {
  font-weight: 700;
  font-size: 0.92rem;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.player-level {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-top: 4px;
  font-size: 0.7rem;
  background: rgba(240,192,96,0.10);
  color: var(--gold-l);
  border: 1px solid rgba(240,192,96,0.25);
  border-radius: 5px;
  padding: 1px 7px;
  font-weight: 700;
  letter-spacing: 0.02em;
  width: fit-content;
}
.player-host-badge,
.player-you-badge,
.bot-badge {
  font-family: 'Outfit', sans-serif;
  font-size: 9px;
  border-radius: 5px;
  padding: 2px 6px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  line-height: 1.4;
}
.player-host-badge {
  background: rgba(240,192,96,0.15);
  color: var(--gold);
  border: 1px solid rgba(240,192,96,0.35);
}
.player-you-badge {
  background: rgba(52,211,153,0.12);
  color: #6ee7b7;
  border: 1px solid rgba(52,211,153,0.3);
}
.bot-badge {
  background: rgba(167,139,250,0.10);
  color: var(--purple-l);
  border: 1px solid rgba(167,139,250,0.30);
}

.player-count-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text2);
  margin-bottom: 12px;
  font-family: 'JetBrains Mono', monospace;
}
.player-count-info .count { font-weight: 700; color: var(--text); font-size: 1rem; }
.player-count-info .range { color: var(--text3); }

.bot-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(255,255,255,0.025);
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
  margin-top: 10px;
}
.bot-controls .bot-label { flex: 1; font-size: 0.85rem; color: var(--text2); }
.bot-count-display {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 1.1rem;
  min-width: 24px;
  text-align: center;
  color: var(--text);
}

/* ════════════════════════════════════════════
   GAME · HUD bar
   ════════════════════════════════════════════ */
.hud-bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  background: linear-gradient(180deg, var(--surface), var(--surface2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 18px;
  backdrop-filter: blur(10px);
}
.hud-meta { display: flex; align-items: center; gap: 22px; }
.hud-stat { display: flex; flex-direction: column; }
.hud-stat-label {
  font-family: 'Outfit', sans-serif;
  font-size: 9px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--text2);
  font-weight: 700;
}
.hud-stat-value {
  font-family: 'Outfit', sans-serif;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.1;
  color: var(--text);
}
.hud-stat-value.gold   { color: var(--gold); }
.hud-stat-value.purple { color: var(--purple-l); }

.hud-target {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 6px 14px;
  background: rgba(124,58,237,0.10);
  border: 1px solid rgba(124,58,237,0.30);
  border-radius: 100px;
  font-family: 'Outfit', sans-serif;
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--purple-l);
  font-weight: 700;
}
.hud-target strong {
  color: #fff;
  font-size: 16px;
  letter-spacing: 0;
}

/* ── Live ticker ── */
.ticker {
  position: relative;
  overflow: hidden;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  height: 38px;
  display: flex; align-items: center;
  mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
}
.ticker-track {
  display: flex; gap: 28px;
  white-space: nowrap;
  align-items: center;
  padding: 0 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}
.ticker-item {
  color: var(--text2);
  display: inline-flex; align-items: center; gap: 6px;
  flex-shrink: 0;
  animation: tickerSlide .4s ease-out;
}
.ticker-item .symbol { color: var(--text); font-weight: 700; }
.ticker-item .up   { color: var(--green); }
.ticker-item .down { color: var(--red); }
.ticker-item .bell { color: var(--gold); font-weight: 700; }
.ticker-item.event-trade { color: var(--blue); }
.ticker-item.event-bell  { color: var(--gold); font-weight: 700; }
.ticker-item.event-empty { color: var(--text3); font-style: italic; }
@keyframes tickerSlide {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ════════════════════════════════════════════
   GAME · Scoreboard
   ════════════════════════════════════════════ */
.scoreboard {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 2px 8px;
  scrollbar-width: none;
}
.scoreboard::-webkit-scrollbar { display: none; }

.player-card {
  flex-shrink: 0;
  min-width: 142px;
  background: linear-gradient(180deg, var(--surface), var(--surface2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  transition: transform .2s, border-color .2s, box-shadow .2s;
  backdrop-filter: blur(8px);
  position: relative;
  overflow: hidden;
}
.player-card.me {
  border-color: rgba(240,192,96,0.4);
  box-shadow: 0 0 0 1px rgba(240,192,96,0.15), 0 8px 30px rgba(240,192,96,0.08);
}
.player-card.leading {
  border-color: rgba(52,211,153,0.4);
  box-shadow: 0 0 0 1px rgba(52,211,153,0.15), 0 8px 30px rgba(52,211,153,0.12);
}
.player-card.cornered {
  animation: cornerShake 0.5s ease-in-out infinite alternate;
}
@keyframes cornerShake {
  from { transform: translateX(-1px) rotate(-0.3deg); }
  to   { transform: translateX(1px) rotate(0.3deg); }
}

.pcard-avatar { position: relative; width: 44px; height: 44px; flex-shrink: 0; }
.pcard-avatar img,
.pcard-avatar .bot-av {
  width: 44px; height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border2);
  background: var(--bg3);
}
.pcard-avatar .bot-av {
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  background: linear-gradient(135deg, #1e2a44, #0f172a);
}
.pcard-avatar img.disconnected { opacity: 0.35; filter: grayscale(1); }
.player-card.me      .pcard-avatar img { border-color: var(--gold); }
.player-card.leading .pcard-avatar img { border-color: var(--green); }

.pcard-level {
  position: absolute;
  bottom: -3px; right: -3px;
  background: linear-gradient(135deg, var(--gold), #ff8c42);
  color: #1a1206;
  font-family: 'Outfit', sans-serif;
  font-size: 9px;
  font-weight: 800;
  border-radius: 6px;
  padding: 1px 5px;
  border: 2px solid var(--bg2);
  line-height: 1.2;
}
.pcard-level.bot {
  background: linear-gradient(135deg, var(--purple), #a855f7);
  color: #fff;
}

.pcard-info { min-width: 0; }
.pcard-name {
  font-weight: 700;
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}
.pcard-score {
  font-family: 'Outfit', sans-serif;
  font-size: 18px;
  font-weight: 800;
  color: var(--gold);
  line-height: 1;
  margin-top: 4px;
}
.player-card.leading .pcard-score { color: var(--green); }
.pcard-cards {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: var(--text2);
  letter-spacing: 1px;
  margin-top: 3px;
  text-transform: uppercase;
}
.pcard-cards.warn  { color: #fbbf24; }
.pcard-cards.alert { color: var(--red); font-weight: 700; }

/* ════════════════════════════════════════════
   GAME · El Mercado (trading floor)
   ════════════════════════════════════════════ */
.market {
  position: relative;
  min-height: 280px;
  border-radius: 20px;
  padding: 28px 24px 24px;
  overflow: hidden;
  background:
    radial-gradient(ellipse 80% 60% at 50% 50%, rgba(124,58,237,0.18), transparent 70%),
    radial-gradient(ellipse 60% 40% at 50% 100%, rgba(240,192,96,0.10), transparent 70%),
    linear-gradient(180deg, rgba(20,28,46,0.85), rgba(8,11,20,0.7));
  border: 1px solid var(--border2);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.06),
    0 20px 60px rgba(0,0,0,0.55);
}
.market::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(124,58,237,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(124,58,237,0.06) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 50%, #000 30%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 50% 50%, #000 30%, transparent 80%);
  pointer-events: none;
}

.market-label {
  position: absolute;
  top: 14px; left: 50%;
  transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 10px;
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 5px;
  text-transform: uppercase;
  color: var(--gold);
  z-index: 2;
}
.market-label::before,
.market-label::after {
  content: '';
  width: 28px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold));
}
.market-label::after {
  background: linear-gradient(90deg, var(--gold), transparent);
}

.market-status {
  position: absolute;
  top: 16px; right: 22px;
  display: inline-flex; align-items: center; gap: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--green);
  z-index: 2;
}
.market-status::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: blink 2s infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.3} }

.market-clock {
  position: absolute;
  top: 16px; left: 22px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--text2);
  z-index: 2;
}

/* Floor: fixed seats, one per player */
.market-floor {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  padding: 44px 0 8px;
  max-width: 980px;
  margin: 0 auto;
  align-items: start; /* seats keep their own height; growing seats don't push others */
}

.market-empty {
  grid-column: 1 / -1;
  align-self: center;
  text-align: center;
  color: var(--text2);
  font-size: 13px;
  line-height: 1.7;
  padding: 24px 0;
}
.market-empty strong {
  color: var(--text);
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  display: block;
  margin-bottom: 4px;
  font-size: 16px;
  letter-spacing: 1px;
}
.market-empty span { font-size: 11px; color: var(--text3); }

/* ── Seat (one per player, fixed position) ── */
.seat {
  background: linear-gradient(180deg, rgba(30,40,62,0.55), rgba(15,22,38,0.45));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 10px 10px;
  display: flex; flex-direction: column;
  align-items: center; gap: 8px;
  min-height: 196px;
  transition: border-color .25s, box-shadow .25s, background .25s;
  position: relative;
  backdrop-filter: blur(8px);
}
.seat-trader {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px;
  color: var(--text2);
  max-width: 100%;
  width: 100%;
  justify-content: center;
}
.seat-trader img,
.seat-trader .bot-av {
  width: 26px; height: 26px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border2);
  background: var(--bg3);
  flex-shrink: 0;
}
.seat-trader .bot-av {
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  background: linear-gradient(135deg, #1e2a44, #0f172a);
}
.seat-trader span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
  max-width: 110px;
}

.seat.empty .seat-trader { opacity: 0.45; }
.seat.empty .seat-body  {
  display: flex; align-items: center; justify-content: center;
  flex: 1;
  font-family: 'Outfit', sans-serif;
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--text3);
  text-transform: uppercase;
}

.seat.has-offer {
  border-color: var(--border2);
  background: linear-gradient(180deg, rgba(40,52,80,0.7), rgba(20,28,46,0.6));
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  animation: seatPop .35s cubic-bezier(.175,.885,.32,1.275);
}
.seat.mine {
  border-color: rgba(240,192,96,0.5);
  background: linear-gradient(180deg, rgba(60,42,12,0.65), rgba(30,20,6,0.5));
  box-shadow:
    0 0 0 1px rgba(240,192,96,0.3),
    0 12px 32px rgba(240,192,96,0.18);
}
@keyframes seatPop {
  from { transform: scale(0.92); }
  to   { transform: scale(1); }
}

.seat-body {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px;
  width: 100%;
}

/* ── Card stack (visual quantity) ── */
.card-stack {
  position: relative;
  width: 80px;
  height: 70px;
  display: flex; align-items: center; justify-content: center;
  animation: cardThrow .35s cubic-bezier(.175,.885,.32,1.275) both;
}
.card-stack .stack-card {
  position: absolute;
  width: 46px;
  height: 64px;
  border-radius: 6px;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(240,192,96,0.18), transparent 60%),
    linear-gradient(160deg, #1c2540 0%, #0a0f1c 100%);
  border: 1px solid rgba(240,192,96,0.3);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.08),
    0 4px 10px rgba(0,0,0,0.5);
}
/* Card-back glyph (small sun-burst monogram) */
.card-stack .stack-card::after {
  content: 'P';
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Outfit', sans-serif;
  font-weight: 900;
  font-size: 18px;
  color: rgba(240,192,96,0.5);
  letter-spacing: 0;
}
.card-stack .stack-card::before {
  content: '';
  position: absolute; inset: 4px;
  border: 1px solid rgba(240,192,96,0.15);
  border-radius: 4px;
}
/* Fan layout based on data-qty */
.card-stack[data-qty="1"] .stack-card:nth-child(1) {
  transform: rotate(0deg);
}
.card-stack[data-qty="2"] .stack-card:nth-child(1) { transform: translateX(-9px) rotate(-7deg); }
.card-stack[data-qty="2"] .stack-card:nth-child(2) { transform: translateX(9px)  rotate(7deg);  }

.card-stack[data-qty="3"] .stack-card:nth-child(1) { transform: translateX(-16px) rotate(-12deg); }
.card-stack[data-qty="3"] .stack-card:nth-child(2) { transform: rotate(0deg); }
.card-stack[data-qty="3"] .stack-card:nth-child(3) { transform: translateX(16px) rotate(12deg); }

.card-stack[data-qty="4"] .stack-card:nth-child(1) { transform: translateX(-22px) rotate(-15deg); }
.card-stack[data-qty="4"] .stack-card:nth-child(2) { transform: translateX(-7px)  rotate(-5deg); }
.card-stack[data-qty="4"] .stack-card:nth-child(3) { transform: translateX(7px)   rotate(5deg); }
.card-stack[data-qty="4"] .stack-card:nth-child(4) { transform: translateX(22px)  rotate(15deg); }

.seat.mine .card-stack .stack-card {
  background:
    radial-gradient(ellipse at 50% 30%, rgba(240,192,96,0.3), transparent 60%),
    linear-gradient(160deg, #5a3a08 0%, #2a1a04 100%);
  border-color: rgba(240,192,96,0.55);
}
.seat.mine .card-stack .stack-card::after {
  color: var(--gold-l);
}

@keyframes cardThrow {
  from { transform: translateY(-30px) scale(0.7); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

.seat-qty-badge {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 14px;
  color: var(--gold);
  letter-spacing: -0.5px;
}
.seat-qty-badge::after {
  content: ' cartas';
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--text2);
  text-transform: uppercase;
  margin-left: 3px;
}
.seat-qty-badge.singular::after { content: ' carta'; }

.seat-mine-tag {
  font-family: 'Outfit', sans-serif;
  font-size: 9px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 700;
}

.btn-accept {
  width: 100%;
  background: linear-gradient(135deg, var(--green), #059669);
  color: #052e16;
  border: none;
  border-radius: 8px;
  padding: 7px 8px;
  font-family: 'Outfit', sans-serif;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform .1s, box-shadow .15s;
  box-shadow: 0 4px 12px rgba(52,211,153,0.25);
}
.btn-accept:hover:not(:disabled) {
  box-shadow: 0 6px 18px rgba(52,211,153,0.4);
  transform: translateY(-1px);
}
.btn-accept:active { transform: scale(0.97); }
.btn-accept:disabled { opacity: 0.4; cursor: not-allowed; }

/* Muted state — selection doesn't match the offer's qty/type yet */
.btn-accept.muted {
  background: rgba(255,255,255,0.04);
  color: var(--text2);
  border: 1px dashed var(--border2);
  box-shadow: none;
  letter-spacing: 0.5px;
}
.btn-accept.muted:hover { background: rgba(255,255,255,0.07); transform: none; box-shadow: none; }

/* ── Match request inbox (inside offerer's seat) ── */
.seat-inbox {
  width: 100%;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px dashed var(--border2);
  display: flex; flex-direction: column;
  gap: 6px;
}
.inbox-label {
  font-family: 'Outfit', sans-serif;
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gold);
  text-align: center;
  font-weight: 700;
}

.match-row {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 6px 8px 8px;
  background: linear-gradient(180deg, rgba(240,192,96,0.06), rgba(240,192,96,0.02));
  border: 1px solid rgba(240,192,96,0.25);
  border-radius: 8px;
  overflow: hidden;
  animation: matchRowSlide .28s cubic-bezier(.175,.885,.32,1.275);
}
@keyframes matchRowSlide {
  from { transform: translateY(-6px); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

.match-row .match-avatar,
.match-row .match-bot-av {
  width: 24px; height: 24px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(255,255,255,0.15);
  background: var(--bg3);
  flex-shrink: 0;
}
.match-row .match-bot-av {
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  background: linear-gradient(135deg, #1e2a44, #0f172a);
}

.match-info { min-width: 0; line-height: 1.1; }
.match-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.match-sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: var(--text2);
  margin-top: 2px;
}
.match-sub strong { color: var(--gold); }

.match-actions {
  display: flex; gap: 4px;
}
.btn-confirm,
.btn-reject {
  width: 26px; height: 26px;
  border: none;
  border-radius: 6px;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  transition: transform .1s, box-shadow .15s, opacity .15s;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}
.btn-confirm {
  background: linear-gradient(135deg, var(--green), #059669);
  color: #052e16;
  box-shadow: 0 2px 8px rgba(52,211,153,0.3);
}
.btn-confirm:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(52,211,153,0.45); }
.btn-confirm:active { transform: scale(0.92); }

.btn-reject {
  background: rgba(255,255,255,0.06);
  color: var(--text2);
  border: 1px solid var(--border2);
}
.btn-reject:hover { background: rgba(248,113,113,0.15); color: var(--red); border-color: var(--red); }
.btn-reject:active { transform: scale(0.92); }

/* Countdown bar (drains left→right) */
.match-row .countdown-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--gold), var(--red));
  transform-origin: left;
  transform: scaleX(1);
  animation-name: countdownDrain;
  animation-fill-mode: forwards;
  animation-timing-function: linear;
}
@keyframes countdownDrain {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

/* My seat awaiting badge */
.seat.awaiting {
  border-color: rgba(167,139,250,0.45);
  box-shadow: 0 0 0 1px rgba(167,139,250,0.25), 0 8px 28px rgba(124,58,237,0.18);
}

.seat-waiting {
  width: 100%;
  display: flex; align-items: center; justify-content: center;
  gap: 8px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 10px;
  color: var(--text2);
  text-align: center;
  padding: 6px 8px;
  background: rgba(167,139,250,0.07);
  border: 1px solid rgba(167,139,250,0.2);
  border-radius: 6px;
  margin-bottom: 6px;
}
.seat-waiting strong { color: var(--purple-l); font-family: 'JetBrains Mono', monospace; font-weight: 700; }
.waiting-spinner {
  width: 12px; height: 12px;
  border: 2px solid rgba(167,139,250,0.25);
  border-top-color: var(--purple-l);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  flex-shrink: 0;
}

.btn-cancel-req {
  width: 100%;
  background: rgba(255,255,255,0.04);
  color: var(--text2);
  border: 1px dashed var(--border2);
  border-radius: 8px;
  padding: 6px 8px;
  font-family: 'Outfit', sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.btn-cancel-req:hover {
  background: rgba(248,113,113,0.1);
  border-color: var(--red);
  color: var(--red);
}
.btn-cancel-req:active { transform: scale(0.97); }

/* ════════════════════════════════════════════
   GAME · Hand panel (sticky)
   ════════════════════════════════════════════ */
.hand-panel {
  position: sticky;
  bottom: 12px;
  z-index: 10;
  background: linear-gradient(180deg, rgba(14,20,34,0.94), rgba(8,11,20,0.97));
  border: 1px solid var(--border2);
  border-radius: 16px;
  padding: 16px 18px;
  backdrop-filter: blur(20px);
  box-shadow: 0 -8px 32px rgba(0,0,0,0.6);
}
.hand-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.hand-title {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text);
}
.hand-title small {
  font-family: 'JetBrains Mono', monospace;
  color: var(--text2);
  font-weight: 500;
  letter-spacing: 1px;
  font-size: 10px;
  margin-left: 8px;
  text-transform: none;
}
.selection-hint {
  margin-left: auto;
  font-size: 11px;
  color: var(--text2);
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.5px;
}
.selection-hint strong { color: var(--gold); }

/* Hand: 9 individual cards laid out by commodity order — centered as a unit */
.hand-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  align-items: flex-end;
  padding-top: 8px; /* breathing room for selected lift */
  /* Keep total slot count constant (real + ghost) so layout doesn't shift during offer-pending */
}
/* Subtle commodity grouping: small gap before a new commodity type */
.hand-grid .commodity-slot.group-start {
  margin-left: 10px;
}
.hand-grid .commodity-slot.group-start:first-child {
  margin-left: 0;
}

.commodity-slot {
  --c1: #2a3550;
  --c2: #131b2e;
  --accent: #888;
  width: 78px;
  height: 108px;
  border-radius: 12px;
  padding: 9px 6px 8px;
  background: linear-gradient(165deg, var(--c1) 0%, var(--c2) 100%);
  border: 1px solid rgba(255,255,255,0.08);
  display: flex; flex-direction: column;
  align-items: center; justify-content: space-between;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
  transition: transform .15s cubic-bezier(.34,1.56,.64,1), box-shadow .2s, border-color .2s, opacity .2s, filter .2s;
  position: relative;
  overflow: hidden;
  box-shadow: 0 6px 16px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.08);
}
.commodity-slot::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 30%, rgba(255,255,255,0.08) 50%, transparent 70%);
  transform: translateX(-100%);
  transition: transform .5s;
  pointer-events: none;
}
.commodity-slot:not(.empty):hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 28px rgba(0,0,0,0.55);
}
.commodity-slot:not(.empty):hover::before { transform: translateX(100%); }

.commodity-slot.locked {
  opacity: 0.5;
  cursor: not-allowed;
  filter: saturate(0.6);
}

/* Ghost slot — placeholder for cards currently in pending offer */
.commodity-slot.ghost {
  opacity: 0.18;
  filter: saturate(0.3);
  border: 1px dashed rgba(255,255,255,0.18) !important;
  background: rgba(255,255,255,0.015) !important;
  cursor: not-allowed;
  pointer-events: none;
  box-shadow: none !important;
}
.commodity-slot.ghost::before { display: none; }
.commodity-slot.ghost .cs-name,
.commodity-slot.ghost .cs-pts { opacity: 0.35; }

/* Glowing — new card just received from a successful trade */
.commodity-slot.glowing {
  border-color: var(--green) !important;
  animation: cardGlow 1s ease-in-out infinite alternate;
}
@keyframes cardGlow {
  from {
    box-shadow:
      0 0 0 1px rgba(52,211,153,0.5),
      0 0 14px rgba(52,211,153,0.35),
      inset 0 1px 0 rgba(255,255,255,0.1);
  }
  to {
    box-shadow:
      0 0 0 2px rgba(52,211,153,0.85),
      0 0 32px rgba(52,211,153,0.6),
      inset 0 1px 0 rgba(255,255,255,0.15);
  }
}

.commodity-slot.selected {
  border-color: var(--gold);
  box-shadow:
    0 0 0 2px var(--gold),
    0 14px 28px rgba(240,192,96,0.3),
    inset 0 1px 0 rgba(255,255,255,0.15);
  transform: translateY(-8px);
}

.cs-icon {
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
  margin-top: 4px;
}
.cs-icon svg { width: 100%; height: 100%; }
.cs-name {
  font-family: 'Outfit', sans-serif;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.95);
  text-align: center;
  line-height: 1.1;
}
.cs-pts {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 700;
  color: rgba(255,255,255,0.55);
  letter-spacing: 0.3px;
}
.cs-pts strong { color: rgba(255,255,255,0.95); }

/* Selection order badge: small ① ② ③ on each selected card */
.cs-order {
  position: absolute;
  top: 4px; left: 4px;
  background: linear-gradient(135deg, var(--gold), #ff8c42);
  color: #1a1206;
  font-family: 'Outfit', sans-serif;
  font-weight: 900;
  font-size: 11px;
  width: 19px; height: 19px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(240,192,96,0.5);
  border: 2px solid var(--bg2);
  animation: selectedPop .25s cubic-bezier(.175,.885,.32,1.275);
  line-height: 1;
}
@keyframes selectedPop {
  from { transform: scale(0); }
  to   { transform: scale(1); }
}

/* Action row */
.action-row {
  display: flex; gap: 10px;
  margin-top: 14px;
  align-items: center;
  flex-wrap: wrap;
}

/* ════════════════════════════════════════════
   GAME · Round result
   ════════════════════════════════════════════ */
.round-result {
  background:
    radial-gradient(ellipse at 50% 0%, rgba(240,192,96,0.18), transparent 60%),
    linear-gradient(180deg, var(--surface), var(--surface2));
  border: 1px solid rgba(240,192,96,0.4);
  border-radius: 16px;
  padding: 28px 24px;
  text-align: center;
  backdrop-filter: blur(10px);
  animation: resultPop .5s cubic-bezier(.175,.885,.32,1.275);
}
@keyframes resultPop {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
.result-tag {
  display: inline-block;
  font-family: 'Outfit', sans-serif;
  font-size: 11px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 6px;
}
.result-icon {
  width: 84px; height: 84px;
  margin: 14px auto 6px;
  filter: drop-shadow(0 6px 24px rgba(240,192,96,0.5));
}
.result-icon svg { width: 100%; height: 100%; }
.result-name {
  font-family: 'Outfit', sans-serif;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #fff, var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.result-winner {
  margin-top: 6px;
  font-size: 14px;
  color: var(--text2);
}
.result-winner strong { color: var(--text); }
.result-points {
  margin-top: 12px;
  font-family: 'Outfit', sans-serif;
  font-size: 22px;
  font-weight: 800;
  color: var(--green);
}
.result-actions {
  margin-top: 20px;
  display: flex; gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ════════════════════════════════════════════
   TOAST
   ════════════════════════════════════════════ */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: rgba(20,28,46,0.95);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 11px 22px;
  font-size: 0.9rem;
  font-weight: 600;
  transition: transform .25s ease;
  z-index: 999;
  pointer-events: none;
  white-space: nowrap;
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.error { border-color: var(--red); color: var(--red); }

/* ════════════════════════════════════════════
   SPINNER
   ════════════════════════════════════════════ */
.spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--border2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ════════════════════════════════════════════
   LANDING (index.html)
   ════════════════════════════════════════════ */
.pit-landing {
  position: relative; z-index: 5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  gap: 24px;
}
.pit-landing > div:first-child { text-align: center; }
.pit-landing h1 {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(56px, 9vw, 88px);
  font-weight: 900;
  letter-spacing: -2px;
  line-height: 1;
  background: linear-gradient(135deg, var(--gold) 0%, #ff8c42 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
}
.pit-landing .tagline {
  font-size: 1.1rem;
  color: var(--text2);
  text-align: center;
  max-width: 540px;
  margin: 0 auto;
  line-height: 1.6;
}
.landing-card {
  background: linear-gradient(180deg, var(--surface), var(--surface2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 440px;
  backdrop-filter: blur(10px);
}
.landing-card h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 14px;
}
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-group label {
  font-family: 'Outfit', sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text2);
}
.form-group input {
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 12px 14px;
  font-size: 1rem;
  outline: none;
  transition: border-color .15s, background .15s;
  font-family: 'JetBrains Mono', monospace;
}
.form-group input:focus {
  border-color: var(--gold);
  background: rgba(0,0,0,0.35);
}
.divider { text-align: center; color: var(--text2); font-size: 0.85rem; margin: 12px 0; }
.rules-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.rules-list li {
  display: flex;
  gap: 10px;
  font-size: 0.92rem;
  color: var(--text2);
  line-height: 1.5;
}
.rules-list li span:first-child { font-size: 1.2rem; flex-shrink: 0; line-height: 1.2; }

#auth-loading {
  font-size: 0.9rem;
  color: var(--text2);
}

/* ════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════ */
@media (max-width: 720px) {
  .pit-main { padding: 14px 12px 24px; gap: 12px; }
  .pit-header { padding: 14px 16px; }
  .pit-header h1 { font-size: 16px; }
  .pit-header h1 small { display: none; }
  .pit-header .room-code-badge { padding: 6px 10px; font-size: 12px; letter-spacing: 2px; }

  .hud-bar { grid-template-columns: 1fr auto; gap: 10px; padding: 10px 14px; }
  .ticker { display: none; }
  .hud-meta { gap: 16px; }
  .hud-stat-value { font-size: 18px; }

  .player-card { min-width: 124px; padding: 10px 12px; }

  .market { padding: 24px 12px 16px; min-height: 240px; }
  .market-floor { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; padding-top: 38px; }
  .market-clock { display: none; }

  .seat { min-height: 174px; padding: 10px 8px 8px; }
  .card-stack { width: 70px; height: 60px; }
  .card-stack .stack-card { width: 38px; height: 54px; }
  .card-stack .stack-card::after { font-size: 14px; }

  .hand-grid { gap: 4px; padding-top: 6px; }
  .hand-grid .commodity-slot.group-start { margin-left: 6px; }
  .commodity-slot { width: 60px; height: 92px; padding: 6px 4px; }
  .cs-icon { width: 30px; height: 30px; margin-top: 2px; }
  .cs-name { font-size: 7.5px; letter-spacing: 0.8px; }
  .cs-pts { font-size: 7.5px; }
  .cs-order { top: 3px; left: 3px; width: 17px; height: 17px; font-size: 10px; }

  .action-row { flex-direction: column; align-items: stretch; }
  .action-row .btn { width: 100%; }
  .btn-bell { margin-left: 0; order: -1; }

  .pit-landing h1 { font-size: 3.5rem; }
}

@media (max-width: 400px) {
  .commodity-slot { width: 50px; height: 76px; padding: 5px 2px; }
  .cs-icon { width: 24px; height: 24px; }
  .cs-name { display: none; }
}
