@import url('https://fonts.googleapis.com/css2?family=Archivo+Black&family=Bricolage+Grotesque:opsz,wght@12..96,600;12..96,700&family=Work+Sans:wght@400;500;600;700&display=swap');

/* ============================================================================
   patch.css — "Risograph atlas" skin over the prebuilt bundle.
   Hooks are the bundle's own data-cy / data-testid attributes plus the .gx*
   classes patch.js adds, never Tailwind utilities (a rebuild renames those).
   Delete this file and patch.js, re-run debrand.py, and the stock UI returns.
   The globe plates are regenerated by riso_globe.py from textures.src/.
   ========================================================================= */

:root {
  --paper:  #F2EDE3;
  --paper-2:#FBF8F2;
  --ink:    #1A1712;
  --ink-2:  #564E42;
  --ink-3:  #7A6F5E;
  --rule:   #DCD3C4;
  --red:    #D9451F;        /* riso red   — primary action, hot end */
  --red-d:  #B23516;
  --blue:   #1B4CB8;        /* riso blue  — the ocean, numerals, links */
  --blue-d: #143A8E;
  --on-ink: #FBF8F2;
  --shadow: 6px 6px 0 var(--ink);
  --shadow-sm: 4px 4px 0 var(--ink);
  --bd: 3px solid var(--ink);
}
.dark {
  --paper:  #17140F;
  --paper-2:#211D16;
  --ink:    #EFE9DC;
  --ink-2:  #B7AC9A;
  --ink-3:  #8C8272;
  --rule:   #3A342A;
  --red:    #F2643B;
  --red-d:  #FF8259;
  --blue:   #6E93E8;
  --blue-d: #8EAEF2;
  --on-ink: #17140F;
}

/* ── 1. Dead controls ─────────────────────────────────────────────────── */
header a[href*="localhost.invalid"],
footer a[href*="localhost.invalid"],
p:has(> a[href*="localhost.invalid"]),
.version-display,
.rainbow {
  display: none !important;
}

/* ── 2. The paper ─────────────────────────────────────────────────────────
   The stock sky pulled clouds.png and stars.png off two CDNs — remote calls
   from an offline build, and a broken background the moment there's no
   network. Flat local paper and an inline grain plate replace both. */
.sky {
  background: var(--paper) !important;
  transition: none !important;
}
.night { --myColor1: transparent; --myColor2: transparent; --foreground: transparent; }
.stars { display: none !important; }
.clouds {
  margin-top: 0 !important;
  opacity: 1 !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.22'/%3E%3C/svg%3E") !important;
  background-repeat: repeat !important;
  mix-blend-mode: multiply;
}
.dark .clouds { mix-blend-mode: screen; opacity: .5 !important; }

body {
  font-family: 'Work Sans', ui-sans-serif, system-ui, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
main { padding-inline: 22px; max-width: 760px; }
[data-route="/game"] main,
[data-route="/practice"] main { max-width: 1180px; }

a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 3px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── 3. Masthead ──────────────────────────────────────────────────────── */
main > header {
  height: 4.5rem !important;
  padding-top: 26px !important;
}
main > header h1 {
  font-family: 'Archivo Black', 'Work Sans', sans-serif !important;
  font-size: 2.35rem !important;
  font-weight: 400 !important;
  letter-spacing: -.035em;
  line-height: .9;
  color: var(--ink);
  white-space: nowrap;   /* the bundle's w-min wraps a two-word name into the icons */
}
@media (max-width: 640px) { main > header h1 { font-size: 1.45rem !important; } }
@media (max-width: 400px) { main > header h1 { font-size: 1.25rem !important; } }
main > header hr {
  border: none !important;
  border-top: 4px solid var(--ink) !important;
}
main > header a, main > header button {
  min-height: 44px; min-width: 44px;
  display: inline-flex; align-items: center; justify-content: center;
}
main > header a[data-cy="home-link"] img { width: 27px !important; height: 27px !important; }

.gx-count {
  position: absolute;
  right: 92px;
  bottom: 6px;
  background: var(--ink);
  color: var(--on-ink);
  font-family: 'Archivo Black', sans-serif;
  font-size: .78rem;
  letter-spacing: .03em;
  text-transform: uppercase;
  padding: 7px 12px;
  white-space: nowrap;
}
@media (max-width: 760px) { .gx-count { display: none; } }

/* ── 4. Game layout ───────────────────────────────────────────────────── */
@media (min-width: 1024px) {
  .gx {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 372px;
    grid-template-areas: "top top" "globe side";
    column-gap: 40px;
    align-items: start;
  }
  .gx > *:nth-child(1) { grid-area: top; }
  .gx > *:nth-child(2) { grid-area: globe; }
  .gx > *:nth-child(3) { grid-area: side; margin-bottom: 0 !important; padding-top: 0 !important; }
}

/* ── 5. Guess input ───────────────────────────────────────────────────── */
.gx form {
  width: min(520px, 100%) !important;
  gap: 14px;
  margin-block: 26px 12px !important;
}
.gx form input[data-cy="guesser"] {
  height: 58px;
  border: var(--bd) !important;
  border-radius: 0 !important;
  background: var(--paper-2) !important;
  box-shadow: var(--shadow-sm) var(--blue) !important;
  box-shadow: 5px 5px 0 var(--blue) !important;
  padding-inline: 18px !important;
  font-size: 1.08rem;
  font-weight: 500;
  color: var(--ink) !important;
}
.gx form input[data-cy="guesser"]::placeholder { color: var(--ink-3); }
.gx form input[data-cy="guesser"]:focus {
  outline: none;
  box-shadow: 5px 5px 0 var(--red) !important;
}
.gx form button[type="submit"] {
  height: 58px;
  border: var(--bd) !important;
  border-radius: 0 !important;
  background: var(--red) !important;
  color: var(--on-ink) !important;
  font-family: 'Archivo Black', sans-serif;
  font-size: 1.02rem;
  letter-spacing: .02em;
  text-transform: uppercase;
  padding-inline: 26px !important;
  box-shadow: 5px 5px 0 var(--ink);
  transition: transform .08s ease, box-shadow .08s ease;
}
.gx form button[type="submit"]:hover { background: var(--red-d) !important; }
.gx form button[type="submit"]:active {
  transform: translate(3px, 3px);
  box-shadow: 2px 2px 0 var(--ink);
}

@media (max-width: 480px) {
  .gx form { gap: 10px; }
  .gx form input[data-cy="guesser"] { font-size: 1rem; padding-inline: 12px !important; }
  .gx form button[type="submit"] { font-size: .88rem; padding-inline: 15px !important; }
}

/* ── 6. The verdict ───────────────────────────────────────────────────── */
p[data-testid="guess-msg"] {
  font-family: 'Bricolage Grotesque', 'Archivo Black', sans-serif;
  font-weight: 700;
  font-size: 2.5rem;
  line-height: 1.05;
  letter-spacing: -.025em;
  min-height: 1.5em;                /* reserve the line so the globe holds still */
  color: var(--ink) !important;     /* the app tints this; the skin is two-colour */
  margin-block: 10px 2px;
}
p[data-testid="guess-msg"][data-long="true"] {
  font-family: 'Work Sans', sans-serif;
  font-size: 1.02rem;
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: normal;
  color: var(--ink-2) !important;
  max-width: 48ch;
  margin-inline: auto;
}
@media (max-width: 640px) { p[data-testid="guess-msg"] { font-size: 1.85rem; } }

/* ── 7. Globe zoom controls ───────────────────────────────────────────── */
.gx button.select-none {
  width: 52px; height: 48px;
  border: var(--bd) !important;
  border-radius: 0 !important;
  background: var(--paper-2) !important;
  color: var(--ink) !important;
  font-family: 'Archivo Black', sans-serif;
  font-size: 1.3rem;
  line-height: 1;
  padding: 0 !important;
  box-shadow: var(--shadow-sm);
}
.gx button.select-none:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }

/* globe.gl paints a pale atmosphere past the sphere; on paper it reads as a
   smudge. The clip box is 2x the sphere radius, so a proportional mask trims
   the halo at any size without touching the globe. closest-side matters:
   the default farthest-corner would put 100% out at the box diagonal. */
.gx > *:nth-child(2) > div:first-child {
  -webkit-mask-image: radial-gradient(circle closest-side at 50% 50%, #000 0 97.5%, transparent 98.2%);
  mask-image: radial-gradient(circle closest-side at 50% 50%, #000 0 97.5%, transparent 98.2%);
}

/* ── 8. Guess panel ───────────────────────────────────────────────────── */
.gx > *:nth-child(3) {
  background: var(--paper-2);
  border: var(--bd);
  box-shadow: 8px 8px 0 var(--ink);
  padding: 20px 22px !important;
  margin-top: 26px;
}
.gx-head + p { display: none; }
.gx-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: var(--bd);
  margin-bottom: 4px;
}
.gx-head b {
  font-family: 'Archivo Black', sans-serif;
  font-size: .95rem;
  font-weight: 400;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--ink);
}
.gx-head span { font-size: .84rem; font-weight: 600; color: var(--ink-3); }

[data-cy="countries-list"] {
  display: grid !important;
  grid-template-columns: 1fr;
  gap: 0 !important;
  counter-reset: guess;
}
@media (max-width: 1023px) {
  [data-cy="countries-list"] { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 18px !important; }
}
[data-cy="countries-list"] li { counter-increment: guess; }
[data-cy="countries-list"] li button {
  width: 100%;
  min-height: 46px;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--rule);
}
[data-cy="countries-list"] li:last-child button { border-bottom: none; }
[data-cy="countries-list"] li button:hover { background: rgba(217, 69, 31, .09); }
[data-cy="countries-list"] li button::before {
  content: counter(guess);
  flex: 0 0 auto;
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  background: var(--rule);
  color: var(--ink);
  font-family: 'Archivo Black', sans-serif;
  font-size: .78rem;
}
[data-cy="countries-list"] li:first-child button::before { background: var(--red); color: var(--on-ink); }
[data-cy="countries-list"] li:nth-child(2) button::before { background: #E8865F; }
[data-cy="countries-list"] li:nth-child(3) button::before { background: #F0BFA6; }
[data-cy="countries-list"] li img { width: 24px; height: auto; border: 1px solid var(--ink); }
[data-cy="countries-list"] li span {
  margin-left: 0 !important;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
}

.gx > *:nth-child(3) > div:last-of-type {
  margin-top: 18px !important;
  padding-top: 16px;
  border-top: var(--bd);
}
.gx > *:nth-child(3) [data-i18n="Game8"] {
  font-size: .8rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--ink-3);
}
/* label, figure and unit toggle read as one line */
.gx > *:nth-child(3) > div:last-of-type > div:first-child {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: nowrap;
}
.gx > *:nth-child(3) > div:last-of-type > div:first-child > p:first-child { white-space: nowrap; }
[data-testid="closest-border"] {
  font-family: 'Archivo Black', sans-serif;
  font-size: 1.15rem;
  color: var(--blue);
}
[data-cy="change-sort"] { min-height: 44px; display: inline-flex; align-items: center; }
[data-cy="change-sort"] span {
  text-decoration: none !important;
  font-size: .88rem !important;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--blue);
  border-bottom: 2px solid var(--blue);
}

/* ── 9. Toggles ───────────────────────────────────────────────────────── */
.block.h-8.w-14.rounded-full {
  border: 2px solid var(--ink) !important;
  border-radius: 0 !important;
  background: var(--paper-2) !important;
}
[data-cy^="toggle-"] {
  border-radius: 0 !important;
  background: var(--blue) !important;
  top: .3rem !important; left: .3rem !important;
}

/* ── 10. Buttons and selects ──────────────────────────────────────────── */
button.bg-blue-700 {
  background: var(--red) !important;
  color: var(--on-ink) !important;
  border: var(--bd) !important;
  border-radius: 0 !important;
  font-family: 'Archivo Black', sans-serif;
  font-weight: 400;
  text-transform: uppercase;
  font-size: .92rem;
  min-height: 46px;
  box-shadow: var(--shadow-sm);
}
button.bg-blue-700:hover { background: var(--red-d) !important; }
button.bg-blue-700:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
button.border-red-700 {
  border: var(--bd) !important;
  border-radius: 0 !important;
  color: var(--ink) !important;
  background: var(--paper-2) !important;
  font-family: 'Archivo Black', sans-serif;
  font-weight: 400;
  text-transform: uppercase;
  font-size: .92rem;
  min-height: 46px;
  box-shadow: var(--shadow-sm);
}
button.border-red-700:hover { background: var(--red) !important; color: var(--on-ink) !important; }
select {
  border: var(--bd) !important;
  border-radius: 0 !important;
  background-color: var(--paper-2) !important;
  color: var(--ink) !important;
  min-height: 46px;
  font-weight: 700;
  padding-inline: 14px !important;
  box-shadow: var(--shadow-sm);
}

/* ── 11. Statistics dialog ────────────────────────────────────────────── */
.m {
  border: var(--bd) !important;
  border-radius: 0 !important;
  background: var(--paper-2) !important;
  box-shadow: 10px 10px 0 var(--ink) !important;
  padding: 26px 28px !important;
}
.m h2 {
  font-family: 'Archivo Black', sans-serif !important;
  font-size: 1.15rem !important;
  font-weight: 400 !important;
  text-transform: uppercase;
  letter-spacing: .02em;
  color: var(--ink) !important;
  text-align: left !important;
  padding-bottom: 12px;
  border-bottom: var(--bd);
  margin-bottom: 8px;
}
.m table { border-collapse: collapse; }
.m tbody { display: flex; flex-direction: column; }
.m tr {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 20px; padding: 11px 0; border-bottom: 1px solid var(--rule);
}
.m td {
  border: none !important; padding: 0 !important;
  font-size: 1rem !important; font-weight: 500;
  color: var(--ink-2) !important; text-align: left !important;
}
.m td[data-cy] { color: var(--ink) !important; font-weight: 700; }
/* Average guesses is the only stat that measures skill — lead with it. */
.m tr:has(td[data-cy="avg.-guesses"]) {
  order: -1; border-bottom: var(--bd); padding-bottom: 14px; margin-bottom: 6px;
}
.m tr:has(td[data-cy="avg.-guesses"]) td[data-cy] {
  font-family: 'Archivo Black', sans-serif;
  font-size: 2.6rem !important;
  font-weight: 400;
  line-height: 1;
  letter-spacing: -.03em;
  color: var(--red) !important;
}
.m tr:last-child { border-bottom: none; }
.m button.absolute { color: var(--ink); }
.m .flex.w-full { gap: 12px; padding-top: 22px !important; }

/* ── 12. Reading pages ────────────────────────────────────────────────── */
[data-route="/"] main > div,
[data-route="/faq"] main > div,
[data-route="/privacy-policy"] main > div {
  background: var(--paper-2);
  border: var(--bd);
  box-shadow: 8px 8px 0 var(--ink);
  padding: 10px 28px 28px;
  margin-top: 22px;
}
[data-route="/"] main p, [data-route="/faq"] main p { max-width: 68ch; color: var(--ink-2); }
[data-route="/"] main h2, [data-route="/faq"] main h2, [data-route="/settings"] main h2 {
  font-family: 'Archivo Black', sans-serif !important;
  font-size: 1.7rem !important;
  font-weight: 400 !important;
  letter-spacing: -.02em;
  text-align: left !important;
  color: var(--ink);
}

/* the play affordance was a captioned thumbnail; make it read as a control */
div:has(> b[data-i18n="Aux1"]) {
  display: flex !important;
  align-items: center;
  gap: 10px;
  width: fit-content;
  margin: 30px auto 10px !important;
  padding: 8px 26px 8px 8px !important;
  border: var(--bd);
  background: var(--red);
  box-shadow: var(--shadow);
  transition: transform .08s ease, box-shadow .08s ease;
}
div:has(> b[data-i18n="Aux1"]):active { transform: translate(3px, 3px); box-shadow: 3px 3px 0 var(--ink); }
div:has(> b[data-i18n="Aux1"]) > div { margin: 0 !important; }
b[data-i18n="Aux1"] {
  color: var(--on-ink);
  font-family: 'Archivo Black', sans-serif;
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: .01em;
}

/* ── 13. Settings ─────────────────────────────────────────────────────── */
[data-route="/settings"] main > div > div > div.mx-auto {
  background: var(--paper-2);
  border: var(--bd);
  box-shadow: 8px 8px 0 var(--ink);
  padding: 6px 22px;
  max-width: 27rem !important;
}
[data-route="/settings"] main > div > div > div.mx-auto > div {
  padding-block: 14px;
  border-bottom: 1px solid var(--rule);
  min-height: 58px;
}
[data-route="/settings"] main > div > div > div.mx-auto > div:last-child { border-bottom: none; }
[data-route="/settings"] main [data-testid="toggle-text"],
[data-route="/settings"] main label p { font-weight: 600; }

/* ── 14. Footer ───────────────────────────────────────────────────────── */
footer {
  color: var(--ink-3);
  border-top: 2px solid var(--rule);
  padding-top: 16px !important;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
}
footer a { color: var(--ink-2); }

/* 12. Header marks — patch.js replaces the bundle's filled glyphs with stroked
   ones; they inherit ink through currentColor instead of dark:fill utilities. */
main > header svg[data-mark] { color: var(--ink); width: 24px; height: 24px; }
main > header svg[data-mark] path,
main > header svg[data-mark] circle { fill: none; stroke-width: 2.2px; }
