/* Shared look for the whole site: chalk-stream teal + gorse gold */

:root {
  --bg: #eef2ee;
  --panel: #ffffff;
  --ink: #14231f;
  --mut: #5d6f69;
  --line: #d3ddd7;
  --m: #1f8a7d;
  --u: #d99a0b;
  --link: #176f65;
  --glow: rgba(31, 138, 125, .14);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1917;
    --panel: #14251f;
    --ink: #e6f0ea;
    --mut: #8fa59d;
    --line: #25403a;
    --m: #3cc9b5;
    --u: #f5b933;
    --link: #3cc9b5;
    --glow: rgba(60, 201, 181, .16);
    color-scheme: dark;
  }
}

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

html { scroll-behavior: smooth; scroll-padding-top: 80px; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
}

h1, h2, h3, .logo { font-family: "Bricolage Grotesque", system-ui, sans-serif; }

a { color: var(--link); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--m); outline-offset: 3px; border-radius: 4px;
}
img { max-width: 100%; display: block; }

/* ---------- Navigation ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  align-items: center;
  justify-content: space-between;
  padding: 14px max(20px, calc((100vw - 1120px) / 2 + 20px));
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.logo { font-size: 1.2rem; font-weight: 700; color: var(--ink); text-decoration: none; }
.logo span { color: var(--m); }
.nav nav { display: flex; flex-wrap: wrap; gap: 6px 20px; align-items: center; }
.nav nav a { color: var(--mut); text-decoration: none; font-size: .95rem; transition: color .2s; }
.nav nav a:hover { color: var(--ink); }
.nav nav a.pill { color: var(--bg); background: var(--ink); padding: 6px 16px; border-radius: 99px; font-weight: 600; }
.nav nav a.pill:hover { color: var(--bg); opacity: .85; }

main { max-width: 1120px; margin: 0 auto; padding: 0 20px 40px; }

footer {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 20px 40px;
  border-top: 1px solid var(--line);
  color: var(--mut);
  font-size: .88rem;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  align-items: center;
  justify-content: space-between;
}
footer form { margin: 0; }

/* ---------- Plain pages: login, admin ---------- */
main > h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); line-height: 1.15; margin: 28px 0 12px; }
main > h2 { font-size: 1.25rem; margin: 24px 0 10px; }
main > p { margin-bottom: 12px; max-width: 60ch; }
main > table { margin-top: 8px; }

label { display: block; margin-bottom: .75rem; }
label.inline { display: flex; gap: .5rem; align-items: center; }
input, select, textarea, button { font: inherit; }
input:not([type=checkbox]):not([type=hidden]), select, textarea {
  padding: .45rem .75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
}
form.stack { max-width: 22rem; }
form.stack input:not([type=checkbox]) { display: block; width: 100%; }

button {
  padding: .45rem 1.1rem;
  border: 1px solid var(--ink);
  border-radius: 99px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 600;
  cursor: pointer;
  transition: opacity .2s;
}
button:hover { opacity: .85; }
button.ghost { background: transparent; color: var(--ink); }
button.link { padding: 0; border: none; background: none; color: var(--link); font-weight: 400; text-decoration: underline; }

.row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; margin-bottom: 1rem; }
.row.form label { display: flex; flex-direction: column; gap: 2px; margin: 0; font-size: .85rem; color: var(--mut); }
.row.form label.inline { flex-direction: row; align-items: center; padding-bottom: .5rem; }
.row .grow { flex: 1 1 14rem; }
.row .grow input { width: 100%; }

.tw { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .6rem .5rem; border-bottom: 1px solid var(--line); text-align: left; }
th { font-size: .85rem; color: var(--mut); font-weight: 600; }
td.actions { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin: 0; }
td.actions button { padding: .2rem .8rem; font-size: .85rem; }

.error { color: #d9534f; }
.ok { color: var(--m); }

/* ---------- Games ---------- */
.games h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); line-height: 1.15; margin: 28px 0 12px; }
.games-head { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; justify-content: space-between; }
.games-head .btn, .game-actions a {
  display: inline-block; padding: .45rem 1.1rem; border: 1px solid var(--ink); border-radius: 99px;
  color: var(--ink); text-decoration: none; font-weight: 600;
}
.games-search { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin: 4px 0 24px; }
.games-search input { flex: 1 1 16rem; max-width: 28rem; }
.games .muted { color: var(--mut); }
.games .badge {
  display: inline-block; padding: 0 .65rem; border: 1px solid var(--u); border-radius: 99px;
  font-size: .8rem; color: var(--u);
}
.game-grid { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 20px; margin-bottom: 24px; }
.game-card {
  display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--line);
  border-radius: 14px; background: var(--panel); transition: border-color .2s, box-shadow .2s;
}
.game-card:hover { border-color: var(--m); box-shadow: 0 6px 24px var(--glow); }
.game-link { display: flex; flex-direction: column; gap: 10px; color: var(--ink); text-decoration: none; }
.game-link img, .game-placeholder { width: 100%; aspect-ratio: 16 / 10; border-radius: 10px; object-fit: cover; }
.game-placeholder {
  display: grid; place-items: center; color: #fff; font: 800 3rem "Bricolage Grotesque", system-ui, sans-serif;
  background: linear-gradient(135deg, hsl(var(--hue) 60% 42%), hsl(calc(var(--hue) + 50) 70% 55%));
}
.game-title { font-family: "Bricolage Grotesque", system-ui, sans-serif; font-weight: 700; font-size: 1.15rem; line-height: 1.2; }
.game-desc {
  color: var(--mut); font-size: .9rem; display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3;
  -webkit-box-orient: vertical; overflow: hidden;
}
.game-meta { display: flex; gap: 12px; align-items: center; margin-top: auto; font-size: .88rem; }
.games .crumb { margin-top: 20px; font-size: .9rem; }
.games .crumb a { text-decoration: none; }
.game-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.game-about { max-width: 70ch; margin-bottom: 14px; }
.game-frame {
  display: block; width: 100%; height: min(78vh, 760px); min-height: 420px; margin: 8px 0 10px;
  border: 1px solid var(--line); border-radius: 12px; background: #000;
}
.game-frame:fullscreen { border: none; border-radius: 0; height: 100%; }
.row.form small { color: var(--mut); font-size: .8rem; }

/* ---------- Two-factor authentication ---------- */
.account-links { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; }
ol.steps { max-width: 60ch; margin: 0 0 16px 1.4rem; }
ol.steps li { margin-bottom: 10px; }
img.qr { margin: 10px 0; background: #fff; padding: 8px; border-radius: 8px; image-rendering: pixelated; }
code.key { font-size: 1rem; letter-spacing: .05em; word-break: break-all; }
pre.recovery-codes {
  display: inline-block; margin: 4px 0 16px; padding: 12px 20px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--panel); font-size: 1.05rem; line-height: 1.8;
}

/* ---------- Home page (scoped so it can't leak into the dashboard) ---------- */
.home .hero { padding: clamp(40px, 9vw, 96px) 0 24px; }
.home .hero h1 { font-size: clamp(3.2rem, 12vw, 8rem); line-height: .95; font-weight: 800; letter-spacing: -.04em; }
.home .lede { margin-top: 18px; max-width: 44ch; font-size: clamp(1.1rem, 2.4vw, 1.4rem); color: var(--mut); }
.home .route { width: 100%; height: auto; display: block; margin-top: 36px; overflow: visible; }

.home .stats { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 8px; border-top: 1px solid var(--line); }
.home .stats[hidden] { display: none; }
.home .stats div { padding: 16px 12px 4px 0; }
.home .stats b { display: block; font-family: "Bricolage Grotesque", system-ui, sans-serif; font-size: 2.2rem; line-height: 1.1; font-weight: 700; font-variant-numeric: tabular-nums; }
.home .stats div:nth-child(2) b { color: var(--m); }
.home .stats div:nth-child(3) b { color: var(--u); }
.home .stats span { color: var(--mut); font-size: .88rem; }

.home .about {
  display: grid; grid-template-columns: 1.1fr .9fr; gap: 48px; align-items: center;
  margin-top: 56px; padding-top: 40px; border-top: 1px solid var(--line);
}
.home h2 { font-size: clamp(1.8rem, 4vw, 2.6rem); line-height: 1.1; font-weight: 700; letter-spacing: -.02em; margin-bottom: 16px; }
.home .about p, .home .teddy p { max-width: 52ch; margin-bottom: 14px; }
.home .about img { width: 100%; max-height: 460px; object-fit: cover; border-radius: 14px; }

.home .actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 22px; }
.home .btn {
  display: inline-block; padding: 10px 24px; border-radius: 99px; border: 1px solid var(--ink);
  background: var(--ink); color: var(--bg); font-weight: 600; text-decoration: none; transition: transform .2s, opacity .2s;
}
.home .btn:hover { transform: translateY(-2px); opacity: .9; }
.home .btn.ghost { background: transparent; color: var(--ink); }

.home .facts { margin-top: 56px; }
.home .facts div { display: grid; grid-template-columns: 240px 1fr; gap: 8px 32px; padding: 24px 0; border-top: 1px solid var(--line); }
.home .facts div:last-child { border-bottom: 1px solid var(--line); }
.home .facts h3 { font-size: 1.25rem; font-weight: 700; }
.home .facts p { color: var(--mut); max-width: 60ch; }

.home .teddy { display: grid; grid-template-columns: minmax(180px, 320px) 1fr; gap: 40px; align-items: center; margin-top: 56px; }
.home .teddy figure {
  position: relative; aspect-ratio: 1; border-radius: 14px; overflow: hidden; background: var(--panel);
  border: 1px solid var(--line); display: grid; place-content: center; font-size: 4rem;
}
.home .teddy figure img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

@media (max-width: 760px) {
  .home .about, .home .teddy { grid-template-columns: 1fr; gap: 28px; }
  .home .facts div { grid-template-columns: 1fr; }
  .home .stats { grid-template-columns: repeat(2, 1fr); }
  .nav { padding: 12px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
