/* ---------------------------------------------------------------
   Lynxy - shared foundation for every game on the site.

   Design tokens, page chrome (top bar, footer), buttons, modals,
   the cookie banner and the legal-page layout live here. Anything
   that belongs to a single game lives in that game's own sheet,
   loaded after this one.
---------------------------------------------------------------- */

:root {
  --bg: #f4f6fb;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #eef1f8;
  --border: #dfe4ef;
  --border-strong: #b9c1d4;
  --text: #171b26;
  --text-dim: #666f85;
  --accent: #4f6cf7;
  --accent-2: #8b5cf6;
  --accent-soft: #e5eafe;
  --accent-text: #ffffff;
  --given: #171b26;
  --entry: #3757e8;
  --error: #e0435b;
  --error-soft: #fde8ec;
  --ok: #17a673;
  --highlight: #edf1fe;
  --peer: #f2f4fa;
  --same: #dfe6fd;
  --shadow: 0 1px 2px rgba(18, 24, 40, .06), 0 8px 24px rgba(18, 24, 40, .07);
  --shadow-lg: 0 24px 60px rgba(18, 24, 40, .22);
  --radius: 14px;
  --radius-lg: 20px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1117;
    --bg-elev: #161b25;
    --surface: #161b25;
    --surface-2: #1e2430;
    --border: #262d3b;
    --border-strong: #46506a;
    --text: #e8ecf5;
    --text-dim: #9aa3b8;
    --accent: #6f8bff;
    --accent-2: #a78bfa;
    --accent-soft: #212a45;
    --accent-text: #0b0f17;
    --given: #e8ecf5;
    --entry: #8ea6ff;
    --error: #ff6b82;
    --error-soft: #3a1c26;
    --ok: #35d39a;
    --highlight: #1c2333;
    --peer: #171d28;
    --same: #263250;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, .6);
  }
}

:root[data-theme="dark"] {
  --bg: #0e1117;
  --bg-elev: #161b25;
  --surface: #161b25;
  --surface-2: #1e2430;
  --border: #262d3b;
  --border-strong: #46506a;
  --text: #e8ecf5;
  --text-dim: #9aa3b8;
  --accent: #6f8bff;
  --accent-2: #a78bfa;
  --accent-soft: #212a45;
  --accent-text: #0b0f17;
  --given: #e8ecf5;
  --entry: #8ea6ff;
  --error: #ff6b82;
  --error-soft: #3a1c26;
  --ok: #35d39a;
  --highlight: #1c2333;
  --peer: #171d28;
  --same: #263250;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); }

.icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg-elev); /* fallback for browsers without color-mix */
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  padding: max(8px, env(safe-area-inset-top)) 0 8px;
}

.topbar__inner {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar--wide .topbar__inner { max-width: 1060px; }

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  letter-spacing: -.02em;
}

.brand__mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 16px;
}

.brand__logo {
  width: 34px;
  height: 34px;
  display: block;
}

.brand__name { font-size: 17px; }
.brand__suffix { color: var(--text-dim); font-weight: 600; }

/* Lynx button that takes a player from a game back to the home page. */
.home-btn {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  display: grid;
  place-items: center;
  padding: 3px;
}

.home-btn img { width: 100%; height: 100%; display: block; }
.home-btn:active { transform: scale(.96); }

.icon-btn {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.icon-btn:active { transform: scale(.96); }
.icon-btn--end { margin-left: auto; }

/* Only one of the two glyphs is shown, depending on the active theme. */
.icon--moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon--sun { display: none; }
  :root:not([data-theme="light"]) .icon--moon { display: block; }
}
:root[data-theme="dark"] .icon--sun { display: none; }
:root[data-theme="dark"] .icon--moon { display: block; }
:root[data-theme="light"] .icon--sun { display: block; }
:root[data-theme="light"] .icon--moon { display: none; }

/* ------------------------------- buttons ------------------------------- */

.btn {
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  padding: 10px 16px;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* display above would otherwise win over the hidden attribute. */
.btn[hidden] { display: none; }

.btn--primary {
  background: var(--accent);
  color: var(--accent-text);
}

.btn--primary:active { transform: scale(.98); }

.btn--ghost {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.btn--lg { font-size: 15px; padding: 13px 22px; border-radius: 14px; }

.linklike {
  font: inherit;
  font-size: inherit;
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
}

/* -------------------------------- footer ------------------------------- */

.footer {
  border-top: 1px solid var(--border);
  padding: 22px 16px calc(20px + env(safe-area-inset-bottom));
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

.footer__links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  justify-content: center;
  margin-bottom: 8px;
}

/* One row per group of links: the games first, the legal pages under them. */
.footer__group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  justify-content: center;
  align-items: center;
  margin-bottom: 10px;
}

.footer__label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-dim);
  opacity: .75;
}

/* The page you are on, in the list of every game. */
.footer__group a[aria-current="page"] {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.footer__note { margin: 0; font-size: 12px; }

/* -------------------------------- modals ------------------------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal[hidden] { display: none; }

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 11, 20, .55);
  backdrop-filter: blur(3px);
  animation: fade .2s ease;
}

.modal__card {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 24px 20px 20px;
  text-align: center;
  animation: rise .25s cubic-bezier(.2, .8, .3, 1);
}

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.97); } }

.modal__icon { font-size: 40px; line-height: 1; }
.modal__title { margin: 8px 0 4px; font-size: 21px; letter-spacing: -.02em; }
.modal__text { margin: 0; color: var(--text-dim); font-size: 14px; }

.modal__actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.modal__actions .btn { flex: 1; }

/* ------------------------------- consent ------------------------------- */

.consent {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 70;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
}

.consent[hidden] { display: none; }

.consent__card {
  max-width: 560px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 16px;
  animation: rise .25s cubic-bezier(.2, .8, .3, 1);
}

.consent__title { margin: 0 0 6px; font-size: 16px; }
.consent__text { margin: 0; font-size: 13px; color: var(--text-dim); }

.consent__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}

.consent__nudge { margin: 10px 0 0; font-size: 13px; color: var(--text-dim); text-align: center; }

/* "Accept all" is the obvious choice; "Essential only" is a link inside the
   sentence above it: readable and fully working, just not a second button. */
.consent__accept { flex: 1; }

.consent__reject {
  font: inherit;
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.consent__reject:hover { color: var(--text); }

/* -------------------------- legal / text pages ------------------------- */

.doc {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 40px;
  flex: 1;
}

.doc h1 { font-size: 26px; letter-spacing: -.02em; margin: 0 0 4px; }
.doc h2 { font-size: 17px; margin: 28px 0 6px; }
.doc h3 { font-size: 15px; margin: 18px 0 4px; }
.doc p, .doc li { font-size: 15px; color: var(--text); }
.doc ul { padding-left: 20px; }
.doc li { margin: 4px 0; }

.doc__updated {
  color: var(--text-dim);
  font-size: 13px;
  margin: 0 0 8px;
}

.doc__card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 16px 0;
  box-shadow: var(--shadow);
}

.doc__back {
  display: inline-block;
  margin-top: 24px;
  font-weight: 600;
  text-decoration: none;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
