/* Colors, type and shape come from heraldry (site/heraldry/, linked in index.html). The page frame
   (top bar, page head, buttons, footer) is Valhalla's, so the two sites look like one. */
:root { --content-width: 640px; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--page-bg); color: var(--text);
  font: 15px/1.5 var(--font-body); min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
  overflow-x: hidden; padding-bottom: env(safe-area-inset-bottom, 0px);
}
a { color: var(--link); }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.skip-link { position: fixed; top: -100px; left: 16px; z-index: 60; padding: 8px 12px; background: var(--bg-raised); color: var(--text); }
.skip-link:focus { top: 8px; }
main { flex: 1; outline: none; }
main:focus-visible, h1:focus-visible { outline: none; }
.wrap { width: min(var(--content-width), 100% - 32px); margin-inline: auto; overflow-wrap: anywhere; }
.none, .faint { color: var(--text-faint); }
.empty { padding: 60px 0; text-align: center; color: var(--text-dim); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; padding-top: env(safe-area-inset-top, 0px);
  background: var(--topbar-bg);
  backdrop-filter: var(--topbar-filter); -webkit-backdrop-filter: var(--topbar-filter);
  border-bottom: 1px solid var(--topbar-line);
}
.topbar-inner { width: min(var(--content-width), 100% - 32px); margin-inline: auto; min-height: 56px; display: flex; align-items: center; gap: 12px; }
.brand {
  display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--topbar-ink); margin-right: auto;
  font: var(--display-weight) 22px/1 var(--font-display); letter-spacing: var(--display-tracking); text-transform: var(--display-case); white-space: nowrap;
}
.brand em { font-style: normal; color: var(--topbar-accent); }
.brand-mark { width: 28px; height: 28px; }
.tabs { display: flex; flex: none; gap: 4px; background: var(--tabs-bg); padding: 4px; border-radius: var(--radius-pill); border: 1px solid var(--tabs-line); }
.tabs a { text-decoration: none; padding: 5px 14px; border-radius: var(--radius-pill); color: var(--topbar-dim); font-weight: 500; font-size: 14px; white-space: nowrap; }
.tabs a[aria-current="page"] { background: var(--tab-active-bg); color: var(--tab-active-ink); box-shadow: var(--shadow); }

/* ---------- page head ---------- */
.page-head { padding: 24px 0 8px; }
.page-head h1 { margin: 0; color: var(--heading-ink); font: var(--display-weight) clamp(32px, 7vw, 44px)/1.05 var(--font-display); text-transform: var(--display-case); letter-spacing: var(--display-tracking); font-variant-numeric: tabular-nums; }
.page-head p { margin: 6px 0 0; color: var(--text-dim); }
.section-title { color: var(--heading-ink); font: var(--display-weight) 20px/1.1 var(--font-display); text-transform: var(--display-case); letter-spacing: var(--display-tracking); margin: 22px 0 10px; }
.section-title .count, .history .count { color: var(--text-faint); font-weight: 400; font-size: 14px; margin-left: 4px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; padding: 0 16px; border-radius: var(--radius-sm);
  background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 15px; text-decoration: none; border: 1px solid var(--accent); cursor: pointer;
  touch-action: manipulation;
}
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line-strong); }
.btn.small { height: 34px; padding: 0 12px; font-size: 14px; }
.btn.big { width: 100%; height: 54px; margin-top: 14px; font-size: 18px; }
.btn.wide { width: 100%; margin-top: 8px; }
.btn:disabled { opacity: .4; cursor: not-allowed; filter: none; }
.btn.danger { color: var(--text-dim); }

/* Player count: one row of equal buttons, the chosen one filled. */
.seg { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; padding: 4px; background: var(--bg-sunken); border: 1px solid var(--line); border-radius: var(--radius); }
.seg button {
  height: 52px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-dim); cursor: pointer;
  font: var(--display-weight) 22px/1 var(--font-display); font-variant-numeric: tabular-nums; touch-action: manipulation;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow); }

.toolbar { display: flex; gap: 8px; margin: 14px 0 10px; }
.toolbar .btn { flex: 1; }

/* ---------- seats: one row per player ---------- */
.seats { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.seat {
  display: flex; align-items: center; gap: 10px; min-height: 64px; padding: 8px 10px 8px 14px;
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius);
}
.seat.picked { border-color: var(--accent); background: var(--row-selected); }
.seat.out { opacity: .5; }
.seat.out .name { text-decoration: line-through; }
.seat-dot { width: 14px; height: 14px; border-radius: 50%; flex: none; background: var(--seat); box-shadow: 0 0 0 2px var(--bg-raised), 0 0 0 3px var(--seat); }
.name {
  flex: 1; min-width: 0; height: 42px; padding: 0 10px; font-size: 16px; font-weight: 500;
  border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent;
}
.name:hover { border-color: var(--line); }
.name:focus { border-color: var(--accent); background: var(--bg); outline: none; }
.pick {
  width: 48px; height: 48px; flex: none; border-radius: 50%; cursor: pointer; touch-action: manipulation;
  border: 2px dashed var(--line-strong); background: transparent; color: var(--text-faint);
  font: var(--display-weight) 22px/1 var(--font-display); font-variant-numeric: tabular-nums;
}
.pick:hover:not(:disabled) { border-color: var(--accent); color: var(--text); }
.picked .pick { border: 2px solid var(--accent); background: var(--accent); color: var(--accent-ink); }
.pick:disabled { cursor: not-allowed; }

/* d20 results beside a name; a tie-break shows each roll. */
.rolls { display: inline-flex; gap: 4px; flex: none; }
.die {
  min-width: 30px; height: 26px; padding: 0 6px; display: inline-grid; place-items: center; border-radius: var(--radius-xs);
  background: var(--bg-sunken); border: 1px solid var(--line-strong); color: var(--text-dim);
  font: 600 13px/1 var(--font-body); font-variant-numeric: tabular-nums;
}
.rolls .die:last-child { color: var(--text); border-color: var(--accent); }

/* ---------- the round under way ---------- */
.order { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 10px; }
.order li {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius);
}
.order .pos {
  width: 48px; height: 48px; flex: none; display: grid; place-items: center; border-radius: 50%;
  background: var(--bg-sunken); border: 1px solid var(--line-strong); color: var(--text-dim);
  font: var(--display-weight) 24px/1 var(--font-display); font-variant-numeric: tabular-nums;
}
.order .who { flex: 1; min-width: 0; font: var(--display-weight) clamp(20px, 5.5vw, 28px)/1.15 var(--font-display); letter-spacing: var(--display-tracking); }
.order li:first-child { border-color: var(--accent); box-shadow: var(--shadow); }
.order li:first-child .pos { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---------- history ---------- */
.more { margin-top: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-raised); }
.more > summary { cursor: pointer; padding: 12px 14px; font-weight: 600; font-size: 15px; }
.more[open] > summary { border-bottom: 1px solid var(--line); }
.more > .none { margin: 0; padding: 14px; }
.rounds { list-style: none; margin: 0; padding: 0; }
.rounds > li { padding: 10px 14px; border-bottom: 1px solid var(--line); }
.rounds > li:nth-child(even) { background: var(--row-alt); }
.rounds b { font-size: 14px; color: var(--text-dim); }
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 6px 0 0; }
.chip {
  height: 30px; padding: 0 10px; border-radius: var(--radius-pill); border: 1px solid var(--line-strong); background: var(--bg-raised);
  color: var(--text); font-size: 13px; display: inline-flex; align-items: center; gap: 6px;
}
.chip .seat-dot { width: 9px; height: 9px; box-shadow: none; }
.history-actions { padding: 10px 14px; display: flex; justify-content: flex-end; }

.game-actions { display: flex; gap: 8px; margin: 16px 0 8px; }
.game-actions .btn { flex: 1; }

/* ---------- theme picker ---------- */
/* Four tiles in a row, each a swatch over its name, so they fit across a phone. */
.theme-picker { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin: 18px 0 8px; }
.theme-picker > span { grid-column: 1 / -1; font-size: 13px; font-weight: 600; color: var(--text-dim); }
.theme-picker button {
  display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 8px 4px 7px; cursor: pointer; touch-action: manipulation;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--bg-raised); color: var(--text-dim); font-size: 13px;
}
.theme-picker button:hover { color: var(--text); border-color: var(--accent); }
.theme-picker button[aria-pressed="true"] { color: var(--text); border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.swatch { width: 26px; height: 26px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px rgb(127 127 127 / .5); }

/* ---------- footer ---------- */
.fine { font-size: 12px; color: var(--text-faint); }
.footer { border-top: 1px solid var(--line); padding: 22px 16px 28px; text-align: center; color: var(--text-faint); font-size: 13px; margin-top: 24px; }
.footer p { margin: 4px auto; max-width: 900px; }
.footer a { color: var(--text-dim); }

/* ---------- phones ---------- */
@media (max-width: 520px) {
  .brand-word { display: none; }
  .tabs a { padding: 5px 10px; font-size: 13px; }
  .seat { gap: 8px; padding-left: 12px; }
  .seat .btn.small { padding: 0 10px; }
}
@media (max-width: 380px) {
  .wrap, .topbar-inner { width: calc(100% - 20px); }
  .seat { flex-wrap: wrap; }
  .seat .name { flex-basis: calc(100% - 40px); }
  .seat .rolls { margin-left: 24px; margin-right: auto; }
  .seat .pick { margin-left: auto; }
}
