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

:root {
  --bg: #1a1f2e;
  --surface: #252d3d;
  --surface2: #2e3a50;
  --border: #3a4560;
  --text: #e8ecf4;
  --text-muted: #8892a8;
  --accent: #4f8ef7;
  --accent-hover: #3d7ae8;
  --red: #e25c5c;
  --green: #4caf7d;
  --warn: #f5a623;
  --suit-red: #e25c5c;
  --suit-black: #e8ecf4;
  --card-bg: #fff;
  --card-border: #d0d4dc;
  --radius: 8px;
  --radius-lg: 14px;
}

html, body { height: 100%; font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 16px; }

a { color: var(--accent); text-decoration: none; }
.muted { color: var(--text-muted); font-size: 0.875rem; }
code { background: var(--surface2); padding: 2px 6px; border-radius: 4px; font-family: monospace; font-size: 1.1em; letter-spacing: 0.05em; }

/* ── Layout ──────────────────────────────────────────────────── */
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.logo { font-size: 1.25rem; font-weight: 700; color: var(--text); }
nav { display: flex; align-items: center; gap: 12px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }

main { padding: 24px; max-width: 1100px; margin: 0 auto; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 24px;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius); border: none;
  font-size: 0.9rem; font-weight: 600; cursor: pointer;
  background: var(--surface2); color: var(--text); transition: background 0.15s;
}
.btn:hover { background: var(--border); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-large { padding: 14px 32px; font-size: 1.1rem; }

/* ── Hero ─────────────────────────────────────────────────────── */
.hero {
  display: flex; flex-direction: column; align-items: center;
  gap: 24px; text-align: center; padding: 80px 16px;
}
.hero h1 { font-size: 3rem; font-weight: 800; }
.subtitle { color: var(--text-muted); font-size: 1.1rem; }
.rules-summary {
  display: flex; gap: 32px; flex-wrap: wrap; justify-content: center;
}
.rule-item { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.rule-item .icon { font-size: 2rem; font-weight: 700; color: var(--accent); }

/* ── Lobby ───────────────────────────────────────────────────── */
.lobby { display: flex; flex-direction: column; gap: 24px; max-width: 600px; }
.lobby h2 { font-size: 1.5rem; margin-bottom: 4px; }
.create-form { display: flex; flex-direction: column; gap: 16px; }
.create-form h3, .open-rooms h3 { margin-bottom: 8px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 0.875rem; color: var(--text-muted); }
label select, label input[type=number] {
  padding: 8px 12px; background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 0.95rem;
}
label small { color: var(--text-muted); font-size: 0.75rem; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; }

/* ── Game root ───────────────────────────────────────────────── */
.game-root { display: flex; flex-direction: column; min-height: calc(100vh - 57px); }
.screen { flex: 1; }

/* ── Waiting screen ──────────────────────────────────────────── */
.waiting-card { max-width: 480px; margin: 60px auto; display: flex; flex-direction: column; gap: 16px; }
.waiting-card h2 { font-size: 1.5rem; }
.player-list { display: flex; flex-direction: column; gap: 8px; }
.player-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; background: var(--surface2); border-radius: var(--radius);
}
.player-item img { width: 28px; height: 28px; border-radius: 50%; }
.player-item .bot-badge { font-size: 0.7rem; background: var(--border); padding: 2px 6px; border-radius: 4px; color: var(--text-muted); }

/* ── Game topbar ─────────────────────────────────────────────── */
.game-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
  flex-wrap: wrap; gap: 8px;
}
.round-info { display: flex; gap: 12px; font-size: 0.875rem; font-weight: 600; }
.trump-indicator {
  font-size: 1.5rem; font-weight: 700; min-width: 60px; text-align: center;
}
.trump-indicator.red { color: var(--suit-red); }
.trump-indicator.black { color: var(--suit-black); }

/* ── Scores overlay ──────────────────────────────────────────── */
.scores-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center; z-index: 200;
}
.scores-card { max-width: 700px; width: 95%; max-height: 80vh; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.scores-card h3 { font-size: 1.25rem; }
.scores-table-wrap { overflow-x: auto; }

/* ── Bidding panel ───────────────────────────────────────────── */
.panel { margin: 16px; }
.panel h3 { margin-bottom: 12px; }
.bid-status { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.bid-chip {
  padding: 4px 10px; border-radius: 20px; font-size: 0.8rem;
  background: var(--surface2); border: 1px solid var(--border);
}
.bid-chip.submitted { background: var(--green); color: #fff; border-color: var(--green); }
.bid-chip.adjusting { background: var(--warn); color: #000; border-color: var(--warn); }
#bid-input-area { display: flex; gap: 8px; align-items: center; }
.bid-input {
  width: 80px; padding: 8px 12px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-size: 1.1rem; text-align: center;
}
.notice { padding: 10px 14px; border-radius: var(--radius); font-size: 0.875rem; margin-top: 10px; }
.notice-warn { background: rgba(245,166,35,0.15); border: 1px solid var(--warn); color: var(--warn); }

/* ── Bid reveal ──────────────────────────────────────────────── */
.bid-reveal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 300; gap: 20px;
}
.bid-reveal h3 { font-size: 1.5rem; }
#bid-reveal-list { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; }
.bid-reveal-item {
  background: var(--surface); border: 2px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px 28px; text-align: center;
  min-width: 120px;
}
.bid-reveal-item .player-name { font-size: 0.875rem; color: var(--text-muted); }
.bid-reveal-item .bid-value { font-size: 2.5rem; font-weight: 800; color: var(--accent); }

/* ── Opponents ───────────────────────────────────────────────── */
.opponents-area {
  display: flex; justify-content: center; gap: 16px; flex-wrap: wrap;
  padding: 12px 16px;
}
.opponent-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 16px; text-align: center;
  min-width: 110px;
}
.opponent-box.current-turn { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(79,142,247,0.3); }
.opponent-box img { width: 36px; height: 36px; border-radius: 50%; margin-bottom: 6px; }
.opponent-name { font-size: 0.8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 90px; }
.opponent-stats { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }
.opponent-cards { display: flex; gap: 2px; justify-content: center; margin-top: 6px; flex-wrap: wrap; }
.card-back {
  width: 18px; height: 26px; border-radius: 3px;
  background: linear-gradient(135deg, #3b5bdb 0%, #1c3a8a 100%);
  border: 1px solid #2a4bbf;
}

/* ── Trick area ──────────────────────────────────────────────── */
.trick-area {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.trick-cards { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; align-items: center; }
.trick-entry { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.trick-entry .player-label { font-size: 0.7rem; color: var(--text-muted); }

/* ── Playing card ─────────────────────────────────────────────── */
.playing-card {
  width: 62px; height: 90px; border-radius: 6px;
  background: var(--card-bg); border: 1.5px solid var(--card-border);
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 5px 6px; cursor: default; user-select: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  position: relative;
}
.playing-card.playable { cursor: pointer; transition: transform 0.1s, box-shadow 0.1s; }
.playing-card.playable:hover { transform: translateY(-8px); box-shadow: 0 8px 18px rgba(0,0,0,0.4); }
.playing-card.selected { transform: translateY(-12px); box-shadow: 0 0 0 3px var(--accent), 0 8px 18px rgba(0,0,0,0.4); }
.card-rank { font-size: 0.9rem; font-weight: 700; line-height: 1; }
.card-suit-icon { font-size: 1.3rem; line-height: 1; text-align: center; }
.card-rank-bottom { font-size: 0.9rem; font-weight: 700; line-height: 1; transform: rotate(180deg); align-self: flex-end; }
.card-red { color: var(--suit-red); }
.card-black { color: #1a1a2e; }

/* ── Hand area ───────────────────────────────────────────────── */
.hand-area { padding: 8px 16px 20px; }
.hand-cards {
  display: flex; justify-content: center; flex-wrap: wrap; gap: 6px;
  min-height: 100px;
}
.hand-msg { text-align: center; margin-top: 8px; }

/* ── Round end ───────────────────────────────────────────────── */
.round-end-card { max-width: 560px; margin: 40px auto; display: flex; flex-direction: column; gap: 16px; }
.round-end-card h2 { font-size: 1.4rem; }
.round-results-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.round-results-table th, .round-results-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.round-results-table .exact { color: var(--green); font-weight: 700; }
.round-results-table .miss { color: var(--red); }

/* ── Game end ─────────────────────────────────────────────────── */
.game-end-card { max-width: 480px; margin: 40px auto; display: flex; flex-direction: column; gap: 16px; text-align: center; }
.game-end-card h2 { font-size: 1.8rem; }
.winner-row { background: rgba(79,142,247,0.1); border: 1px solid var(--accent); border-radius: var(--radius); padding: 10px; }
.winner-row td { font-weight: 700; color: var(--accent); }

/* ── Animations ──────────────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.3s ease-out; }
