@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;700;800;900&display=swap');

/* ──────── Design Tokens ──────── */
:root {
  --bg: #0c0e1a;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-raised: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.08);
  --border-bright: rgba(255, 255, 255, 0.14);
  --text: #eef2ff;
  --text-muted: #7c85a6;
  --accent: #6366f1;
  --accent-glow: rgba(99, 102, 241, 0.35);
  --green: #22c55e;
  --green-glow: rgba(34, 197, 94, 0.25);
  --red: #f43f5e;
  --red-glow: rgba(244, 63, 94, 0.25);
  --gold: #fbbf24;
  --gold-glow: rgba(251, 191, 36, 0.2);
  --blue: #38bdf8;
  --felt: #0a2e1f;
  --felt-light: #134e35;
  --radius: 14px;
  --radius-sm: 10px;
  --card-width: 60px;
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
}

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

body {
  min-height: 100dvh;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 60% at 10% 20%, rgba(99, 102, 241, 0.12), transparent),
    radial-gradient(ellipse 60% 50% at 90% 80%, rgba(34, 197, 94, 0.08), transparent);
  -webkit-font-smoothing: antialiased;
}

.eyebrow {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ──────── Buttons ──────── */
.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.login-button,
.suit-button,
.card-button,
.mini-button {
  min-height: 40px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.85rem;
  transition: all 180ms ease;
}

.primary-button {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #818cf8);
  box-shadow: 0 4px 16px var(--accent-glow);
  padding: 0 18px;
  border: 1px solid rgba(255,255,255,0.1);
}
.primary-button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--accent-glow);
}

.ghost-button, .mini-button {
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0 14px;
}
.ghost-button:hover:not(:disabled), .mini-button:hover:not(:disabled) {
  background: var(--surface-raised);
  border-color: var(--border-bright);
}

.danger-button {
  color: #fff;
  background: linear-gradient(135deg, var(--red), #e11d48);
  box-shadow: 0 4px 16px var(--red-glow);
  padding: 0 14px;
  border: 1px solid rgba(255,255,255,0.1);
}

/* ──────── Panels ──────── */
.login-panel,
.sync-panel,
.side-panel,
.center-table,
.score-card,
.player-seat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
}

/* ── Login ── */
.login-panel {
  padding: 16px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  align-items: center;
}

.login-panel h2 { font-size: 1rem; font-weight: 800; }

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

.login-button {
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  color: var(--text);
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.login-button strong { font-size: 0.95rem; }
.login-button small { color: var(--text-muted); font-size: 0.72rem; font-weight: 600; }
.login-button.active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #818cf8);
  border-color: rgba(255,255,255,0.2);
  box-shadow: 0 4px 20px var(--accent-glow);
}
.login-button:hover:not(.active) { background: var(--surface-raised); border-color: var(--border-bright); }

/* ── Sync ── */
.sync-panel {
  padding: 16px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  align-items: center;
}
.sync-panel h2 { margin: 0; font-size: 1rem; }
.sync-panel p { margin: 4px 0 0; color: var(--text-muted); font-size: 0.8rem; font-weight: 600; }

.sync-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.sync-controls label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.sync-controls input {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--surface);
  font-weight: 700;
  text-transform: uppercase;
  width: 140px;
}
.sync-controls input:focus { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ── Scoreboard ── */
.score-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.score-card {
  padding: 14px;
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
}
.score-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
}
.team-one::before { background: linear-gradient(90deg, var(--green), #4ade80); }
.team-two::before { background: linear-gradient(90deg, var(--blue), #7dd3fc); }

.score-card span {
  display: block;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.score-card strong {
  display: block;
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--text);
}
.score-card b {
  display: block;
  margin-top: 4px;
  font-size: 1.6rem;
  font-weight: 900;
}

/* ──────── Game Grid ──────── */
.game-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  align-items: start;
  width: 100%;
}

/* ── Side Panel ── */
.side-panel {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.panel-section { min-width: 0; }

.state-list {
  display: grid;
  gap: 0;
  margin: 0;
}
.state-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.state-list div:last-child { border-bottom: 0; }
.state-list dt { color: var(--text-muted); font-weight: 700; font-size: 0.85rem; }
.state-list dd {
  margin: 0;
  text-align: right;
  font-weight: 800;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.trick-score {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.trick-score span {
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  font-weight: 800;
  text-align: center;
  font-size: 0.85rem;
}

.event-log {
  display: grid;
  gap: 6px;
  max-height: 260px;
  margin: 0;
  padding-left: 18px;
  overflow-y: auto;
}
.event-log li {
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

/* ──────── Play Area — Flow Grid (NO absolute positioning) ──────── */
.play-area {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius);
  min-height: 560px;
  background:
    radial-gradient(ellipse 50% 40% at center, rgba(34, 197, 94, 0.1), transparent),
    linear-gradient(160deg, var(--felt), var(--felt-light) 40%, var(--felt));
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 0 40px rgba(34, 197, 94, 0.08);
  overflow: visible;
}

.seat-slot {
  display: flex;
  overflow: visible;
  padding: 8px;
}

.slot-top   { grid-column: 1 / -1; grid-row: 1; justify-content: center; }
.slot-left  { grid-column: 1;       grid-row: 2; align-items: flex-start; }
.slot-right { grid-column: 3;       grid-row: 2; align-items: flex-start; }
.slot-bottom{ grid-column: 1 / -1; grid-row: 3; justify-content: center; }

.players-ring-slot {
  width: 100%;
  overflow: visible;
  display: flex;
}

.slot-top .players-ring-slot,
.slot-bottom .players-ring-slot {
  justify-content: center;
}

.slot-top .player-seat,
.slot-bottom .player-seat {
  width: min(420px, 100%);
}

/* ── Player Seats ── */
.player-seat {
  display: grid;
  grid-template-rows: auto auto auto auto;
  gap: 8px;
  padding: 12px;
  min-width: 0;
  width: 100%;
  max-width: 420px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255,255,255, 0.06);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
  overflow: visible;
}

.seat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.seat-header h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
}
.seat-header span {
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 700;
}

.badges { display: flex; flex-wrap: wrap; gap: 5px; }
.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.8);
  background: rgba(255,255,255,0.1);
}
.badge.turn {
  color: #000;
  background: var(--gold);
  box-shadow: 0 0 12px var(--gold-glow);
}
.badge.login {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}

/* ── Cards ── */
.hand {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  row-gap: 8px;
  align-content: flex-start;
  min-height: 60px;
  overflow: visible;
  padding-top: 4px;
  padding-bottom: 12px;
}

.card-button,
.card-face {
  width: var(--card-width);
  height: auto;
  aspect-ratio: 5 / 7;
  border-radius: 10px;
  box-sizing: border-box;
  border: 1.5px solid rgba(255,255,255,0.22);
  background:
    linear-gradient(160deg, rgba(255,255,255,0.97), rgba(226,232,240,0.92)),
    #fff;
  color: #111827;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.32);
  transition: transform 200ms cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 200ms ease;
}

.card-button {
  display: grid;
  place-items: center;
  padding: 0;
}
.card-button:hover:not(:disabled) {
  transform: translateY(-10px) scale(1.08);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.48), 0 0 24px var(--accent-glow);
  z-index: 10;
  border-color: var(--accent);
}
.card-button.illegal { opacity: 0.35; filter: grayscale(0.6); }

.card-face {
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-items: center;
  justify-items: center;
  padding: 6px 4px;
  font-weight: 900;
  height: 100%;
  position: relative;
}
.card-rank { font-size: 1.1rem; line-height: 1; }
.card-suit {
  font-size: 1.5rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
}
.playing-card .corner {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}
.playing-card .corner.top-left {
  justify-self: start;
  align-self: start;
}
.playing-card .corner.bottom-right {
  justify-self: end;
  align-self: end;
  transform: rotate(180deg);
}
.playing-card .rank {
  font-size: 0.9rem;
  line-height: 1;
}
.playing-card .center-area {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
}
.playing-card .suit-icon-small {
  width: 14px;
  height: 14px;
}
.playing-card .suit-icon-large {
  width: 30px;
  height: 30px;
}
.suit-icon {
  width: 18px;
  height: 18px;
  display: inline-block;
}
.card-suit .suit-icon {
  width: 22px;
  height: 22px;
}
.inline-card {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 800;
}
.inline-joker {
  color: #4f46e5;
}
.inline-suit-icon {
  width: 16px;
  height: 16px;
}
.state-list .suit-icon-dark,
.phodi-box .suit-icon-dark {
  filter: brightness(2.2);
}
.card-red { color: var(--red); }
.card-joker {
  color: #e2e8f0;
  background:
    linear-gradient(160deg, #0f172a, #1e293b),
    #111827;
  border-color: rgba(255,255,255,0.22);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4);
}
.card-joker .suit-icon {
  filter: brightness(1.2) drop-shadow(0 4px 10px rgba(148, 163, 184, 0.4));
}

.card-back {
  display: block;
  width: 28px;
  min-height: 40px;
  border-radius: 5px;
  background:
    radial-gradient(circle at 25% 25%, rgba(255,255,255,0.18) 0 2px, transparent 2px 8px),
    radial-gradient(circle at 75% 75%, rgba(255,255,255,0.14) 0 2px, transparent 2px 8px),
    repeating-linear-gradient(135deg, rgba(59,130,246,0.35) 0 3px, rgba(30,64,175,0.35) 3px 6px),
    linear-gradient(160deg, #1e3a8a, #0f172a);
  border: 1px solid rgba(255,255,255,0.1);
}

/* ── Center Table ── */
.center-table {
  grid-column: 2;
  grid-row: 2;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
  padding: 16px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: var(--radius);
  min-height: 180px;
  align-self: center;
}

.status-line {
  color: var(--gold);
  font-weight: 800;
  font-size: 0.95rem;
  line-height: 1.35;
  text-shadow: 0 0 14px var(--gold-glow);
}

.trick-pile {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-items: center;
}

.played-card {
  display: grid;
  gap: 4px;
  justify-items: center;
  transition: all 0.4s ease;
}
.played-card span {
  font-size: 0.7rem;
  font-weight: 700;
  text-align: center;
  color: var(--text-muted);
}

/* ── Trick Result Animation ── */
.winner-card {
  animation: winnerPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.winner-card .card-face {
  box-shadow: 0 0 20px var(--gold), 0 0 40px rgba(251, 191, 36, 0.3);
  border-color: var(--gold);
}
.winner-card span {
  color: var(--gold);
  font-weight: 800;
}

.loser-card {
  animation: loserFade 0.5s ease forwards;
}

@keyframes winnerPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.15) translateY(-6px); }
  100% { transform: scale(1.08) translateY(-4px); }
}

@keyframes loserFade {
  0% { opacity: 1; transform: scale(1); }
  100% { opacity: 0.4; transform: scale(0.92); }
}

.trick-winner-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 700;
  animation: bannerSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.trick-winner-banner.team-a {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.2), rgba(34, 197, 94, 0.05));
  border: 1px solid rgba(34, 197, 94, 0.4);
  color: var(--green);
}
.trick-winner-banner.team-b {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(56, 189, 248, 0.05));
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: var(--blue);
}
.trick-winner-banner .winner-icon {
  font-size: 1.4rem;
}
.trick-winner-banner strong {
  font-size: 1rem;
}
.trick-winner-banner span:last-child {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
}

@keyframes bannerSlideIn {
  0% { opacity: 0; transform: translateY(10px) scale(0.95); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.action-panel { display: grid; gap: 10px; }
.action-panel p { margin: 0; color: var(--text-muted); font-weight: 600; font-size: 0.85rem; }
.action-row { display: flex; flex-wrap: wrap; gap: 8px; }
.suit-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.suit-button {
  min-width: 80px;
  padding: 8px 12px;
  font-size: 1rem;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background:
    linear-gradient(160deg, rgba(255,255,255,0.96), rgba(226,232,240,0.9)),
    #fff;
  border: 1px solid rgba(15,23,42,0.12);
  color: #111827;
  box-shadow: 0 8px 18px rgba(15,23,42,0.18);
}
.suit-label { font-weight: 800; }
.mini-suit .suit-icon { width: 16px; height: 16px; }
.suit-button.card-red {
  background:
    linear-gradient(160deg, rgba(255,255,255,0.96), rgba(226,232,240,0.9)),
    #fff;
  color: var(--red);
  box-shadow: 0 8px 18px rgba(15,23,42,0.18);
}
.suit-button:hover:not(:disabled) {
  transform: translateY(-2px);
}

.phodi-box {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px dashed var(--gold);
  border-radius: var(--radius-sm);
  background: rgba(251, 191, 36, 0.08);
  color: var(--gold);
}

.hidden-hand-note { color: var(--text-muted); font-weight: 700; font-size: 0.8rem; }

/* ──────── Responsive ──────── */
@media (max-width: 1100px) {
  .game-grid { grid-template-columns: 1fr; }

  .score-strip { grid-template-columns: repeat(2, 1fr); }
  .login-grid { grid-template-columns: repeat(2, 1fr); }
  .login-panel, .sync-panel { grid-template-columns: 1fr; }

  .play-area {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto auto auto;
    min-height: auto;
  }
  .slot-top    { grid-column: 1 / -1; grid-row: 1; }
  .slot-left   { grid-column: 1;       grid-row: 2; }
  .slot-right  { grid-column: 2;       grid-row: 2; }
  .center-table{ grid-column: 1 / -1; grid-row: 3; }
  .slot-bottom { grid-column: 1 / -1; grid-row: 4; }

  .player-seat { max-width: 100%; }
}

@media (max-width: 640px) {
  :root {
    --card-width: 38px;
  }

  .hand {
    gap: 3px;
    row-gap: 6px;
    padding-top: 4px;
    padding-bottom: 10px;
    min-height: 50px;
  }

  .card-button {
    padding: 0;
  }

  .card-button,
  .card-face {
    border-radius: 7px;
  }

  .app-shell { padding: 10px; }

  .topbar { gap: 8px; }
  .topbar h1 { font-size: 1.6rem; }
  .topbar-brand .logo { font-size: 1.8rem; }
  .topbar-actions { width: 100%; }
  .topbar-actions button { flex: 1; }

  .login-panel, .sync-panel { padding: 12px; }
  .login-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .login-button { padding: 10px; }

  .sync-controls { flex-direction: column; }
  .sync-controls input { width: 100%; }

  .score-strip { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .score-card { padding: 10px; }
  .score-card b { font-size: 1.3rem; }

  .side-panel { padding: 14px; }

  .play-area {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(5, auto);
    padding: 10px;
    gap: 8px;
  }
  .slot-top, .slot-left, .slot-right, .slot-bottom {
    grid-column: 1;
  }
  .slot-top    { grid-row: 1; }
  .slot-left   { grid-row: 2; }
  .center-table{ grid-column: 1; grid-row: 3; }
  .slot-right  { grid-row: 4; }
  .slot-bottom { grid-row: 5; }

  .player-seat { max-width: 100%; }
  .center-table { padding: 12px; }

  .card-button, .card-face { width: var(--card-width); }
  .card-rank { font-size: 0.85rem; }
  .card-suit { font-size: 1rem; }
  .card-face .rank { font-size: 0.7rem; }
  .card-face .suit-icon-small { width: 10px; height: 10px; }
  .card-face .suit-icon-large { width: 20px; height: 20px; }
  .card-face.card-joker .suit-icon-small { width: 14px; height: 14px; }
  .card-face.card-joker .suit-icon-large { width: 28px; height: 28px; }
  .card-suit .suit-icon { width: 16px; height: 16px; }
  .suit-button .suit-icon { width: 14px; height: 14px; }
  .inline-suit-icon { width: 12px; height: 12px; }
  .card-back { width: 20px; min-height: 28px; font-size: 0.5rem; border-radius: 4px; }

  .trick-pile { gap: 6px; }
}

/* Login screen */
.login-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(12, 14, 26, 0.94), rgba(10, 46, 31, 0.88)),
    repeating-linear-gradient(45deg, rgba(255,255,255,0.035) 0 1px, transparent 1px 18px);
}

.login-stage {
  width: min(1040px, 100%);
  min-height: 620px;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 24px;
  background: rgba(255,255,255,0.045);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(18px);
}

.login-hero {
  position: relative;
  display: grid;
  align-content: space-between;
  min-height: 620px;
  padding: 38px;
  background:
    linear-gradient(150deg, rgba(251,191,36,0.18), transparent 28%),
    linear-gradient(340deg, rgba(56,189,248,0.16), transparent 34%),
    linear-gradient(135deg, rgba(10,46,31,0.86), rgba(12,14,26,0.72));
  border-right: 1px solid rgba(255,255,255,0.1);
}

.phantx-mark {
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 18px;
  color: #0c0e1a;
  background: linear-gradient(135deg, #fbbf24, #f97316);
  box-shadow: 0 18px 42px rgba(249, 115, 22, 0.25);
  font-size: 1.35rem;
  font-weight: 900;
}

.card-fan {
  position: absolute;
  inset: 125px 60px auto auto;
  width: 360px;
  height: 330px;
}

.fan-card {
  position: absolute;
  width: 150px;
  height: 210px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-items: center;
  justify-items: center;
  padding: 12px;
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 16px;
  color: #111827;
  background:
    linear-gradient(160deg, rgba(255,255,255,0.96), rgba(226,232,240,0.9)),
    #fff;
  box-shadow: 0 28px 60px rgba(0, 0, 0, 0.34);
  font-weight: 900;
}
.fan-card .rank {
  font-size: 1.4rem;
  line-height: 1;
}
.fan-card .center-area {
  min-height: 64px;
}
.fan-card .suit-icon-small {
  width: 18px;
  height: 18px;
}
.fan-card .suit-icon-large {
  width: 56px;
  height: 56px;
}

.fan-card-one {
  left: 18px;
  top: 48px;
  transform: rotate(-15deg);
  color: #e11d48;
  z-index: 2;
}

.fan-card-two {
  left: 112px;
  top: 20px;
  transform: rotate(3deg);
  color: #0f172a;
  z-index: 3;
}
.fan-card-three {
  left: 198px;
  top: 68px;
  transform: rotate(17deg);
  color: #e2e8f0;
  background:
    linear-gradient(160deg, #0f172a, #1e293b),
    #111827;
  z-index: 4;
}

.fan-card-three .suit-icon {
  filter: brightness(1.2) drop-shadow(0 4px 10px rgba(148, 163, 184, 0.4));
}


.hero-copy {
  position: relative;
  z-index: 1;
  max-width: 440px;
}

.hero-copy h1 {
  margin: 10px 0 0;
  font-size: clamp(4.2rem, 10vw, 7.8rem);
  line-height: 0.82;
  letter-spacing: 0;
  color: #fff;
  text-shadow: 0 18px 46px rgba(0,0,0,0.32);
}

.login-card {
  display: grid;
  align-content: center;
  gap: 18px;
  padding: clamp(28px, 5vw, 54px);
  background:
    linear-gradient(180deg, rgba(15,23,42,0.72), rgba(12,14,26,0.94)),
    rgba(12,14,26,0.9);
}

.login-logo {
  width: fit-content;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid rgba(251,191,36,0.28);
  border-radius: 999px;
  color: var(--gold);
  background: rgba(251,191,36,0.08);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.login-title {
  margin: 4px 0 0;
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 0.96;
  letter-spacing: 0;
}

.login-subtitle {
  max-width: 360px;
  color: #aeb8d4;
  font-size: 1rem;
  line-height: 1.55;
}

.login-form {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.login-form label {
  color: #cbd5e1;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-form input {
  width: 100%;
  min-height: 52px;
  padding: 0 15px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  color: var(--text);
  background: rgba(255,255,255,0.06);
  outline: none;
  transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.login-form input::placeholder {
  color: rgba(174,184,212,0.64);
}

.login-form input:focus {
  border-color: rgba(251,191,36,0.72);
  background: rgba(255,255,255,0.09);
  box-shadow: 0 0 0 4px rgba(251,191,36,0.12);
}

.login-submit {
  min-height: 54px;
  margin-top: 8px;
  border-radius: 12px;
  font-size: 0.95rem;
  background: linear-gradient(135deg, #fbbf24, #f97316);
  box-shadow: 0 16px 34px rgba(249, 115, 22, 0.24);
}

.login-submit:hover:not(:disabled) {
  box-shadow: 0 20px 44px rgba(249, 115, 22, 0.32);
}

.login-error {
  min-height: 22px;
  color: #fecdd3;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.35;
}

.login-hint:empty {
  display: none;
}

@media (max-width: 1100px) {
  .login-stage {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .login-hero {
    min-height: 300px;
    border-right: 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
  }

  .card-fan {
    inset: 58px 30px auto auto;
    transform: scale(0.74);
    transform-origin: top right;
  }
}

@media (max-width: 640px) {
  .login-screen {
    padding: 12px;
    place-items: stretch;
  }

  .login-stage {
    min-height: calc(100dvh - 24px);
    border-radius: 18px;
  }

  .login-hero {
    min-height: 210px;
    padding: 22px;
  }

  .phantx-mark {
    width: 54px;
    height: 54px;
    border-radius: 14px;
    font-size: 1rem;
  }

  .card-fan {
    inset: 34px -2px auto auto;
    transform: scale(0.46);
  }

  .hero-copy h1 {
    font-size: clamp(3rem, 18vw, 4.4rem);
  }

  .login-card {
    padding: 24px;
    align-content: start;
  }

  .login-title {
    font-size: 2.25rem;
  }

  .login-subtitle {
    font-size: 0.94rem;
  }
}

/* Modern game UI refresh */
.app-shell {
  display: grid;
  grid-template-rows: auto auto 1fr;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  width: min(1520px, 100%);
  margin: 0 auto;
  padding: 22px;
  gap: 18px;
}

.topbar {
  position: sticky;
  top: 12px;
  z-index: 20;
  padding: 14px 16px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.075), rgba(255,255,255,0.035)),
    rgba(12,14,26,0.78);
  box-shadow: 0 20px 55px rgba(0,0,0,0.24);
  backdrop-filter: blur(18px);
}

.topbar-brand .logo {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(251,191,36,0.36);
  border-radius: 14px;
  color: #0c0e1a;
  background: linear-gradient(135deg, #fbbf24, #f97316);
  font-size: 1rem;
  font-weight: 900;
  filter: none;
  box-shadow: 0 14px 30px rgba(249,115,22,0.24);
}
.topbar-brand .logo-icon {
  width: 26px;
  height: 26px;
}

.topbar h1 {
  letter-spacing: 0;
}

.user-badge {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid rgba(34,197,94,0.24);
  border-radius: 999px;
  color: #bbf7d0;
  background: rgba(34,197,94,0.09);
  font-size: 0.82rem;
  font-weight: 800;
}

.score-strip {
  gap: 12px;
}

.score-card {
  min-height: 112px;
  padding: 16px;
  background:
    linear-gradient(145deg, rgba(255,255,255,0.085), rgba(255,255,255,0.035)),
    rgba(15,23,42,0.64);
  border-color: rgba(255,255,255,0.1);
  box-shadow: 0 18px 42px rgba(0,0,0,0.18);
}

.score-card::after {
  content: '';
  position: absolute;
  inset: auto 12px 12px auto;
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: rgba(255,255,255,0.045);
}

.score-card span {
  color: #96a3c7;
}

.score-card strong {
  position: relative;
  z-index: 1;
  min-height: 26px;
  color: #f8fafc;
  font-size: 0.95rem;
}

.score-card b {
  position: relative;
  z-index: 1;
  margin-top: 8px;
  font-size: 2rem;
}

.game-grid {
  grid-template-columns: minmax(288px, 330px) minmax(0, 1fr);
  gap: 18px;
}

.side-panel {
  position: sticky;
  top: 104px;
  padding: 18px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.035)),
    rgba(15,23,42,0.7);
  border-color: rgba(255,255,255,0.1);
  box-shadow: 0 20px 55px rgba(0,0,0,0.22);
}

.panel-section {
  padding: 0 0 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.panel-section:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.state-list div {
  padding: 10px 0;
}

.state-list dd {
  color: #f8fafc;
}

.trick-score span {
  border: 1px solid rgba(255,255,255,0.08);
  background:
    linear-gradient(135deg, rgba(34,197,94,0.13), rgba(56,189,248,0.08)),
    rgba(255,255,255,0.05);
}

.event-log {
  max-height: 300px;
  padding: 0 4px 0 22px;
}

.event-log li {
  padding: 7px 0;
  color: #b6c0d8;
  border-bottom: 1px solid rgba(255,255,255,0.055);
}

.event-log li:last-child {
  border-bottom: 0;
}

.play-area {
  position: relative;
  min-height: 650px;
  gap: 14px;
  padding: 18px;
  border-radius: 22px;
  background:
    radial-gradient(circle at center, rgba(251,191,36,0.12), transparent 21%),
    radial-gradient(ellipse 70% 55% at 50% 45%, rgba(34,197,94,0.16), transparent 58%),
    linear-gradient(150deg, #073021 0%, #0c5137 45%, #061d18 100%);
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow:
    inset 0 0 0 7px rgba(255,255,255,0.035),
    inset 0 0 80px rgba(0,0,0,0.28),
    0 28px 80px rgba(0,0,0,0.28);
}

.play-area::before {
  content: '';
  position: absolute;
  inset: 18px;
  border: 1px solid rgba(251,191,36,0.18);
  border-radius: 17px;
  pointer-events: none;
}

.player-seat {
  padding: 14px;
  border-radius: 16px;
  position: relative;
  background:
    linear-gradient(145deg, rgba(15,23,42,0.78), rgba(15,23,42,0.48)),
    rgba(0,0,0,0.28);
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 18px 42px rgba(0,0,0,0.2);
}

.player-seat.is-self {
  padding: 16px;
  width: min(520px, 100%);
  max-width: 520px;
  border-color: rgba(99,102,241,0.65);
  box-shadow:
    0 20px 46px rgba(0,0,0,0.28),
    0 0 0 2px rgba(99,102,241,0.35),
    0 0 28px rgba(99,102,241,0.35);
  background:
    linear-gradient(145deg, rgba(30,41,59,0.88), rgba(15,23,42,0.58)),
    rgba(0,0,0,0.32);
}
.player-seat.is-self::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 20px;
  border: 1px solid rgba(129,140,248,0.4);
  pointer-events: none;
}

.seat-header h3 {
  color: #f8fafc;
  font-size: 1rem;
}

.seat-header span {
  color: #98a4c0;
}

.badge {
  height: 24px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.08);
}

.badge.turn {
  color: #111827;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
}

.badge.login {
  background: linear-gradient(135deg, var(--accent), #38bdf8);
}

.hand {
  gap: 6px;
  row-gap: 8px;
  min-height: 70px;
}

.seat-actions {
  display: grid;
  gap: 8px;
  min-height: 0;
}

.seat-action-label {
  color: #fde68a;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.seat-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.seat-actions .action-button {
  min-width: 88px;
}

.mini-suit {
  min-width: 44px;
  min-height: 38px;
  padding: 0 10px;
}

.card-button,
.card-face {
  width: var(--card-width);
  height: auto;
  aspect-ratio: 5 / 7;
  border-radius: 10px;
  box-sizing: border-box;
}

.card-button {
  background: transparent;
  border: 0;
  box-shadow: none;
}

.card-face {
  border: 1.5px solid rgba(255,255,255,0.22);
  background:
    linear-gradient(160deg, rgba(255,255,255,0.97), rgba(226,232,240,0.92)),
    #fff;
  box-shadow: 0 14px 32px rgba(0,0,0,0.3);
  font-weight: 900;
}

.card-joker {
  color: #e2e8f0;
  background:
    linear-gradient(160deg, #0f172a, #1e293b),
    #111827;
  border-color: rgba(255,255,255,0.22);
  box-shadow: 0 16px 42px rgba(0,0,0,0.42);
}

.card-joker .suit-icon {
  object-fit: contain;
  filter: brightness(1.2) drop-shadow(0 4px 10px rgba(148, 163, 184, 0.4));
}

.card-button:hover:not(:disabled) .card-face {
  border-color: rgba(251,191,36,0.72);
  box-shadow: 0 18px 34px rgba(0,0,0,0.34), 0 0 0 3px rgba(251,191,36,0.15);
}

.card-back {
  width: 34px;
  min-height: 48px;
  border-radius: 8px;
  background:
    radial-gradient(circle at 25% 25%, rgba(255,255,255,0.18) 0 2px, transparent 2px 8px),
    radial-gradient(circle at 75% 75%, rgba(255,255,255,0.14) 0 2px, transparent 2px 8px),
    repeating-linear-gradient(135deg, rgba(59,130,246,0.35) 0 3px, rgba(30,64,175,0.35) 3px 6px),
    linear-gradient(160deg, #1e3a8a, #0f172a);
  box-shadow: 0 10px 20px rgba(0,0,0,0.22);
}

.center-table {
  min-height: 245px;
  padding: 18px;
  border-radius: 18px;
  background:
    linear-gradient(145deg, rgba(3,7,18,0.5), rgba(3,7,18,0.22)),
    rgba(0,0,0,0.18);
  border: 1px solid rgba(255,255,255,0.11);
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.025),
    0 22px 48px rgba(0,0,0,0.22);
}

.status-line {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(251,191,36,0.26);
  border-radius: 999px;
  color: #fde68a;
  background: rgba(251,191,36,0.08);
  font-size: 0.9rem;
}

.trick-pile {
  min-height: 112px;
  padding: 12px;
  border: 1px dashed rgba(255,255,255,0.12);
  border-radius: 16px;
  background: rgba(255,255,255,0.035);
}

.action-panel {
  min-height: 76px;
  padding: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  background: rgba(255,255,255,0.045);
}

.action-row,
.suit-actions {
  gap: 10px;
}

.action-button {
  min-width: 112px;
}

.suit-button {
  min-width: 116px;
  border-radius: 12px;
}

.seat-actions .mini-suit {
  min-width: 44px;
  min-height: 38px;
  padding: 0 10px;
}

.trick-winner-banner {
  justify-content: center;
  border-radius: 14px;
}

@media (max-width: 1100px) {
  .topbar,
  .side-panel {
    position: static;
  }

  .game-grid {
    grid-template-columns: 1fr;
  }

  .play-area {
    min-height: auto;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 10px;
  }

  .topbar {
    top: 0;
    border-radius: 14px;
  }

  .user-badge {
    width: 100%;
    justify-content: center;
  }

  .score-card {
    min-height: 94px;
  }

  .play-area {
    padding: 10px;
    border-radius: 18px;
  }

  .play-area::before {
    inset: 8px;
    border-radius: 14px;
  }

  .hand {
    gap: 3px;
    row-gap: 6px;
    min-height: 50px;
  }

  .card-button,
  .card-face {
    width: var(--card-width);
    border-radius: 7px;
  }

  .card-face .rank { font-size: 0.7rem; }
  .card-face .suit-icon-small { width: 10px; height: 10px; }
  .card-face .suit-icon-large { width: 20px; height: 20px; }
  .card-face { padding: 4px 3px; }
  .card-face.card-joker .suit-icon-small { width: 14px; height: 14px; }
  .card-face.card-joker .suit-icon-large { width: 28px; height: 28px; }

  .card-back {
    width: 20px;
    min-height: 28px;
    border-radius: 4px;
  }

  .player-seat {
    padding: 10px;
  }

  .player-seat.is-self {
    padding: 12px;
    width: 100%;
    max-width: 100%;
  }
}

/* Lobby styles */
.lobby-screen .login-stage {
  width: min(720px, 100%);
  grid-template-columns: 1fr;
  min-height: auto;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.lobby-screen .login-card {
  border-radius: 22px;
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 26px 70px rgba(0,0,0,0.38);
}


.room-selection-card {
  text-align: left;
  align-content: start;
}

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

.lobby-title {
  display: flex;
  align-items: center;
  gap: 14px;
}

.lobby-title .login-logo {
  margin: 0;
}

.lobby-title .login-title {
  margin: 0;
}

.lobby-title .login-subtitle {
  margin-top: 6px;
}

.lobby-screen .login-subtitle {
  max-width: 100%;
}

.lobby-actions {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  margin-top: 1.5rem;
}

.lobby-choice {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  flex-shrink: 0;
}

.lobby-choice button {
  min-height: 44px;
  white-space: nowrap;
  border-radius: 999px;
  font-size: 0.9rem;
  letter-spacing: 0.01em;
  padding: 0 16px !important;
  flex: 1;
}

.lobby-choice button.is-active {
  border-color: rgba(251,191,36,0.7);
  box-shadow: 0 0 0 2px rgba(251,191,36,0.2);
}

.lobby-panel {
  padding: 0.25rem 0 0;
}

.lobby-form {
  gap: 0.75rem;
}

.lobby-form button {
  width: 100%;
}

.secondary-button {
  color: #c7d2fe;
  background: rgba(15,23,42,0.55);
  box-shadow: none;
  padding: 0 18px;
  border: 1px solid rgba(129,140,248,0.55);
}

.secondary-button:hover:not(:disabled) {
  transform: translateY(-1px);
  background: rgba(30,41,59,0.6);
  box-shadow: 0 8px 20px rgba(15,23,42,0.35);
}

@media (max-width: 768px) {
  .lobby-header {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
  }

  .lobby-choice {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .lobby-screen .login-stage {
    width: 100%;
  }

  .lobby-screen .login-card {
    padding: 20px;
  }

  .lobby-header {
    flex-direction: column;
    gap: 1.2rem;
    align-items: stretch;
  }

  .lobby-choice {
    grid-template-columns: repeat(2, 1fr);
  }

  .lobby-title {
    gap: 10px;
  }

  .lobby-title .login-title {
    font-size: 1.8rem;
  }

  .login-logo {
    padding: 0 8px !important;
    font-size: 0.65rem !important;
  }
}

.teams-container {
  display: flex;
  gap: 1.5rem;
  margin-top: 1.5rem;
}
.team-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: rgba(255,255,255,0.02);
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.05);
}
.team-column h3 {
  color: #fff;
  font-size: 1rem;
  margin: 0 0 0.5rem 0;
  text-align: center;
}
.seat-btn {
  padding: 0.75rem;
  font-size: 0.9rem;
  text-align: center;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.seat-btn[data-taken="true"] {
  background: rgba(251,191,36,0.15);
  color: rgba(255,255,255,0.8);
  border-color: rgba(251,191,36,0.4);
  cursor: not-allowed;
}

