/* styles.css */
:root {
  --bg: #0b0f14;
  --panel: #141c24;
  --text: #e6eef7;
  --muted: #9bb0c3;
  --accent: #49a6ff;
  --ok: #2ecc71;
  --barH: 52px;

  /* Card base size (+20%) */
  --cardW: 94px;
  --cardH: 132px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  height: 100%;
  min-height: 100%;
  background: #000;
  background-image: url('/images/roomback.jpg');
  background-size: cover;
  background-position: center center;
  background-attachment: fixed;
}

/* Top bar - minimal, overlay */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 12px;
  background: rgba(13, 20, 27, 0.7);
  border-bottom: 1px solid rgba(15, 27, 40, 0.7);
  backdrop-filter: blur(6px);
}
.topbar .brand { display: flex; align-items: center; gap: 10px; }
.topbar .back { color: var(--muted); text-decoration: none; }
.topbar .controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.topbar .controls .smallbtn { padding: 6px 10px; font-size: 13px; }
.badge { background: #3a3f46; padding: 2px 8px; border-radius: 20px; font-size: 12px; }
.badge.ok { background: #1f4d2f; color: #a7f3d0; }

/* Basic controls */
input, select, button {
  background: #0f1720; color: var(--text); border: 1px solid #243243; padding: 6px 8px; border-radius: 4px;
}
button { cursor: pointer; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.muted { color: var(--muted); }

/* Lobby layout */
.wrap { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; padding: 12px; max-width: 1200px; margin: 0 auto; }
.panel { background: var(--panel); border: 1px solid #1e2a36; border-radius: 8px; padding: 10px; }
.panel h3 { margin: 6px 0 10px; font-weight: 600; }
.row { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.row.wrap { flex-wrap: wrap; }
.list { display: flex; flex-direction: column; gap: 6px; }
.list-item { display: flex; justify-content: space-between; align-items: center; background: #0e1620; border: 1px solid #1c2a3a; border-radius: 6px; padding: 8px; }
.ev { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: #a8c3dd; font-size: 12px; }
.events { max-height: 220px; overflow: auto; border: 1px solid #1e2c3d; border-radius: 6px; padding: 6px; background: #0e1620; }

/* Ensure lobby content clears the fixed topbar */
body.lobby .wrap {
  margin-top: calc(var(--barH) + 10px);
}

/* Invite panel helpers */
.invite-panel .invite-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.invite-panel .invite-link { width: 100%; max-width: 480px; }

/* Deposit invoice prominence */
#depositInvoiceRow { display: flex; align-items: flex-start; gap: 8px; }
#depositInvoiceRow.prominent {
  background: #0e1620;
  border: 1px solid #1c2a3a;
  border-radius: 8px;
  padding: 8px;
}
.invoice-text {
  width: 100%;
  height: 96px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.35;
  color: #eaf4ff;
  background: #0a141e;
  border: 1px solid #2a3a4e;
  border-radius: 6px;
  padding: 8px;
}
.invoice-text.highlight {
  box-shadow: 0 0 0 2px rgba(73,166,255,0.35);
  border-color: #49a6ff;
}

/* QR styles */
.qrwrap { display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
.qrbox { padding:8px; background:#0e1620; border:1px solid #1c2a3a; border-radius:6px; }
.qrbox canvas { display:block; width:196px; height:196px; }

/* Stage (room pages) */
.stage {
  position: relative;
  width: 100%;
  height: 100vh;
  padding-top: var(--barH);
  overflow: hidden;
}
.table-wrap {
  position: relative;
  width: 100%;
  height: calc(100vh - var(--barH));
  margin: 0 auto;
  overflow: hidden;
  border-radius: 16px;
  box-shadow: inset 0 0 240px rgba(0,0,0,0.55);
}

/* 3x2 positional grid: 5 seats + 1 action box */
.sitgrid {
  position: absolute; inset: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  gap: 10px;
  padding: 14px;
}
.cell { position: relative; display: flex; align-items: center; justify-content: center; padding: 6px; }

/* Seat boxes */
.seat { width: min(500px, 96%); }
.seat .seatbox {
  background: rgba(8,12,16,0.45);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 10px;
  min-height: 80px;
  backdrop-filter: blur(4px);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.seat .seatbox.folded { opacity: 0.6; }
.seat .seatbox:hover { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(0,0,0,0.35); }

/* Highlight current turn */
.seat .seatbox.turn {
  border-color: #ff8c1a;
  box-shadow: 0 0 0 2px rgba(255,140,26,0.35), 0 8px 18px rgba(0,0,0,0.45);
}

.namepill {
  display: inline-block; padding: 4px 8px; margin-bottom: 6px; border-radius: 999px;
  background: rgba(0,0,0,0.35); border: 1px solid rgba(255,255,255,0.08);
  font-weight: 600; font-size: 13px; backdrop-filter: blur(2px);
  cursor: pointer;
}

/* Seat row: video + cards side-by-side */
.seatrow { display: flex; align-items: center; gap: 8px; }

/* Mini video area (slightly smaller to make room for bigger cards) */
.av {
  width: 140px;
  height: 105px;
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  flex: 0 0 auto;
  cursor: pointer;
}
.av video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  cursor: default;
}
.av .badge {
  position: absolute;
  left: 6px; top: 6px;
  font-size: 11px; padding: 0 6px;
  background: rgba(0,0,0,0.5);
}

/* Cards */
.cards { position: relative; height: var(--cardH); width: max-content; pointer-events: none; }
.cardholder { position: absolute; top: 0; left: 0; width: var(--cardW); height: var(--cardH); }
.cardholder.hole { top: -8px; }
.cardimg {
  display: block; width: var(--cardW); height: var(--cardH); object-fit: cover; border-radius: 6px;
  box-shadow: 0 10px 18px rgba(0,0,0,0.35), 0 0 0 1px rgba(255,255,255,0.06) inset; background: #0b0f14;
}
.cardback {
  width: var(--cardW); height: var(--cardH); border-radius: 6px; background: linear-gradient(135deg, #8c0f1f, #4a0a14);
  box-shadow: 0 10px 18px rgba(0,0,0,0.35), 0 0 0 1px rgba(255,255,255,0.06) inset; background-size: cover; background-position: center;
}

/* Center info */
.center-info {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  text-align: center; font-weight: 600; color: #d8f3e5; text-shadow: 0 1px 0 #093018;
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 8px 12px;
  backdrop-filter: blur(2px);
}

/* Action box */
.actionbox {
  width: min(520px, 96%);
  background: rgba(8,12,16,0.55);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 10px;
  backdrop-filter: blur(6px);
}
.actionbox .hdr {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 8px;
}
.actionbox .hdr .muted { font-size: 13px; }
.actionbox .controls { display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); gap: 8px; }
.actionbox .controls .wide { grid-column: span 2; }
.actionbox .controls .bigbtn { padding: 10px 8px; font-weight: 600; }
button.deal { background: #1d3a24; border-color: #2a5f39; }

/* Subcontrols (ante, transfer) */
.subcontrols { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.subcontrols .subrow { display: grid; grid-template-columns: 56px 1fr 100px 1fr; gap: 8px; align-items: center; }
.subcontrols .subrow .lbl { color: var(--muted); font-size: 13px; }

/* Overlay (events + results) */
.overlay {
  position: fixed; inset: 0; z-index: 1200;
  display: none;
  align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(0,0,0,0.55);
}
.overlay.open { display: flex; }
.overlay .panel {
  width: min(900px, 96vw);
  max-height: 90vh;
  overflow: auto;
  background: #0d141b;
  border: 1px solid #1e2a36;
  border-radius: 12px;
  box-shadow: 0 14px 40px rgba(0,0,0,0.5);
}
.overlay .head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid #0f1b28;
  background: #0c1219;
}
.overlay .body { padding: 10px 12px; }
.overlay .foot { display: flex; gap: 8px; justify-content: flex-end; padding: 10px 12px; border-top: 1px solid #0f1b28; }

/* Results formatting */
.results .resultWrap { border: 1px solid #2b394a; border-radius: 6px; padding: 8px; background: rgba(14,22,32,0.8); }
.results .heading { font-weight: 600; margin-bottom: 6px; }
.resLine { display: grid; grid-template-columns: 200px 140px 1fr; gap: 8px; padding: 2px 0; }
.resLine.win { background: #15321f; }

/* QR Scan overlay */
.scanwrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
#scanVideo {
  width: 100%;
  max-width: 560px;
  border-radius: 10px;
  background: #000;
  outline: 1px solid rgba(255,255,255,0.08);
}
.scanframe {
  position: absolute;
  width: min(75%, 420px);
  height: min(75%, 420px);
  border: 2px solid rgba(73,166,255,0.8);
  border-radius: 12px;
  box-shadow: 0 0 0 200vmax rgba(0,0,0,0.25) inset;
  pointer-events: none;
}

/* Responsive tweaks */
@media (max-width: 1100px) {
  .actionbox .controls { grid-template-columns: repeat(4, minmax(0,1fr)); }
}
@media (max-width: 900px) {
  .sitgrid {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(6, minmax(120px, 1fr));
  }
  .actionbox .controls { grid-template-columns: repeat(4, minmax(0,1fr)); }
  .subcontrols .subrow { grid-template-columns: 50px 1fr 90px 1fr; }
}
@media (max-width: 700px) {
  .actionbox .controls { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .resLine { grid-template-columns: 140px 120px 1fr; }
  .subcontrols .subrow { grid-template-columns: 46px 1fr 80px 1fr; }
}

