:root {
  --bg: #0f3d2e;
  --bg2: #0c3326;
  --panel: #ffffff;
  --ink: #1c2b25;
  --muted: #6b7a73;
  --accent: #2e8b57;
  --accent-ink: #ffffff;
  --red: #b3261e;
  --line: #d7e0db;
  --shadow: 0 4px 18px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  background: radial-gradient(circle at 50% 0%, var(--bg), var(--bg2));
  color: var(--ink);
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--red); font-size: 13px; margin-top: 8px; }
.spacer { flex: 1; }
.code {
  font-family: Consolas, monospace;
  background: rgba(255,255,255,.12);
  padding: 2px 8px; border-radius: 6px; letter-spacing: 2px;
}
.code.big { font-size: 20px; }

/* ---------- screens ---------- */
.screen { min-height: 100vh; display: flex; flex-direction: column; }
#screen-auth { align-items: center; justify-content: center; }

/* ---------- auth ---------- */
.auth-card {
  background: var(--panel); border-radius: 16px; box-shadow: var(--shadow);
  padding: 28px 32px; width: 340px; text-align: center;
}
.auth-card h1 { margin: 0 0 4px; font-size: 30px; color: var(--accent); }
.tabs { display: flex; gap: 6px; margin: 18px 0 14px; }
.tab {
  flex: 1; padding: 8px; border: 1px solid var(--line); background: #f4f7f5;
  border-radius: 8px; cursor: pointer; font-size: 14px;
}
.tab.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
#auth-form { display: flex; flex-direction: column; gap: 12px; }
#auth-form label { text-align: left; font-size: 13px; color: var(--muted); }
#auth-form input {
  width: 100%; padding: 10px; margin-top: 4px; font-size: 15px;
  border: 1px solid var(--line); border-radius: 8px;
}
#auth-form button {
  margin-top: 6px; padding: 11px; font-size: 15px; border: 0; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink); cursor: pointer;
}

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px; color: #fff;
}
.brand { font-weight: 700; font-size: 18px; }
.phase {
  background: rgba(255,255,255,.18); padding: 4px 12px; border-radius: 20px;
  font-size: 13px; text-transform: uppercase; letter-spacing: 1px;
}
button.ghost {
  background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.4);
  padding: 6px 12px; border-radius: 8px; cursor: pointer;
}
button.ghost.danger { border-color: rgba(255,100,100,.6); color: #ffaaaa; }
button.ghost.danger:hover { background: rgba(255,80,80,.15); }
.role {
  font-size: 13px; color: rgba(255,255,255,.75); font-weight: 500;
}

/* ---------- lobby ---------- */
#screen-lobby { padding-bottom: 40px; }
.lobby-grid { display: flex; gap: 16px; padding: 0 18px; flex-wrap: wrap; }
.panel {
  background: var(--panel); border-radius: 14px; box-shadow: var(--shadow);
  padding: 16px 18px; margin: 14px 18px 0;
}
.lobby-grid .panel { margin-top: 0; flex: 1 1 260px; }
.panel h2 { margin: 0 0 12px; font-size: 17px; }
form .row { display: flex; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
form label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
form input, form select {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px;
}
form button {
  padding: 9px 18px; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-size: 14px;
}
#lobby-table { width: 100%; border-collapse: collapse; font-size: 14px; }
#lobby-table th, #lobby-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
#lobby-table th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
.badge { padding: 2px 10px; border-radius: 12px; font-size: 12px; }
.badge.waiting { background: #e8f3ec; color: var(--accent); }
.badge.playing { background: #fdecea; color: var(--red); }
.badge.finished { background: #eceff1; color: #607d8b; }
button.mini { padding: 5px 12px; border: 0; border-radius: 6px; cursor: pointer; background: var(--accent); color: #fff; }

/* ---------- game ---------- */
#game-body { flex: 1; display: flex; flex-direction: column; padding: 0 18px 24px; gap: 14px; }
.info-strip {
  background: rgba(255,255,255,.92); border-radius: 12px; padding: 10px 16px;
  font-size: 14px; display: flex; gap: 18px; flex-wrap: wrap; box-shadow: var(--shadow);
}
.info-strip b { color: var(--accent); }

#table-area { display: flex; flex-direction: column; gap: 12px; }
.players { display: flex; gap: 12px; flex-wrap: wrap; }
.player {
  background: rgba(255,255,255,.92); border-radius: 12px; padding: 10px 14px;
  min-width: 130px; box-shadow: var(--shadow); font-size: 13px;
  transition: outline-color .15s;
}
.player .name { font-weight: 700; font-size: 14px; }
.player.turn { outline: 3px solid var(--accent); outline-offset: 2px; }
.player.playing-for.turn { outline-color: #e67e22; }
.player .stat { color: var(--muted); margin-top: 4px; }
.face-row { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 8px; }
.back-row { display: flex; gap: 3px; flex-wrap: wrap; margin-top: 8px; }
.card.small { width: 38px; height: 54px; border-radius: 5px; padding: 2px; }
.card.small img { border-radius: 3px; }

/* suit colors */
.suit-red { color: #c0392b; font-weight: 700; }
.suit-black { color: #1a1a1a; font-weight: 700; }

/* playing-for highlight */
.player.playing-for {
  outline: 3px solid #e67e22;
  outline-offset: 2px;
  background: #fff8f0;
}
.pf-badge {
  display: inline-block; font-size: 11px; font-weight: 700;
  background: #e67e22; color: #fff; padding: 1px 7px;
  border-radius: 10px; margin-left: 6px; vertical-align: middle;
}
.pf-hint { color: #e67e22; font-size: 14px; font-weight: 600; }

/* pickup & snos on the table (face-down during auction) */
.pickup-table { display: flex; gap: 24px; justify-content: center; align-items: center; min-height: 54px; }
.table-group { display: flex; gap: 5px; align-items: center; }
.table-group .card { width: 48px; height: 68px; border-radius: 7px; padding: 3px; }
.pickup-label { font-size: 12px; color: #fff; opacity: .7; margin-right: 6px; }

/* current trick on the table */
.trick { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap;
  min-height: 96px; align-items: center; }
.trick-slot { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.trick-who { font-size: 12px; color: #fff; opacity: .85; }

.hand-area { display: flex; flex-direction: column; gap: 6px; }
.hand { display: flex; gap: 8px; flex-wrap: wrap; }
/* ===== Playing Cards ===== */
.card {
  width: 56px; height: 80px; border-radius: 7px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  cursor: default; user-select: none; overflow: hidden;
  line-height: 0; padding: 3px;
}
.card img { width: 100%; height: 100%; display: block; border-radius: 4px; }
.card.clickable { cursor: pointer; transition: transform .1s, box-shadow .1s; }
.card.clickable:hover { transform: translateY(-10px); box-shadow: 0 8px 16px rgba(0,0,0,.35); }
.card.selected {
  outline: 3px solid var(--accent); outline-offset: 1px;
  transform: translateY(-6px);
}
.card.trick-fly {
  background: #fff; box-shadow: 0 4px 12px rgba(0,0,0,.4); border-radius: 7px; padding: 3px;
  line-height: 0; overflow: hidden;
}

.action-panel {
  background: rgba(255,255,255,.95); border-radius: 12px; padding: 14px 16px;
  box-shadow: var(--shadow); min-height: 58px;
}
.action-panel .hint { color: var(--muted); font-size: 14px; }
.action-panel .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.action-panel button {
  padding: 8px 14px; border: 1px solid #c8d5ce; border-radius: 8px; cursor: pointer;
  background: #dce8e0; font-size: 14px;
}
.action-panel button.primary { background: var(--accent); color: #fff; }
.action-panel button.danger { background: var(--red); color: #fff; }
.action-panel .snos-grid { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

/* ---------- proposal ---------- */
.proposal-box {
  margin-top: 10px; padding: 10px 14px;
  background: #fff9e6; border: 1px solid #e6d9a0; border-radius: 10px;
}
.proposal-text { font-size: 14px; color: #5a4e2e; }
.proposal-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.proposal-btns { margin-top: 6px; }
.proposal-indicator { color: #8b6914; font-weight: 600; }

/* ---------- overlay (scoring / game over) ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center; z-index: 10;
}
.overlay-card {
  background: #fff; border-radius: 16px; box-shadow: var(--shadow);
  padding: 24px 28px; width: min(560px, 92vw); max-height: 85vh; overflow: auto;
}
.overlay-card h2 { margin: 0 0 12px; color: var(--accent); }
#overlay-body .line { padding: 5px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
#overlay-next { margin-top: 16px; padding: 10px 20px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; cursor: pointer; font-size: 15px; }
.overlay-actions { margin-top: 16px; text-align: center; }
.overlay-actions button { padding: 10px 20px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; cursor: pointer; font-size: 15px; }
table.results { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 14px; }
table.results th, table.results td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; }

.waiting { text-align: center; color: #fff; margin-top: 60px; }
.waiting .code { font-size: 26px; letter-spacing: 4px; }
.waiting button { margin-top: 16px; padding: 8px 16px; border: 0; border-radius: 8px; background: var(--red); color: #fff; cursor: pointer; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1c2b25; color: #fff; padding: 10px 18px; border-radius: 10px;
  box-shadow: var(--shadow); z-index: 20; font-size: 14px;
}
