/*
 * Free Country: the base stylesheet.
 *
 * A gritty, modern tactical HUD. Phone first. Plain CSS, no framework, no build step.
 *
 * Rules
 * - Colors come only from the --color-* tokens in :root, written as 6-digit hex.
 *   tests/Unit/Design/PaletteTest.php reads them and checks every text pairing for
 *   WCAG AA contrast. Shades of black for shadows and scanlines are the one exception.
 * - Sizes are in rem, so text follows the player's text-size settings.
 *   Tap targets have a 44px floor. Story text is never below 1rem (16px).
 * - Square edges. Nothing gets border-radius.
 * - No inline styles anywhere: the Content-Security-Policy blocks them.
 * - Color is never the only signal. Pair it with text, a sign, a shape or a label.
 * - Motion is short and optional. prefers-reduced-motion turns it off.
 *
 * Contents
 *   1. Fonts          6. Buttons           11. Notices and badges
 *   2. Tokens         7. Scene card        12. Panels
 *   3. Base           8. Tab bar           13. Forms
 *   4. Layout         9. Bars and stats    14. Utilities
 *   5. Type          10. Combat log        15. Motion
 */

/* 1. Fonts ------------------------------------------------------------------
 * Self-hosted. No requests to outside servers. SIL Open Font License 1.1;
 * each family's OFL.txt sits next to its files. latin-ext only downloads when
 * a page uses a character from that range.
 */

@font-face {
  font-family: "Barlow";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/barlow/barlow-latin-ext-400-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Barlow";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/barlow/barlow-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Barlow";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/barlow/barlow-latin-ext-400-italic.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Barlow";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/barlow/barlow-latin-400-italic.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Barlow";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/barlow/barlow-latin-ext-600-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Barlow";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/barlow/barlow-latin-600-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Barlow Condensed";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/barlow-condensed/barlow-condensed-latin-ext-500-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Barlow Condensed";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/barlow-condensed/barlow-condensed-latin-500-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Barlow Condensed";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/barlow-condensed/barlow-condensed-latin-ext-600-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Barlow Condensed";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/barlow-condensed/barlow-condensed-latin-600-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Barlow Condensed";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/barlow-condensed/barlow-condensed-latin-ext-700-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Barlow Condensed";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/barlow-condensed/barlow-condensed-latin-700-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/jetbrains-mono/jetbrains-mono-latin-ext-400-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/jetbrains-mono/jetbrains-mono-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/jetbrains-mono/jetbrains-mono-latin-ext-700-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/jetbrains-mono/jetbrains-mono-latin-700-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* 2. Tokens ----------------------------------------------------------------- */

:root {
  /* Color roles. Contrast for every pairing is listed in docs/design.md. */
  --color-bg: #0e110c;
  --color-surface: #161a13;
  --color-surface-raised: #1f2519;
  --color-line: #3a4331;
  --color-line-strong: #5d6a4c;
  --color-text: #ebe8dc;
  --color-text-muted: #a4a694;
  --color-action: #a9451e;
  --color-action-edge: #cc5f33;
  --color-action-pressed: #8f3714;
  --color-action-text: #e8824f;
  --color-threat: #ff6a5c;
  --color-threat-fill: #ff4d3d;
  --color-player: #9fbb63;
  --color-loot: #d4b660;
  --color-disabled-bg: #22281d;
  --color-disabled-text: #9a9c8b;

  /* Type */
  --font-display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --text-story: 1.125rem;
  --text-body: 1rem;
  --text-small: 0.875rem;
  --text-tiny: 0.75rem;

  /* Touch */
  --tap: max(44px, 2.75rem);
  --tap-action: max(52px, 3.25rem);
  --tabbar-height: max(60px, 3.75rem);

  /* Space */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;

  /* Shape */
  --shell-max: 36rem;
  --edge: 1px solid var(--color-line);
  --edge-strong: 1px solid var(--color-line-strong);
  --shade: rgb(0 0 0 / 35%);
}

/* 3. Base ------------------------------------------------------------------- */

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

html {
  color-scheme: dark;
  background-color: var(--color-bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* iPhone and iPad: follow the Dynamic Type text size from the phone's settings.
   The -webkit-touch-callout test limits this to iOS, where the base size is 17px. */
@supports (font: -apple-system-body) and (-webkit-touch-callout: default) {
  html {
    font: -apple-system-body;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: var(--text-body);
  line-height: 1.5;
  color: var(--color-text);
  background-color: var(--color-bg);
  background-image: radial-gradient(120% 50% at 50% 0%, var(--color-surface) 0%, var(--color-bg) 70%);
  background-attachment: fixed;
  overflow-wrap: break-word;
  -webkit-tap-highlight-color: transparent;
}

img,
svg {
  display: block;
  max-width: 100%;
}

a {
  color: var(--color-action-text);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 3px solid var(--color-text);
  outline-offset: 2px;
}

::selection {
  color: var(--color-text);
  background-color: var(--color-action);
}

p {
  margin: 0 0 1em;
}

/* 4. Layout ----------------------------------------------------------------- */

.skip-link {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  z-index: 100;
  padding: var(--space-2) var(--space-3);
  color: var(--color-text);
  background-color: var(--color-surface-raised);
  border: var(--edge-strong);
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

.shell {
  width: 100%;
  max-width: var(--shell-max);
  margin-inline: auto;
  padding-inline: var(--space-4);
}

.page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: max(var(--space-4), env(safe-area-inset-top, 0px));
  padding-bottom: var(--space-5);
}

.main {
  display: flex;
  flex: 1;
  flex-direction: column;
}

.has-tabbar .page {
  padding-bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom, 0px) + var(--space-5));
}

.site-footer {
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: var(--edge);
  font-family: var(--font-mono);
  font-size: var(--text-small);
  color: var(--color-text-muted);
}

.site-footer p {
  margin-bottom: var(--space-1);
}

/* 5. Type ------------------------------------------------------------------- */

h1,
h2,
h3,
.display {
  margin: 0 0 var(--space-3);
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

h1 {
  font-size: 2.25rem;
}

h2 {
  font-size: 1.625rem;
  font-weight: 600;
}

h3 {
  font-size: 1.25rem;
  font-weight: 600;
}

.story {
  font-size: var(--text-story);
  line-height: 1.6;
}

.story p {
  max-width: 38em;
}

.story em {
  font-style: italic;
}

.story strong {
  font-weight: 600;
}

.label {
  margin: 0 0 var(--space-1);
  font-family: var(--font-display);
  font-size: var(--text-small);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.mono,
.readout,
code {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums slashed-zero;
}

.readout {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.text-muted {
  color: var(--color-text-muted);
}

.text-threat {
  color: var(--color-threat);
}

.text-player {
  color: var(--color-player);
}

.text-loot {
  color: var(--color-loot);
}

/* 6. Buttons ----------------------------------------------------------------
 * Buttons press in the moment a finger lands: no transition, a 2px drop, and
 * the shading flips from the bottom edge to the top. iOS needs the touchstart
 * listener in app.js before it shows :active at all.
 */

.btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  width: 100%;
  min-height: var(--tap-action);
  margin: 0;
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-display);
  font-size: 1.1875rem;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: 0.08em;
  text-align: center;
  text-decoration: none;
  text-transform: uppercase;
  color: var(--color-text);
  background-color: var(--color-surface-raised);
  border: var(--edge-strong);
  border-radius: 0;
  box-shadow: inset 0 -3px 0 var(--shade);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.btn:active {
  transform: translateY(2px);
  box-shadow: inset 0 3px 0 var(--shade);
}

.btn--primary {
  background-color: var(--color-action);
  border-color: var(--color-action-edge);
}

.btn--primary:active {
  background-color: var(--color-action-pressed);
}

@media (hover: hover) {
  .btn:hover {
    border-color: var(--color-text);
  }
}

.btn:disabled,
.btn[aria-disabled="true"] {
  color: var(--color-disabled-text);
  background-color: var(--color-disabled-bg);
  border-color: var(--color-line);
  box-shadow: none;
  transform: none;
  cursor: not-allowed;
}

.btn__index {
  position: absolute;
  left: var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-small);
  font-weight: 400;
  letter-spacing: 0;
  opacity: 0.8;
}

.btn__label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.125rem;
  padding-inline: var(--space-6);
}

.btn__note {
  font-family: var(--font-mono);
  font-size: var(--text-small);
  font-weight: 400;
  letter-spacing: 0.02em;
  text-transform: none;
}

/* 7. Scene card --------------------------------------------------------------
 * Art at the top, framed as a drone feed. Story text in the middle. Two to
 * four big action buttons at the bottom, where the thumb lands.
 */

.scene {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--space-5);
}

.scene__title {
  margin-bottom: 0;
  font-size: 2.25rem;
  font-weight: 700;
}

.scene__subtitle {
  font-size: 1.375rem;
  font-weight: 600;
}

.scene__body p:last-child {
  margin-bottom: 0;
}

.scene__reference {
  font-size: var(--text-small);
  color: var(--color-text-muted);
}

.scene__actions {
  display: grid;
  gap: var(--space-3);
  margin-top: auto;
  padding-top: var(--space-2);
}

.scene__actions form {
  margin: 0;
}

/* The feed: art behind scanlines, corner brackets, a center reticle and HUD labels. */

.feed {
  position: relative;
  margin: 0;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background-color: var(--color-surface);
  border: var(--edge);
}

.feed__art {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.feed::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, transparent 0 2px, rgb(0 0 0 / 22%) 2px 3px),
    radial-gradient(ellipse at center, transparent 55%, rgb(0 0 0 / 50%) 100%);
}

.feed::after {
  --arm: 1.125rem;
  --weight: 2px;
  --ink: var(--color-text);

  content: "";
  position: absolute;
  inset: var(--space-2);
  z-index: 2;
  pointer-events: none;
  background:
    linear-gradient(var(--ink), var(--ink)) left top / var(--arm) var(--weight) no-repeat,
    linear-gradient(var(--ink), var(--ink)) left top / var(--weight) var(--arm) no-repeat,
    linear-gradient(var(--ink), var(--ink)) right top / var(--arm) var(--weight) no-repeat,
    linear-gradient(var(--ink), var(--ink)) right top / var(--weight) var(--arm) no-repeat,
    linear-gradient(var(--ink), var(--ink)) left bottom / var(--arm) var(--weight) no-repeat,
    linear-gradient(var(--ink), var(--ink)) left bottom / var(--weight) var(--arm) no-repeat,
    linear-gradient(var(--ink), var(--ink)) right bottom / var(--arm) var(--weight) no-repeat,
    linear-gradient(var(--ink), var(--ink)) right bottom / var(--weight) var(--arm) no-repeat,
    linear-gradient(var(--ink), var(--ink)) center / 0.875rem 1px no-repeat,
    linear-gradient(var(--ink), var(--ink)) center / 1px 0.875rem no-repeat;
  opacity: 0.85;
}

.feed__hud {
  position: absolute;
  inset: calc(var(--space-2) + 0.375rem) calc(var(--space-2) + 1.5rem);
  z-index: 3;
  display: grid;
  grid-template-columns: 1fr auto;
  align-content: space-between;
  gap: var(--space-1);
  pointer-events: none;
  font-family: var(--font-mono);
  font-size: var(--text-tiny);
  line-height: 1.2;
  text-transform: uppercase;
}

.feed__chip {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 0.375em;
  padding: 0.125rem 0.375rem;
  color: var(--color-text);
  background-color: var(--color-bg);
  border: var(--edge);
  white-space: nowrap;
}

.feed__chip:nth-child(even) {
  justify-self: end;
}

.feed__rec {
  display: inline-block;
  width: 0.5em;
  height: 0.5em;
  background-color: var(--color-threat-fill);
}

/* 8. Tab bar -----------------------------------------------------------------
 * Fixed to the bottom on logged-in screens. The active tab has a rust bar on
 * top, brighter text and aria-current. Unavailable tabs say "Soon".
 */

.tabbar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background-color: var(--color-surface);
  border-top: var(--edge-strong);
}

.tabbar__list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 0;
  list-style: none;
}

.tabbar__item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  min-height: var(--tabbar-height);
  padding: 0.375rem 0.125rem;
  font-family: var(--font-display);
  font-size: var(--text-small);
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.06em;
  text-decoration: none;
  text-transform: uppercase;
  color: var(--color-text-muted);
  touch-action: manipulation;
}

.tabbar__icon {
  width: 1.5rem;
  height: 1.5rem;
  opacity: 0.7;
}

a.tabbar__item:active {
  background-color: var(--color-surface-raised);
}

.tabbar__item[aria-current="page"] {
  color: var(--color-text);
}

.tabbar__item[aria-current="page"]::before {
  content: "";
  position: absolute;
  top: -1px;
  right: 18%;
  left: 18%;
  height: 3px;
  background-color: var(--color-action-edge);
}

.tabbar__item[aria-current="page"] .tabbar__icon {
  opacity: 1;
}

.tabbar__item.is-unavailable {
  color: var(--color-disabled-text);
  cursor: not-allowed;
}

.tabbar__item.is-unavailable .tabbar__icon {
  opacity: 0.4;
}

/* "Soon" sits on top of the dimmed icon like a stamp, so it never spills out of the tab.
 * The dimmed icon is see-through, which lifts it into a higher paint layer, so the stamp
 * needs position and z-index to stay on top. */

.tabbar__glyph {
  display: grid;
  place-items: center;
}

.tabbar__glyph > * {
  grid-area: 1 / 1;
}

.tabbar__soon {
  position: relative;
  z-index: 1;
  padding: 0.0625rem 0.25rem;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  background-color: var(--color-bg);
  border: var(--edge);
}

/* 9. Bars and stats ----------------------------------------------------------
 * Bars are rows of square segments. The exact value is always printed beside
 * the bar, so the color is never the only way to read it.
 */

.meter {
  display: grid;
  gap: 0.375rem;
}

.meter__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
}

.meter__head .label {
  margin: 0;
}

.meter__value {
  font-size: var(--text-small);
}

.bar {
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  gap: 3px;
  height: 0.75rem;
}

.bar__seg {
  background-color: var(--color-line);
}

.meter--player .bar__seg.is-lit {
  background-color: var(--color-player);
}

.meter--threat .bar__seg.is-lit {
  background-color: var(--color-threat-fill);
}

.meter--loot .bar__seg.is-lit {
  background-color: var(--color-loot);
}

.meter--neutral .bar__seg.is-lit {
  background-color: var(--color-text-muted);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin: 0;
  background-color: var(--color-line);
  border: var(--edge);
}

.stat {
  padding: var(--space-2) var(--space-3);
  background-color: var(--color-surface);
}

.stat dt {
  margin: 0;
}

.stat dd {
  margin: 0;
  font-size: 1.5rem;
  line-height: 1.2;
}

/* 10. Combat log ------------------------------------------------------------- */

.log {
  margin: 0;
  padding: var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-body);
  line-height: 1.55;
  list-style: none;
  background-color: var(--color-surface);
  border: var(--edge);
}

.log__line + .log__line {
  margin-top: var(--space-1);
}

.log__time {
  margin-right: var(--space-2);
  color: var(--color-text-muted);
}

.log__value {
  font-weight: 700;
  white-space: nowrap;
}

.log__value.is-damage {
  color: var(--color-threat);
}

.log__value.is-heal {
  color: var(--color-player);
}

.log__value.is-loot {
  color: var(--color-loot);
}

/* 11. Notices and badges ------------------------------------------------------
 * Every notice starts with a word (Alert, Loot, Done) so the color is never
 * the only signal.
 */

.notice {
  display: flex;
  gap: var(--space-3);
  align-items: baseline;
  margin: 0 0 var(--space-3);
  padding: var(--space-3);
  background-color: var(--color-surface);
  border: var(--edge);
  border-left: 4px solid var(--color-text-muted);
}

.notice p {
  margin: 0;
}

.notice__tag {
  flex: none;
  font-family: var(--font-mono);
  font-size: var(--text-small);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.notice--player {
  border-left-color: var(--color-player);
}

.notice--player .notice__tag {
  color: var(--color-player);
}

.notice--threat {
  border-left-color: var(--color-threat-fill);
}

.notice--threat .notice__tag {
  color: var(--color-threat);
}

.notice--loot {
  border-left-color: var(--color-loot);
}

.notice--loot .notice__tag {
  color: var(--color-loot);
}

.badge {
  display: inline-block;
  padding: 0.1875rem 0.375rem;
  font-family: var(--font-mono);
  font-size: var(--text-tiny);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  vertical-align: middle;
  color: var(--color-text-muted);
  border: 1px solid currentColor;
}

.badge--action {
  color: var(--color-action-text);
}

.badge--threat {
  color: var(--color-threat);
}

.badge--player {
  color: var(--color-player);
}

.badge--loot {
  color: var(--color-loot);
}

/* 12. Panels ----------------------------------------------------------------- */

.panel {
  background-color: var(--color-surface);
  border: var(--edge);
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background-color: var(--color-surface-raised);
  border-bottom: var(--edge);
}

.panel__head .label {
  margin: 0;
}

.panel__body {
  padding: var(--space-3);
}

.panel__body > :last-child {
  margin-bottom: 0;
}

/* Dialogue: a panel with the speaker's portrait beside their line. */

.dialogue__body {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr);
  gap: var(--space-3);
  align-items: start;
}

.dialogue__portrait {
  width: 4.5rem;
  height: 4.5rem;
  border: var(--edge-strong);
}

.dialogue__body .story p:last-child {
  margin-bottom: 0;
}

/* 13. Forms ------------------------------------------------------------------ */

.field {
  display: grid;
  gap: var(--space-1);
  margin-bottom: var(--space-4);
}

.field .label {
  margin: 0;
}

.input {
  width: 100%;
  min-height: var(--tap);
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-body);
  font-size: max(1rem, 16px);
  color: var(--color-text);
  background-color: var(--color-bg);
  border: var(--edge-strong);
  border-radius: 0;
}

.input::placeholder {
  color: var(--color-text-muted);
  opacity: 1;
}

.input:focus-visible {
  outline-offset: 1px;
}

.input[aria-invalid="true"] {
  border-color: var(--color-threat-fill);
}

.field__help {
  font-size: var(--text-small);
  color: var(--color-text-muted);
}

.field__error {
  font-size: var(--text-small);
  font-weight: 600;
  color: var(--color-threat);
}

/* 14. Utilities --------------------------------------------------------------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.stack > * + * {
  margin-top: var(--space-4);
}

.error-plain {
  padding-block: var(--space-6);
}

/* 15. Motion -----------------------------------------------------------------
 * The feed flickers once as it "boots". Nothing loops. Players who ask for
 * reduced motion get no animation and no transitions.
 */

@keyframes feed-boot {
  0% {
    opacity: 0.2;
  }

  30% {
    opacity: 0.9;
  }

  45% {
    opacity: 0.5;
  }

  100% {
    opacity: 1;
  }
}

.feed__art {
  animation: feed-boot 600ms steps(6, end) both;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
