/* ============================================================
   Fair Divider — Multiplayer · Monocromo Ink (see docs/DESIGN_SYSTEM.md)
   Strictly grayscale ink on warm white. Square. Flat (hairlines).
   Inter only — self-hosted via fonts.css (no Google Fonts import).
   ============================================================ */

:root {
  color-scheme: light;

  /* Palette — Monocromo Ink (architectural, strictly grayscale) */
  --bg: oklch(97.5% 0.003 85);
  --bg-deep: oklch(96% 0.003 85);
  --surface: oklch(99.4% 0.002 85);
  --surface-sunken: oklch(96.5% 0.003 85);
  --ink: oklch(22% 0 0);
  --ink-muted: oklch(52% 0 0);   /* canonical muted ≈ #757575 (aligned w/ standalone) */
  --ink-subtle: oklch(50% 0 0);
  --separator: oklch(22% 0 0 / 0.14);
  --accent: oklch(22% 0 0);
  --accent-ink: oklch(22% 0 0);
  --accent-soft: oklch(94% 0 0);
  --positive: oklch(22% 0 0);
  --positive-soft: oklch(94% 0 0);
  --positive-ink: oklch(22% 0 0);
  --negative: oklch(50% 0.20 25);
  --negative-soft: oklch(96% 0.04 25);

  --player-accent: oklch(22% 0 0);

  --serif: 'Inter', var(--sans, system-ui, sans-serif);
  --num: "Inter", ui-sans-serif, system-ui, sans-serif;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;

  /* Monocromo Ink — square everywhere, 0 radius, coherent */
  --r-xs: 0;
  --r-sm: 0;
  --r-md: 0;
  --r-lg: 0;
  --r-btn: 0;
  --r-pill: 0;

  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;

  /* Monocromo Ink — flat: depth via a 1px hairline ring, never a soft shadow */
  --shadow-sm: 0 0 0 1px var(--separator);
  --shadow-md: 0 0 0 1px var(--separator);
  --shadow-lg: 0 0 0 1px var(--separator);

  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 150ms;
  --dur: 280ms;
}

/* ============================================================
   Reset
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  position: relative;
}

/* No ambient blobs — clean white canvas */
body::before { display: none; }

html[dir="rtl"] body { direction: rtl; }

button { font-family: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================
   Utility
   ============================================================ */
.hidden { display: none !important; }

/* ============================================================
   App shell
   ============================================================ */
.app {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: clamp(16px, 4vw, 40px) clamp(16px, 4vw, 32px);
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
  position: relative;
  z-index: 1;
}

.screen-narrow {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
}

.screen-wide {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
}

/* ============================================================
   Cards — solid white, depth from shadow
   ============================================================ */
.card {
  background: var(--surface);
  border-radius: var(--r-md) var(--r-lg) var(--r-md) var(--r-lg);
  padding: clamp(22px, 4vw, 36px);
  box-shadow: var(--shadow-md);
  position: relative;
  isolation: isolate;
}

.card-head {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-bottom: var(--s-5);
  padding-bottom: var(--s-4);
}

.card-head h2 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem);
  margin: 0;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.btn-back {
  width: 44px;
  height: 44px;
  border-radius: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-sunken);
  color: var(--ink);
  font-size: 20px;
  transition: transform var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.btn-back:hover { background: var(--accent-soft); }
.btn-back:active { transform: scale(0.94); }
html[dir="rtl"] .btn-back { transform: scaleX(-1); }

/* ============================================================
   Landing header
   ============================================================ */
.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  justify-content: center;
}
.brand-mark {
  width: clamp(28px, 5vw, 40px);
  height: auto;
  color: var(--accent);
  flex-shrink: 0;
}

.landing-header {
  text-align: center;
  padding: var(--s-6) var(--s-3) var(--s-2);
}

.landing-header h1 {
  font-family: var(--serif);
  font-weight: 800;
  font-size: clamp(2.6rem, 1.4rem + 5vw, 4.6rem);
  line-height: 0.95;
  letter-spacing: -0.025em;
  margin: 0;
  color: var(--ink);
}

.landing-header p {
  font-family: var(--serif);
  font-style: normal;
  font-weight: 400;
  font-size: clamp(1.05rem, 0.9rem + 0.6vw, 1.4rem);
  color: var(--accent-ink);
  margin: var(--s-3) 0 0;
  letter-spacing: 0.01em;
}

.lang-selector {
  display: flex;
  justify-content: center;
}

.lang-selector select {
  background: var(--surface);
  border-radius: var(--r-pill);
  padding: 8px 18px;
  font-size: 13px;
  color: var(--ink-muted);
  min-height: 36px;
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   Landing options (mode cards)
   Both cards are white; primary gets full shadow + coral arrow,
   secondary is flatter — differentiated by elevation only.
   ============================================================ */
.landing-options {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}

.mode-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: clamp(20px, 4vw, 28px) clamp(22px, 4vw, 32px);
  border-radius: var(--r-md) var(--r-lg) var(--r-md) var(--r-lg);
  background: var(--surface);
  color: var(--ink);
  text-align: start;
  min-height: 96px;
  transition: transform var(--dur) var(--ease-expo), box-shadow var(--dur) var(--ease);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

/* Coral arrow — brand anchor */
.mode-card::after {
  content: "→";
  position: absolute;
  top: 50%;
  inset-inline-end: 22px;
  transform: translateY(-50%);
  font-size: 24px;
  font-family: var(--serif);
  color: var(--accent);
  transition: transform var(--dur) var(--ease-expo);
}
html[dir="rtl"] .mode-card::after { content: "←"; }

.mode-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.mode-card:hover::after { transform: translateY(-50%) translateX(4px); }
html[dir="rtl"] .mode-card:hover::after { transform: translateY(-50%) translateX(-4px); }
.mode-card:active { transform: translateY(0); }
.mode-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Secondary card — flatter */
.mode-card--outline {
  box-shadow: var(--shadow-sm);
}
.mode-card--outline:hover { box-shadow: var(--shadow-md); }

.mode-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.4rem;
  letter-spacing: -0.01em;
}

.mode-desc {
  font-family: var(--serif);
  font-style: normal;
  font-size: 0.95rem;
  color: var(--ink-muted);
}

.mode-card--outline .mode-desc { color: var(--accent-ink); }
.mode-card--outline::after { color: var(--accent); }

.landing-divider {
  text-align: center;
  font-family: var(--serif);
  font-style: normal;
  font-size: 0.95rem;
  color: var(--ink-subtle);
  position: relative;
  padding: 4px 0;
}
.landing-divider::before,
.landing-divider::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 30%;
  height: 1px;
  background: var(--separator);
}
.landing-divider::before { inset-inline-start: 0; }
.landing-divider::after { inset-inline-end: 0; }

.landing-link {
  display: block;
  margin-top: var(--s-5);
  text-align: center;
  font-family: var(--serif);
  font-style: normal;
  font-size: 0.95rem;
  color: var(--ink-subtle);
}
.landing-link:hover { color: var(--accent); }

/* ============================================================
   Forms — no resting border; filled bg conveys field affordance.
   Focus ring is accessibility, not decoration.
   ============================================================ */
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-4);
  margin-bottom: var(--s-4);
}
@media (max-width: 480px) {
  .field-grid { grid-template-columns: 1fr; }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--s-4);
}

.field label {
  font-family: var(--serif);
  font-style: normal;
  font-size: 0.9rem;
  color: var(--ink-muted);
}

.form-section-title {
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-subtle);
  margin: var(--s-5) 0 var(--s-3);
}
.form-section-title:first-child {
  margin-top: 0;
}

.input {
  width: 100%;
  background: var(--surface-sunken);
  border: none;
  border-radius: var(--r-sm);
  padding: 14px 16px;
  min-height: 48px;
  font-size: 16px;
  color: var(--ink);
  box-shadow: 0 0 0 1px oklch(22% 0 0 / 0.30);   /* perceivable boundary (WCAG 1.4.11) */
  transition: background var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.input:focus, .input:focus-visible {
  outline: none;
  background: var(--surface);
  box-shadow: 0 0 0 2px var(--accent);
}

.code-input {
  font-family: var(--num);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 0.18em;
  text-align: center;
  text-transform: uppercase;
}

.name-picker-title {
  font-family: var(--serif);
  font-style: normal;
  color: var(--ink-muted);
  margin: 0 0 var(--s-3);
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 14px 24px;
  border-radius: var(--r-sm);
  font-family: var(--sans);
  font-weight: 600;
  font-size: 15px;
  border: none;
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
  white-space: nowrap;
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.btn:active { transform: translateY(1px); }
.btn:disabled,
.btn[aria-disabled="true"],
.btn.is-disabled {
  cursor: not-allowed;
  opacity: 0.5;
  box-shadow: none;
  filter: grayscale(0.25);
  transform: none;
  pointer-events: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
  box-shadow: var(--shadow-md);
  border-radius: var(--r-btn);
}
.btn-primary:hover {
  background: oklch(35% 0 0);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--surface-sunken);
  color: var(--ink);
  font-family: var(--sans);
  font-style: normal;
  font-weight: 600;
  border-radius: var(--r-sm);
}
.btn-secondary:hover { background: oklch(94.5% 0 0); }
.btn-secondary:active { transform: translateY(1px); }

.btn-text {
  background: none;
  color: var(--accent-ink);
  font-family: var(--sans);
  font-style: normal;
  font-weight: 600;
  font-size: 0.95rem;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: var(--r-sm);
}
.btn-text:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.btn-text:active { transform: translateY(1px); }

/* ============================================================
   Room code (boarding pass style)
   ============================================================ */
/* Shareable-code card — hairline ring (flat), eyebrow + big ink code + COPY LINK bar */
.room-code-wrap {
  text-align: center;
  padding: clamp(20px, 4vw, 28px) clamp(16px, 4vw, 24px);
  margin-bottom: var(--s-5);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.room-code-wrap > p:first-child {
  font-family: var(--serif);
  font-style: normal;
  color: var(--accent);
  font-size: 1rem;
  margin: 0 0 var(--s-3);
}

/* Plain big ink code (no decorative box) — the eyebrow above labels it */
.room-code {
  display: inline-block;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: var(--s-2) 0;
  font-family: var(--num);
  font-weight: 800;
  font-size: clamp(2rem, 1rem + 5vw, 3.2rem);
  letter-spacing: 0.16em;
  color: var(--ink);
  cursor: pointer;
  user-select: all;
  transition: opacity var(--dur-fast) var(--ease);
  min-height: 48px;
  font-variant-numeric: tabular-nums;
  position: relative;
}
.room-code:hover { opacity: 0.7; }
.room-code.copied {
  animation: copiedPulse 500ms var(--ease-expo);
}

@keyframes copiedPulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

.room-code-hint {
  font-family: var(--serif);
  font-style: normal;
  color: var(--ink-subtle);
  font-size: 0.85rem;
  margin: var(--s-3) 0 0;
}

/* ============================================================
   Lobby players / player pills
   ============================================================ */
#lobby-players-status {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  margin-top: var(--s-4);
}

.players-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.player-pill,
.lobby-player-row,
.player-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 14px 18px;
  background: var(--surface-sunken);
  border-radius: var(--r-sm);
  min-height: 56px;
  transition: background var(--dur-fast) var(--ease);
}

/* Avatar: participant initial on an ink square (replaces the old empty block) */
.pill-avatar,
.p-avatar {
  flex: none;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  color: var(--bg);
  font-weight: 700;
  font-size: 0.8rem;
  border-radius: 0;
}

.player-pill .pill-name,
.player-row .p-name {
  font-family: var(--sans);
  font-weight: 600;
  color: var(--ink);
  font-size: 15px;
}

/* Status as a square label-caps BADGE, pushed to the row end.
   Filled ink = present/active (READY / CHOOSING); hairline outline = WAITING. */
.player-pill .pill-status,
.player-row .p-status {
  margin-inline-start: auto;
  flex: none;
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1.4;
  padding: 4px 9px;
  border-radius: 0;
  white-space: nowrap;
}
/* Filled ink badge — present / their turn / accepted the proposal (definitive) */
.player-row .p-status.ready,
.player-pill .pill-status.choosing,
.player-pill .pill-status.accepted {
  background: var(--ink);
  color: var(--bg);
}
/* Outline badge — slot not yet claimed / not this player's turn / still deciding */
.player-row .p-status.waiting,
.player-pill .pill-status.idle,
.player-pill .pill-status.deciding {
  background: transparent;
  color: var(--ink-muted);
  box-shadow: inset 0 0 0 1px var(--separator);
}

/* Active pill (game) — subtle ink-tinted surface for whose turn it is */
.player-pill.active { background: var(--accent-soft); }

/* "(You)" marker after the participant's own name */
.p-you {
  margin-inline-start: 4px;
  font-weight: 500;
  font-size: 0.82em;
  color: var(--ink-subtle);
  letter-spacing: 0.01em;
}

.lobby-footer {
  margin-top: var(--s-5);
  text-align: center;
  font-family: var(--serif);
  font-style: normal;
  color: var(--ink-subtle);
  font-size: 0.95rem;
}

.lobby-players {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

/* ============================================================
   Game layout
   ============================================================ */
.game-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-5);
}

@media (min-width: 1024px) {
  .game-layout {
    grid-template-columns: minmax(0, 1fr) 340px;
  }
}

.game-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
  flex-wrap: wrap;
}

.meta-tags {
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
}

.meta-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface-sunken);
  border-radius: var(--r-pill);
  font-size: 12.5px;
  color: var(--ink-muted);
  font-family: var(--sans);
}
.meta-tag strong {
  color: var(--ink);
  font-family: var(--num);
  font-weight: 700;
  letter-spacing: 0.04em;
}

/* Room code tag — clickable button variant */
.meta-tag--code {
  cursor: pointer;
  transition: transform 160ms var(--ease), box-shadow 160ms var(--ease);
  font: inherit;
  color: inherit;
  text-align: inherit;
  /* Dashed accent border here is functional — it signals "click to copy room code" */
  border: 1px dashed var(--accent);
  background: var(--accent-soft);
}
.meta-tag--code:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.meta-tag--code:active {
  transform: scale(0.98);
}
.meta-tag--code .meta-tag-label {
  display: none;
}

/* Prominent variant */
.meta-tag--code.meta-tag--code-prominent {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-4) var(--s-5);
  width: 100%;
  flex-basis: 100%;
  border: 1px dashed var(--accent);
  border-radius: var(--r-md);
  background: var(--accent-soft);
  box-shadow: var(--shadow-md);
}
.meta-tag--code.meta-tag--code-prominent .meta-tag-label {
  display: block;
  font-family: var(--serif);
  font-style: normal;
  font-size: 0.9rem;
  color: var(--accent-ink);
  margin: 0;
  text-align: center;
  line-height: 1.4;
}
.meta-tag--code.meta-tag--code-prominent strong {
  font-family: var(--num);
  font-size: clamp(1.6rem, 6vw, 2.2rem);
  letter-spacing: 0.18em;
  color: var(--ink);
  font-weight: 700;
}

/* ============================================================
   Turn banner
   ============================================================ */
.turn-banner {
  padding: var(--s-6) var(--s-4) var(--s-5);
  text-align: center;
  margin-bottom: var(--s-5);
}

.turn-banner h3 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(1.6rem, 1.1rem + 2vw, 2.4rem);
  line-height: 1.18;
  letter-spacing: -0.015em;
  text-wrap: balance;
  margin: 0;
  color: var(--ink);
}

/* It's your turn → prominent ink. Waiting for someone → calm, lighter, muted
   (so the wait reads as an intentional pause, not a cramped notice). */
.turn-banner.my-turn h3 { font-weight: 700; color: var(--ink); }
.turn-banner.waiting-turn h3 { font-weight: 500; color: var(--ink-muted); }

.turn-banner h3 em {
  font-style: normal;
  color: var(--ink);
  font-weight: 700;
}

#game-screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}

/* ============================================================
   Precision bar
   ============================================================ */
.precision-bar {
  padding: var(--s-3) 0 var(--s-5);
}

.precision-info {
  display: flex;
  justify-content: space-between;
  font-family: var(--serif);
  font-style: normal;
  font-size: 0.85rem;
  color: var(--ink-muted);
  margin-bottom: 6px;
}
.precision-info span:last-child {
  font-family: var(--num);
  font-style: normal;
  color: var(--accent-ink);
  font-weight: 600;
}

.precision-track {
  height: 6px;
  background: var(--surface-sunken);
  border-radius: var(--r-pill);
  overflow: hidden;
}

.precision-fill {
  height: 100%;
  width: 100%;
  transform: scaleX(0);
  transform-origin: left;
  background: var(--accent);
  border-radius: var(--r-pill);
  transition: transform var(--dur) var(--ease-expo);
  will-change: transform;
}
[dir="rtl"] .precision-fill { transform-origin: right; }

/* ============================================================
   Choice cards
   ============================================================ */
#game-choice-cards {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  margin-bottom: var(--s-5);
}

.choice-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: clamp(18px, 3vw, 24px) clamp(20px, 4vw, 28px);
  background: var(--surface);
  border-radius: var(--r-sm) var(--r-md) var(--r-sm) var(--r-md);
  min-height: 88px;
  text-align: start;
  cursor: pointer;
  transition: transform var(--dur) var(--ease-expo), box-shadow var(--dur) var(--ease);
  position: relative;
  box-shadow: var(--shadow-sm);
}
.choice-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.choice-card:active { transform: translateY(0); }
.choice-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.choice-card.disabled,
.choice-card[aria-disabled="true"] {
  cursor: not-allowed;
  box-shadow: none;
  background: var(--surface-sunken);
}
.choice-card.disabled:hover,
.choice-card[aria-disabled="true"]:hover {
  transform: none;
  box-shadow: none;
}
.choice-card.is-best {
  background: var(--positive-soft);
}

.choice-room {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(1.15rem, 1rem + 0.5vw, 1.45rem);
  letter-spacing: -0.005em;
  color: var(--ink);
}

.choice-tag {
  display: block;
  font-family: var(--serif);
  font-style: normal;
  font-size: 0.85rem;
  color: var(--accent-ink);
  margin-top: 2px;
}

.choice-price {
  font-family: var(--num);
  font-weight: 700;
  font-size: clamp(1.4rem, 1.1rem + 1vw, 1.9rem);
  font-variant-numeric: tabular-nums;
  color: var(--accent-ink);
  letter-spacing: -0.01em;
}

.best-deal {
  position: absolute;
  top: -10px;
  inset-inline-start: 20px;
  background: var(--positive-ink);
  color: var(--bg);
  font-family: var(--sans);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   Players bar (game)
   ============================================================ */
.players-bar {
  padding-top: var(--s-4);
}

.players-bar h4 {
  font-family: var(--serif);
  font-style: normal;
  font-weight: 400;
  font-size: 0.9rem;
  color: var(--ink-muted);
  margin: 0 0 var(--s-3);
}

.pills-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

.pills-row .player-pill {
  flex: 0 1 auto;
  padding: 10px 14px;
  min-height: 44px;
  background: var(--surface-sunken);
}

/* ============================================================
   History sidebar
   ============================================================ */
.game-sidebar .card {
  padding: clamp(20px, 3vw, 28px);
}

.sidebar-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.25rem;
  margin: 0 0 var(--s-3);
  color: var(--ink);
  letter-spacing: -0.005em;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  max-height: 420px;
  overflow-y: auto;
}

.history-item {
  padding: 12px 14px;
  background: var(--surface-sunken);
  border-radius: var(--r-sm);
  font-size: 13.5px;
  color: var(--ink-muted);
  line-height: 1.45;
}
.history-item strong { color: var(--ink); font-family: var(--num); font-weight: 700; }
.history-item em { color: var(--accent-ink); font-family: var(--serif); font-style: normal; }

/* History rows (the live markup) — lead with the chosen ROOM in ink, demote the
   chooser to a quiet label-caps line; hairline divider instead of zebra fills. */
.hist-item {
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--separator);
}
.hist-item:last-child { border-bottom: none; }
.hist-room {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.3;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.hist-meta {
  margin-top: 3px;
  font-family: var(--sans);
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-subtle);
  overflow-wrap: anywhere;
}

.empty-illo {
  width: 56px;
  height: auto;
  color: var(--ink-subtle);
  display: block;
  margin: 0 auto var(--s-3);
}

.history-empty {
  text-align: center;
  font-family: var(--serif);
  font-style: normal;
  color: var(--ink-subtle);
  padding: var(--s-5) var(--s-3);
  margin: 0;
}

.history-sidebar {
  width: 100%;
}

@media (max-width: 1023px) {
  .game-sidebar {
    order: 2;
  }
  .game-sidebar .card {
    padding: var(--s-4);
  }
  .sidebar-title {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .sidebar-title::after {
    content: "▾";
    font-size: 14px;
    color: var(--accent);
    transition: transform var(--dur) var(--ease);
  }
  .game-sidebar.is-collapsed .history-list { display: none; }
  .game-sidebar.is-collapsed .sidebar-title::after { transform: rotate(-90deg); }
  .history-list { max-height: 260px; }
}

/* ============================================================
   Allocation grid (result visualization)
   ============================================================ */
.allocation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--s-3);
  margin-top: var(--s-5);
}

.allocation-card {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-4);
  background: var(--surface);
  border-radius: 0;
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.allocation-card.is-proposal { box-shadow: var(--shadow-md); }
.allocation-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.allocation-bar-track {
  height: 6px;
  background: var(--surface-sunken);
  border-radius: var(--r-pill);
  overflow: hidden;
  margin-bottom: var(--s-1);
}

.allocation-bar {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--accent);
  border-radius: var(--r-pill);
  transform-origin: left;
  transform: scaleX(0);
  animation: barGrow 600ms var(--ease-expo) forwards;
}
html[dir="rtl"] .allocation-bar { transform-origin: right; }

@keyframes barGrow {
  to { transform: scaleX(var(--bar-scale, 0)); }
}

.allocation-room {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-subtle);
  font-weight: 600;
  font-family: var(--sans);
}

.allocation-amount {
  font-family: var(--num);
  font-size: clamp(1.4rem, 3vw, 2rem);
  font-weight: 800;
  line-height: 1;
  color: var(--accent-ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.015em;
}

.allocation-tenant {
  font-family: var(--serif);
  font-style: normal;
  font-size: 0.9rem;
  color: var(--ink-muted);
  overflow-wrap: anywhere;
}

.allocation-total {
  text-align: end;
  font-family: var(--num);
  font-size: 0.82rem;
  color: var(--ink-subtle);
  margin-top: var(--s-3);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

@media (prefers-reduced-motion: reduce) {
  .allocation-bar {
    animation: none;
    transform: scaleX(var(--bar-scale, 0));
  }
}

/* ============================================================
   Results card
   ============================================================ */
.results-card {
  padding: var(--s-5) 0;
}

.result-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-4);
  background: var(--surface-sunken);
  border-radius: var(--r-sm);
  margin-bottom: var(--s-2);
}

.result-player {
  font-family: var(--serif);
  font-weight: 700;
  color: var(--ink);
  min-width: 90px;
}

.result-assignment {
  font-family: var(--serif);
  font-style: normal;
  color: var(--ink-muted);
  flex: 1;
}

.result-room {
  font-family: var(--serif);
  font-weight: 600;
  color: var(--accent-ink);
  font-style: normal;
}

.result-rent {
  font-family: var(--num);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent-ink);
  font-size: 1.1rem;
  letter-spacing: -0.005em;
}

/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(12px);
  background: var(--ink);
  color: var(--bg);
  padding: 14px 22px;
  border-radius: var(--r-sm);
  font-family: var(--sans);
  font-weight: 500;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease-expo);
  z-index: 1000;
  max-width: calc(100vw - 32px);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================================
   Connection lost banner
   ============================================================ */
.connection-lost-banner {
  position: fixed;
  top: calc(16px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  background: var(--negative-soft);
  border-radius: var(--r-sm);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--serif);
  font-style: normal;
  color: var(--ink);
  box-shadow: var(--shadow-md);
  z-index: 999;
  max-width: calc(100vw - 32px);
  font-size: 0.95rem;
}

.connection-lost-banner::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 0;
  background: var(--negative);
  box-shadow: 0 0 0 4px oklch(from var(--negative) l c h / 0.2);
  animation: pulseDot 1.4s ease-in-out infinite;
  flex: none;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ============================================================
   Footer
   ============================================================ */
.app-footer {
  text-align: center;
  padding: var(--s-5) var(--s-4) calc(var(--s-5) + env(safe-area-inset-bottom));
  font-family: var(--serif);
  font-style: normal;
  font-size: 0.85rem;
  color: var(--ink-subtle);
}
.app-footer a { color: var(--ink-muted); }
.app-footer a:hover { color: var(--accent); }
.footer-sep { margin: 0 8px; }

/* ============================================================
   Responsive breakpoints
   ============================================================ */
@media (min-width: 560px) {
  .landing-options { gap: var(--s-5); }
}

@media (min-width: 640px) {
  .card { padding: 36px 40px; }
}

@media (max-width: 375px) {
  .app { padding: 12px; }
  .card { padding: 20px; border-radius: 0; }
  .landing-header h1 { font-size: 2.4rem; }
  .room-code { padding: 18px 24px; font-size: 1.7rem; letter-spacing: 0.14em; }
}

/* ============================================================
   Motion preferences
   ============================================================ */
@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;
  }
}

/* ============================================================
   Focus ring
   ============================================================ */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 0;
}
.mode-card:focus-visible,
.choice-card:focus-visible,
.room-code:focus-visible {
  outline-offset: 4px;
}

/* ============================================================
   Architectural composition (Monocromo Ink) — multiplayer parity
   Uppercase structural labels + headings, consistent with standalone.
   ============================================================ */
.landing-header h1 { text-transform: uppercase; letter-spacing: 0.01em; }
.landing-header p {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--ink-subtle);
}
.card-head h2,
.name-picker-title { text-transform: uppercase; letter-spacing: 0.03em; }
.mode-title { text-transform: uppercase; letter-spacing: 0.03em; font-weight: 700; }
.room-code-wrap > p:first-child {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-subtle);
}
.lobby-player-row .player-status {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
  font-weight: 600;
}
.btn-primary, .btn-secondary {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
/* Text buttons (Leave/etc.) read as clean links, not bold-caps headings */
.btn-text { text-transform: none; letter-spacing: 0; font-weight: 600; }

/* ============================================================
   Design-audit fix #4 — bring the multiplayer landing on-system
   (left-aligned, compact uppercase wordmark, custom-caret select)
   ============================================================ */
.landing-header { text-align: left; }
.brand { justify-content: flex-start; }
.lang-selector { justify-content: flex-start; }
.landing-header h1 {
  font-size: clamp(1.3rem, 1rem + 1.2vw, 1.65rem);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.lang-selector select {
  appearance: none;
  -webkit-appearance: none;
  box-shadow: var(--shadow-sm);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.5rem 2rem 0.5rem 1rem;
  background-color: var(--surface);
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-muted) 50%),
                    linear-gradient(135deg, var(--ink-muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

/* ============================================================
   Button-bar unification (owner request, 2026-06-18) — mirror standalone:
   solid-ink full-width square bars; secondary/warning = outline, invert on hover.
   Exemptions: .btn-back, .btn-text, .room-code, .lang-selector, form controls.
   ============================================================ */
.btn {
  width: 100%;
  border-radius: 0;
  font-size: 0.72rem;          /* match the standalone "EMPEZAR" bar proportion */
  font-weight: 700;
  letter-spacing: 0.12em;
  box-shadow: none;
}
.btn-primary {
  background: var(--ink);
  color: var(--bg);
  border-radius: 0;
  box-shadow: none;
}
.btn-primary:hover { background: oklch(35% 0 0); box-shadow: none; transform: none; }
.btn-secondary, .btn-warning {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 0;
  box-shadow: none;
}
.btn-secondary:hover, .btn-warning:hover { background: var(--ink); color: var(--bg); transform: none; }
.action-buttons { flex-direction: column; flex-wrap: nowrap; }
.result-actions { display: flex; flex-direction: column; gap: var(--s-3); margin-top: var(--s-4); }

/* Mode cards on-system: square, flat, no coral arrow, no hover-lift */
.mode-card { border-radius: 0; }
.mode-card::after { display: none; }
.mode-card:hover { transform: none; }
.mode-card:hover::after { transform: none; }
.mode-card--outline { border: 1px solid oklch(22% 0 0 / 0.14); }

/* Italic is banned (DS principle #4) — emphasis via weight */
em, i { font-style: normal; font-weight: 600; }

/* Footer on-system — override legacy tokens.css slate/indigo colors */
.app-footer { color: var(--ink-subtle); border-top: 1px solid var(--separator); }
.app-footer a { color: var(--ink-muted); text-decoration: none; }
.app-footer a:hover { color: var(--ink); }
.footer-sep { color: var(--ink-subtle); }

/* ============================================================
   Waiting room — participants header, copy-link bar, leave bar
   (Monocromo Ink: label-caps header, hairline divider, square bars)
   ============================================================ */

/* COPY LINK — full-width ink bar inside the code card */
.lobby-copy-link { margin-top: var(--s-4); }

/* "PARTICIPANTS   n/total" — label-caps header over a hairline divider */
.lobby-participants-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
  margin: var(--s-5) 0 var(--s-3);
  padding-bottom: var(--s-3);
  border-bottom: 1px solid var(--separator);
}
.lobby-participants-label {
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink);
}
.lobby-participants-count {
  font-family: var(--num);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink-subtle);
  font-variant-numeric: tabular-nums;
}

/* LEAVE ROOM — full-width outline bar at the bottom of the card.
   Keeps the .btn-text class (so the existing handler selector still binds)
   but renders as the signature square outline bar; inverts on hover. */
.btn-leave-bar {
  display: block;
  width: 100%;
  margin-top: var(--s-5);
  padding: var(--s-4) var(--s-5);
  text-align: center;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 0;
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  font-weight: 700;
}
.btn-leave-bar:hover {
  background: var(--ink);
  color: var(--bg);
  text-decoration: none;
}
