@font-face {
  font-family: 'Archivo Black';
  font-style: normal; font-weight: 400; font-display: swap;
  src: url('/static/fonts/archivo-black.woff2') format('woff2');
}
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal; font-weight: 300 700; font-display: swap;
  src: url('/static/fonts/space-grotesk.woff2') format('woff2');
}

:root {
  --paper: #F7F1E4;
  --deep:  #EFE7D6;
  --ink:   #221E19;
  --tile:  #FFFBF2;
  --body:  #554E45;
  --muted: #8B8174;
  --faint: #ADA290;
  --line:  #C6BBA5;
  --rule:  #D9CFBA;
  --error:    oklch(0.55 0.19 25);
  --error-bg: #FBEDE9;
  --error-ink: oklch(0.42 0.15 25);
  --display: 'Archivo Black', 'Arial Black', sans-serif;
  --ui: 'Space Grotesk', 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--deep);
  color: var(--ink);
  font-family: var(--ui);
  -webkit-text-size-adjust: 100%;
}

a { color: oklch(0.60 0.18 25); text-decoration: none; }
a:hover { color: oklch(0.48 0.18 25); }

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* --- top bar ------------------------------------------------------ */

.topbar {
  background: var(--ink);
  color: var(--paper);
  padding: 16px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  flex-shrink: 0;
}
.topbar__row { display: flex; justify-content: space-between; align-items: center; }
.topbar__row--base { align-items: baseline; }
.topbar__brand { font-size: 11px; letter-spacing: 0.2em; font-weight: 500; opacity: 0.5; }
.topbar__brand a { color: inherit; }
.topbar__brand a:hover { opacity: 1; color: inherit; }
.topbar__title { font-family: var(--display); font-size: 23px; letter-spacing: -0.01em; }
.topbar__meta { font-size: 13px; font-weight: 500; opacity: 0.65; }
.badge {
  border: 2px solid var(--paper);
  border-radius: 3px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
}

/* --- turn stream --------------------------------------------------- */

.stream {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 17px;
  padding: 18px 16px;
  overflow-y: auto;
}
.divider { display: flex; align-items: center; gap: 10px; }
.divider::before, .divider::after { content: ''; height: 2px; background: var(--rule); flex-grow: 1; }
.divider span { font-size: 10px; letter-spacing: 0.15em; font-weight: 700; color: var(--faint); }

.turn { display: flex; flex-direction: column; gap: 7px; align-items: flex-start; }
.turn--mine { align-items: flex-end; }
.turn__head { display: flex; align-items: center; gap: 8px; }
.turn--mine .turn__head { flex-direction: row-reverse; }
.turn__name { font-size: 13px; font-weight: 700; }
.turn__meta { font-size: 12px; color: var(--muted); }
.turn__pts { font-size: 12px; font-weight: 700; color: var(--muted); }

.avatar {
  width: 22px; height: 22px;
  background: oklch(0.70 0.18 var(--hue, 25));
  border: 2px solid var(--ink);
  border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-size: 11px; color: var(--ink);
  flex-shrink: 0;
}
.avatar--sm { width: 16px; height: 16px; border-radius: 2px; }
.avatar--lg { width: 28px; height: 28px; font-size: 13px; }

.tiles { display: flex; gap: 5px; flex-wrap: wrap; }
.tile {
  width: 40px; height: 48px;
  background: var(--tile);
  border: 2px solid var(--ink);
  border-radius: 4px;
  box-shadow: 3px 3px 0 oklch(0.70 0.18 var(--hue, 25));
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-size: 21px; color: var(--ink);
  flex-shrink: 0;
}
.tile--empty { background: transparent; border: 2px dashed var(--line); box-shadow: none; }
.tile--sm { width: 30px; height: 36px; font-size: 16px; box-shadow: 2px 2px 0 oklch(0.70 0.18 var(--hue, 25)); }

/* --- composer ------------------------------------------------------ */

.composer {
  border-top: 3px solid var(--ink);
  background: var(--tile);
  padding: 15px 16px calc(18px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
}
.composer__head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.composer__label { font-size: 11px; font-weight: 700; letter-spacing: 0.15em; }
.composer__note { font-size: 11px; color: var(--muted); font-weight: 500; }
.composer__slots { position: relative; }
.composer__slots .tiles { min-height: 48px; }
.composer__input {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  opacity: 0;
  border: 0; padding: 0;
  font-size: 16px;
  cursor: text;
}
.composer__input:focus { outline: none; }
.composer__slots:focus-within .tile--empty { border-color: var(--muted); }

.field {
  border: 2px solid var(--ink);
  border-radius: 4px;
  padding: 9px 12px 11px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: var(--paper);
}
.field__label { font-size: 10px; letter-spacing: 0.13em; font-weight: 700; color: var(--muted); }
.field input {
  border: 0; background: transparent; padding: 0;
  font-family: var(--ui); font-size: 16px; color: var(--ink);
  width: 100%;
}
.field input:focus { outline: none; }
.field input::placeholder { color: var(--faint); }

.actions { display: flex; gap: 10px; }
.btn {
  height: 48px;
  border: 2px solid var(--ink);
  border-radius: 5px;
  font-family: var(--display);
  font-size: 15px;
  letter-spacing: 0.05em;
  color: var(--ink);
  background: var(--tile);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.btn--send {
  flex-grow: 1;
  background: oklch(0.70 0.18 var(--hue, 25));
  box-shadow: 3px 3px 0 var(--ink);
}
.btn--send[disabled] {
  background: var(--deep);
  border-color: var(--line);
  color: var(--faint);
  box-shadow: none;
  cursor: default;
}
.btn--fold {
  width: 100px;
  border-color: var(--line);
  background: transparent;
  font-family: var(--ui);
  font-size: 13px; font-weight: 700; letter-spacing: 0.08em;
  color: var(--muted);
}
.btn--wide { width: 100%; }

.alert {
  display: flex; gap: 8px; align-items: flex-start;
  background: var(--error-bg);
  border: 2px solid var(--error);
  border-radius: 4px;
  padding: 9px 11px;
  font-size: 12.5px; line-height: 1.4;
  color: var(--error-ink);
  text-wrap: pretty;
}
.alert svg { flex-shrink: 0; margin-top: 1px; }

.waiting {
  border: 2px dashed var(--line);
  border-radius: 5px;
  padding: 16px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  text-wrap: pretty;
}

/* --- join ----------------------------------------------------------- */

.join {
  flex-grow: 1;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 64px 26px 34px;
  gap: 40px;
}
.join__mark { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; }
.join__mark .tile { width: 36px; height: 44px; font-size: 19px; }
.join__tagline {
  font-size: 16px; line-height: 1.5; text-align: center;
  color: var(--body); text-wrap: pretty; max-width: 280px; margin: 0 auto;
}
.join__card {
  display: flex; align-items: center; gap: 10px;
  background: var(--tile); border: 2px solid var(--ink);
  border-radius: 5px; padding: 12px 14px;
  font-size: 14px; line-height: 1.4; text-wrap: pretty;
}
.join__fine { font-size: 12px; color: var(--muted); text-align: center; line-height: 1.5; }

/* --- playback ------------------------------------------------------- */

.score { display: flex; align-items: baseline; gap: 10px; }
.score__n { font-family: var(--display); font-size: 46px; letter-spacing: -0.02em; line-height: 1; }
.reveal { display: flex; flex-direction: column; gap: 8px; }
.reveal__head { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; }
.reveal__pairs { display: flex; gap: 5px; align-items: flex-start; flex-wrap: wrap; }
.pair { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 54px; }
.pair span { font-size: 11px; line-height: 1.2; text-align: center; color: var(--body); text-wrap: pretty; }

.footbar {
  border-top: 3px solid var(--ink);
  background: var(--tile);
  padding: 15px 16px calc(18px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 11px;
  flex-shrink: 0;
}
.footbar p { margin: 0; font-size: 12px; color: var(--body); text-align: center; line-height: 1.45; text-wrap: pretty; }

/* --- records -------------------------------------------------------- */

.section { display: flex; flex-direction: column; gap: 11px; }
.section__label { font-size: 10px; letter-spacing: 0.15em; font-weight: 700; color: var(--muted); }
.record {
  display: flex; align-items: center; gap: 12px;
  background: var(--tile); border: 2px solid var(--ink);
  border-radius: 5px; padding: 11px 13px;
  color: var(--ink);
}
.record__rank {
  width: 26px; height: 32px;
  background: var(--paper); border: 2px solid var(--ink); border-radius: 3px;
  box-shadow: 2px 2px 0 oklch(0.70 0.18 var(--hue, 25));
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-size: 13px; flex-shrink: 0;
}
.record__body { display: flex; flex-direction: column; gap: 1px; flex-grow: 1; }
.record__title { font-size: 14px; font-weight: 700; }
.record__sub { font-size: 11px; color: var(--muted); }
.record__n { font-family: var(--display); font-size: 26px; letter-spacing: -0.02em; line-height: 1; }
.record__unit { font-size: 10px; font-weight: 700; color: var(--muted); }

.tally { display: flex; align-items: center; gap: 12px; padding: 3px 2px; }
.tally__name { font-size: 15px; font-weight: 700; flex-grow: 1; }
.tally__turns { font-size: 12px; color: var(--muted); font-weight: 500; }
.tally__pts { font-family: var(--display); font-size: 19px; min-width: 52px; text-align: right; }

.page { flex-grow: 1; display: flex; flex-direction: column; gap: 24px; padding: 20px 16px; overflow-y: auto; }
.empty { color: var(--muted); font-size: 13px; line-height: 1.5; text-wrap: pretty; }

.board, .board__stream {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.btn--fold.btn--wide { width: 100%; }

/* --- guessing ------------------------------------------------------- */

.guess {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding-bottom: 13px;
  border-bottom: 2px dashed var(--line);
}
.guess .field { padding: 8px 12px 10px; }

.linkish {
  border: 0;
  background: transparent;
  padding: 0;
  font-family: var(--ui);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
}
.linkish:hover { color: var(--ink); }

.verdict {
  border-top: 3px solid var(--ink);
  background: var(--deep);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  flex-shrink: 0;
}
.verdict__head { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.verdict__quote {
  font-size: 16px;
  line-height: 1.4;
  padding: 9px 12px;
  background: var(--tile);
  border: 2px solid var(--ink);
  border-radius: 4px;
  text-wrap: pretty;
}
.verdict__mine { font-size: 12px; color: var(--muted); text-wrap: pretty; }
.verdict .btn { height: 44px; font-size: 13px; }

.guessline {
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--body);
  padding-left: 23px;
  text-wrap: pretty;
}
.guessline__who { color: var(--muted); }
.tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 2px solid currentColor;
  border-radius: 3px;
  padding: 1px 5px;
  margin-left: 4px;
}
.tag--hit { color: oklch(0.45 0.15 150); }
.tag--miss { color: var(--muted); }
