:root {
  --bg: #0b1020;
  --felt: #115c4d;
  --panel: #1c2438;
  --text: #e8eef2;
  --muted: #9bb0bd;
  --accent: #ffcc00;
  --danger: #ff4d4d;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, Noto Sans, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background: radial-gradient(circle at 50% 20%, #101635 0%, var(--bg) 60%);
}

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

.top-bar {
  display: grid;
  grid-template-columns: 160px 1fr 220px;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid #2b3553;
}
.title { font-weight: 800; letter-spacing: 1px; }
.scoreboard { text-align: center; font-variant-numeric: tabular-nums; }
.round-info { text-align: right; color: var(--muted); }

.splash { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(circle at center, rgba(16,22,53,0.92), rgba(11,16,32,0.96)); z-index: 20; }
.splash.hidden { display: none; }
.splash-card { width: min(700px, 92%); background: #0f172a; border: 1px solid #334155; border-radius: 16px; padding: 20px; box-shadow: 0 30px 80px rgba(0,0,0,0.5); }
.splash-card h2 { margin: 0 0 8px; }
.splash-card .rules { margin: 8px 0 16px 18px; line-height: 1.6; color: var(--muted); }
.start-btn { background: linear-gradient(135deg, #f59e0b, #facc15); border: none; color: #111; font-weight: 800; padding: 12px 18px; border-radius: 10px; cursor: pointer; }
.start-btn:hover { filter: brightness(1.05); }

.table {
  position: relative;
  flex: 1;
  background: radial-gradient(circle at center, var(--felt), #09463a 70%);
  border-top: 1px solid #0d3f35;
  border-bottom: 1px solid #0d3f35;
  display: grid;
  grid-template-areas:
    "north north north"
    "west center east"
    "south south south";
  grid-template-rows: 22% 1fr 22%;
  grid-template-columns: 25% 1fr 25%;
  padding: 6px;
}

.player { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.seat.north { grid-area: north; }
.seat.south { grid-area: south; }
.seat.west { grid-area: west; }
.seat.east { grid-area: east; }

.name { font-weight: 700; }
.meta { display: flex; gap: 10px; align-items: center; height: 20px; }
.bid { color: var(--accent); }
.won { color: #a0e9ff; }
.hand { display: flex; gap: 8px; }
.hand.vertical { flex-direction: column; }

/* Compact CPU hands to avoid scroll and clutter */
.hand.cpu { gap: 0; position: relative; }
.hand.cpu .card { width: 52px; height: 75px; box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
.hand.cpu.vertical .card { margin-top: -56px; }
.hand.cpu:not(.vertical) .card { margin-left: -36px; }
.hand.cpu .card:first-child { margin-top: 0; margin-left: 0; }

.center { grid-area: center; display: grid; grid-template-rows: 1fr auto; gap: 10px; padding: 8px; }
.trick-area {
  position: relative;
  display: grid;
  grid-template-areas:
    "... north ..."
    "west ... east"
    "... south ...";
  grid-template-rows: 1fr 1fr 1fr;
  grid-template-columns: 1fr 1fr 1fr;
}
.trick-slot { width: 110px; height: 160px; margin: auto; filter: drop-shadow(0 8px 12px rgba(0,0,0,0.5)); }
.deal-layer { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.flying-card { position: absolute; width: 64px; height: 96px; background: #fff; border-radius: 8px; box-shadow: 0 8px 20px rgba(0,0,0,0.4); transition: transform 0.35s ease, opacity 0.35s ease; }

.trick-slot.north { grid-area: north; }
.trick-slot.south { grid-area: south; }
.trick-slot.west { grid-area: west; }
.trick-slot.east { grid-area: east; }

.status { text-align: center; color: #fff; min-height: 24px; }

.controls {
  display: grid;
  grid-template-columns: 1fr auto auto 320px;
  gap: 10px;
  align-items: center;
  padding: 10px 16px;
  background: var(--panel);
  border-top: 1px solid #2b3553;
}
.ad-slot { display: grid; place-items: center; }
.ad-placeholder { width: 300px; height: 250px; background: #111827; color: #94a3b8; border: 1px dashed #334155; border-radius: 8px; display: grid; place-items: center; font-size: 14px; }
.bidding { display: flex; gap: 16px; align-items: center; }
.bid-input { display: flex; gap: 8px; align-items: center; }
.hint { color: var(--muted); }

.card {
  width: 84px; height: 120px; border-radius: 10px; background: #fff; color: #000;
  display: grid; place-items: center; position: relative; user-select: none; cursor: pointer;
  box-shadow: 0 8px 20px rgba(0,0,0,0.35);
}
.card img { width: 100%; height: 100%; border-radius: 10px; }
.card.back { background: linear-gradient(135deg, #17336a, #2e5cb8); color: #fff; }
.card.disabled { opacity: 0.5; pointer-events: none; }
.card.playable { outline: 3px solid var(--accent); }

.modal { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,0.6); }
.modal.hidden { display: none; }
.modal-content { background: #0f172a; border: 1px solid #334155; border-radius: 12px; width: min(720px, 92%); max-height: 80vh; overflow: auto; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid #334155; }
.modal-header button { background: transparent; border: none; color: #94a3b8; font-size: 22px; cursor: pointer; }
.modal-header button:hover { color: #e2e8f0; }
.modal-content #modalBody { padding: 12px 14px; }

.score-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.score-table th, .score-table td { border-bottom: 1px solid #334155; padding: 6px 8px; text-align: center; }
.score-table th { background: #0b1220; position: sticky; top: 0; }

.turn-indicator { color: var(--accent); font-weight: 700; }

@media (max-width: 900px) {
  .hand { gap: 4px; }
  .trick-slot { width: 88px; height: 128px; }
  .card { width: 64px; height: 96px; }
}


