/* Baithak Games — shared BRIGHT theme (matches the hub: cream→peach→rose→sky) */
:root {
  --ink: #3a2c1c;
  --muted: #8a755c;
  --paper: #fffdf8;
  --display: 'Baloo 2', system-ui, sans-serif;
  --gold: #ffb020;
  --gold-light: #ffd166;
  --gold-deep: #c77e00;
  --acc: #e11d48;
  --acc2: #f59e0b;
  --danger: #e11d48;
  --card-bg: #fffdf8;
  --line: #eadfc8;
  --radius: 18px;
  --text: #3a2c1c;
  --text-dim: #8a755c;
  --cream: #fff8e7;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: linear-gradient(165deg, #fff8e7 0%, #ffefd9 32%, #ffe3ec 64%, #d9ecff 100%);
  background-attachment: fixed;
  min-height: 100vh;
  min-height: 100dvh;
}

.screen { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px; }
.hidden { display: none !important; }

/* ---- viewport lock (v4): game pages never scroll; the game UI sits on the
   animated background as a self-contained experience. Inner containers may
   scroll (lobbies, feeds) but html/body never do. ---- */
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body[data-bgfx] { height: 100dvh; max-height: 100dvh; }
/* multiplayer shell: #app fills the viewport */
body[data-bgfx] #app {
  height: 100dvh; max-height: 100dvh;
  display: flex; flex-direction: column; overflow: hidden;
}
/* solo shell: topbar keeps natural height, main takes the rest */
body[data-bgfx] > header.topbar { flex: 0 0 auto; position: relative; z-index: 1; }
body[data-bgfx] > main {
  flex: 1 1 auto; min-height: 0; width: 100%; min-width: 0;
  overflow-y: auto; overscroll-behavior: contain;
  position: relative; z-index: 1;
}
/* screens inside #app: fill it; safe centering keeps content centered when it
   fits but top-aligns (never clips) when it overflows */
#app .screen {
  min-height: 0; flex: 1 1 auto; max-height: 100%; width: 100%;
  overflow-y: auto; overscroll-behavior: contain;
  justify-content: center;
  justify-content: safe center;
}

.card {
  background: var(--paper);
  border: 2px solid rgba(255, 255, 255, .9);
  border-radius: 22px;
  padding: 24px;
  box-shadow: 0 4px 14px rgba(120, 80, 20, .10), 0 18px 40px -18px rgba(120, 80, 20, .25);
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.card h1 { margin: 0 0 8px; font-size: 36px; font-family: var(--display); font-weight: 800; }
.card h2 { margin: 0 0 8px; font-family: var(--display); font-weight: 800; }
.card h3 { font-family: var(--display); font-weight: 800; }
.tagline { color: var(--muted); margin: 0 0 20px; font-size: 16px; font-weight: 600; }

.btn {
  border: 0; border-radius: 999px; padding: 12px 24px;
  font-size: 16px; font-weight: 800; cursor: pointer;
  font-family: inherit; transition: transform .1s;
}
.btn:active { transform: scale(.96); }
.btn-gold {
  background: linear-gradient(180deg, var(--gold-light), var(--gold));
  color: #2a1a00;
  box-shadow: 0 4px 0 var(--gold-deep), 0 8px 20px rgba(255,176,32,.35);
}
.btn-ghost {
  background: rgba(255, 255, 255, .75); color: var(--ink);
  border: 2px solid var(--line);
}
.btn-big { width: 100%; font-size: 18px; margin-top: 12px; }
.btn-small { padding: 8px 16px; font-size: 14px; }

/* lobby buttons: block-level, stacked with clear gaps — never overlapping,
   even if an older cached stylesheet is in play */
#screen-lobby .btn { display: block; }
#btn-addbot { margin: 12px auto 0; }

.name-input, .code-input {
  width: 100%; padding: 12px 16px; border-radius: 12px;
  border: 2px solid var(--line); background: #fff;
  color: var(--ink); font-size: 16px; margin-bottom: 8px; font-family: inherit;
}
.name-input::placeholder, .code-input::placeholder { color: var(--muted); }

.seats { display: flex; flex-direction: column; gap: 8px; margin: 16px 0; }
.seat-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 12px;
  background: rgba(120, 80, 20, .06);
}
.seat-row .host-badge { color: var(--gold-deep); font-size: 12px; font-weight: 800; }

/* game bar */
.game-bar {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; max-width: 480px; padding: 12px 16px; gap: 8px;
}
.score-chip {
  background: var(--paper); border: 2px solid var(--line);
  border-radius: 999px; padding: 8px 16px; font-weight: 800; font-size: 18px;
  box-shadow: 0 2px 8px rgba(120, 80, 20, .08);
}
.turn-label { font-weight: 800; color: var(--acc); font-size: 15px; text-align: center; }

.action-bar { display: flex; gap: 8px; padding: 12px; flex-wrap: wrap; justify-content: center; }

/* chat */
#chat-drawer {
  position: fixed; right: 0; top: 0; bottom: 0; width: min(360px, 92vw);
  background: var(--paper); border-left: 2px solid var(--line);
  color: var(--ink);
  display: flex; flex-direction: column; z-index: 50;
  box-shadow: -12px 0 32px rgba(120, 80, 20, .12);
  animation: slideIn .25s ease;
}
@keyframes slideIn { from { transform: translateX(100%); } to { transform: none; } }
.chat-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); font-weight: 800; font-family: var(--display); }
.chat-head button { background: none; border: 0; color: var(--ink); font-size: 18px; cursor: pointer; }
#chat-msgs { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.chat-msg { background: rgba(120, 80, 20, .06); border-radius: 10px; padding: 8px 12px; font-size: 14px; }
.chat-msg .nm { color: var(--acc); font-weight: 800; font-size: 12px; }
.chat-input-row { display: flex; gap: 8px; padding: 12px; }
.chat-input-row input { flex: 1; padding: 10px 14px; border-radius: 999px; border: 2px solid var(--line); background: #fff; color: var(--ink); font-family: inherit; }

/* toasts */
#toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: var(--paper); border: 2px solid var(--gold);
  color: var(--ink);
  border-radius: 999px; padding: 10px 20px; font-weight: 700;
  animation: toastPop .3s cubic-bezier(.34,1.56,.64,1);
  box-shadow: 0 4px 16px rgba(120, 80, 20, .18);
}
@keyframes toastPop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* modal */
#modal { position: fixed; inset: 0; background: rgba(58, 44, 28, .45); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-card { background: var(--paper); border: 2px solid var(--gold); border-radius: 20px; padding: 28px; max-width: 380px; width: 100%; text-align: center; animation: toastPop .3s cubic-bezier(.34,1.56,.64,1); color: var(--ink); }
.modal-card h3 { margin: 0 0 10px; font-size: 22px; font-family: var(--display); }
.modal-card p { color: var(--muted); margin: 0 0 20px; }
.modal-card .btn-row { display: flex; gap: 10px; justify-content: center; }

/* confetti */
.confetti { position: fixed; width: 10px; height: 10px; z-index: 300; pointer-events: none; animation: confettiFall 2.5s ease-out forwards; }
@keyframes confettiFall {
  0% { transform: translateY(-10px) rotate(0); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

.over-card h2 { font-size: 32px; }
.btn-row { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }

/* ---- BaithakBG shared animated background layer ----
   The script inserts <canvas class="bgfx-canvas"> as the FIRST child of
   <body> (plus a .bgfx-scrim div when the page doesn't define one); these
   rules keep them behind content and never interactive.
   NOTE: baithak.css is now v4 — game pages must use ../shared/baithak.css?v=5. */
.bgfx-canvas { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.bgfx-scrim {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(255,250,238,.70), rgba(255,250,238,.34) 45%, rgba(255,250,238,.62));
}
body[data-bgfx] #app { position: relative; z-index: 1; }
@media (prefers-reduced-motion: reduce) {
  .bgfx-canvas { display: none !important; }
}
