/* Same felt-table palette as the Android client's ui/theme/Color.kt, so the two clients read as
   one app. */
:root {
  --felt-dark: #0b3d2e;
  --felt: #14532d;
  --felt-light: #2f7a4f;
  --gold: #d4af37;
  --cream: #fbf7f0;
  --card-red: #b3261e;
  --error-red: #cf6679;
  --ink: #1a1a1a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--felt-dark);
  color: var(--cream);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

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

button, input, select {
  font-family: inherit;
  font-size: 14px;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  background: var(--felt-light);
  color: var(--cream);
}
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-gold { background: var(--gold); color: var(--felt-dark); }
.btn-red { background: var(--card-red); color: var(--cream); }
.btn-outline { background: transparent; border: 1px solid rgba(251,247,240,0.4); color: var(--cream); }
.btn-small { padding: 6px 10px; font-size: 12px; border-radius: 6px; }

.field {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(251,247,240,0.3);
  background: rgba(255,255,255,0.06);
  color: var(--cream);
  margin-bottom: 10px;
}
.field::placeholder { color: rgba(251,247,240,0.5); }
.field:focus { outline: 2px solid var(--gold); }

.hint { font-size: 12px; color: rgba(251,247,240,0.65); margin: -4px 0 10px; }
.error-text { color: var(--error-red); font-size: 13px; margin: 6px 0; }
.success-text { color: var(--gold); font-size: 13px; margin: 6px 0; font-weight: 600; }

/* ---- auth screens ---- */
.auth-wrap {
  max-width: 380px;
  margin: 10vh auto;
  padding: 24px;
  width: 100%;
}
.auth-title { font-size: 26px; font-weight: 700; margin-bottom: 18px; color: var(--gold); }
.auth-wrap .btn { width: 100%; margin-top: 6px; }
/* display: block (not the button default of inline-block) so "Forgot password?" and
   "New here? Create an account" each get their own line instead of running together
   edge-to-edge with no space, since there's no text node between the two <button> elements
   for the browser to collapse into a gap. */
.auth-switch { display: block; background: none; border: none; color: var(--cream); text-decoration: underline; cursor: pointer; margin-top: 12px; font-size: 13px; padding: 0; text-align: left; }

/* ---- top bar (lobby/teams) ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(0,0,0,0.25);
}
.topbar h1 { font-size: 18px; margin: 0; color: var(--gold); }
.topbar .actions { display: flex; gap: 8px; }

.page { padding: 16px; max-width: 720px; margin: 0 auto; width: 100%; flex: 1; overflow-y: auto; }

.row { display: flex; align-items: center; gap: 8px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.spread { flex: 1; }

.card-item {
  background: rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 8px;
}
.card-item .title { font-size: 15px; }
.your-table-tag { font-size: 12px; font-weight: 600; color: var(--gold); }
.seated-table-tag { font-size: 12px; font-weight: 600; color: rgba(251,247,240,0.75); }
.card-item .subtitle { font-size: 12px; color: rgba(251,247,240,0.7); margin-top: 2px; }

.section-title { font-size: 15px; font-weight: 700; margin: 18px 0 8px; color: var(--gold); }
.muted { color: rgba(251,247,240,0.65); font-size: 13px; }

/* ---- game table ---- */
.status-panel {
  background: rgba(0,0,0,0.38);
  border-radius: 10px;
  padding: 8px 12px;
  margin: 10px;
}
.status-top { display: flex; align-items: center; gap: 8px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #9e9e9e; }
.status-dot.connected { background: #4caf50; }
.status-lines { flex: 1; }
.status-lines > div { margin: 2px 0; font-size: 13px; }
.status-phase { font-weight: 700; }
.status-trump { color: var(--gold); font-weight: 700; }
.status-trump-hidden { color: rgba(251,247,240,0.75); font-size: 12px; }
.status-reveal-link { color: var(--gold); font-weight: 700; cursor: pointer; font-size: 12px; text-decoration: underline; }
.status-score { color: rgba(251,247,240,0.85); font-size: 13px; }
.status-lasthand { font-size: 13px; }
.status-lasthand.won { color: var(--gold); }
.status-lasthand.lost { color: rgba(251,247,240,0.75); }

.menu-btn { font-weight: 700; cursor: pointer; padding: 2px 6px; border-radius: 6px; position: relative; }
.menu-btn:hover { background: rgba(255,255,255,0.1); }
.menu-dropdown {
  position: absolute;
  right: 0;
  top: 28px;
  background: #1e1e1e;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  min-width: 180px;
  z-index: 30;
  overflow: hidden;
}
.menu-dropdown .item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  color: var(--cream);
}
.menu-dropdown .item:hover { background: rgba(255,255,255,0.08); }

.felt-table {
  margin: 0 10px;
  flex: 1;
  min-height: 320px;
  background: var(--felt);
  border: 3px solid var(--gold);
  border-radius: 28px;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 8px;
  overflow: hidden;
}
.seat-top, .seat-bottom { display: flex; justify-content: center; }
.seat-middle-row { display: flex; align-items: center; padding: 0 2px; }
.seat-side { flex: 0 0 auto; }
.trick-slot { flex: 1 1 auto; min-width: 0; display: flex; justify-content: center; align-items: center; position: relative; }

.seat-col { display: flex; flex-direction: column; align-items: center; padding: 8px; }
.seat-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 8px;
  border-radius: 12px;
  background: rgba(0,0,0,0.22);
  border: 1px solid rgba(251,247,240,0.35);
  min-width: 64px;
}
.seat-badge.active { background: rgba(212,175,55,0.28); border: 2px solid var(--gold); }
.seat-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--cream); font-weight: 700; font-size: 13px;
  background: #808080;
  margin-bottom: 2px;
}
.seat-avatar.bot { background: var(--felt-light); }
.seat-avatar.human { background: var(--gold); color: var(--felt-dark); }
.seat-name { font-size: 12px; }
.seat-sub { font-size: 11px; color: rgba(251,247,240,0.7); }
.seat-trump { font-size: 11px; font-weight: 700; margin-top: 2px; }

.facedown-row { display: flex; margin-top: 4px; }
.facedown-row img { width: 16px; margin: 0 1px; border-radius: 3px; border: 1px solid rgba(251,247,240,0.6); }

.add-bot-btn, .force-bot-btn, .invite-btn, .remove-seat-btn { margin-top: 4px; }

.trick-label {
  font-size: 12px;
  color: rgba(251,247,240,0.85);
  max-width: 100%;
  /* Wraps onto up to 2 lines instead of truncating to one with an ellipsis — the old behavior
     hid the winner's name by default behind a tap-to-reveal tooltip nobody noticed. -webkit-
     line-clamp is a safety net for a pathologically long display name; this slot is normally
     wide enough for the whole label to fit in 1-2 lines. */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-align: center;
}
.card-face {
  border-radius: 6px;
  background: var(--cream);
  border: 1px solid rgba(0,0,0,0.35);
  aspect-ratio: 67 / 94;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex: 0 0 auto;
}
.card-face img { width: 100%; height: 100%; object-fit: contain; }
.card-face.highlighted { border: 2px solid var(--gold); box-shadow: 0 0 6px var(--gold); cursor: pointer; }
.card-face.clickable { cursor: pointer; }
.card-face.clickable:hover { transform: translateY(-3px); transition: transform 0.1s; }

.trick-fan { position: relative; }
.trick-fan-card { position: absolute; top: 0; display: flex; flex-direction: column; align-items: center; }
.trick-fan-card .seat-label { font-size: 11px; color: rgba(251,247,240,0.8); margin-top: 2px; }
.trick-caption-row { display: flex; justify-content: space-around; margin-top: 2px; }
.trick-caption-row span { font-size: 11px; color: rgba(251,247,240,0.8); }

.bidding-panel { padding: 8px 10px 0; }
.bid-row { display: flex; align-items: center; gap: 8px; overflow-x: auto; padding: 6px 0; }
.bid-amount-btn { flex: 0 0 auto; }

.hand-row {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  overflow-x: auto;
}
.hand-title { padding: 4px 10px 0; font-weight: 600; }

/* ---- dialogs ---- */
.dialog-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 16px;
}
.dialog-box {
  background: var(--felt-dark);
  border-radius: 16px;
  padding: 16px;
  max-width: 480px;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}
.dialog-title { font-weight: 700; font-size: 17px; }
.dialog-body { flex: 1; overflow-y: auto; margin: 10px 0; }
.chat-line { margin: 6px 0; }
.chat-sender { color: var(--gold); font-weight: 700; font-size: 12px; }
.chat-body { font-size: 14px; }

.history-heading { color: var(--gold); font-weight: 700; font-size: 13px; margin: 10px 0 4px; }
.history-line { font-size: 13px; margin: 2px 0; }
.history-sub { font-size: 12px; color: rgba(251,247,240,0.75); margin-left: 10px; }

/* ---- toast ---- */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.85);
  color: var(--cream);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 200;
  display: none;
  max-width: 90vw;
  text-align: center;
}

/* ---- celebration ---- */
#celebration {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 150;
  cursor: pointer;
}
#celebration .banner {
  background: rgba(11,61,46,0.9);
  border: 2px solid var(--gold);
  border-radius: 16px;
  padding: 20px 32px;
  color: var(--gold);
  font-weight: 700;
  font-size: 22px;
  text-align: center;
  animation: pop 0.4s ease-out;
}
@keyframes pop { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.confetti-piece {
  position: absolute;
  font-size: 22px;
  animation: burst 1.3s ease-out forwards;
}
@keyframes burst {
  from { transform: translate(0,0) rotate(0deg); opacity: 1; }
  to { transform: translate(var(--dx), var(--dy)) rotate(var(--spin)); opacity: 0.2; }
}

.settings-link { cursor: pointer; text-decoration: underline; font-size: 12px; color: rgba(251,247,240,0.7); }

@media (max-width: 480px) {
  .auth-wrap { margin: 6vh auto; padding: 16px; }
}
