/* Lamplighters, a gaslit city at night. Fixed palette (the same in light and dark OS modes).
   Mobile first: the board is a five-lamp track, the table is a grid of seat tiles that holds ten
   seats in two columns at 390px, and your own choices sit in a bar at the bottom. */
:root {
  --bg: #161a2c;
  --surface: #212643;
  --surface2: #2c3255;
  --line: rgba(255, 255, 255, .12);
  --ink: #eef0fa;
  --muted: #a2a8cc;
  --accent: #f2c14e;           /* lamplight */
  --accent-ink: #2a1f06;
  --you: #6fd1c2;              /* you */
  --lit: #f7d98a;
  --dark: #5a608c;
  --good: #5fc98a;
  --bad: #ef7a7a;
  /* tutorial kit (tutorial.css), which tables.css and chat.css follow */
  --tut-accent: #f2c14e;
  --tut-accent-ink: #2a1f06;
  --tut-bubble: #262c4c;
  --tut-ink: #eef0fa;
  --tut-muted: #a2a8cc;
  --tut-dim: rgba(8, 10, 22, .66);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  touch-action: manipulation; min-height: 100vh; overflow-x: hidden;
  background-image: radial-gradient(ellipse 120% 60% at 50% 0%, #232a4c 0%, var(--bg) 70%);
  background-attachment: fixed;
}
button { font: inherit; color: inherit; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; }
.muted { color: var(--muted); font-size: 13px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ico { width: 20px; height: 20px; display: inline-block; vertical-align: -4px; flex: none; }

.app { position: relative; max-width: 760px; margin: 0 auto; padding: 0 12px 20px; padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }

/* ---------- top bar + menu ---------- */
.topbar { display: flex; align-items: center; gap: 4px; height: 50px; }
.back, .iconbtn { width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: 12px; color: var(--muted); text-decoration: none; font-size: 22px; background: none; border: 0; cursor: pointer; padding: 0; }
.back:hover, .iconbtn:hover, .iconbtn[aria-expanded="true"] { color: var(--ink); background: var(--surface2); }
.brand { flex: 1; text-align: center; font: 700 20px/1 Georgia, "Times New Roman", serif; letter-spacing: .06em; color: var(--accent); }
.menu { position: absolute; right: 12px; top: 46px; z-index: 45; min-width: 200px; padding: 6px; background: var(--surface); border-radius: 14px; box-shadow: 0 14px 36px rgba(0, 0, 0, .5); display: flex; flex-direction: column; animation: pop .14s ease-out; }
.menu button { min-height: 46px; text-align: left; padding: 0 14px; border: 0; background: none; border-radius: 10px; cursor: pointer; font-weight: 600; color: var(--ink); }
.menu button:hover, .menu button:focus-visible { background: var(--surface2); }
@keyframes pop { from { transform: translateY(-4px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- buttons ---------- */
.btn { min-height: 46px; padding: 8px 16px; border-radius: 12px; border: 0; background: var(--surface2); color: var(--ink); cursor: pointer; font-weight: 650; transition: background .15s, transform .1s, opacity .15s; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn:hover:not(:disabled) { background: #363d68; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: #f8d066; }
.btn.yes { background: var(--good); color: #0c2418; }
.btn.no { background: var(--bad); color: #2b0d0d; }
.btn.quiet { background: transparent; }
.btn.small { min-height: 40px; padding: 4px 14px; font-size: 14px; }
.btn.wide { flex: 1 1 0; }
.btn .ico { width: 26px; height: 26px; }

/* ---------- status ---------- */
.status { min-height: 38px; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 0 4px 4px; font-size: 15px; color: var(--muted); text-align: center; }
.status.mine { color: var(--ink); font-weight: 650; }
.status .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.thinking::after { content: ''; display: inline-block; width: 1.2em; text-align: left; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

/* ---------- the board: five districts ---------- */
.board { background: linear-gradient(180deg, #1b2138 0%, #1a1f36 100%); border: 1px solid var(--line); border-radius: 18px; padding: 10px 8px 8px; }
.track { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.track li { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0 2px; border-radius: 12px; }
.track li.now { background: rgba(242, 193, 78, .12); box-shadow: inset 0 0 0 1.5px rgba(242, 193, 78, .45); }
.track svg { width: 40px; height: 40px; }
.track li.lit svg { filter: drop-shadow(0 0 7px rgba(247, 217, 138, .6)); }
.track .n { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .04em; }
.track li.now .n { color: var(--accent); }
.track .sz { font-size: 11px; color: var(--muted); }
.track li.lit .sz { color: var(--lit); }
.track li.dark .sz { color: var(--dark); }
.track .two { color: var(--bad); font-weight: 700; }
.tracknote { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.refusals { display: inline-flex; align-items: center; gap: 4px; }
.refusals i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); opacity: .3; }
.refusals i.on { opacity: 1; background: var(--bad); }
.refusals.hot i.on { animation: throb 1.1s ease-in-out infinite; }
@keyframes throb { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.35); } }

/* ---------- your role ---------- */
.role { margin: 10px 0 0; padding: 10px 12px; border-radius: 14px; display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); }
.role.ashen { background: #2a1e30; border-color: rgba(239, 122, 122, .35); }
.role .who { font-weight: 800; font-size: 15px; }
.role.ashen .who { color: #f0a3a3; }
.role.lamp .who { color: var(--accent); }
.role .with { font-size: 13px; color: var(--muted); margin-top: 1px; }
.role .grow { flex: 1 1 auto; min-width: 0; }
.role .hide { flex: none; min-height: 40px; padding: 4px 12px; border-radius: 10px; border: 0; background: var(--surface2); color: var(--muted); font-size: 13px; font-weight: 650; cursor: pointer; }
.role.hidden .who, .role.hidden .with { filter: blur(7px); user-select: none; }

/* ---------- the table: seat tiles (2 columns at 390px, so ten seats fit) ---------- */
.roster { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin: 10px 0 0; }
.seat {
  position: relative; display: flex; align-items: center; gap: 7px; min-height: 52px; width: 100%;
  padding: 6px 8px; border: 0; border-radius: 13px; background: var(--surface); color: var(--ink);
  text-align: left; cursor: pointer; box-shadow: inset 0 0 0 1px var(--line);
  transition: box-shadow .18s, background .18s, opacity .18s;
}
.seat .pip { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--pc, #4a5180); color: #10142a; font-weight: 800; font-size: 12px; }
.seat .who { flex: 1 1 auto; min-width: 0; }
.seat .nm { display: block; font-size: 13.5px; font-weight: 700; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat .sub { display: block; font-size: 11px; color: var(--muted); line-height: 1.2; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat.me { box-shadow: inset 0 0 0 1.5px var(--you); }
.seat.me .nm { color: var(--you); }
.seat.ally { background: #2a1e30; }
.seat.crew { background: #33324f; box-shadow: inset 0 0 0 2px var(--accent); }
.seat.warden .pip { background: var(--accent); }
.seat.pickable { cursor: pointer; }
.seat.pickable:hover { background: var(--surface2); }
.seat.dim { opacity: .55; }
.seat.away .nm { font-style: italic; opacity: .75; }
.seat .badge { flex: none; display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 5px; border-radius: 8px; font-size: 12px; font-weight: 800; background: var(--surface2); color: var(--muted); }
.seat .badge.yes { background: rgba(95, 201, 138, .22); color: var(--good); }
.seat .badge.no { background: rgba(239, 122, 122, .22); color: var(--bad); }
.seat .badge.done { background: rgba(242, 193, 78, .22); color: var(--accent); }
.seat .badge.wait { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); }
.seat .lantern { flex: none; width: 18px; height: 18px; color: var(--accent); }
.seat.fresh { animation: pop .3s ease-out; }

/* ---------- your bar ---------- */
.you { position: sticky; bottom: 0; z-index: 5; margin: 10px -12px 0; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(180deg, rgba(22, 26, 44, .1) 0%, var(--bg) 22%); }
.you .prompt { text-align: center; font-size: 14px; color: var(--muted); min-height: 20px; margin-bottom: 8px; }
.you.turn .prompt { color: var(--ink); font-weight: 650; }
.controls { display: flex; gap: 8px; align-items: stretch; justify-content: center; flex-wrap: wrap; }
.controls .btn { flex: 1 1 140px; max-width: 320px; }
.controls .hint { font-size: 13px; color: var(--muted); text-align: center; flex: 1 1 100%; }
.cardbtn { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 88px; padding: 8px 10px; border: 0; border-radius: 16px; cursor: pointer; font-weight: 750; flex: 1 1 130px; max-width: 200px; }
.cardbtn svg { width: 42px; height: 42px; }
.cardbtn.light { background: #f7edd6; color: #4a3a12; }
.cardbtn.snuff { background: #2a2f4d; color: #cdd2f0; box-shadow: inset 0 0 0 1.5px #5a608c; }
.cardbtn:active { transform: translateY(1px); }
.cardbtn:disabled { opacity: .45; cursor: not-allowed; }

/* the intro, when nobody is at a table yet */
.intro { text-align: center; padding: 6px 4px 0; }
.intro p { margin: 0 0 10px; font-size: 14px; color: var(--muted); }
.intro .btn { min-width: 200px; }

/* ---------- sheet ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(8, 10, 22, .6); }
.sheet { position: relative; width: 100%; max-width: 520px; max-height: 86vh; overflow-y: auto; background: var(--surface); border-radius: 20px 20px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); animation: up .18s ease-out; box-shadow: 0 -10px 40px rgba(0, 0, 0, .5); }
@keyframes up { from { transform: translateY(30px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet h3 { font: 700 18px/1.2 Georgia, serif; margin-bottom: 8px; color: var(--accent); }
.sheet p { margin: 6px 0; }
.sheet .actions { display: flex; gap: 8px; margin-top: 14px; }
.sheet .actions .btn { flex: 1 1 0; }
.sheet .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin: 14px 0 5px; }
.log { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow-y: auto; font-size: 13px; }
.log li { padding: 5px 2px; border-bottom: 1px solid var(--line); color: var(--muted); }
.log li:first-child, .log li.mine { color: var(--ink); }
.rounds { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.rounds li { padding: 7px 2px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: baseline; }
.rounds .tag { flex: none; font-weight: 800; font-size: 12px; }
.rounds .tag.lit { color: var(--lit); }
.rounds .tag.dark { color: var(--dark); }
.rounds .tag.no { color: var(--bad); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }

/* ---------- modals ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 40; background: rgba(8, 10, 22, .66); display: flex; align-items: center; justify-content: center; padding: 12px; }
.modal { background: var(--surface); border-radius: 18px; width: 100%; max-width: 620px; max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(0, 0, 0, .55); }
.over-modal { max-width: 440px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; gap: 8px; }
.modal-head h2 { font: 700 20px/1.2 Georgia, serif; color: var(--accent); }
.modal-body { padding: 0 18px 14px; overflow-y: auto; }
.modal-foot { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px 16px; }
.modal-foot .btn { flex: 1 1 120px; }
.rules h3 { font-size: 15px; margin: 16px 0 4px; color: var(--accent); font-family: Georgia, serif; }
.rules p, .rules li { font-size: 14px; }
.rules ol, .rules ul { padding-left: 20px; margin: 4px 0; }
.rules li { margin: 5px 0; }
.result-banner { font: 800 24px/1.2 Georgia, serif; margin: 0 0 10px; }
.result-banner.win { color: var(--accent); }
.result-banner.loss { color: var(--muted); }

/* ---------- wider screens ---------- */
@media (min-width: 560px) {
  .roster { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .track svg { width: 52px; height: 52px; }
  .seat { min-height: 56px; }
}
@media (min-width: 760px) {
  .roster { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
/* very small phones: keep two columns but tighten everything */
@media (max-width: 360px) {
  .seat { gap: 5px; padding: 5px 6px; }
  .seat .pip { width: 22px; height: 22px; font-size: 11px; }
  .track svg { width: 34px; height: 34px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- online (a table with friends: tables.js) ---------- */
/* a short notice (connection lost, the table was updated, someone left) floats under the status line,
   over the board's top edge, so nothing moves */
.game { position: relative; }
.net-note { position: absolute; left: 50%; top: 34px; transform: translateX(-50%); z-index: 6; width: max-content; max-width: min(88vw, 360px);
  padding: 4px 12px; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-size: 12.5px; font-weight: 700; line-height: 1.3; text-align: center;
  white-space: normal; box-shadow: 0 4px 14px rgba(0, 0, 0, .45); pointer-events: none; animation: pop .25s ease-out; }
/* the waiting table: an open seat */
.seat.open { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); color: var(--muted); cursor: default; }
.seat.open .nm { color: var(--muted); font-weight: 600; }
/* one divider above the online rows */
.menu #menu-online, .menu #menu-leave { border-top: 1px solid var(--line); border-radius: 0 0 10px 10px; }
/* the kit's end bar (Play again / Leave after the night) makes room while a bottom sheet is open */
.sheet-wrap:not([hidden]) ~ .bp-tables-endbar { display: none !important; }
