/* ============================================================
   Bonava Game Night — shared.css
   Dark "game night" theme, mobile-first, big tap targets.
   Every game page + the landing page link this file.
   Per-game accent comes in via  html { --accent: #xxx }  set by
   the game definition in shared.js (BNG.mount).
   ============================================================ */

:root {
  --bg: #0d1017;
  --bg2: #131824;
  --card: #171d2b;
  --card2: #1d2436;
  --line: #2a3348;
  --text: #eef1f7;
  --muted: #94a0b8;
  --accent: #e5484d;          /* overridden per game */
  --good: #37c26e;
  --bad: #e5484d;
  --gold: #f0c34e;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(0,0,0,.35);
}

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

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  min-height: 100%;
}
body { padding-bottom: env(safe-area-inset-bottom); }

h1,h2,h3 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
p { margin: .35em 0; }
a { color: var(--accent); text-decoration: none; }

button, input, select {
  font: inherit; color: inherit;
  touch-action: manipulation;
}
button { cursor: pointer; user-select: none; -webkit-user-select: none; }

/* ---------- layout shell ---------- */
.wrap { max-width: 760px; margin: 0 auto; padding: 0 12px 90px; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px calc(10px);
  padding-top: calc(10px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar .back {
  display: flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--line);
  color: var(--text); font-size: 20px; text-decoration: none;
}
.topbar .ttl {
  flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0;
  font-size: 18px; font-weight: 800;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar .ttl .ico { font-size: 22px; }
.topbar .tools { display: flex; gap: 6px; }
.iconbtn {
  min-width: 44px; min-height: 44px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--line);
  font-size: 18px; line-height: 1;
}
.iconbtn:active { background: var(--card2); }

/* ---------- cards / sections ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin: 12px 0;
}
.card > h3 {
  font-size: 13px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin-bottom: 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.sub { color: var(--muted); font-size: 13px; }

/* ---------- scoreboard chips ---------- */
.scoreboard {
  display: flex; gap: 8px; overflow-x: auto; padding: 12px 2px 6px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.scoreboard::-webkit-scrollbar { display: none; }
.pchip {
  flex: 0 0 auto; min-width: 96px; max-width: 150px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 9px 12px; position: relative;
}
.pchip.leader { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.pchip.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.pchip .nm {
  display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 600; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pchip .tot { font-size: 24px; font-weight: 800; margin-top: 1px; font-variant-numeric: tabular-nums; }
.pchip .crown { position: absolute; top: -9px; right: 8px; font-size: 15px; }
.pchip .bar { height: 4px; border-radius: 3px; background: var(--bg2); margin-top: 6px; overflow: hidden; }
.pchip .bar i { display: block; height: 100%; border-radius: 3px; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto; display: inline-block; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 10px 18px; border-radius: 13px;
  background: var(--card2); border: 1px solid var(--line);
  font-size: 16px; font-weight: 700; color: var(--text); width: auto;
}
.btn:active { transform: scale(.985); }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn.big { width: 100%; min-height: 58px; font-size: 18px; }
.btn.ghost { background: transparent; }
.btn.danger { color: #ff8b8f; border-color: #5c2a2e; }
.btn.small { min-height: 40px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .38; pointer-events: none; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.btnrow .btn { flex: 1; }

/* chip-grid: the "easy click boxes" for standardized scoring */
.chipgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.chipgrid.c3 { grid-template-columns: repeat(3, 1fr); }
.chipgrid.c5 { grid-template-columns: repeat(5, 1fr); }
.chipgrid .chip {
  min-height: 52px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card2); font-size: 16.5px; font-weight: 700;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.chipgrid .chip small { font-size: 10.5px; font-weight: 600; color: var(--muted); }
.chipgrid .chip:active { background: var(--accent); color: #fff; }
.chipgrid .chip:active small { color: #fff; }
.chipgrid .chip:disabled { opacity: .35; pointer-events: none; }

/* tokens (added values you can tap to remove) */
.tokens { display: flex; flex-wrap: wrap; gap: 6px; min-height: 30px; margin: 8px 0; }
.tokens .tok {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 11px; font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.tokens .tok:active { background: var(--bad); }
.tokens .hint { color: var(--muted); font-size: 12.5px; align-self: center; }

.bigval {
  font-size: 40px; font-weight: 800; text-align: center; margin: 4px 0;
  font-variant-numeric: tabular-nums;
}
.bigval.neg { color: #ff9b9f; }

/* ---------- player entry cells ---------- */
.cellrow {
  display: flex; align-items: center; gap: 10px; padding: 9px 4px;
  border-bottom: 1px solid var(--line);
}
.cellrow:last-child { border-bottom: none; }
.cellrow .who { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cellbtn {
  min-width: 84px; min-height: 48px; border-radius: 11px;
  background: var(--bg2); border: 1px dashed var(--line);
  font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--muted);
}
.cellbtn.filled { border-style: solid; color: var(--text); background: var(--card2); }
.cellbtn.neg { color: #7ee2a2; }   /* negative = good in golf-style games */

/* steppers */
.stepper { display: inline-flex; align-items: center; gap: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.stepper button { width: 48px; height: 48px; background: var(--card2); border: none; font-size: 22px; font-weight: 800; }
.stepper button:active { background: var(--accent); color:#fff; }
.stepper .val { min-width: 64px; text-align: center; font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; background: var(--bg2); align-self: stretch; display:flex; align-items:center; justify-content:center; border-left:1px solid var(--line); border-right:1px solid var(--line);}

/* ---------- history table ---------- */
.tblwrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.hist { border-collapse: collapse; width: 100%; font-size: 14px; }
table.hist th, table.hist td {
  padding: 7px 9px; text-align: center; border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
table.hist th { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; }
table.hist td:first-child, table.hist th:first-child { text-align: left; }
table.hist tr.totalrow td { font-weight: 800; font-size: 15px; border-top: 2px solid var(--line); border-bottom: none; }
table.hist td.best { color: var(--good); font-weight: 800; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; letter-spacing: .04em; }
.badge.made { background: #14351f; color: #7ee2a2; }
.badge.set { background: #3d1a1c; color: #ff9b9f; }
.badge.wild { background: #2b2140; color: #c9a7f5; }

/* ---------- modal ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(5,8,14,.72); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
  background: var(--bg2); border: 1px solid var(--line);
  border-radius: 20px 20px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow);
}
@media (min-width: 640px) {
  .overlay { align-items: center; }
  .sheet { border-radius: 20px; }
}
.sheet h2 { font-size: 17px; margin-bottom: 12px; display:flex; justify-content:space-between; align-items:center; }
.sheet h2 .x { background:none; border:none; font-size:22px; color:var(--muted); min-width:44px; min-height:44px; }

/* numpad */
.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.numpad button {
  min-height: 56px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); font-size: 22px; font-weight: 700;
}
.numpad button:active { background: var(--accent); color: #fff; }

/* ---------- setup / roster ---------- */
.roster .prow { display: flex; align-items: center; gap: 8px; padding: 7px 0; }
.roster .prow input {
  flex: 1; min-width: 0; min-height: 48px; border-radius: 11px;
  background: var(--bg2); border: 1px solid var(--line); padding: 0 12px;
  font-size: 16px; font-weight: 600;
}
.roster .prow input:focus { outline: none; border-color: var(--accent); }
.dotbtn { width: 48px; height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--card2);
  display: flex; align-items: center; justify-content: center; }
.swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; padding: 8px 0 4px; }
.swatches button { height: 44px; border-radius: 10px; border: 2px solid transparent; }
.swatches button.sel { border-color: #fff; }

/* rule rows */
.rulerow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.rulerow:last-child { border-bottom: none; }
.rulerow .lbl { font-weight: 600; font-size: 15px; }
.rulerow .lbl .sub { display: block; font-weight: 400; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }
.seg button { min-height: 44px; padding: 0 14px; background: var(--card); border: none; font-size: 14px; font-weight: 700; color: var(--muted); }
.seg button.on { background: var(--accent); color: #fff; }
select.rulesel {
  min-height: 44px; border-radius: 11px; background: var(--card2); border: 1px solid var(--line);
  padding: 0 10px; font-size: 15px; font-weight: 600; max-width: 55vw;
}

/* ---------- winner banner ---------- */
.winner {
  border: 1px solid var(--gold); background: linear-gradient(160deg, #2b2410, #171d2b 70%);
  border-radius: var(--radius); padding: 18px 14px; margin: 12px 0; text-align: center;
}
.winner .big { font-size: 24px; font-weight: 800; margin: 4px 0; }
.winner .emo { font-size: 40px; animation: pop .5s ease; }
@keyframes pop { 0% { transform: scale(.3); } 70% { transform: scale(1.2); } 100% { transform: scale(1); } }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--card2); border: 1px solid var(--line); color: var(--text);
  padding: 12px 20px; border-radius: 999px; font-weight: 700; font-size: 15px;
  z-index: 200; box-shadow: var(--shadow); white-space: nowrap;
  animation: toastin .25s ease;
}
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 12px); } }

/* turn line */
.turnline { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted);
  padding: 2px 4px 0; font-weight: 600; }
.turnline b { color: var(--text); }

/* ---------- details/cheatsheet ---------- */
details.cheat { margin: 12px 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
details.cheat summary { padding: 13px 14px; font-weight: 700; cursor: pointer; list-style: none; display:flex; justify-content:space-between; }
details.cheat summary::after { content: "▾"; color: var(--muted); }
details.cheat[open] summary::after { content: "▴"; }
details.cheat .inner { padding: 0 14px 14px; }
details.cheat table { width: 100%; border-collapse: collapse; font-size: 14px; }
details.cheat td { padding: 5px 4px; border-bottom: 1px solid var(--line); }
details.cheat td:last-child { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ============ landing page ============ */
.hero { text-align: center; padding: 34px 12px 10px; }
.hero .logo { font-size: 44px; }
.hero h1 { font-size: 30px; margin: 6px 0 2px; }
.hero .dom { color: var(--muted); font-size: 14px; letter-spacing: .04em; }
.gamegrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 18px; }
@media (min-width: 640px) { .gamegrid { grid-template-columns: repeat(3, 1fr); } }
.gcard {
  display: block; background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 18px 14px 14px; color: var(--text); text-decoration: none;
  position: relative; overflow: hidden; min-height: 128px;
  transition: transform .1s ease;
}
.gcard:active { transform: scale(.97); }
.gcard::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 4px;
  background: var(--gaccent, var(--accent));
}
.gcard .gi { font-size: 34px; }
.gcard .gn { font-size: 17px; font-weight: 800; margin-top: 6px; }
.gcard .gd { font-size: 12.5px; color: var(--muted); margin-top: 2px; line-height: 1.35; }
.gcard .live {
  display: inline-flex; align-items: center; gap: 5px; margin-top: 8px;
  font-size: 11px; font-weight: 800; color: #7ee2a2;
}
.gcard .live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--good);
  animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: .35; } }
.foot { text-align: center; color: var(--muted); font-size: 12.5px; padding: 26px 0 12px; }
