:root {
  --bg: #14171c;
  --panel: #1d222a;
  --panel-edge: #2b323c;
  --ink: #eef2f6;
  --ink-dim: #97a2af;
  --amber: #f0a92b;
  --amber-deep: #c9761a;
  --green: #4ec27a;
  --grey: #6b7683;
  --house-edge: #262c35;
  --wire-0: #e0803a;
  --wire-1: #4a9ed8;
  --wire-2: #7fb861;
  --wire-3: #b47ad0;
  --wire-4: #d8b23c;
  --wire-5: #52b5a8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 1.5rem 1.5rem;
  background:
    radial-gradient(circle at 50% -10%, #232a34 0%, var(--bg) 55%) no-repeat;
  background-color: var(--bg);
  min-height: 100vh;
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.masthead {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.5rem 0 0;
  text-align: center;
}

.masthead h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.masthead__tagline {
  margin: 0.25rem 0 0;
  color: var(--ink-dim);
  font-size: 0.9rem;
}

/* The board holds the kegs box, the houses, and the wires drawn between them.
   Everything the wires connect has to share this positioned ancestor. */
.board {
  position: relative;
  max-width: 108rem;
  margin: 1.5rem auto 0;
}

/* Wires sit under the boxes. The box fills are nearly transparent so a wire
   shows through them, while the cards themselves are opaque, so each wire
   visually terminates at the edge of the card it points at. */
.wires {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  overflow: visible;
}

/* The modifier only carries the colour; whether that colour is a stroke or a
   fill is decided by the element, so a path never gets filled in. */
.wire {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  opacity: 0.55;
}

.wire-dot {
  fill: currentColor;
  stroke: none;
  opacity: 0.9;
}

.wire--0 { color: var(--wire-0); }
.wire--1 { color: var(--wire-1); }
.wire--2 { color: var(--wire-2); }
.wire--3 { color: var(--wire-3); }
.wire--4 { color: var(--wire-4); }
.wire--5 { color: var(--wire-5); }

.kegs {
  max-width: 56rem;
  margin: 0 auto;
}

.kegs, .house {
  position: relative;
  z-index: 1;
  padding: 1.15rem 1.25rem 1.35rem;
  border: 1px solid var(--house-edge);
  border-radius: 1.25rem;
  background: rgba(255, 255, 255, 0.018);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
  text-align: center;
}

.box__name {
  display: inline-block;
  margin: 0 0 1rem;
  padding: 0.35rem 1.1rem;
  border: 1px solid var(--house-edge);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

/* Houses sit side by side when there is room, and stack when there is not. */
.houses {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(38rem, 1fr));
  gap: 2rem;
  margin-top: 4rem;
  align-items: start;
}

.keg-cards, .taps {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.25rem;
}

/* --- Keg card ---------------------------------------------------------- */

.keg-card {
  flex: 0 1 14rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem 1rem 1.15rem;
  border: 1px solid var(--panel-edge);
  border-radius: 1rem;
  background: linear-gradient(180deg, var(--panel) 0%, #171b21 100%);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.keg-card--pouring {
  border-color: var(--amber-deep);
  box-shadow: 0 0 0 1px rgba(240, 169, 43, 0.25), 0 12px 32px -18px var(--amber);
}

.keg-card__body { width: 100%; }

.keg-card__name {
  margin: 0.75rem 0 0.15rem;
  font-size: 1.05rem;
  font-weight: 650;
}

.keg-card__meta {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
}

.keg-card__size { color: var(--ink-dim); }

/* --- Tap card ---------------------------------------------------------- */

.tap {
  /* Grow to share the row evenly, but never balloon when a house has one tap. */
  flex: 1 1 12rem;
  max-width: 20rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem 1rem 1.15rem;
  text-align: center;
  border: 1px solid var(--panel-edge);
  border-radius: 1rem;
  background: linear-gradient(180deg, var(--panel) 0%, #171b21 100%);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.tap--pouring {
  border-color: var(--amber-deep);
  box-shadow: 0 0 0 1px rgba(240, 169, 43, 0.25), 0 12px 32px -18px var(--amber);
}

.tap--offline { opacity: 0.55; }

.tap__name {
  margin: 0 0 0.3rem;
  font-size: 1.15rem;
  font-weight: 650;
}

.tap__keg {
  margin: 0 0 0.85rem;
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--ink-dim);
}

.tap__keg--empty { color: var(--grey); font-style: italic; }

.tap__seen {
  margin: 0.6rem 0 0;
  font-size: 0.72rem;
  color: var(--grey);
}

/* --- Status pill ------------------------------------------------------- */

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status__dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--grey);
}

.tap--idle .status { color: var(--green); }
.tap--idle .status__dot { background: var(--green); }

.tap--pouring .status { color: var(--amber); background: rgba(240, 169, 43, 0.12); }
.tap--pouring .status__dot { background: var(--amber); animation: pulse 1s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.7); }
}

/* --- Keg --------------------------------------------------------------- */

.keg-defs { position: absolute; width: 0; height: 0; }

.keg {
  position: relative;
  width: 5.75rem;
  filter: drop-shadow(0 14px 14px rgba(0, 0, 0, 0.45));
}

.keg__svg { display: block; width: 100%; height: auto; }

.keg--empty { filter: drop-shadow(0 14px 14px rgba(0, 0, 0, 0.45)); }

.keg--pouring { filter: drop-shadow(0 0 14px rgba(240, 169, 43, 0.4)); }

.keg-card--pouring .status__dot { background: var(--amber); }

/* Beer only runs while the tap is pouring. */
.keg__stream {
  position: absolute;
  bottom: -0.35rem;
  left: 50%;
  translate: -50% 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 0;
}

.keg--pouring .keg__stream { opacity: 1; }

.keg__drop {
  width: 0.3rem;
  height: 0.55rem;
  border-radius: 0 0 50% 50%;
  background: linear-gradient(180deg, var(--amber) 0%, var(--amber-deep) 100%);
  animation: drip 900ms linear infinite;
}

.keg__drop:nth-child(2) { animation-delay: 300ms; }
.keg__drop:nth-child(3) { animation-delay: 600ms; }

@keyframes drip {
  0%   { opacity: 0; transform: translateY(-0.5rem) scaleY(0.6); }
  30%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(1.4rem) scaleY(1.2); }
}

@media (prefers-reduced-motion: reduce) {
  .keg__drop, .tap--pouring .status__dot { animation: none; }
}

/* --- Buttons, forms and flashes ---------------------------------------- */

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
  margin: 0.75rem 0 0;
}

.button-form { display: inline; margin: 0; }

/* Running total, on both tap cards and keg cards. */
.usage {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.4rem;
  margin: 0.7rem 0 0;
}

.usage__label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--grey);
}

.usage__total {
  font-size: 1rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.tap__seen { font-variant-numeric: tabular-nums; }

.button {
  display: inline-block;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--panel-edge);
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink-dim);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
}

.button:hover {
  color: var(--ink);
  border-color: var(--amber-deep);
  background: rgba(240, 169, 43, 0.1);
}

.button--primary {
  border-color: var(--amber-deep);
  background: var(--amber);
  color: #1a1206;
}

.button--primary:hover { background: #ffbe45; color: #1a1206; }

.masthead__back { margin: 0 0 0.75rem; font-size: 0.8rem; }
.masthead__back a { color: var(--ink-dim); text-decoration: none; }
.masthead__back a:hover { color: var(--amber); }

.flash {
  max-width: 72rem;
  margin: 1rem auto 0;
  padding: 0.7rem 1rem;
  border: 1px solid var(--amber-deep);
  border-radius: 0.6rem;
  background: rgba(240, 169, 43, 0.1);
  color: var(--amber);
  font-size: 0.85rem;
}

.form {
  max-width: 26rem;
  padding: 1.5rem;
  border: 1px solid var(--panel-edge);
  border-radius: 1rem;
  background: var(--panel);
}

.form__field { margin-bottom: 1.1rem; }

.form__field label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.form__field input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--panel-edge);
  border-radius: 0.5rem;
  background: #12161b;
  color: var(--ink);
  font: inherit;
}

.form__field input:focus {
  outline: none;
  border-color: var(--amber-deep);
  box-shadow: 0 0 0 3px rgba(240, 169, 43, 0.15);
}

.form__actions { display: flex; gap: 0.6rem; align-items: center; }

.form__errors {
  margin-bottom: 1.1rem;
  padding: 0.75rem 1rem;
  border: 1px solid #a13c3c;
  border-radius: 0.6rem;
  background: rgba(180, 60, 60, 0.12);
  color: #f0a0a0;
  font-size: 0.85rem;
}

.form__errors p { margin: 0.15rem 0; }

.keg-card__cost {
  color: var(--ink);
  font-weight: 600;
}

.keg-card__cost::before {
  content: "·";
  margin: 0 0.35rem;
  color: var(--grey);
  font-weight: 400;
}

.form__hint {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.72rem;
  color: var(--grey);
}

/* --- Settling up a finished keg ---------------------------------------- */

.settle {
  max-width: 40rem;
  margin: 0 auto;
}

.notice {
  margin: 0 0 1.25rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--panel-edge);
  border-radius: 0.6rem;
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.85rem;
  color: var(--ink-dim);
}

.notice a { color: var(--amber); }

.settle__table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--panel-edge);
  border-radius: 1rem;
  background: var(--panel);
  overflow: hidden;
}

.settle__table th,
.settle__table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--panel-edge);
}

.settle__table thead th {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.settle__table .numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.settle__table .strong { font-weight: 650; color: var(--ink); }

.settle__table tbody tr:last-child td { border-bottom: 1px solid var(--panel-edge); }

.settle__table tfoot th,
.settle__table tfoot td {
  border-bottom: none;
  background: rgba(255, 255, 255, 0.03);
  font-weight: 600;
}

.settle__note {
  margin: 1rem 0 0;
  font-size: 0.78rem;
  color: var(--grey);
}

.settle__actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.settle__hint {
  font-size: 0.78rem;
  color: var(--grey);
}

.button--danger {
  border-color: #7d3535;
  background: rgba(180, 60, 60, 0.14);
  color: #e79a9a;
}

.button--danger:hover {
  border-color: #a44646;
  background: rgba(180, 60, 60, 0.24);
  color: #ffc4c4;
}
