/* Fun Bridge — bold, phone-first. */

:root {
  --bg: #11041f;
  --bg2: #1d0a33;
  --felt: #0f6b4a;
  --felt-edge: #0a4f37;
  --ink: #f7f3ff;
  --muted: #b7a8d4;
  --accent: #ff5d8f;
  --accent2: #ffd166;
  --good: #3ddc84;
  --card-bg: #fffdf6;
  --card-red: #e0354f;
  --card-black: #232038;
  --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(120% 100% at 50% 0%, var(--bg2), var(--bg) 70%);
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, sans-serif;
  overscroll-behavior: none;
}

#app, .screen { height: 100%; }

.screen {
  display: flex;
  flex-direction: column;
  max-width: 560px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
}

.center-screen { justify-content: center; align-items: center; gap: 10px; }

.muted { color: var(--muted); font-size: 0.9rem; text-align: center; }

/* ---------- brand / home ---------- */

.brand {
  font-size: 3.4rem;
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: 0.04em;
  text-align: center;
  background: linear-gradient(135deg, var(--accent2), var(--accent) 60%, #b388ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 14px rgba(255, 93, 143, 0.35));
}

.brand.small { font-size: 1.3rem; text-align: left; }

.tagline { color: var(--muted); margin: 0 0 18px; }

.home-controls { display: flex; flex-direction: column; gap: 12px; width: min(320px, 86vw); }

#join-code {
  font-size: 1.8rem;
  font-weight: 800;
  text-align: center;
  letter-spacing: 0.5em;
  text-indent: 0.5em;
  padding: 12px;
  border-radius: var(--radius);
  border: 2px solid #3c2b59;
  background: #241040;
  color: var(--ink);
  outline: none;
}
#join-code:focus { border-color: var(--accent); }
#join-code.bad { border-color: var(--card-red); animation: shake 0.25s; }
@keyframes shake { 25% { translate: -4px 0; } 75% { translate: 4px 0; } }

.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid #3c2b59; }

/* ---------- buttons ---------- */

.btn {
  border: none;
  border-radius: var(--radius);
  padding: 14px 22px;
  font-size: 1.05rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  color: #2a0b18;
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  box-shadow: 0 6px 0 #97244c, 0 10px 24px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: transform 0.06s, box-shadow 0.06s;
}
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 #97244c; }
.btn:disabled { filter: grayscale(0.8) brightness(0.6); cursor: not-allowed; }
.btn.big { font-size: 1.2rem; padding: 16px 24px; }
.btn.alt { background: linear-gradient(135deg, #7af0c0, #38b6ff); box-shadow: 0 6px 0 #1f6e99, 0 10px 24px rgba(0,0,0,0.35); color: #06283c; }
.btn.alt:active:not(:disabled) { box-shadow: 0 2px 0 #1f6e99; }
.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 2px dashed #5b4485;
  box-shadow: none;
}
.btn.small-btn { padding: 10px 16px; font-size: 0.95rem; }

.chip-btn {
  border: 1px solid #5b4485;
  background: #2a1547;
  color: var(--ink);
  border-radius: 999px;
  padding: 4px 12px;
  font-weight: 700;
  cursor: pointer;
}

/* ---------- lobby ---------- */

.lobby { gap: 14px; }
.lobby-head { display: flex; justify-content: space-between; align-items: center; }

.pin-box {
  display: flex; align-items: center; gap: 10px;
  background: #2a1547; border-radius: 999px; padding: 6px 8px 6px 14px;
}
.pin-label { font-size: 0.65rem; color: var(--muted); letter-spacing: 0.1em; }
.pin { font-size: 1.4rem; font-weight: 900; letter-spacing: 0.18em; color: var(--accent2); }

.panel { background: rgba(255, 255, 255, 0.05); border-radius: var(--radius); padding: 14px; }
.panel h2 { margin: 0 0 10px; font-size: 1rem; }
.panel .count { color: var(--accent2); }

.field span { font-size: 0.8rem; color: var(--muted); }
.name-row { display: flex; gap: 8px; margin-top: 6px; }
.name-row input {
  flex: 1; padding: 10px 12px; border-radius: 12px;
  border: 2px solid #3c2b59; background: #241040; color: var(--ink);
  font-size: 1rem; outline: none;
}
.name-row input:focus { border-color: var(--accent); }

.player-list { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.player-list li { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.player-list .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--good); }
.player-list .offline .dot { background: #777; }
.player-list .pname { flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { font-size: 0.6rem; padding: 2px 8px; border-radius: 999px; background: #3c2b59; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.tag-you { background: var(--accent); color: #2a0b18; }
.tag-host { background: var(--accent2); color: #2a0b18; }
.remove-bot { margin-left: auto; }

.lobby-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.lobby-foot .btn { width: 100%; }

/* ---------- game ---------- */

.game { gap: 8px; }

.game-head { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip {
  background: #2a1547; border-radius: 999px; padding: 6px 12px;
  font-weight: 900; font-size: 0.95rem; display: flex; align-items: center; gap: 6px;
}
.chip small { font-weight: 600; color: var(--muted); }
.chip.red { color: #ff8da8; }
.chip.contract { background: linear-gradient(135deg, #3c2b59, #2a1547); border: 1px solid #5b4485; }
.chip.partner { border: 1px solid #5b4485; }
.muted-chip { color: var(--muted); font-weight: 600; }
.pin-chip { margin-left: auto; color: var(--accent2); }

.table {
  position: relative;
  flex: 1;
  min-height: 270px;
  border-radius: 24px;
  background:
    radial-gradient(80% 70% at 50% 40%, #15815b, var(--felt) 60%, var(--felt-edge));
  box-shadow: inset 0 0 0 6px rgba(0, 0, 0, 0.18), inset 0 10px 40px rgba(0,0,0,0.25);
  overflow: hidden;
}

.seat-area { position: absolute; display: flex; justify-content: center; }
.seat-area.top { top: 8px; left: 0; right: 0; }
.seat-area.bottom { bottom: 8px; left: 0; right: 0; }
.seat-area.left { left: 8px; top: 50%; transform: translateY(-50%); }
.seat-area.right { right: 8px; top: 50%; transform: translateY(-50%); }

.player {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 10px; border-radius: 14px;
  background: rgba(0, 0, 0, 0.25);
  min-width: 76px; max-width: 120px;
}
.seat-area.left .player, .seat-area.right .player { max-width: 86px; }
.player.turn { box-shadow: 0 0 0 3px var(--accent2), 0 0 22px rgba(255, 209, 102, 0.55); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 3px var(--accent2), 0 0 34px rgba(255, 209, 102, 0.85); } }
.player.me { background: rgba(0, 0, 0, 0.45); }
.avatar {
  position: relative;
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.05rem; font-weight: 900;
  color: #2a0b18;
  background: linear-gradient(135deg, var(--accent2), var(--accent));
}
.avatar.bot { background: linear-gradient(135deg, #7af0c0, #38b6ff); color: #06283c; }
.off-dot { position: absolute; right: -4px; top: -2px; width: 9px; height: 9px; background: #ff5d5d; border-radius: 50%; }
.pmeta { display: flex; flex-direction: column; align-items: center; }
.player .pname { font-size: 0.78rem; font-weight: 800; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ptricks { font-size: 0.6rem; color: var(--accent2); letter-spacing: 0.1em; }
.ptricks small { color: var(--muted); }

.bid-bubble {
  position: absolute; bottom: -14px;
  background: var(--ink); color: #2a0b18;
  font-weight: 900; font-size: 0.8rem;
  border-radius: 999px; padding: 2px 10px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.4);
}

.trick-area { position: absolute; inset: 0; pointer-events: none; }
.trick-card { position: absolute; }
.trick-card.top { top: 27%; left: 50%; transform: translateX(-50%); }
.trick-card.bottom { bottom: 27%; left: 50%; transform: translateX(-50%); }
.trick-card.left { left: 30%; top: 50%; transform: translateY(-50%); }
.trick-card.right { right: 30%; top: 50%; transform: translateY(-50%); }

/* ---------- cards ---------- */

.card {
  width: 52px; height: 74px;
  background: var(--card-bg);
  border-radius: 9px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 900;
  user-select: none;
  flex-shrink: 0;
  transition: transform 0.12s;
}
.card .card-rank { font-size: 1.35rem; line-height: 1; }
.card .card-suit { font-size: 1.25rem; line-height: 1.1; }
.card.red { color: var(--card-red); }
.card.black { color: var(--card-black); }
.card.mini { width: 40px; height: 56px; border-radius: 7px; }
.card.mini .card-rank { font-size: 1.05rem; }
.card.mini .card-suit { font-size: 0.95rem; }
.card.faded { opacity: 0.45; }
.card.disabled { filter: brightness(0.55); }
.card.selected { transform: translateY(-14px) scale(1.06); box-shadow: 0 8px 18px rgba(0,0,0,0.5), 0 0 0 3px var(--accent); }

/* ---------- hand ---------- */

.hand-dock { min-height: 92px; }
.hand {
  display: flex;
  padding: 14px 10px 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.hand::-webkit-scrollbar { display: none; }
.hand .card { margin-right: -18px; position: relative; }
.hand .card:last-child { margin-right: 0; }
/* On your turn, playable cards sit on top of the dimmed ones so their
   right edge isn't hidden by the next card in the overlapping fan. */
.hand .card.disabled { z-index: 1; }
.hand .card.playable { z-index: 10; }
.hand .card.playable.selected { z-index: 20; }

/* ---------- action dock / sheets ---------- */

.action-dock { display: flex; flex-direction: column; }

.waiting, .your-turn, .spectator-note {
  text-align: center; color: var(--muted); font-weight: 700; padding: 6px;
}
.your-turn { color: var(--accent2); animation: pulse-text 1.2s infinite; }
@keyframes pulse-text { 50% { opacity: 0.5; } }

.play-dock { display: flex; justify-content: center; padding: 4px; }

.sheet {
  background: #241040;
  border: 1px solid #3c2b59;
  border-radius: var(--radius);
  padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
}
.sheet-title { font-size: 0.8rem; color: var(--muted); font-weight: 700; text-align: center; }

.pick-row { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.pick {
  min-width: 46px; height: 46px;
  border-radius: 12px;
  border: 2px solid #3c2b59;
  background: #1d0a33;
  color: var(--ink);
  font-size: 1.15rem; font-weight: 900;
  cursor: pointer;
}
.pick.red { color: #ff8da8; }
.pick:disabled { opacity: 0.25; cursor: not-allowed; }
.pick.on { border-color: var(--accent); background: #3c1130; box-shadow: 0 0 12px rgba(255, 93, 143, 0.5); }

.sheet-actions { display: flex; gap: 10px; justify-content: center; }
.sheet-actions .btn { flex: 1; max-width: 220px; }

.partner-sheet { max-height: 46vh; overflow-y: auto; }
.partner-grid { display: flex; flex-direction: column; gap: 8px; }
.partner-row { display: flex; gap: 4px; overflow-x: auto; padding: 4px 0; }
.partner-row .card { cursor: pointer; }
.partner-row .card.selected { transform: translateY(-6px) scale(1.05); }

/* ---------- result overlay ---------- */

.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(13, 3, 26, 0.82);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.overlay-card {
  background: var(--bg2);
  border-radius: 24px;
  padding: 30px 24px;
  text-align: center;
  display: flex; flex-direction: column; gap: 14px;
  max-width: 420px; width: 100%;
  border: 2px solid #3c2b59;
}
.overlay-card.win { border-color: var(--accent2); box-shadow: 0 0 60px rgba(255, 209, 102, 0.35); }
.overlay-card h1 { margin: 0; font-size: 2rem; }
.overlay-card p { margin: 0; color: var(--muted); }

.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.confetti span {
  position: absolute;
  top: -10%;
  left: calc(var(--i) * 4.1%);
  font-size: 1.6rem;
  animation: fall 2.6s linear infinite;
  animation-delay: calc(var(--i) * -0.21s);
}
@keyframes fall {
  to { transform: translateY(115vh) rotate(540deg); }
}

/* ---------- toast ---------- */

.toast {
  position: fixed; left: 50%; bottom: 30px; z-index: 99;
  transform: translate(-50%, 20px);
  background: var(--ink); color: #2a0b18;
  font-weight: 800;
  padding: 10px 18px; border-radius: 999px;
  opacity: 0; transition: all 0.25s;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Slightly larger cards on bigger screens */
@media (min-width: 480px) {
  .card { width: 58px; height: 82px; }
  .hand .card { margin-right: -14px; }
}
