/* FLX Match — logo-native palette (Adam 2026-09-23), sampled from the FLE
   circular mark. Deliberately NOT the media-kit palette; see
   finger-lakes-effect/AGENTS.md for the open global conflict. Fonts match
   FLX Trail so the two games read as one franchise. */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=VT323&display=swap');

:root {
  --brown: #3C180C;
  --brown-2: #53291a;
  --cream: #F0D89C;
  --teal: #3CA096;
  --teal-hi: #4fc0b4;
  --fg: #F0D89C;
  --fg-dim: #c8ae78;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100%;
  font-family: 'VT323', 'Courier New', monospace;
  font-size: 20px;
  background: var(--brown);
  color: var(--fg);
  image-rendering: pixelated;
}

/* `safe center` centres on tall viewports but falls back to flex-start when the
   content is taller than the screen, so the finish screen never gets its top
   cropped into the unscrollable overflow zone (same fix as FLX Trail). */
body {
  display: flex;
  align-items: safe center;
  justify-content: center;
  padding: 20px 14px 40px;
}
.wrap { width: 100%; max-width: 520px; }

h1 {
  font-family: 'Press Start 2P', monospace;
  font-size: 1.5rem; line-height: 1.5; color: var(--teal);
  margin-bottom: 14px;
}
h2 {
  font-family: 'Press Start 2P', monospace;
  font-size: 1.1rem; color: var(--teal); margin-bottom: 12px;
}

.card {
  background: var(--brown-2);
  border: 3px solid var(--teal);
  padding: 24px 20px;
  text-align: center;
}

.sub { color: var(--teal); margin-bottom: 14px; }
.body { color: var(--fg); line-height: 1.35; margin-bottom: 18px; }
.fine { color: var(--fg-dim); font-size: 0.95rem; margin-top: 12px; line-height: 1.3; }
.fine a { color: var(--teal); }

/* Every link gets an explicit colour INCLUDING :visited. Without this the UA
   stylesheet paints visited links purple, which is nearly unreadable on the
   brown ground — it was live on the finish screen's "Have a look" link, which
   sits in .body and so had no author rule at all. Styling `a` alone is not
   enough: the UA's `a:visited` ties a bare `a` on specificity, so the visited
   state needs naming outright. */
a, a:visited { color: var(--teal); }
a:hover { color: var(--teal-hi); }

.btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.72rem; line-height: 1.6;
  background: var(--teal); color: var(--brown);
  border: none; padding: 14px 18px; cursor: pointer;
  width: 100%; max-width: 320px;
}
.btn:hover { background: var(--teal-hi); }
.btn-ghost { background: transparent; color: var(--teal); border: 2px solid var(--teal); }
.btn-ghost:hover { background: var(--teal); color: var(--brown); }

/* ---- board ---- */

.hud {
  display: flex; justify-content: space-between;
  padding: 0 4px 10px; color: var(--fg-dim); font-size: 1.05rem;
}
.hud strong { color: var(--fg); }

.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.tile {
  position: relative;
  aspect-ratio: 1;
  border: none; padding: 0; background: none; cursor: pointer;
  /* perspective lives on the tile so each face rotates independently */
  perspective: 600px;
}
.tile .face {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  backface-visibility: hidden;
  transition: transform 220ms ease;
  border: 2px solid var(--brown);
}
.tile .back {
  background: var(--teal);
  transform: rotateY(0deg);
}
/* A plain teal back would be flat; the inset ring reads as a card back at
   thumbnail size without needing another asset. */
.tile .back::after {
  content: ''; width: 46%; height: 46%;
  border: 3px solid var(--brown); border-radius: 50%;
  opacity: 0.55;
}
.tile .front {
  background: var(--cream);
  transform: rotateY(180deg);
}
.tile .front img { width: 88%; height: 88%; object-fit: contain; }

.tile.up .back { transform: rotateY(-180deg); }
.tile.up .front { transform: rotateY(0deg); }
.tile.done { cursor: default; }
.tile.done .front { border-color: var(--teal); }

/* ---- finish ---- */

.result { display: flex; justify-content: center; gap: 36px; margin: 6px 0 4px; }
.result div { display: flex; flex-direction: column; }
.result strong {
  font-family: 'Press Start 2P', monospace;
  font-size: 1.3rem; color: var(--fg);
}
.result span { color: var(--fg-dim); font-size: 0.95rem; margin-top: 6px; }
.streak { color: var(--teal); font-size: 1.15rem; margin: 10px 0 18px; }

hr { border: none; border-top: 2px solid var(--brown); margin: 22px 0; }


@media (max-width: 420px) {
  html, body { font-size: 18px; }
  h1 { font-size: 1.15rem; }
  .grid { gap: 6px; }
  .card { padding: 20px 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .tile .face { transition: none; }
}

/* Shown only if clipboard write fails, so the player can select the text. */
.share-fallback {
  user-select: all; white-space: pre-wrap;
  background: var(--brown); border: 2px solid var(--fg-dim);
  padding: 8px 10px; margin-top: 10px;
}


/* ---- leaderboard ---- */

.champ { color: var(--fg); margin-top: 14px; }

.board { margin-top: 16px; }
.lb-you { color: var(--fg); font-size: 1.1rem; margin-bottom: 14px; }

.name-form { margin: 0 0 18px; }
.name-form label { display: block; color: var(--teal); margin-bottom: 8px; }
.name-row { display: flex; gap: 8px; justify-content: center; }
.name-row input {
  font-family: 'VT323', monospace; font-size: 1.1rem;
  background: var(--brown); color: var(--fg);
  border: 2px solid var(--teal); padding: 8px 10px;
  min-width: 0; flex: 1; max-width: 220px;
}
.btn-small { width: auto; padding: 10px 14px; font-size: 0.62rem; }
.btn:disabled { opacity: 0.6; cursor: wait; }
.err { color: #f0a08c; }

.tabs { display: flex; justify-content: center; gap: 0; margin-bottom: 12px; }
.tab {
  font-family: 'Press Start 2P', monospace; font-size: 0.6rem;
  background: transparent; color: var(--fg-dim);
  border: 2px solid var(--teal); padding: 10px 14px; cursor: pointer;
}
.tab + .tab { border-left: none; }
.tab[aria-selected="true"] { background: var(--teal); color: var(--brown); }

.lb-list { list-style: none; text-align: left; }
.lb-list li {
  display: grid;
  grid-template-columns: 2.6em minmax(0, 1fr) auto auto;
  column-gap: 12px; align-items: baseline;
  padding: 5px 6px; border-bottom: 1px solid var(--brown);
}
.lb-list li.me { background: var(--brown); color: var(--teal-hi); }
.lb-list .rk { color: var(--teal); }
.lb-list .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-list .a, .lb-list .b { text-align: right; }
.lb-list .b { color: var(--fg-dim); }
/* Streak sits on its own line under the name so the row stays four columns
   wide on a phone. */
.lb-list .st { grid-column: 2 / -1; color: var(--fg-dim); font-size: 0.85rem; }
.lb-list .st:empty { display: none; }
.lb-list .lb-empty { display: block; text-align: center; color: var(--fg-dim); border: none; }
