/* Theme Pub: hand-written styles. Chalkboard, brass, burgundy and dark wood. */

:root {
  --wood-dark: #21140d;
  --wood: #3b2416;
  --burgundy: #6d1f2b;
  --burgundy-dark: #3d0f18;
  --brass: #c9a24a;
  --brass-light: #e6c66e;
  --brass-dark: #8a6a24;
  --cream: #f3e9d2;
  --cream-dark: #e2d3b0;
  --chalkboard: #263229;
  --chalk: #e9efe6;
  --ink: #241710;
  --focus: #ffd166;

  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-sign: Georgia, "Times New Roman", serif;
  --radius: 0.6rem;

  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
}

body {
  font-family: var(--font-body);
  line-height: 1.45;
  color: var(--cream);
  background: var(--wood-dark);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  /* A dark halo inside the yellow ring keeps it visible on the cream
     toasts and brass buttons as well as the dark panels. */
  box-shadow: 0 0 0 2px #120a05;
}

a {
  color: var(--brass-light);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.button-brass {
  font: inherit;
  font-weight: 700;
  padding: 0.6rem 1.4rem;
  color: var(--ink);
  background: linear-gradient(var(--brass-light), var(--brass));
  border: 2px solid var(--brass-dark);
  border-radius: var(--radius);
  cursor: pointer;
}

.button-brass:hover {
  background: linear-gradient(#f0d687, var(--brass-light));
}

a.button-brass {
  display: inline-block;
  text-decoration: none;
}

.button-small {
  padding: 0.35rem 0.9rem;
  font-size: 0.9rem;
}

/* ---------- Lobby ---------- */

.lobby-page {
  min-height: 100vh;
  background:
    radial-gradient(ellipse at top, rgb(201 162 74 / 0.18), transparent 60%),
    linear-gradient(var(--burgundy-dark), var(--wood-dark) 70%);
}

.lobby {
  max-width: 76rem;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 3rem;
}

.lobby-header {
  text-align: center;
  margin-bottom: 2rem;
}

.game-title {
  margin: 0;
  font-family: var(--font-sign);
  font-size: clamp(2.6rem, 7vw, 4.5rem);
  letter-spacing: 0.06em;
  color: var(--brass-light);
  text-shadow: 0 2px 0 var(--brass-dark), 0 6px 18px rgb(0 0 0 / 0.5);
}

.headcount {
  display: inline-block;
  margin: 0.75rem 0 0;
  padding: 0.3rem 1rem;
  font-family: var(--font-sign);
  color: var(--chalk);
  background: var(--chalkboard);
  border: 3px solid var(--wood);
  border-radius: 0.3rem;
}

.persona-picker {
  margin: 0;
  padding: 0;
  border: 0;
}

.persona-picker legend {
  padding: 0;
  margin-bottom: 0.9rem;
  font-family: var(--font-sign);
  font-size: 1.35rem;
}

.persona-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13.5rem, 1fr));
  gap: 1rem;
}

.persona-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1.1rem 1rem 1rem;
  overflow: hidden;
  color: var(--ink);
  background: var(--cream);
  border: 3px solid var(--cream-dark);
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.persona-card:hover {
  transform: translateY(-2px);
}

.persona-card:has(.persona-radio:checked) {
  border-color: var(--burgundy);
  box-shadow: 0 0 0 3px var(--brass), 0 8px 22px rgb(0 0 0 / 0.45);
}

.persona-card:has(.persona-radio:focus-visible) {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.persona-radio {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.persona-swatch {
  position: absolute;
  inset: 0 0 auto;
  display: flex;
  height: 0.45rem;
}

.persona-swatch > span {
  flex: 1;
}

.persona-name {
  font-family: var(--font-sign);
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.1;
}

.persona-nickname {
  margin-top: -0.25rem;
  font-size: 0.9rem;
  font-style: italic;
  color: var(--burgundy);
}

.persona-tagline {
  font-style: italic;
  font-weight: 600;
}

.persona-bio {
  font-size: 0.88rem;
  color: #4a3a2c;
}

.persona-stats {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: auto;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--cream-dark);
}

.persona-stat {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stat-label {
  flex: none;
  width: 3.8rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Icons shrink rather than wrap, so 12 pints still fit on one row. */
.icon-row {
  display: flex;
  min-width: 0;
  gap: 1px;
}

.icon {
  flex: 0 1 0.75rem;
  min-width: 0;
  height: 1.125rem;
}

.join-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1.75rem;
}

.join-name label {
  font-family: var(--font-sign);
  font-size: 1.2rem;
}

.join-name input {
  width: 14rem;
  padding: 0.55rem 0.75rem;
  font: inherit;
  color: var(--ink);
  background: var(--cream);
  border: 2px solid var(--brass-dark);
  border-radius: var(--radius);
}

.join-result {
  max-width: 36rem;
  margin: 1rem auto 0;
  text-align: center;
}

.join-result:empty {
  display: none;
}

.join-error,
.pub-full p {
  margin: 0;
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
}

.join-error {
  color: var(--cream);
  background: var(--burgundy);
  border: 2px solid var(--burgundy-dark);
}

.pub-full p {
  font-family: var(--font-sign);
  color: var(--chalk);
  background: var(--chalkboard);
  border: 3px solid var(--wood);
}

.keyboard-note {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.9rem;
  opacity: 0.8;
}

/* ---------- Game page ---------- */

.game-page {
  overflow: hidden;
}

.pub-canvas {
  position: fixed;
  inset: 0;
  display: block;
  width: 100vw;
  height: 100vh;
}

/* The HUD covers the canvas but only its panels take clicks. Its text
   scales with the text size setting (--text-scale, set by overlay.ts), so
   everything inside is sized in em. */
.hud {
  position: fixed;
  inset: 0;
  font-size: calc(var(--text-scale, 1) * 1rem);
  pointer-events: none;
}

.hud > * {
  pointer-events: auto;
}

/* In the HUD's top-centre column, above the toasts. */
.compat-banner {
  display: none;
  align-items: center;
  gap: 0.75em;
  max-width: 100%;
  padding: 0.5em 0.5em 0.5em 1em;
  font-size: 0.9em;
  color: var(--ink);
  background: var(--cream);
  border: 2px solid var(--brass);
  border-radius: var(--radius);
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.4);
  pointer-events: auto;
}

:root[data-renderer="webgl2"] .compat-banner {
  display: flex;
}

.compat-banner p {
  margin: 0;
}

.banner-close {
  flex: none;
  width: 2em;
  height: 2em;
  font-size: 1.3em;
  line-height: 1;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.banner-close:hover {
  background: var(--cream-dark);
}

/* Connection notices: the canvas script sets data-connection on <html>. */
.connection-notice {
  display: none;
}

.conn-reconnecting {
  position: absolute;
  top: 3.75em;
  left: 50%;
  margin: 0;
  padding: 0.4em 1em;
  font-family: var(--font-sign);
  color: var(--chalk);
  background: var(--chalkboard);
  border: 2px solid var(--wood);
  border-radius: var(--radius);
  transform: translateX(-50%);
}

:root[data-connection="reconnecting"] .conn-reconnecting {
  display: block;
}

.conn-takeover,
.conn-closed {
  position: absolute;
  inset: 0;
  place-items: center;
  padding: 1.25rem;
  background: rgb(33 20 13 / 0.82);
}

:root[data-connection="takeover"] .conn-takeover,
:root[data-connection="closed"] .conn-closed {
  display: grid;
}

.notice-card {
  max-width: 30em;
  padding: 1.5em 1.75em;
  text-align: center;
  color: var(--chalk);
  background: var(--chalkboard);
  border: 6px solid var(--wood);
  border-radius: 0.4rem;
}

.notice-card h1 {
  margin-top: 0;
  font-family: var(--font-sign);
  font-size: 1.5em;
}

.notice-card p {
  margin-bottom: 0;
}

.unsupported {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: 1.25rem;
  overflow-y: auto;
  background: linear-gradient(var(--burgundy-dark), var(--wood-dark));
}

:root[data-renderer="unsupported"] .unsupported {
  display: grid;
}

:root[data-renderer="unsupported"] .pub-canvas {
  display: none;
}

.unsupported-card {
  max-width: 38rem;
  padding: 1.5rem 1.75rem;
  color: var(--chalk);
  background: var(--chalkboard);
  border: 6px solid var(--wood);
  border-radius: 0.4rem;
}

.unsupported-card h1 {
  margin-top: 0;
  font-family: var(--font-sign);
  font-size: 1.6rem;
}

.unsupported-card h2 {
  margin-bottom: 0.25rem;
  font-family: var(--font-sign);
  font-size: 1.15rem;
}

.unsupported-card ul {
  margin-top: 0.25rem;
  padding-left: 1.2rem;
}

.noscript {
  position: fixed;
  inset: auto 0 45%;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .persona-card {
    transition: none;
  }

  .persona-card:hover {
    transform: none;
  }
}

/* ---------- HUD (SPEC.md "Screen regions") ---------- */

.hud kbd {
  display: inline-block;
  min-width: 1.5em;
  padding: 0 0.35em;
  font: 700 0.85em/1.5 var(--font-body);
  text-align: center;
  color: var(--ink);
  background: var(--cream);
  border: 1px solid var(--brass-dark);
  border-bottom-width: 2px;
  border-radius: 0.3em;
}

/* Shared panel look: a chalkboard in a wooden frame. */
.players-panel,
.menu-panel,
.dialog-card,
.panel {
  color: var(--chalk);
  background: var(--chalkboard);
  border: 0.3em solid var(--wood);
  border-radius: 0.45em;
  box-shadow: 0 0.5em 1.4em rgb(0 0 0 / 0.5), inset 0 0 0 1px rgb(201 162 74 / 0.35);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75em;
  margin-bottom: 0.6em;
}

.panel-title {
  margin: 0;
  font-family: var(--font-sign);
  font-size: 1.25em;
  font-weight: 700;
  color: var(--brass-light);
}

.panel-close {
  flex: none;
  width: 2em;
  height: 2em;
  font-size: 1.1em;
  line-height: 1;
  color: var(--chalk);
  background: transparent;
  border: 1px solid rgb(233 239 230 / 0.35);
  border-radius: 50%;
  cursor: pointer;
}

.panel-close:hover {
  background: rgb(233 239 230 / 0.12);
}

.panel-hint {
  margin: 0.75em 0 0;
  font-size: 0.85em;
  opacity: 0.85;
}

/* Top left: title, pub clock, headcount. */
.hud-top-left {
  position: absolute;
  top: 0.75em;
  left: 0.75em;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.3em;
  pointer-events: none;
}

.hud-top-left > p {
  margin: 0;
}

.hud-title {
  font-family: var(--font-sign);
  font-size: 1.2em;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--brass-light);
  text-shadow: 0 1px 0 var(--brass-dark), 0 2px 8px rgb(0 0 0 / 0.8);
}

.hud-clock {
  display: flex;
  align-items: baseline;
  gap: 0.5em;
  padding: 0.15em 0.7em;
  font-family: var(--font-sign);
  color: var(--chalk);
  background: var(--chalkboard);
  border: 0.2em solid var(--wood);
  border-radius: 0.3em;
}

.hud-clock:empty,
.hud-headcount:empty {
  display: none;
}

.clock-time {
  font-size: 1.4em;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.clock-lockin {
  font-size: 0.8em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--brass-light);
}

.hud-headcount {
  padding: 0.1em 0.6em;
  font-size: 0.9em;
  color: var(--cream);
  background: rgb(33 20 13 / 0.75);
  border-radius: 1em;
}

/* Top centre: the compatibility banner, then the toasts below it.
   overlay.ts removes each toast after data-ttl and keeps at most data-max;
   CSS hides any extra in the meantime. */
.hud-top-centre {
  position: absolute;
  top: 0.75em;
  left: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5em;
  width: min(40em, calc(100vw - 20em));
  transform: translateX(-50%);
  pointer-events: none;
}

.toasts {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4em;
  max-width: 30em;
}

.toast {
  max-width: 100%;
  padding: 0.45em 1.1em;
  font-family: var(--font-sign);
  font-size: 1.05em;
  text-align: center;
  color: var(--ink);
  background: linear-gradient(var(--cream), var(--cream-dark));
  border: 0.15em solid var(--brass);
  border-radius: 0.5em;
  box-shadow: 0 0.3em 1em rgb(0 0 0 / 0.45);
  animation: toast-in 0.25s ease-out;
}

.toast:nth-last-child(n + 4) {
  display: none;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-0.6em);
  }
}

/* Top right: the menu. */
.hud-menu {
  position: absolute;
  top: 0.75em;
  right: 0.75em;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.4em;
}

.hud-menu .button-brass {
  font-size: 0.9em;
}

.menu-panel {
  min-width: 13em;
  padding: 0.4em;
}

.menu-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.menu-leave {
  margin: 0;
}

.menu-item {
  display: block;
  width: 100%;
  padding: 0.55em 0.8em;
  font: inherit;
  text-align: left;
  color: var(--chalk);
  background: transparent;
  border: 0;
  border-radius: 0.3em;
  cursor: pointer;
}

.menu-item:hover,
.menu-item:focus-visible {
  background: rgb(233 239 230 / 0.12);
}

.menu-item-leave {
  margin-top: 0.25em;
  color: #ffd8dc;
  border-top: 1px dashed rgb(233 239 230 / 0.3);
  border-radius: 0 0 0.3em 0.3em;
}

/* Right edge: the player list, peeked with Tab or opened from the menu. */
.players-panel {
  position: absolute;
  top: 4em;
  right: 0.75em;
  width: min(22em, calc(100vw - 1.5em));
  max-height: calc(100vh - 13em);
  padding: 0.8em 0.9em;
  overflow-y: auto;
}

.players-panel.is-peek .panel-close,
.players-panel.is-peek .panel-hint {
  display: none;
}

.player-rows {
  display: flex;
  flex-direction: column;
  gap: 0.35em;
  margin: 0;
  padding: 0;
  list-style: none;
}

.player-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.1em 0.6em;
  padding: 0.4em 0.5em;
  background: rgb(233 239 230 / 0.06);
  border-radius: 0.3em;
}

.player-who {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.4em;
}

.player-name {
  font-weight: 700;
}

.player-you,
.player-persona {
  font-size: 0.85em;
  opacity: 0.8;
}

.player-title {
  grid-column: 1;
  font-family: var(--font-sign);
  font-size: 0.85em;
  font-style: italic;
  color: var(--brass-light);
}

.player-status {
  grid-column: 1;
  font-size: 0.8em;
  font-style: italic;
  opacity: 0.75;
}

.player-row[data-status="away"],
.player-row[data-status="dozing"] {
  opacity: 0.7;
}

.mute-toggle {
  grid-column: 2;
  grid-row: 1 / span 3;
  padding: 0.3em 0.6em;
  font: inherit;
  font-size: 0.8em;
  color: var(--chalk);
  background: transparent;
  border: 1px solid rgb(233 239 230 / 0.4);
  border-radius: 1em;
  cursor: pointer;
}

.mute-toggle:hover {
  background: rgb(233 239 230 / 0.12);
}

.mute-toggle[aria-pressed="true"] {
  color: var(--ink);
  background: var(--brass);
  border-color: var(--brass-dark);
}

.mute-toggle[aria-pressed="true"]::before {
  content: "✓ ";
}

/* Bottom left: the chat log and box. CSS shows only the last 50 lines. The
   log fades (is-idle, from overlay.ts) after data-fade without a new line,
   and shows again while typing. */
/* The chat stops short of the centred context panel (30em wide). */
.hud-chat {
  position: absolute;
  bottom: 0.75em;
  left: 0.75em;
  display: flex;
  flex-direction: column;
  gap: 0.35em;
  width: min(28em, calc(50vw - 16.5em));
  min-width: min(16em, calc(100vw - 1.5em));
  pointer-events: none;
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 0.15em;
  max-height: 14em;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  /* Older lines fade out at the top edge rather than being cut off. */
  mask-image: linear-gradient(to bottom, transparent, #000 1.5em);
  transition: opacity 0.6s ease;
}

.chat-log:empty {
  display: none;
}

.hud-chat.is-typing .chat-log {
  pointer-events: auto;
}

.hud-chat.is-idle:not(.is-typing) .chat-log {
  opacity: 0;
}

.chat-line {
  flex: none;
  align-self: flex-start;
  max-width: 100%;
  margin: 0;
  padding: 0.15em 0.55em;
  overflow-wrap: anywhere;
  color: var(--cream);
  background: rgb(33 20 13 / 0.72);
  border-radius: 0.35em;
}

.chat-line:nth-last-child(n + 51) {
  display: none;
}

.chat-name {
  margin-right: 0.4em;
  font-weight: 700;
  color: var(--brass-light);
}

.chat-say .chat-text {
  font-style: italic;
}

.chat-bark,
.chat-event {
  color: #cfc6b4;
}

/* NPC barks are grey all through, the speaker's name included, so players'
   own words stand out. */
.chat-bark .chat-name {
  color: #b3ab9b;
}

.chat-form {
  display: none;
  margin: 0;
  pointer-events: auto;
}

.hud-chat.is-typing .chat-form {
  display: block;
}

.chat-input {
  width: 100%;
  padding: 0.5em 0.75em;
  font: inherit;
  color: var(--ink);
  background: var(--cream);
  border: 0.15em solid var(--brass);
  border-radius: 0.45em;
  box-shadow: 0 0.2em 0.8em rgb(0 0 0 / 0.45);
}

.chat-hint {
  align-self: flex-start;
  margin: 0;
  padding: 0.15em 0.55em;
  font-size: 0.85em;
  color: var(--cream);
  background: rgb(33 20 13 / 0.6);
  border-radius: 0.35em;
  cursor: pointer;
  pointer-events: auto;
}

.hud-chat.is-typing .chat-hint {
  display: none;
}

.chat-error {
  margin: 0;
}

.chat-error:empty {
  display: none;
}

.chat-error-text {
  display: inline-block;
  padding: 0.2em 0.6em;
  font-size: 0.9em;
  color: var(--cream);
  background: var(--burgundy);
  border: 1px solid var(--burgundy-dark);
  border-radius: 0.35em;
}

/* Bottom centre: the context panel (dialogue, bar, darts... and for now
   the door prompt). */
.context-panel {
  position: absolute;
  bottom: 0.75em;
  left: 50%;
  width: min(30em, calc(100vw - 32em));
  min-width: min(20em, calc(100vw - 1.5em));
  transform: translateX(-50%);
}

/* At large text sizes a long panel (the song picker) scrolls rather than
   running off the top of the window. */
.context-panel > .panel {
  max-height: calc(100vh - 5em);
  overflow-y: auto;
}

.context-panel:empty {
  display: none;
}

.panel {
  padding: 0.8em 1em 0.9em;
}

.prompt-panel {
  text-align: center;
}

.panel-options {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6em;
  margin-top: 0.7em;
}

.panel-option {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  min-width: 7em;
  padding: 0.5em 1em;
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  background: linear-gradient(var(--brass-light), var(--brass));
  border: 2px solid var(--brass-dark);
  border-radius: 0.45em;
  cursor: pointer;
}

.panel-option:hover {
  background: linear-gradient(#f0d687, var(--brass-light));
}

.panel-option-leave {
  color: var(--cream);
  background: linear-gradient(#8a2a39, var(--burgundy));
  border-color: var(--burgundy-dark);
}

.panel-option-leave:hover {
  background: linear-gradient(#9c3444, #7d2533);
}

/* The dialogue panel (DialoguePanel): who you're talking to, what they say,
   and up to four numbered replies in a column. */
.dialogue-panel .panel-head {
  margin-bottom: 0.4em;
}

.dialogue-leave {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 0.4em;
  padding: 0.2em 0.6em;
  font: inherit;
  font-size: 0.85em;
  color: var(--chalk);
  background: transparent;
  border: 1px solid rgb(233 239 230 / 0.35);
  border-radius: 0.45em;
  cursor: pointer;
}

.dialogue-leave:hover {
  background: rgb(233 239 230 / 0.12);
}

.dialogue-lines {
  display: flex;
  flex-direction: column;
  gap: 0.35em;
}

.dialogue-line {
  margin: 0;
  line-height: 1.4;
}

.dialogue-who {
  margin-right: 0.3em;
  font-family: var(--font-sign);
  font-weight: 700;
  color: var(--brass-light);
}

.dialogue-who::after {
  content: ":";
}

.dialogue-options {
  flex-direction: column;
  align-items: stretch;
  gap: 0.4em;
}

.dialogue-option {
  min-width: 0;
  padding: 0.4em 0.8em;
  text-align: left;
}

.dialogue-option kbd {
  flex: none;
}

/* Bottom right: room for the pint and bladder meters (M5). */
.hud-meters {
  position: absolute;
  right: 0.75em;
  bottom: 0.75em;
  width: 14em;
  height: 5em;
  pointer-events: none;
}

/* Settings and help: dialogs over a dimmed pub. The card's auto margins
   centre it, and a card taller than the window still scrolls from its top. */
.hud-dialog {
  position: absolute;
  inset: 0;
  display: flex;
  padding: 1em;
  overflow-y: auto;
  background: rgb(33 20 13 / 0.55);
}

.dialog-card {
  width: min(32em, 100%);
  margin: auto;
  padding: 1em 1.2em 1.1em;
}

.settings-form fieldset {
  margin: 0 0 0.8em;
  padding: 0.5em 0.8em 0.7em;
  border: 1px solid rgb(233 239 230 / 0.25);
  border-radius: 0.35em;
}

.settings-form legend {
  padding: 0 0.3em;
  font-family: var(--font-sign);
  color: var(--brass-light);
}

.setting {
  display: grid;
  align-items: center;
  gap: 0.6em;
  padding: 0.3em 0;
}

.setting-range {
  grid-template-columns: 8em 1fr 3em;
}

.setting-range output {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.setting-range input {
  width: 100%;
  accent-color: var(--brass);
}

.setting-toggle {
  grid-template-columns: auto 1fr;
  align-items: start;
}

.setting-toggle input {
  width: 1.2em;
  height: 1.2em;
  margin: 0.15em 0 0;
  accent-color: var(--brass);
}

.setting-hint {
  display: block;
  font-size: 0.85em;
  opacity: 0.8;
}

.help-keys {
  width: 100%;
  border-collapse: collapse;
}

.help-keys th,
.help-keys td {
  padding: 0.3em 0.4em;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px dashed rgb(233 239 230 / 0.2);
}

.help-keys th {
  font-weight: 400;
  white-space: nowrap;
}

/* High-contrast panels (Settings). */
:root[data-contrast="high"] .players-panel,
:root[data-contrast="high"] .menu-panel,
:root[data-contrast="high"] .dialog-card,
:root[data-contrast="high"] .panel,
:root[data-contrast="high"] .hud-clock {
  color: #fff;
  background: #000;
  border-color: #ffd166;
  box-shadow: none;
}

:root[data-contrast="high"] .chat-line,
:root[data-contrast="high"] .hud-headcount,
:root[data-contrast="high"] .chat-hint {
  color: #fff;
  background: #000;
}

:root[data-contrast="high"] .toast {
  color: #000;
  background: #fff;
  border-color: #000;
}

:root[data-contrast="high"] .panel-title,
:root[data-contrast="high"] .dialogue-who,
:root[data-contrast="high"] .chat-name,
:root[data-contrast="high"] .player-title,
:root[data-contrast="high"] .settings-form legend {
  color: #ffd166;
}

/* Reduced motion (Settings, or the browser's preference). */
:root[data-motion="reduced"] .toast {
  animation: none;
}

:root[data-motion="reduced"] .chat-log {
  transition: none;
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    animation: none;
  }

  .chat-log {
    transition: none;
  }
}

/* Narrow windows: the context panel gets the full width above the chat. */
@media (max-width: 56em) {
  .context-panel {
    bottom: 5em;
    width: calc(100vw - 1.5em);
  }

  .hud-top-centre {
    width: calc(100vw - 14em);
  }
}

/* A round of shots on offer (ShotsPrompt): In / Not for me, a bar running
   down until the offer closes, and the highlighted answer once the voice of
   reason has talked them out of it. */
.shots-advice {
  margin: 0.3em 0 0;
  font-style: italic;
  color: var(--chalk);
}

.shots-timer {
  height: 0.3em;
  margin-top: 0.6em;
  overflow: hidden;
  background: rgb(233 239 230 / 0.15);
  border-radius: 0.15em;
}

.shots-timer > span {
  display: block;
  height: 100%;
  background: var(--brass);
  transform-origin: left center;
  animation-name: shots-timer;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

@keyframes shots-timer {
  from {
    transform: scaleX(1);
  }
  to {
    transform: scaleX(0);
  }
}

/* The suggested option: a double brass edge and a star, so it never looks
   like the keyboard's focus ring (yellow, outside the button). */
.panel-option-highlight {
  border-style: double;
  border-width: 4px;
  border-color: var(--wood);
}

.panel-option-highlight::after {
  content: "★" / "";
  font-size: 0.8em;
}

:root[data-contrast="high"] .shots-advice {
  color: #ffd166;
}

/* The bar sub-game (BarPanel): waiting with the rude acts on offer, picked
   out of turn, the order form, the pour, cheers and stepping away, with the
   visit's score folded underneath. */
.bar-panel {
  text-align: center;
}

.bar-hint,
.bar-status {
  margin: 0.3em 0 0;
}

.bar-hint {
  font-size: 0.9em;
  opacity: 0.85;
}

.bar-money,
.bar-soft {
  font-style: italic;
  color: var(--brass-light);
}

.bar-link {
  margin-top: 0.3em;
  font: inherit;
  font-size: 0.9em;
  color: var(--brass-light);
  text-decoration: underline;
  background: none;
  border: 0;
  cursor: pointer;
}

.panel-option-rude {
  min-width: 0;
  font-weight: 600;
  color: var(--cream);
  background: linear-gradient(#5b3a26, var(--wood));
  border-color: var(--wood-dark);
}

.panel-option-rude:hover {
  background: linear-gradient(#6c4630, #4a2e1c);
}

.bar-order fieldset {
  margin: 0.6em 0 0;
  padding: 0.4em 0.6em;
  border: 1px solid rgb(233 239 230 / 0.25);
  border-radius: 0.4em;
}

.bar-order legend {
  padding: 0 0.3em;
  font-size: 0.85em;
  opacity: 0.85;
}

.bar-row {
  display: flex;
  gap: 0.4em;
  justify-content: center;
  margin: 0.25em 0;
}

.bar-row select {
  max-width: 48%;
  font: inherit;
  font-size: 0.9em;
}

.bar-snacks label {
  margin: 0 0.5em;
  font-size: 0.9em;
}

.bar-error {
  margin: 0.5em 0 0;
  font-weight: 700;
  color: var(--focus);
}

.bar-score {
  margin-top: 0.6em;
  font-size: 0.85em;
  text-align: left;
}

.bar-score summary {
  cursor: pointer;
}

.bar-score ul {
  margin: 0.3em 0 0;
  padding-left: 1.2em;
}

.bar-points {
  font-weight: 700;
}

/* Bar session scores under a player's title in the player list. */
.player-scores {
  grid-column: 1;
  font-size: 0.8em;
  opacity: 0.85;
}

.player-lead {
  font-weight: 700;
  color: var(--brass-light);
}

/* Leading the pub: a star as well as the colour (alt text for readers). */
.player-lead::before {
  content: "★ " / "top of the pub: ";
}

/* Landlord mode (M6): the staff entrance, the barred notice and page, the
   landlord panel (L), the landlord's prompt, asking for advice and the
   "Landlord's wisdom" card. */
.staff-entrance {
  margin-top: 1.5rem;
  font-size: 0.9rem;
  text-align: center;
}

.staff-entrance summary {
  display: inline-block;
  cursor: pointer;
  color: var(--brass-light);
  opacity: 0.8;
}

.staff-form {
  display: grid;
  gap: 0.4rem;
  width: min(20rem, 100%);
  margin: 0.8rem auto 0;
  padding: 0.9rem 1rem;
  text-align: left;
  color: var(--chalk);
  background: var(--chalkboard);
  border: 3px solid var(--wood);
  border-radius: var(--radius);
}

.staff-hint {
  margin: 0;
  font-size: 0.85em;
  opacity: 0.8;
}

.staff-form input {
  padding: 0.4rem 0.5rem;
  font: inherit;
  color: var(--ink);
  background: var(--cream);
  border: 1px solid var(--brass-dark);
  border-radius: 0.3em;
}

.staff-result:empty {
  display: none;
}

.lobby-notice,
.barred-notice p {
  margin: 0 0 1rem;
  padding: 0.6rem 1rem;
  font-family: var(--font-sign);
  color: var(--chalk);
  background: var(--chalkboard);
  border: 3px solid var(--wood);
  border-radius: var(--radius);
}

.barred-notice p {
  margin: 0;
  color: var(--cream);
  background: var(--burgundy);
  border-color: var(--burgundy-dark);
}

.barred {
  display: flex;
  min-height: 100vh;
  padding: 1rem;
}

.barred-card {
  width: min(32rem, 100%);
  margin: auto;
  padding: 1.5rem 1.6rem;
  text-align: center;
  color: var(--chalk);
  background: var(--chalkboard);
  border: 0.4rem solid var(--wood);
  border-radius: var(--radius);
  box-shadow: 0 0.5em 1.4em rgb(0 0 0 / 0.5);
}

.barred-card h1 {
  font-family: var(--font-sign);
}

.barred-reason q {
  font-family: var(--font-sign);
  font-size: 1.15em;
}

/* The landlord panel: upper middle, clear of the context panel below. */
.landlord-panel {
  position: absolute;
  top: 4em;
  left: 50%;
  width: min(34em, calc(100vw - 1.5em));
  max-height: calc(100vh - 16em);
  overflow-y: auto;
  transform: translateX(-50%);
}

.landlord-card {
  padding: 0.8em 1em 0.9em;
  color: var(--chalk);
  background: var(--chalkboard);
  border: 0.3em solid var(--wood);
  border-radius: 0.45em;
  box-shadow: 0 0.5em 1.4em rgb(0 0 0 / 0.5), inset 0 0 0 1px rgb(201 162 74 / 0.35);
}

.landlord-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3em;
  margin-bottom: 0.6em;
  border-bottom: 1px solid rgb(233 239 230 / 0.25);
}

.landlord-tab {
  padding: 0.3em 0.7em;
  font: inherit;
  font-size: 0.9em;
  color: var(--chalk);
  cursor: pointer;
  background: none;
  border: 0;
  border-bottom: 3px solid transparent;
}

.landlord-tab-on {
  font-weight: 700;
  border-bottom-color: var(--brass);
}

.landlord-heading {
  margin: 0.7em 0 0.3em;
  font-size: 0.95em;
}

.landlord-rows {
  display: flex;
  flex-direction: column;
  gap: 0.35em;
  margin: 0;
  padding: 0;
  list-style: none;
}

.landlord-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.3em 0.6em;
  padding: 0.4em 0.5em;
  background: rgb(233 239 230 / 0.06);
  border-radius: 0.3em;
}

.landlord-who {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.5em;
}

.landlord-name {
  font-weight: 700;
}

.landlord-persona,
.landlord-detail,
.landlord-empty {
  font-size: 0.85em;
  opacity: 0.8;
}

.landlord-question,
.landlord-chalk {
  font-family: var(--font-sign);
}

.landlord-tag {
  padding: 0 0.4em;
  font-size: 0.8em;
  color: var(--cream);
  background: var(--burgundy);
  border-radius: 0.3em;
}

.landlord-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3em;
}

.landlord-button {
  padding: 0.2em 0.6em;
  font: inherit;
  font-size: 0.85em;
  color: var(--ink);
  cursor: pointer;
  background: var(--cream);
  border: 1px solid var(--brass-dark);
  border-radius: 0.3em;
}

.landlord-notice {
  margin: 0 0 0.6em;
  padding: 0.3em 0.6em;
  color: var(--cream);
  background: var(--burgundy);
  border-radius: 0.3em;
}

.landlord-log {
  width: 100%;
  font-size: 0.85em;
  border-collapse: collapse;
}

.landlord-log td {
  padding: 0.2em 0.4em;
  vertical-align: top;
  border-bottom: 1px solid rgb(233 239 230 / 0.12);
}

.landlord-log-time {
  white-space: nowrap;
}

/* The landlord's forms in the context panel, and asking for advice. */
.landlord-form {
  text-align: left;
}

.landlord-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2em 0.9em;
  margin: 0 0 0.6em;
  padding: 0.4em 0.7em 0.6em;
  border: 1px solid rgb(233 239 230 / 0.25);
  border-radius: 0.35em;
}

.landlord-form input[type="text"] {
  width: 100%;
  padding: 0.35em 0.5em;
  font: inherit;
  color: var(--ink);
  background: var(--cream);
  border: 1px solid var(--brass-dark);
  border-radius: 0.3em;
}

.landlord-custom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3em;
  width: 100%;
}

.landlord-custom input[type="text"] {
  flex: 1;
  width: auto;
  min-width: 10em;
}

.landlord-asked {
  margin: 0 0 0.5em;
  font-size: 0.9em;
}

/* The "Landlord's wisdom" card: above the context panel. */
.advice-card-region {
  position: absolute;
  bottom: 12em;
  left: 50%;
  width: min(24em, calc(100vw - 1.5em));
  transform: translateX(-50%);
}

.advice-card-region:empty {
  display: none;
}

.advice-card {
  padding: 0.8em 1em 0.9em;
  text-align: center;
  color: var(--ink);
  background: var(--cream);
  border: 0.3em solid var(--brass);
  border-radius: 0.45em;
  box-shadow: 0 0.5em 1.4em rgb(0 0 0 / 0.5);
}

.advice-text {
  margin: 0.3em 0;
  font-family: var(--font-sign);
  font-size: 1.15em;
}

.advice-from {
  margin: 0;
  font-size: 0.85em;
  font-style: italic;
}

.advice-from::before {
  content: "— ";
}

:root[data-contrast="high"] .landlord-card,
:root[data-contrast="high"] .advice-card {
  color: #fff;
  background: #000;
  border-color: #ffd166;
  box-shadow: none;
}

/* The darts sub-game (DartsPanel, DartsChallenge): the mode panel, picking
   who to challenge, the darts regular's difficulty, challenges, the
   chalkboard queue and the match panel players near the oche see. */
.darts-panel {
  text-align: center;
}

.darts-status,
.darts-hint,
.darts-visit,
.darts-result {
  margin: 0.3em 0 0;
}

.darts-error {
  margin: 0.5em 0 0;
  font-weight: 700;
  color: var(--focus);
}

.darts-difficulty {
  font-size: 0.75em;
  opacity: 0.85;
}

.darts-queue {
  display: inline-block;
  margin: 0.3em 0 0;
  padding-left: 1.4em;
  text-align: left;
}

.darts-scores {
  margin: 0.4em auto 0;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.darts-scores th,
.darts-scores td {
  padding: 0.1em 0.6em;
  text-align: left;
}

.darts-scores thead th {
  font-size: 0.8em;
  font-weight: 400;
  opacity: 0.8;
}

.darts-scores td {
  text-align: right;
}

.darts-turn th::before {
  content: "▶ ";
  color: var(--brass-light);
}

.darts-you th {
  color: var(--brass-light);
}

.darts-you-tag {
  margin-left: 0.3em;
  font-weight: 400;
}

.darts-dart {
  display: inline-block;
  min-width: 2.4em;
  margin: 0 0.15em;
  padding: 0 0.3em;
  font-weight: 700;
  border: 1px solid rgb(233 239 230 / 0.35);
  border-radius: 0.3em;
}

.darts-dart-none {
  opacity: 0.5;
}

.darts-bust,
.darts-result {
  font-weight: 700;
  color: var(--brass-light);
}

.darts-total {
  opacity: 0.85;
}

.player-darts {
  display: block;
}

/* The karaoke machine (KaraokePanel): the song picker, Easy or Normal, the
   duet note, and your place in the queue. */
.karaoke-panel {
  text-align: center;
}

.karaoke-status,
.karaoke-duet {
  margin: 0.3em 0 0;
}

.karaoke-duet {
  font-size: 0.85em;
  opacity: 0.9;
}

.karaoke-error {
  margin: 0.5em 0 0;
  font-weight: 700;
  color: var(--focus);
}

.karaoke-modes {
  display: flex;
  gap: 0.4em;
  justify-content: center;
  margin: 0.4em 0;
}

.karaoke-mode {
  display: flex;
  flex-direction: column;
  max-width: 14em;
  padding: 0.3em 0.6em;
  color: inherit;
  font: inherit;
  background: transparent;
  border: 1px solid rgb(233 239 230 / 0.35);
  border-radius: 0.3em;
  cursor: pointer;
}

.karaoke-mode-on {
  border-color: var(--brass-light);
  box-shadow: inset 0 0 0 1px var(--brass-light);
}

/* The chosen way to sing: ticked, not just outlined. */
.karaoke-mode[aria-pressed="true"] .karaoke-mode-label::before {
  content: "✓ " / "";
}

.karaoke-mode-label {
  font-weight: 700;
}

.karaoke-mode-help {
  font-size: 0.75em;
  opacity: 0.85;
}

.karaoke-song {
  display: flex;
  gap: 0.5em;
  align-items: baseline;
  text-align: left;
}

.karaoke-song-title {
  flex: 1;
}

.karaoke-song-length {
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
}

.karaoke-song-difficulty {
  min-width: 4.5em;
  font-size: 0.8em;
  text-align: right;
}

.karaoke-hard {
  color: var(--brass-light);
}

.karaoke-queue {
  display: inline-block;
  margin: 0.3em 0 0;
  padding-left: 1.4em;
  text-align: left;
}

.player-karaoke {
  display: block;
}

.karaoke-stars {
  color: var(--brass-light);
  letter-spacing: -0.05em;
}

.player-favourite {
  color: var(--brass-light);
}

/* ---------- Accessibility (M10, SPEC.md "Accessibility") ---------- */

/* Every context panel has a close control (Esc does the same), top right. */
.panel {
  position: relative;
}

.panel-esc {
  position: absolute;
  top: 0.35em;
  right: 0.4em;
  padding: 0.1em 0.4em;
  font: inherit;
  font-size: 0.75em;
  color: inherit;
  background: transparent;
  border: 1px solid rgb(233 239 230 / 0.35);
  border-radius: 0.35em;
  cursor: pointer;
}

.panel-esc:hover {
  background: rgb(233 239 230 / 0.12);
}

.panel-esc kbd {
  font-size: 0.85em;
}

/* Leave room for it beside the title. */
.panel:has(> .panel-esc) > .panel-title,
.panel:has(> .panel-esc) .panel-title:first-of-type {
  padding-right: 4.5em;
}

.panel-esc-hint {
  font-weight: 400;
  font-size: 0.85em;
}

/* Captions: a meaningful sound, named in brackets like a subtitle. */
.toast-caption {
  font-family: var(--font-body);
  font-weight: 600;
}

.toast-sound {
  font-style: italic;
  font-weight: 400;
}

/* Easy timing: the asterisk on scores made with it, and what it means. */
.easy-mark {
  font-weight: 700;
  color: var(--brass-light);
}

.easy-legend {
  margin: 0.5em 0 0;
  font-size: 0.85em;
}

/* High contrast: no faded text anywhere in the HUD's panels. */
:root[data-contrast="high"] :is(.panel-hint, .player-persona, .player-status, .setting-hint, .bar-hint, .bar-order legend, .player-scores,
  .landlord-empty, .darts-difficulty, .darts-scores thead th, .darts-dart-none, .darts-total, .karaoke-duet, .karaoke-mode-help,
  .karaoke-song-length, .landlord-detail, .panel-esc-hint) {
  color: #fff;
  opacity: 1;
}

:root[data-contrast="high"] :is(.compat-banner, .conn-reconnecting, .notice-card) {
  color: #fff;
  background: #000;
  border-color: #ffd166;
}

:root[data-contrast="high"] .banner-close {
  color: #fff;
}

:root[data-contrast="high"] :is(.panel-option, .karaoke-mode, .landlord-tab, .mute-toggle, .button-brass, .bar-link) {
  border-width: 2px;
  border-style: solid;
}

:root[data-contrast="high"] .panel-option {
  color: #000;
  background: #fff;
  border-color: #ffd166;
}

:root[data-contrast="high"] .karaoke-song-difficulty {
  color: #000;
  font-weight: 700;
}

:root[data-contrast="high"] .panel-option-leave,
:root[data-contrast="high"] .panel-option-rude {
  color: #fff;
  background: #000;
  border-color: #fff;
}

:root[data-contrast="high"] .panel-option-highlight {
  border-style: double;
  border-width: 4px;
  border-color: #000;
}

:root[data-contrast="high"] .panel-esc {
  border-color: #fff;
}

:root[data-contrast="high"] .easy-mark,
:root[data-contrast="high"] .player-lead,
:root[data-contrast="high"] .darts-you th {
  color: #ffd166;
}

:root[data-contrast="high"] .toast-caption {
  color: #000;
  background: #fff;
}

:root[data-contrast="high"] :focus-visible {
  outline-color: #ffd166;
  box-shadow: 0 0 0 2px #000, 0 0 0 7px #fff;
}

/* Reduced motion: nothing in the HUD slides or fades in. The timer bars
   are information (time left to choose), so they keep running. */
:root[data-motion="reduced"] .hud :not(.shots-timer > span),
:root[data-motion="reduced"] .hud ::before,
:root[data-motion="reduced"] .hud ::after {
  animation: none !important;
  transition: none !important;
}
