:root {
  /* Raw palette */
  --color-ash-grey-50: #f0f4f0;
  --color-ash-grey-100: #e1eae1;
  --color-ash-grey-200: #c3d5c3;
  --color-ash-grey-300: #a5c0a5;
  --color-ash-grey-400: #88aa88;
  --color-ash-grey-500: #6a956a;
  --color-ash-grey-600: #557755;
  --color-ash-grey-700: #3f5a3f;
  --color-ash-grey-800: #2a3c2a;
  --color-ash-grey-900: #151e15;
  --color-ash-grey-950: #0f150f;

  --color-camel-50: #f5f3f0;
  --color-camel-100: #ebe7e0;
  --color-camel-200: #d7cfc1;
  --color-camel-300: #c3b7a2;
  --color-camel-400: #ae9f84;
  --color-camel-500: #9a8765;
  --color-camel-600: #7b6c51;
  --color-camel-700: #5d513c;
  --color-camel-800: #3e3628;
  --color-camel-900: #1f1b14;
  --color-camel-950: #16130e;

  --color-pale-oak-50: #f7f2ee;
  --color-pale-oak-100: #eee6dd;
  --color-pale-oak-200: #deccba;
  --color-pale-oak-300: #cdb398;
  --color-pale-oak-400: #bd9975;
  --color-pale-oak-500: #ac8053;
  --color-pale-oak-600: #8a6642;
  --color-pale-oak-700: #674d32;
  --color-pale-oak-800: #453321;
  --color-pale-oak-900: #221a11;
  --color-pale-oak-950: #18120c;

  --color-dusty-olive-50: #f2f3f2;
  --color-dusty-olive-100: #e4e7e4;
  --color-dusty-olive-200: #cacfc9;
  --color-dusty-olive-300: #afb6af;
  --color-dusty-olive-400: #959e94;
  --color-dusty-olive-500: #7a8679;
  --color-dusty-olive-600: #626b61;
  --color-dusty-olive-700: #495049;
  --color-dusty-olive-800: #313630;
  --color-dusty-olive-900: #181b18;
  --color-dusty-olive-950: #111311;

  --color-coffee-bean-50: #f6f1ef;
  --color-coffee-bean-100: #ede3de;
  --color-coffee-bean-200: #dac7be;
  --color-coffee-bean-300: #c8ab9d;
  --color-coffee-bean-400: #b68f7c;
  --color-coffee-bean-500: #a3725c;
  --color-coffee-bean-600: #835c49;
  --color-coffee-bean-700: #624537;
  --color-coffee-bean-800: #412e25;
  --color-coffee-bean-900: #211712;
  --color-coffee-bean-950: #17100d;

  /* Semantic tokens */
  --bg: var(--color-pale-oak-50);
  --bg-alt: #fff;
  --bg-sunken: var(--color-pale-oak-100);
  --ink: var(--color-coffee-bean-900);
  --ink-soft: var(--color-camel-600);
  --brand: var(--color-coffee-bean-600);
  --brand-dark: var(--color-coffee-bean-700);
  --accent: var(--color-ash-grey-600);
  --accent-dark: var(--color-ash-grey-700);
  --danger: #b8503c;
  --danger-bg: #f5e5e0;
  --border: var(--color-pale-oak-200);
  --shadow: 0 10px 30px -12px rgba(33, 23, 18, 0.16);
  --radius: 18px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: linear-gradient(180deg, var(--color-pale-oak-50) 0%, var(--color-ash-grey-50) 100%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.site-header {
  text-align: center;
  padding: 28px 16px 8px;
}

.site-header h1 {
  margin: 0;
  font-size: 1.9rem;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.tagline {
  margin: 4px 0 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.card {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.tracker {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  text-align: center;
}

.field-label {
  font-size: 0.85rem;
  color: var(--ink-soft);
  text-align: left;
}

.country-select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-sunken);
  font-size: 1rem;
  color: var(--ink);
  appearance: none;
}

.geo-note {
  margin: -6px 0 0;
  font-size: 0.75rem;
  color: var(--ink-soft);
  text-align: left;
}

.go-button {
  margin-top: 6px;
  width: 100%;
  padding: 20px;
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  border: none;
  border-radius: 999px;
  box-shadow: 0 12px 24px -8px rgba(98, 69, 55, 0.55);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  -webkit-tap-highlight-color: transparent;
}

.go-button:active {
  transform: scale(0.97);
  box-shadow: 0 6px 14px -6px rgba(98, 69, 55, 0.55);
}

.go-button:disabled {
  opacity: 0.6;
  cursor: default;
}

#toast {
  min-height: 1.4em;
}

.toast {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  transition: opacity 0.6s ease;
}

.toast-ok {
  background: var(--color-ash-grey-100);
  color: var(--accent-dark);
}

.toast-err {
  background: var(--danger-bg);
  color: var(--danger);
}

.toast-fade {
  opacity: 0;
}

.fineprint {
  margin: 0;
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.stats-section h2,
.leaderboard-section h2,
.about h2 {
  font-size: 1.05rem;
  margin: 0 0 12px;
  color: var(--ink);
}

.as-of {
  margin: 8px 0 0;
  font-size: 0.72rem;
  color: var(--ink-soft);
  text-align: right;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.stat-card {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.stat-label {
  display: flex;
  align-items: center;
  min-height: 2.2em;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
}

.stat-count {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.1;
}

.stat-cost {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-dark);
  margin-top: 8px;
  line-height: 1.1;
}

.stat-sub {
  font-size: 0.7rem;
  color: var(--ink-soft);
  margin-top: 1px;
}

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 12px;
  -webkit-overflow-scrolling: touch;
}

.tab {
  flex: 0 0 auto;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-sunken);
  color: var(--ink-soft);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.tab-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.leaderboard {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 20px 24px 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px 6px;
  margin: 0 -6px;
  border-radius: 10px;
}

.leaderboard-row:nth-child(odd) {
  background: var(--bg-sunken);
}

.lb-rank {
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 0.85rem;
  text-align: center;
}

.lb-flag {
  font-size: 1.1rem;
}

.lb-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-count {
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.lb-cost {
  font-weight: 700;
  color: var(--accent-dark);
}

.empty {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.about p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.legal h2 {
  font-size: 1rem;
  margin: 20px 0 8px;
  color: var(--ink);
}

.legal h2:first-of-type {
  margin-top: 0;
}

.legal p,
.legal li {
  color: var(--ink-soft);
  font-size: 0.9rem;
  line-height: 1.55;
}

.legal ul {
  margin: 4px 0;
  padding-left: 20px;
}

.legal a {
  color: var(--accent-dark);
}

.legal code {
  background: var(--bg-sunken);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.85em;
}

/* On-page "spot". Class names are deliberately generic (no "ad", "advert",
   "banner", "sponsor") so ad blockers don't cosmetically hide it -- there
   is no ad network here, just a first-party card. */
.spot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 60px;
  padding: 8px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--ink-soft);
  font-size: 0.7rem;
  letter-spacing: 0.03em;
  background: rgba(255, 255, 255, 0.4);
}

/* "house" mode: the space is for sale, so the placeholder itself is the
   pitch rather than an empty grey box. */
.spot-pitch {
  text-decoration: none;
  border-style: solid;
  border-color: var(--border);
  background: var(--bg-alt);
  color: var(--ink);
  text-align: center;
  gap: 2px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.spot-pitch:hover {
  border-color: var(--brand);
  transform: translateY(-1px);
}

.spot-pitch-kicker {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink-soft);
}

.spot-pitch-line {
  font-size: 0.82rem;
  line-height: 1.35;
  max-width: 46ch;
}

.spot-pitch-cta {
  white-space: nowrap;
  color: var(--brand);
  font-weight: 600;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  justify-content: center;
  align-items: baseline;
}

.site-footer {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.75rem;
  padding: 12px 24px 28px;
}

.site-footer p {
  margin: 4px 0;
}

.site-footer a {
  color: var(--ink-soft);
  text-decoration: underline;
}

@media (min-width: 640px) {
  .stat-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* --- Flush Rush mini-game --------------------------------------------- */

.header-link {
  color: inherit;
  text-decoration: none;
}

.header-link:hover {
  text-decoration: underline;
}

/* Persistent "get me out" link at the top of each game page. */
.game-nav {
  margin: 0;
  font-size: 0.9rem;
}

.game-nav a {
  color: var(--accent-dark);
  font-weight: 600;
  text-decoration: none;
}

.game-nav a:hover {
  text-decoration: underline;
}

/* Outline pill that pairs with .share-x in the results panel. */
.btn-secondary {
  display: inline-flex;
  align-items: center;
  padding: 10px 22px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-sunken);
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.08s ease;
}

.btn-secondary:active {
  transform: scale(0.97);
}

/* Entry point on the main page: a full-width tappable card that matches
   the surrounding .card styling but reads as a call to action. */
.game-cta {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.game-cta:active {
  transform: scale(0.99);
}

.game-cta-emoji {
  font-size: 1.5rem;
  line-height: 1;
}

.game-cta-text {
  flex: 1;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.game-cta-text strong {
  color: var(--ink);
}

.game-cta-arrow {
  color: var(--accent-dark);
  font-weight: 700;
}

/* The game card lays its children out in a centered column, the way
   .tracker does on the main page. */
.game-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
}

.game-spot-top {
  margin-bottom: 4px;
}

.game-readout {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.game-stat {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.game-stat .stat-label {
  min-height: 0;
  margin-bottom: 4px;
}

.game-stat .stat-count {
  font-size: 2rem;
  transition: color 0.2s ease;
}

/* Last 10 seconds: the timer tile goes red. */
.game-stat.is-low {
  background: var(--danger-bg);
  border-color: var(--danger);
}

.game-stat.is-low .stat-count {
  color: var(--danger);
}

.tap-zone {
  min-height: 200px;
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.25s ease;
}

/* idle state keeps the default .go-button brand gradient. */
.tap-zone[data-state="running"] {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  box-shadow: 0 12px 24px -8px rgba(63, 90, 63, 0.5);
}

.tap-zone[data-state="done"] {
  background: linear-gradient(135deg, var(--color-camel-500), var(--color-camel-700));
}

.game-hint {
  margin: 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
  min-height: 1.2em;
}

.game-best-hint {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
}

.game-result {
  text-align: center;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.game-result-label {
  margin: 0 0 8px;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

.game-result-score {
  margin: 0;
  font-size: 1.05rem;
  color: var(--ink);
}

.game-result-score strong {
  font-size: 1.8rem;
  color: var(--accent-dark);
}

.game-result-sub,
.game-result-best {
  margin: 4px 0 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.game-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 14px;
}

.game-replay-hint {
  margin: 12px 0 0;
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.share-x {
  display: inline-flex;
  align-items: center;
  padding: 10px 22px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
}

.share-x[hidden] {
  display: none;
}

/* Rounded brand button used to start / restart the memory game. */
.pill-btn {
  align-self: center;
  padding: 12px 30px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 20px -8px rgba(98, 69, 55, 0.5);
  transition: transform 0.08s ease, opacity 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.pill-btn:active {
  transform: scale(0.97);
}

.pill-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

/* --- Royal Recall memory game --------------------------------------- */

.recall-pad {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 320px;
  margin: 4px auto 0;
}

.recall-key {
  aspect-ratio: 1 / 1;
  border: 2px solid rgba(0, 0, 0, 0.08);
  border-radius: 18px;
  opacity: 0.5;
  cursor: default;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: opacity 0.15s ease, transform 0.08s ease, box-shadow 0.15s ease,
    filter 0.15s ease;
}

.recall-key[data-color="red"] {
  background: #b8503c;
}
.recall-key[data-color="green"] {
  background: #5f8a5a;
}
.recall-key[data-color="blue"] {
  background: #4a6b8a;
}
.recall-key[data-color="yellow"] {
  background: #c9a24a;
}

/* Only tappable while it's the player's turn. */
.recall[data-state="input"] .recall-key {
  opacity: 0.82;
  cursor: pointer;
}

.recall[data-state="input"] .recall-key:active {
  transform: scale(0.96);
}

.recall-key.is-lit {
  opacity: 1;
  filter: brightness(1.28) saturate(1.2);
  transform: scale(1.04);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.55),
    0 12px 26px -6px rgba(0, 0, 0, 0.35);
}

.recall-status {
  margin: 0;
  min-height: 1.3em;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink-soft);
}

/* Two mini-game call-to-action cards stacked on the main page. */
.game-cta-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
