/* Spellenteller — warm paper, rounded cards, big tap targets. Everything you do
   at the table is a thing you can hit with a thumb; everything you read is a
   card, not a spreadsheet row. */

:root {
  --paper: #f8f3ea;
  --paper-2: #f1e8d9;
  --card: #fffdf9;
  --ink: #1b2830;
  --ink-2: #55636b;
  --ink-3: #97a09a;
  --rule: #e5dbc7;
  --rule-2: #d3c3a3;
  --brass: #a97722;
  --brass-soft: #f6e7c6;
  --sea: #12525d;
  --sea-soft: #dcebec;
  --red: #a63a2c;
  --red-soft: #fadfd9;
  --green: #2f6b3f;
  --green-soft: #dff0e0;
  --r-sm: 10px;
  --r: 16px;
  --r-lg: 24px;
  --shadow: 0 1px 2px rgba(27, 40, 48, 0.04), 0 6px 18px rgba(27, 40, 48, 0.06);
  --shadow-lift: 0 2px 4px rgba(27, 40, 48, 0.06), 0 12px 28px rgba(27, 40, 48, 0.1);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
.wrap { max-width: 1060px; margin: 0 auto; padding: 0 16px 120px; }

/* --- masthead --- */
.masthead {
  padding: 20px 0 14px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.masthead h1 {
  font-family: var(--serif); font-weight: 600; font-size: 28px;
  letter-spacing: -0.01em; margin: 0; cursor: pointer;
}
.masthead .sub {
  font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-3); margin-right: auto;
}
.masthead .tools { display: flex; gap: 8px; align-items: center; }

/* --- colophon --- */
.colophon {
  margin-top: 44px; padding-top: 16px; border-top: 1px solid var(--rule);
  display: flex; flex-wrap: wrap; align-items: center; gap: 7px;
  font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-3);
}
.colophon .dot { color: var(--rule-2); }
.colophon a {
  color: var(--ink-2); text-decoration: none;
  border-bottom: 1px solid var(--rule-2); padding-bottom: 1px;
}
.colophon a:hover { color: var(--brass); border-bottom-color: var(--brass); }

/* --- type --- */
h2 { font-family: var(--serif); font-weight: 600; font-size: 24px; margin: 28px 0 6px; }
h3 { font-family: var(--serif); font-weight: 600; font-size: 18px; margin: 26px 0 8px; }
.lede { color: var(--ink-2); margin: 0 0 16px; max-width: 60ch; }
.label { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

/* --- game picker --- */
.picker { display: grid; gap: 12px; margin-top: 16px; }
.pick {
  display: grid; grid-template-columns: 56px 1fr auto; gap: 16px; align-items: center;
  width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: var(--card); border: 1px solid var(--rule); border-radius: var(--r-lg);
  padding: 18px 20px; box-shadow: var(--shadow);
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}
.pick:hover, .pick:focus-visible { transform: translateY(-2px); box-shadow: var(--shadow-lift); outline: none; background: #fffefb; }
.pick:active { transform: translateY(0); }
.pick .n {
  font-family: var(--serif); font-size: 22px; color: var(--brass); line-height: 1;
  background: var(--brass-soft); border-radius: 50%; width: 46px; height: 46px;
  display: flex; align-items: center; justify-content: center;
}
/* a 4-char room code never fits the round single-digit badge, so it gets a pill sized to its text */
.pick-room { grid-template-columns: auto 1fr auto; }
.pick .cod {
  font-family: var(--serif); font-size: 21px; color: var(--brass); line-height: 1;
  background: var(--brass-soft); border-radius: 999px;
  /* letter-spacing leaves a trailing gap after the last character, so trim it off the right */
  padding: 12px calc(16px - 0.12em) 12px 16px;
  letter-spacing: 0.12em; white-space: nowrap; justify-self: start;
}
.pick .t { font-family: var(--serif); font-size: 21px; }
.pick .d { color: var(--ink-2); font-size: 14px; }
.pick .go { color: var(--brass); font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; }

/* The row is already a button, so the discard control cannot live inside it.
   It sits alongside and is placed over the card instead. */
.pickline { position: relative; }
.pickline .pick { padding-right: 66px; }
/* No host key for this room, so no delete button — take the room back. */
.pickline.nodel .pick { padding-right: 18px; }
/* Centred with auto margins, not translateY(-50%): the generic button:active
   rule sets its own transform, which would drop the button half its height the
   moment you press it. */
.xdel {
  position: absolute; top: 0; bottom: 0; right: 14px; margin: auto 0;
  width: 38px; height: 38px; padding: 0; line-height: 1; font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--rule); border-radius: 50%;
  background: var(--paper); color: var(--ink-3); cursor: pointer;
  transition: color 140ms, background 140ms, border-color 140ms;
}
.xdel:hover, .xdel:focus-visible {
  color: var(--red); border-color: var(--red); background: var(--red-soft); outline: none;
}

/* --- controls --- */
button, .btn {
  font: inherit; font-size: 15px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--rule-2); background: var(--card); color: var(--ink);
  border-radius: 999px; padding: 11px 20px; min-height: 44px;
  transition: transform 120ms ease, background 140ms ease, box-shadow 140ms ease, border-color 140ms;
  text-decoration: none;
}
button:hover, .btn:hover { background: var(--brass-soft); border-color: var(--rule-2); }
button:active { transform: scale(0.97); }
button.primary { background: var(--sea); border-color: var(--sea); color: #fbf7ef; box-shadow: var(--shadow); }
button.primary:hover { background: #17646f; border-color: #17646f; }
button.ghost { border-color: transparent; background: none; color: var(--ink-2); padding: 8px 12px; min-height: 38px; }
button.ghost:hover { background: var(--paper-2); }
button.danger { color: var(--red); border-color: var(--red-soft); background: var(--card); }
button.danger:hover { background: var(--red-soft); }
button.danger-solid { background: var(--red); border-color: var(--red); color: #fdf6f3; box-shadow: var(--shadow); }
button.danger-solid:hover { background: #8c3025; border-color: #8c3025; }
button.small { padding: 7px 15px; font-size: 14px; min-height: 38px; }
button[disabled] { opacity: 0.35; cursor: not-allowed; }
button[disabled]:active { transform: none; }

input, select {
  font: inherit; background: var(--card); color: var(--ink);
  border: 1px solid var(--rule-2); border-radius: var(--r-sm); padding: 11px 14px; min-height: 46px;
  transition: border-color 140ms, box-shadow 140ms;
}
input:focus, select:focus {
  outline: none; border-color: var(--brass); box-shadow: 0 0 0 4px var(--brass-soft);
}
input[type="number"] { font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

.panel {
  background: var(--card); border: 1px solid var(--rule); border-radius: var(--r-lg);
  padding: 18px 20px; margin: 16px 0; box-shadow: var(--shadow);
}
.panel.tint { background: var(--paper-2); box-shadow: none; }
.note { font-size: 14px; color: var(--ink-2); }
.warn {
  color: var(--red); font-size: 14px; background: var(--red-soft);
  border-radius: var(--r); padding: 10px 16px; margin: 12px 0 0;
}
.ok { color: var(--green); }

/* --- room header --- */
.roomhead {
  display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--rule); border-radius: var(--r-lg);
  padding: 16px 20px; box-shadow: var(--shadow); margin-top: 8px;
}

/* --- round bar --- */
/* the wrapper is what sticks: an opaque paper band, so nothing scrolls through the
   gap above the pill or past its rounded corners */
.roundbar-wrap {
  position: sticky; top: 0; z-index: 6;
  padding: 10px 0; margin: 10px 0 6px; background: var(--paper);
}
.roundbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 18px; border-radius: 999px;
  background: var(--sea-soft); box-shadow: var(--shadow);
}
.roundbar .big { font-family: var(--serif); font-size: 22px; color: var(--sea); }
.roundbar .dealer { color: var(--ink-2); font-size: 14px; }
.roundbar .rb-nav { margin-left: auto; display: flex; gap: 8px; }
.roundbar button { background: #fffdf9; }
/* Same specificity as button.primary but later in the file, so the rule above
   won and repainted the primary Next button near-white — while its
   color: #fbf7ef survived. White label on a white pill. Restate it here. */
.roundbar button.primary { background: var(--sea); border-color: var(--sea); color: #fbf7ef; }
.roundbar button.primary:hover { background: #17646f; border-color: #17646f; }

/* --- entry cards --- */
.entry {
  background: var(--card); border: 1px solid var(--rule); border-radius: var(--r-lg);
  padding: 16px 18px; margin-bottom: 12px; box-shadow: var(--shadow);
  transition: border-color 140ms, box-shadow 140ms;
}
.entry.live { border-color: var(--brass); box-shadow: 0 0 0 3px var(--brass-soft), var(--shadow); }
.entry.done { background: #fdfbf4; }
.entry .who { font-family: var(--serif); font-size: 20px; display: flex; gap: 10px; align-items: center; }
.entry .who .tag {
  font-family: var(--sans); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--brass); background: var(--brass-soft); border-radius: 999px; padding: 3px 10px;
}
.entryhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.fields { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-top: 10px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field input { width: 92px; font-size: 17px; }
.field input.wide { width: 240px; }

/* --- tap-to-pick numbers --- */
.pickrow { margin-top: 10px; }
.pickrow > .label { display: block; margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-width: 46px; min-height: 46px; padding: 0 12px; justify-content: center;
  border-radius: 999px; border: 1px solid var(--rule-2); background: var(--card);
  font-variant-numeric: tabular-nums; font-size: 17px; font-weight: 500;
}
.chip:hover { background: var(--brass-soft); }
.chip.on {
  background: var(--sea); border-color: var(--sea); color: #fbf7ef;
  box-shadow: 0 2px 10px rgba(18, 82, 93, 0.28);
}
.chip.on:hover { background: #17646f; }
.chip.wide { min-width: auto; }

/* On a wide screen the label sits beside its numbers instead of above them, so
   a four-player round still fits on one screen. */
@media (min-width: 760px) {
  .entry { padding: 18px 22px; }
  .entry .pickrow { display: grid; grid-template-columns: 132px 1fr; align-items: center; gap: 16px; }
  .entry .pickrow > .label { margin-bottom: 0; }
  .entry .fields { margin-left: 148px; }
  .entry details > summary { margin-left: 148px; }
  .entry details[open] > .fields { margin-left: 148px; }
}

/* --- the score bubble --- */
.result { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.result .v {
  font-family: var(--serif); font-size: 22px; line-height: 1;
  border-radius: 999px; padding: 9px 16px; background: var(--paper-2); color: var(--ink-3);
  min-width: 72px; text-align: center;
}
.result .v.pos { background: var(--green-soft); color: var(--green); }
.result .v.neg { background: var(--red-soft); color: var(--red); }
.result small { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.neg { color: var(--red); }

/* --- scoreboard --- */
.tablewrap {
  overflow-x: auto; margin: 18px 0 0; background: var(--card);
  border: 1px solid var(--rule); border-radius: var(--r-lg); box-shadow: var(--shadow);
}
table.sheet { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
table.sheet th, table.sheet td { padding: 10px 14px; text-align: right; white-space: nowrap; }
table.sheet th:first-child, table.sheet td:first-child {
  text-align: left; position: sticky; left: 0; background: var(--card); font-family: var(--serif);
}
table.sheet thead th {
  font-family: var(--sans); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-3); padding-top: 16px;
}
table.sheet tbody td { border-top: 1px solid var(--rule); }
table.sheet tbody tr:first-child td { border-top: 2px solid var(--rule-2); }
table.sheet tr.cur td, table.sheet tr.cur td:first-child { background: var(--brass-soft); color: var(--brass); }
table.sheet tr.jump { cursor: pointer; }
table.sheet tr.jump:hover td, table.sheet tr.jump:hover td:first-child { background: var(--sea-soft); }
table.sheet tr.totals td, table.sheet tr.totals td:first-child {
  border-top: 2px solid var(--rule-2); font-size: 19px; font-family: var(--serif); background: var(--paper-2);
}
table.sheet tr.meta td, table.sheet tr.meta td:first-child {
  color: var(--ink-2); font-size: 13px; background: var(--paper-2); border: none;
}
table.sheet tr.meta:last-child td:first-child { border-bottom-left-radius: var(--r-lg); }
table.sheet td.lead { color: var(--brass); font-weight: 600; }

/* --- standings --- */
ol.standings { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 10px; }
ol.standings li {
  display: grid; grid-template-columns: 48px 1fr auto; gap: 14px; align-items: center;
  background: var(--card); border: 1px solid var(--rule); border-radius: var(--r-lg);
  padding: 14px 18px; box-shadow: var(--shadow);
}
ol.standings li .p {
  font-family: var(--serif); font-size: 20px; color: var(--ink-3);
  background: var(--paper-2); border-radius: 50%; width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
}
ol.standings li.win { border-color: var(--brass); box-shadow: 0 0 0 3px var(--brass-soft), var(--shadow); }
ol.standings li.win .p { background: var(--brass-soft); color: var(--brass); }
ol.standings li .n { font-family: var(--serif); font-size: 20px; }
ol.standings li .v { font-variant-numeric: tabular-nums; font-size: 20px; font-family: var(--serif); }

.pill {
  display: inline-flex; align-items: center; font-size: 12px; letter-spacing: 0.06em;
  text-transform: uppercase; border: 1px solid var(--rule-2); border-radius: 999px;
  padding: 4px 12px; color: var(--ink-2); background: var(--card);
}
.pill.live { border-color: var(--green); color: var(--green); background: var(--green-soft); }
/* .pill sets display, which would otherwise beat the browser's own [hidden] */
.pill[hidden] { display: none; }
.code {
  font-family: var(--serif); font-size: 30px; letter-spacing: 0.18em; color: var(--sea);
  background: var(--sea-soft); border-radius: var(--r); padding: 4px 16px; display: inline-block;
}
.playerrow { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; padding: 6px 0; }
.playerrow .i { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.playerrow input { width: 100%; }

.rules { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.rules .field input { width: 100%; }
details > summary { cursor: pointer; color: var(--ink-2); font-size: 15px; padding: 8px 0; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before {
  content: "＋"; display: inline-block; width: 22px; color: var(--brass); font-weight: 600;
}
details[open] > summary::before { content: "－"; }
details[open] > summary { color: var(--ink); }
.entry details > summary { font-size: 14px; }
.entry details[open] > .fields { margin-top: 2px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: var(--paper); padding: 12px 22px; border-radius: 999px;
  font-size: 15px; z-index: 50; box-shadow: var(--shadow-lift);
}
.toast.offline { background: var(--red); }

/* --- ask dialog --- */
dialog.ask {
  border: none; padding: 0; background: transparent; overflow: visible;
  width: min(420px, calc(100% - 28px)); max-width: none;
  margin: auto; /* centred rather than pinned to the top on a phone */
}
dialog.ask::backdrop { background: rgba(27, 40, 48, 0.38); }
.ask-in {
  background: var(--card); border: 1px solid var(--rule); border-radius: var(--r-lg);
  padding: 26px 26px 20px; box-shadow: var(--shadow-lift);
  animation: askin 150ms cubic-bezier(0.2, 0.8, 0.3, 1);
}
@keyframes askin { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
.ask-in h3 { font-family: var(--serif); font-size: 23px; margin: 0 0 10px; color: var(--ink); }
.ask-body { margin: 0; color: var(--ink-2); font-size: 15px; line-height: 1.5; }
.ask-what {
  margin: 16px 0 0; padding: 11px 15px; border-radius: var(--r);
  background: var(--paper-2); color: var(--ink-2); font-size: 14px; line-height: 1.45;
}
.ask-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 22px; }
.ask-row button.ghost { padding: 11px 18px; min-height: 44px; }

@media (max-width: 640px) {
  .wrap { padding: 0 12px 110px; }
  .masthead { padding: 14px 0 10px; }
  .masthead h1 { font-size: 24px; }
  .pick { grid-template-columns: 46px 1fr; gap: 14px; padding: 16px; border-radius: var(--r); }
  .pick-room { grid-template-columns: auto 1fr; }
  .pick .n { width: 40px; height: 40px; font-size: 19px; }
  .pick .cod { font-size: 18px; padding: 10px 13px; letter-spacing: 0.1em; }
  .pickline .pick { padding-right: 56px; }
  .xdel { right: 10px; width: 36px; height: 36px; }
  .pick .go { display: none; }
  .entry { border-radius: var(--r); padding: 14px 16px; }
  .roundbar-wrap { padding: 8px 0; }
  .roundbar { padding: 10px 14px; gap: 10px; }
  .roundbar .big { font-size: 19px; }
  .result .v { font-size: 20px; }
  .field input.wide { width: 100%; }
  .code { font-size: 26px; }
  .ask-in { padding: 22px 20px 18px; }
  .ask-in h3 { font-size: 21px; }
  .ask-row button { flex: 1 1 auto; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .ask-in { animation: none; }
}

/* --- prose pages (privacy) ---------------------------------------------------
   Same paper and the same brass numeral badge as the game picker, so a page of
   text still reads as part of the app rather than a legal annex bolted on. */
.doc { max-width: 68ch; }
.doc .lede { font-size: 18px; line-height: 1.55; margin-bottom: 8px; }
.doc-sec {
  display: grid; grid-template-columns: 46px 1fr; gap: 18px;
  padding: 22px 0; border-top: 1px solid var(--rule);
}
.doc-sec:first-of-type { border-top: none; }
.doc-n {
  font-family: var(--serif); font-size: 20px; color: var(--brass); line-height: 1;
  background: var(--brass-soft); border-radius: 50%; width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center; margin-top: 4px;
}
.doc h2 { font-size: 20px; margin: 0 0 8px; }
.doc p { margin: 0 0 12px; color: var(--ink-2); }
.doc strong { color: var(--ink); font-weight: 600; }
.doc ul { margin: 0 0 12px; padding-left: 20px; color: var(--ink-2); }
.doc li { margin-bottom: 6px; }
.doc a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--rule-2); }
.doc a:hover { color: var(--brass); border-bottom-color: var(--brass); }
.doc-note {
  background: var(--paper-2); border-radius: var(--r-sm);
  padding: 12px 14px; font-size: 15px;
}
.doc-out { min-height: 22px; margin: 12px 0 0; font-size: 15px; }
.doc-out.ok { color: var(--green); }
.doc-out.bad { color: var(--red); }
.doc-date { font-size: 13px; color: var(--ink-3); margin-top: 8px; }
a.plain { color: inherit; text-decoration: none; }

@media (max-width: 560px) {
  .doc-sec { grid-template-columns: 34px 1fr; gap: 14px; }
  .doc-n { width: 30px; height: 30px; font-size: 16px; }
}
